cvs: phd / build.php config.php mktoc.php package.xml /include PhDErrors.php PhDPartialReader.class.php PhDReader.class.php buildoptions.php
/themes/php bightml.php chunkedhtml.php phpweb.php
| From: | Gwynne Raskind | Date: | Sat, 24 May 2008 14:49:14 +0000 |
| Subject: | cvs: phd / build.php config.php mktoc.php package.xml /include PhDErrors.php PhDPartialReader.class.php PhDReader.class.php buildoptions.php /themes/php bightml.php chunkedhtml.php phpweb.php |
||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-1679@lists.php.net to get a copy of this message | ||
gwynne Sat May 24 14:49:14 2008 UTC
Removed files:
/phd/include PhDErrors.php buildoptions.php
Modified files:
/phd build.php config.php mktoc.php package.xml
/phd/include PhDPartialReader.class.php PhDReader.class.php
/phd/themes/php bightml.php chunkedhtml.php phpweb.php
Log:
revert my big commit
http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.53&r2=1.54&diff_format=u Index: phd/build.php diff -u phd/build.php:1.53 phd/build.php:1.54 --- phd/build.php:1.53 Sat May 24 14:30:00 2008 +++ phd/build.php Sat May 24 14:49:14 2008 @@ -1,6 +1,6 @@ #!@php_bin@ <?php -/* $Id: build.php,v 1.53 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: build.php,v 1.54 2008/05/24 14:49:14 gwynne Exp $ */ /* {{{ Find the $ROOT directory of PhD @php_dir@ will be replaced by the pear package manager @@ -12,48 +12,12 @@ } /* }}} */ -(include $ROOT . "/config.php") - or die("Configuration file not found.\nRe-run phd-setup.\n"); - -(include $ROOT . "/include/buildoptions.php") - && is_array(PhDConfig::output_theme()) - or die("Invalid configuration.\nThis should never happen, did you edit config.php yourself?\nRe-run phd-setup.\n"); - -/* {{{ BC for PhD 0.0.* (and PHP5.2 on Windows) - i.e. `phd path/to/.manual.xml */ -if (!$optParser->docbook && $argc > 1) { - $arg = $argv[$argc-1]; - if (is_dir($arg)) { - PhDConfig::set_xml_root($arg); - PhDConfig::set_xml_file($arg . DIRECTORY_SEPARATOR . ".manual.xml"); - } elseif (is_file($arg)) { - PhDConfig::set_xml_root(dirname($arg)); - PhDConfig::set_xml_file($arg); - } -} -/* }}} */ - -/* {{{ If no docbook file was passed, ask for it - This loop should be removed in PhD 0.3.0, and replaced with a fatal errormsg */ -while (!is_dir(PhDConfig::xml_root()) || !is_file(PhDConfig::xml_file())) { - print "I need to know where you keep your '.manual.xml' file (I didn't find it in " . PhDConfig::xml_root() . "): "; - $root = trim(fgets(STDIN)); - if (is_file($root)) { - PhDConfig::set_xml_file($root); - PhDConfig::set_xml_root(dirname($root)); - } else { - PhDConfig::set_xml_file($root . "/.manual.xml"); - PhDConfig::set_xml_root($root); - } -} -/* }}} */ - -/* This needs to be done in *all* cases! */ -PhDConfig::set_output_dir(realpath(PhDConfig::output_dir()) . DIRECTORY_SEPARATOR); - -// These files really should be moved into phd/ -PhDConfig::set_version_info(PhDConfig::xml_root()."/phpbook/phpbook-xsl/version.xml"); -PhDConfig::set_acronyms_file(PhDConfig::xml_root()."/entities/acronyms.xml"); +(@include $ROOT."/config.php") + && isset($OPTIONS) + && is_array($OPTIONS) + && isset($OPTIONS["output_format"], $OPTIONS["output_theme"]) + && is_array($OPTIONS["output_theme"]) + or die("Invalid configuration/file not found.\nThis should never happen, did you edit config.php yourself?\n"); require $ROOT. "/include/PhDReader.class.php"; require $ROOT. "/include/PhDPartialReader.class.php"; @@ -62,20 +26,20 @@ require $ROOT. "/include/PhDTheme.class.php"; /* {{{ Build the .ser file names to allow multiple sources for PHD. */ -PhDConfig::set_index_location(PhDConfig::xml_root() . DIRECTORY_SEPARATOR . '.index_' . basename(PhDConfig::xml_file(), '.xml') . '.ser'); -PhDConfig::set_refnames_location(PhDConfig::xml_root() . DIRECTORY_SEPARATOR . '.refnames_' . basename(PhDConfig::xml_file(), '.xml') . '.ser'); +$OPTIONS['index_location'] = $OPTIONS['xml_root'] . DIRECTORY_SEPARATOR . '.index_' . basename($OPTIONS['xml_file'], '.xml') . '.ser'; +$OPTIONS['refnames_location'] = $OPTIONS['xml_root'] . DIRECTORY_SEPARATOR . '.refnames_' . basename($OPTIONS['xml_file'], '.xml') . '.ser'; /* }}} */ /* {{{ Index the DocBook file or load from .ser cache files NOTE: There are two cache files (where * is the basename of the XML source file): - index_*.ser (containing the ID infos) - refnames_*.ser (containing <refname> => File ID) */ -if (!PhDConfig::index() && (file_exists(PhDConfig::index_location()) && file_exists(PhDConfig::refnames_location()))) { +if (!$OPTIONS["index"] && (file_exists($OPTIONS['index_location']) && file_exists($OPTIONS['refnames_location']))) { /* FIXME: Load from sqlite db? */ v("Unserializing cached index files...", VERBOSE_INDEXING); - $IDs = unserialize(file_get_contents(PhDConfig::index_location())); - $REFS = unserialize(file_get_contents(PhDConfig::refnames_location())); + $IDs = unserialize(file_get_contents($OPTIONS['index_location'])); + $REFS = unserialize(file_get_contents($OPTIONS['refnames_location'])); v("Unserialization done", VERBOSE_INDEXING); } else { @@ -84,8 +48,8 @@ /* This file will "return" an $IDs & $REFS array */ require $ROOT. "/mktoc.php"; - file_put_contents(PhDConfig::index_location(), $ids = serialize($IDs)); - file_put_contents(PhDConfig::refnames_location(), $refs = serialize($REFS)); + file_put_contents($OPTIONS['index_location'], $ids = serialize($IDs)); + file_put_contents($OPTIONS['refnames_location'], $refs = serialize($REFS)); $IDs2 = unserialize($ids); $REFS2 = unserialize($refs); @@ -97,7 +61,7 @@ } /* }}} */ -foreach(PhDConfig::output_format() as $output_format) { +foreach($OPTIONS["output_format"] as $output_format) { v("Starting %s rendering", $output_format, VERBOSE_FORMAT_RENDERING); switch($output_format) { @@ -115,7 +79,7 @@ /* {{{ initialize output themes and fetch the methodmaps */ $themes = $elementmaps = $textmaps = array(); - foreach(val(PhDConfig::output_theme(), $output_format) as $theme => $array) { + foreach($OPTIONS["output_theme"][$output_format] as $theme => $array) { is_dir($ROOT. "/themes/$theme") or die("Can't find the '$theme' theme"); v("Using the %s theme (%s)", $theme, join(", ", $array), VERBOSE_THEME_RENDERING); @@ -127,8 +91,8 @@ case "php": $themes[$themename] = new $themename(array($IDs, $REFS), array( - "version" => PhDConfig::version_info(), - "acronym" => PhDConfig::acronyms_file(), + "version" => $OPTIONS["version_info"], + "acronym" => $OPTIONS["acronyms_file"], ) ); break; @@ -157,8 +121,8 @@ /* }}} */ /* {{{ Initialize the PhD[Partial]Reader */ - $idlist = PhDConfig::render_ids()+PhDConfig::skip_ids(); - if (!empty($idlist)) { + if (!empty($OPTIONS["render_ids"]) || !empty($OPTIONS["skip_ids"])) { + $idlist = $OPTIONS["render_ids"]+$OPTIONS["skip_ids"]; v("Running partial build", VERBOSE_RENDER_STYLE); if (!is_array($idlist)) { @@ -170,11 +134,11 @@ } } - $reader = new PhDPartialReader(); + $reader = new PhDPartialReader($OPTIONS); } else { v("Running full build", VERBOSE_RENDER_STYLE); - $reader = new PhDReader(); + $reader = new PhDReader($OPTIONS); } /* }}} */ @@ -328,7 +292,7 @@ $reader->close(); v("Finished rendering", VERBOSE_FORMAT_RENDERING); -} // foreach(PhDConfig::output_themes()) +} // foreach($OPTIONS["output_thtemes"]) /* * vim600: sw=4 ts=4 syntax=php et http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.44&r2=1.45&diff_format=u Index: phd/config.php diff -u phd/config.php:1.44 phd/config.php:1.45 --- phd/config.php:1.44 Sat May 24 14:30:00 2008 +++ phd/config.php Sat May 24 14:49:14 2008 @@ -1,69 +1,186 @@ <?php -/* $Id: config.php,v 1.44 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: config.php,v 1.45 2008/05/24 14:49:14 gwynne Exp $ */ -require $ROOT . "/include/PhDErrors.php"; +/* {{{ PhD error & message handler */ -define("PHD_VERSION", "0.2.4-dev"); +// FC For PHP5.3 +if (!defined("E_DEPRECATED")) { + define("E_DEPRECATED", E_RECOVERABLE_ERROR << 1); +} + +// PhD verbose flags +define('VERBOSE_INDEXING', E_DEPRECATED << 1); +define('VERBOSE_FORMAT_RENDERING', VERBOSE_INDEXING << 1); +define('VERBOSE_THEME_RENDERING', VERBOSE_FORMAT_RENDERING << 1); +define('VERBOSE_RENDER_STYLE', VERBOSE_THEME_RENDERING << 1); +define('VERBOSE_PARTIAL_READING', VERBOSE_RENDER_STYLE << 1); +define('VERBOSE_PARTIAL_CHILD_READING', VERBOSE_PARTIAL_READING << 1); +define('VERBOSE_TOC_WRITING', VERBOSE_PARTIAL_CHILD_READING << 1); +define('VERBOSE_CHUNK_WRITING', VERBOSE_TOC_WRITING << 1); +define('VERBOSE_NOVERSION', VERBOSE_CHUNK_WRITING << 1); + +define('VERBOSE_ALL', (VERBOSE_NOVERSION << 1)-1); + + +/* {{{ Print info messages: v("printf-format-text" [, $arg1, ...], $verbose-level) */ +// trigger_error() only accepts E_USER_* errors :( +function v($msg, $errno) { + $args = func_get_args(); + $errno = array_pop($args); + + $msg = vsprintf(array_shift($args), $args); + + $bt = debug_backtrace(); + return errh($errno, $msg, $bt[0]["file"], $bt[0]["line"]); +} +/* }}} */ -class PhDConfig -{ - private static $optionArray = array( - 'output_format' => array( - 'xhtml' - ), - 'output_theme' => array( - 'xhtml' => array( - 'php' => array( - 'phpweb', - 'chunkedhtml', - 'bightml', - ), - ), - ), - 'chunk_extra' => array( - "legalnotice" => true, - ), - 'index' => true, - 'xml_root' => '.', - 'xml_file' => './.manual.xml', - 'language' => 'en', - 'verbose' => VERBOSE_DEFAULT, - 'date_format' => "H:i:s", - 'render_ids' => array( - ), - 'skip_ids' => array( - ), - 'color_output' => false, - 'output_dir' => '.', - 'php_error_output' => NULL, - 'php_error_color' => false, - 'user_error_output' => NULL, - 'user_error_color' => false, - 'phd_info_output' => NULL, - 'phd_info_color' => false, +/* {{{ The PhD errorhandler */ +function errh($errno, $msg, $file, $line, $ctx = null) { + global $OPTIONS; + static $err = array( + E_DEPRECATED => 'E_DEPRECATED', + E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', + E_STRICT => 'E_STRICT', + E_WARNING => 'E_WARNING', + E_NOTICE => 'E_NOTICE', + + E_USER_ERROR => 'E_USER_ERROR', + E_USER_WARNING => 'E_USER_WARNING', + E_USER_NOTICE => 'E_USER_NOTICE', + + VERBOSE_INDEXING => 'VERBOSE_INDEXING', + VERBOSE_FORMAT_RENDERING => 'VERBOSE_FORMAT_RENDERING', + VERBOSE_THEME_RENDERING => 'VERBOSE_THEME_RENDERING', + VERBOSE_RENDER_STYLE => 'VERBOSE_RENDER_STYLE', + VERBOSE_PARTIAL_READING => 'VERBOSE_PARTIAL_READING', + VERBOSE_PARTIAL_CHILD_READING => 'VERBOSE_PARTIAL_CHILD_READING', + VERBOSE_TOC_WRITING => 'VERBOSE_TOC_WRITING', + VERBOSE_CHUNK_WRITING => 'VERBOSE_CHUNK_WRITING', + VERBOSE_NOVERSION => 'VERBOSE_NOVERSION', ); - - public static function __callStatic($name, $params) - { - $name = strtolower($name); // FC if this becomes case-sensitive - if (strncmp($name, 'set', 3) === 0) { - $name = substr($name, 3); - if ($name[0] === '_') { - $name = substr($name, 1); - } - if (strlen($name) < 1 || count($params) !== 1) { // assert - trigger_error("Misuse of config option setter", E_USER_ERROR); - } - self::$optionArray[$name] = $params[0]; - // no return, intentional - } - return isset(self::$optionArray[$name]) ? self::$optionArray[$name] : NULL; + static $recursive = false; + + // Respect the error_reporting setting + if (!(error_reporting() & $errno)) { + return false; + } + + // Recursive protection + if ($recursive) { + // Fallback to the default errorhandler + return false; + } + $recursive = true; + + $time = date($OPTIONS["date_format"]); + switch($errno) { + case VERBOSE_INDEXING: + case VERBOSE_FORMAT_RENDERING: + case VERBOSE_THEME_RENDERING: + case VERBOSE_RENDER_STYLE: + case VERBOSE_PARTIAL_READING: + case VERBOSE_PARTIAL_CHILD_READING: + case VERBOSE_TOC_WRITING: + case VERBOSE_CHUNK_WRITING: + case VERBOSE_NOVERSION: + $cl1 = $OPTIONS['color_output'] ? "\033[01;{$OPTIONS['color_output']}m" : ''; + $cr = $OPTIONS['color_output'] ? "\033[m" : ''; + fprintf($OPTIONS["phd_info_output"], "{$cl1}[%s - %s]{$cr} %s\n", $time, $err[$errno], $msg); + break; + + // User triggered errors + case E_USER_ERROR: + case E_USER_WARNING: + case E_USER_NOTICE: + fprintf($OPTIONS["user_error_output"], "[%s - %s] %s:%d\n\t%s\n", $time, $err[$errno], $file, $line, $msg); + break; + + // PHP triggered errors + case E_DEPRECATED: + case E_RECOVERABLE_ERROR: + case E_STRICT: + case E_WARNING: + case E_NOTICE: + fprintf($OPTIONS["php_error_output"], "[%s - %s] %s:%d\n\t%s\n", $time, $err[$errno], $file, $line, $msg); + break; + + default: + // Unknown error level.. let PHP handle it + $recursive = false; + return false; + } + + // Abort on fatal errors + if ($errno & (E_USER_ERROR|E_RECOVERABLE_ERROR)) { + exit(1); } + + $recursive = false; + return true; } +/* }}} */ +set_error_handler("errh"); +/* }}} */ -PhDConfig::set_php_error_output(STDERR); -PhDConfig::set_user_error_output(STDERR); -PhDConfig::set_phd_info_output(STDOUT); +define("PHD_VERSION", "0.2.4-dev"); + +/* {{{ Default $OPTIONS */ +$OPTIONS = array ( + 'output_format' => array('xhtml'), + 'output_theme' => array( + 'xhtml' => array( + 'php' => array( + 'phpweb', + 'chunkedhtml', + 'bightml', + ), + ), + ), + 'chunk_extra' => array( + "legalnotice" => true, + ), + 'index' => true, + 'xml_root' => '.', + 'xml_file' => './.manual.xml', + 'language' => 'en', + 'fallback_language' => 'en', + 'enforce_revisions' => false, + 'compatibility_mode' => true, + 'build_log_file' => 'none', + 'verbose' => VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING|VERBOSE_NOVERSION), + 'date_format' => "H:i:s", + 'render_ids' => array( + ), + 'skip_ids' => array( + ), + 'color_output' => false, + 'output_dir' => '.', + 'php_error_output' => STDERR, + 'user_error_output' => STDERR, + 'phd_info_output' => STDOUT, +); +/* }}} */ + +$olderr = error_reporting(); +error_reporting($olderr | $OPTIONS["verbose"]); + +/* {{{ getopt() options */ +$opts = array( + "format:" => "f:", // The format to render (xhtml, pdf...) + "theme:" => "t:", // The theme to render (phpweb, bightml..) + "index:" => "i:", // Re-index or load from cache + "docbook:" => "d:", // The Docbook XML file to render from (.manual.xml) + "output:" => "o:", // The output directory + "partial:" => "p:", // The ID to render (optionally ignoring its children) + "skip:" => "s:", // The ID to skip (optionally skipping its children too) + "verbose:" => "v", // Adjust the verbosity level + "list::" => "l::", // List supported themes/formats + "color::" => "c::", // Use color output if possible + "version" => "V", // Print out version information + "help" => "h", // Print out help +); +/* }}} */ /* {{{ Workaround/fix for Windows prior to PHP5.3 */ if (!function_exists("getopt")) { @@ -77,6 +194,14 @@ } /* }}} */ +$args = getopt(implode("", array_values($opts)), array_keys($opts)); +if($args === false) { + trigger_error("Something happend with getopt(), please report a bug", E_USER_ERROR); +} + +$verbose = 0; +$docbook = false; + /* {{{ phd_bool($var) Returns boolean true/false on success, null on failure */ function phd_bool($val) { if (!is_string($val)) { @@ -104,46 +229,306 @@ } /* }}} */ -abstract class OptionParser -{ - abstract public function getOptionList(); - - public function handlerForOption($opt) - { - if (method_exists($this, "option_{$opt}")) { - return array($this, "option_{$opt}"); +foreach($args as $k => $v) { + switch($k) { + /* {{{ Docbook file */ + case "d": + case "docbook": + if (is_array($v)) { + trigger_error("Can only parse one file at a time", E_USER_ERROR); + } + if (!file_exists($v) || is_dir($v) || !is_readable($v)) { + trigger_error(sprintf("'%s' is not a readable docbook file", $v), E_USER_ERROR); + } + $OPTIONS["xml_root"] = dirname($v); + $OPTIONS["xml_file"] = $v; + $docbook = true; + break; + /* }}} */ + + /* {{{ Output location */ + case "o": + case "output": + if (is_array($v)) { + trigger_error("Only a single output location can be supplied", E_USER_ERROR); + } + @mkdir($v, 0777, true); + if (!is_dir($v) || !is_readable($v)) { + trigger_error(sprintf("'%s' is not a valid directory", $v), E_USER_ERROR); + } + $OPTIONS["output_dir"] = $v; + break; + /* }}} */ + + /* {{{ Build format */ + case "f": + case "format": + if ($v != "xhtml") { + trigger_error("Only xhtml is supported at this time", E_USER_ERROR); + } + break; + /* }}} */ + + /* {{{ Run indexer or not */ + case "i": + case "index": + if (is_array($v)) { + trigger_error(sprintf("You cannot pass %s more than once", $k), E_USER_ERROR); + } + $val = phd_bool($v); + if (is_bool($val)) { + $OPTIONS["index"] = $val; } else { - return NULL; + trigger_error("yes/no || on/off || true/false || 1/0 expected", E_USER_ERROR); } - } - - public function getopt() - { - $opts = $this->getOptionList(); - $args = getopt(implode("", array_values($opts)), array_keys($opts)); - if ($args === false) { - trigger_error("Something happend with getopt(), please report a bug", E_USER_ERROR); + break; + /* }}} */ + + /* {{{ Print out a list of formats/themes */ + case "l": + case "list": + /* FIXME: This list should be created dynamically */ + foreach((array)$v as $val) { + switch($val) { + case "f": + case "format": + case "formats": + echo "Supported formats:\n"; + echo "\txhtml\n"; + break; + + case "t": + case "theme": + case "themes": + echo "Supported themes:\n"; + echo "\tphpweb\n"; + echo "\tchunkedhtml\n"; + echo "\tbightml\n"; + break; + + default: + echo "Unknown list type '$val'\n"; + /* break omitted intentionally */ + + case false: + echo "Supported formats:\n"; + echo "\txhtml\n"; + echo "Supported themes:\n"; + echo "\tphpweb\n"; + echo "\tchunkedhtml\n"; + echo "\tbightml\n"; + break; + } + } + exit(0); + break; + /* }}} */ + + /* {{{ Partial rendering */ + case "p": + case "partial": + foreach((array)$v as $i => $val) { + $recursive = true; + if (strpos($val, "=") !== false) { + list($val, $recursive) = explode("=", $val); + + if (!is_numeric($recursive) && defined($recursive)) { + $recursive = constant($recursive); + } + $recursive = (bool) $recursive; + } + $OPTIONS["render_ids"][$val] = $recursive; + } + break; + /* }}} */ + + /* {{{ Skip list */ + case "s": + case "skip": + foreach((array)$v as $i => $val) { + $recursive = true; + if (strpos($val, "=") !== false) { + list($val, $recursive) = explode("=", $val); + + if (!is_numeric($recursive) && defined($recursive)) { + $recursive = constant($recursive); + } + $recursive = (bool) $recursive; + } + $OPTIONS["skip_ids"][$val] = $recursive; + } + break; + /* }}} */ + + /* {{{ Output themes */ + case "t": + case "theme": + /* Remove the default themes */ + $OPTIONS["output_theme"]["xhtml"]["php"] = array(); + + foreach((array)$v as $i => $val) { + switch($val) { + case "phpweb": + case "chunkedhtml": + case "bightml": + if (!in_array($val, $OPTIONS["output_theme"]["xhtml"]["php"])) { + $OPTIONS["output_theme"]["xhtml"]["php"][] = $val; + } + break; + default: + trigger_error(sprintf("Unknown theme '%s'", $val), E_USER_ERROR); + } } + break; + /* }}} */ - foreach ($args as $k => $v) { - $handler = $this->handlerForOption($k); - if (is_callable($handler)) { - call_user_func($handler, $k, $v); - } else { - var_dump($k, $v); - trigger_error("Hmh, something weird has happend, I don't know this option", E_USER_ERROR); + /* {{{ Verbosity level */ + case "verbose": + foreach((array)$v as $i => $val) { + foreach(explode("|", $val) as $const) { + if (defined($const)) { + $verbose |= (int)constant($const); + } elseif (is_numeric($const)) { + $verbose |= (int)$const; + } else { + trigger_error("Unknown option passed to --$k, $const", E_USER_ERROR); + } } } + $OPTIONS["verbose"] = $verbose; + break; + + case "v": + if (is_array($v)) { + foreach($v as $i => $val) { + $verbose |= pow(2, $i); + } + } else { + $verbose |= 1; + } + $OPTIONS["verbose"] = $verbose; + break; + /* }}} */ + + /* {{{ Color output */ + case "c": + case "color": + if (is_array($v)) { + trigger_error(sprintf("You cannot pass %s more than once", $k), E_USER_ERROR); + } + if (function_exists('posix_isatty') && !posix_isatty($OPTIONS['phd_info_output'])) { + // Terminal doesn't support colors + break; + } + + $bool = phd_bool($v); + // No option or color specified + if ($v === false || ($bool === true && $v != 1)) { + // Fallback to default + $OPTIONS["color_output"] = 34; + } elseif ($bool === false) { + // Explicitly turning coloring off + $OPTIONS["color_output"] = false; + } elseif (is_numeric($v)) { + // Color specified + $OPTIONS["color_output"] = (int)$v; + } else { + trigger_error("yes/no || on/off || true/false || 1/0 expected", E_USER_ERROR); + } + break; + /* }}} */ + + /* {{{ Version info */ + case "V": + case "version": + printf("PhD version: %s\n", PHD_VERSION); + printf("Copyright (c) 2008 The PHP Documentation Group\n"); + exit(0); + /* }}} */ + + /* {{{ Help/usage info */ + case "usage": + case "help": + case "h": + echo "PhD version: " .PHD_VERSION; + echo "\nCopyright (c) 2008 The PHP Documentation Group\n + -v + --verbose <int> Adjusts the verbosity level + -f <formatname> + --format <formatname> The build format to use + -t <themename> + --theme <themename> The theme to use + -i <bool> + --index <bool> Index before rendering (default) or load from cache (false) + -d <filename> + --docbook <filename> The Docbook file to render from + -p <id[=bool]> + --partial <id[=bool]> The ID to render, optionally skipping its children chunks (default to true; render children) + -s <id[=bool]> + --skip <id[=bool]> The ID to skip, optionally skipping its children chunks (default to true; skip children) + -l <formats/themes> + --list <formats/themes> Print out the supported formats/themes (default: both) + -o <directory> + --output <directory> The output directory (default: .) + -c <color> + --color <color> Enable color output when output is to a terminal, optionally specify numerical color value (default: false) + -V + --version Print the PhD version information + -h + --help This help + +Most options can be passed multiple times for greater affect. +NOTE: Long options are only supported using PHP5.3\n"; + exit(0); + break; + /* }}} */ + + /* {{{ Unsupported option this should *never* happen */ + default: + var_dump($k, $v); + trigger_error("Hmh, something weird has happend, I don't know this option", E_USER_ERROR); + /* }}} */ } } -/* {{{ Can't function_call()['key'], so val(function_call(), 'key') */ -function val($a, $k) -{ - return $a[$k]; +error_reporting($olderr | $OPTIONS["verbose"]); + +/* {{{ BC for PhD 0.0.* (and PHP5.2 on Windows) + i.e. `phd path/to/.manual.xml */ +if (!$docbook && $argc > 1) { + $arg = $argv[$argc-1]; + if (is_dir($arg)) { + $OPTIONS["xml_root"] = $arg; + $OPTIONS["xml_file"] = $arg . DIRECTORY_SEPARATOR . ".manual.xml"; + } elseif (is_file($arg)) { + $OPTIONS["xml_root"] = dirname($arg); + $OPTIONS["xml_file"] = $arg; + } } /* }}} */ +/* {{{ If no docbook file was passed, ask for it + This loop should be removed in PhD 0.3.0, and replaced with a fatal errormsg */ +while (!is_dir($OPTIONS["xml_root"]) || !is_file($OPTIONS["xml_file"])) { + print "I need to know where you keep your '.manual.xml' file (I didn't find it in " . $OPTIONS["xml_root"] . "): "; + $root = trim(fgets(STDIN)); + if (is_file($root)) { + $OPTIONS["xml_file"] = $root; + $OPTIONS["xml_root"] = dirname($root); + } else { + $OPTIONS["xml_file"] = $root . "/.manual.xml"; + $OPTIONS["xml_root"] = $root; + } +} +/* }}} */ + +/* This needs to be done in *all* cases! */ +$OPTIONS["output_dir"] = realpath($OPTIONS["output_dir"]) . DIRECTORY_SEPARATOR; + +// Those files really should be moved into phd/ +$OPTIONS["version_info"] = $OPTIONS["xml_root"]."/phpbook/phpbook-xsl/version.xml"; +$OPTIONS["acronyms_file"] = $OPTIONS["xml_root"]."/entities/acronyms.xml"; + /* * vim600: sw=4 ts=4 syntax=php et * vim<600: sw=4 ts=4 http://cvs.php.net/viewvc.cgi/phd/mktoc.php?r1=1.9&r2=1.10&diff_format=u Index: phd/mktoc.php diff -u phd/mktoc.php:1.9 phd/mktoc.php:1.10 --- phd/mktoc.php:1.9 Sat May 24 14:30:00 2008 +++ phd/mktoc.php Sat May 24 14:49:14 2008 @@ -1,6 +1,6 @@ <?php -/* $Id: mktoc.php,v 1.9 2008/05/24 14:30:00 gwynne Exp $ */ -$r = new PhDReader(); +/* $Id: mktoc.php,v 1.10 2008/05/24 14:49:14 gwynne Exp $ */ +$r = new PhDReader($OPTIONS); $REFS = $FILENAMES = array(); $CURRENT_FILENAME = $LAST_CHUNK = ""; http://cvs.php.net/viewvc.cgi/phd/package.xml?r1=1.72&r2=1.73&diff_format=u Index: phd/package.xml diff -u phd/package.xml:1.72 phd/package.xml:1.73 --- phd/package.xml:1.72 Sat May 24 14:30:00 2008 +++ phd/package.xml Sat May 24 14:49:14 2008 @@ -51,17 +51,11 @@ - Added Danish support (for autogenerated texts). (Kalle Sommer) - Added Swedish support (for autogenerated texts). (Kalle Sommer) - Added experimental option (-c/--color) for color in verbose output. (Gwynne) - - Rewrote option parsing, allows the same code to be reused for multiple scripts. (Gwynne) - - Rewrote config option access, avoids globals. (Gwynne) - - Cleaned up error handler. (Gwynne) - - --list option now glob()s the themes/ and formats/ directories. (Gwynne) </notes> <contents> <dir baseinstalldir="phd" name="/"> <file baseinstalldir="phd" name="formats/xhtml.php" role="php"/> - <file baseinstalldir="phd" name="include/buildoptions.php" role="php"/> - <file baseinstalldir="phd" name="include/PhDErrors.php" role="php"/> <file baseinstalldir="phd" name="include/PhDFormat.class.php" role="php"/> <file baseinstalldir="phd" name="include/PhDTheme.class.php" role="php"/> <file baseinstalldir="phd" name="include/PhDHelper.class.php" role="php"/> http://cvs.php.net/viewvc.cgi/phd/include/PhDPartialReader.class.php?r1=1.6&r2=1.7&diff_format=u Index: phd/include/PhDPartialReader.class.php diff -u phd/include/PhDPartialReader.class.php:1.6 phd/include/PhDPartialReader.class.php:1.7 --- phd/include/PhDPartialReader.class.php:1.6 Sat May 24 14:30:00 2008 +++ phd/include/PhDPartialReader.class.php Sat May 24 14:49:14 2008 @@ -1,26 +1,24 @@ <?php -/* $Id: PhDPartialReader.class.php,v 1.6 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: PhDPartialReader.class.php,v 1.7 2008/05/24 14:49:14 gwynne Exp $ */ class PhDPartialReader extends PhDReader { protected $partial = array(); protected $skip = array(); - public function __construct($encoding = "UTF-8", $xml_opts = NULL) { - parent::__construct($encoding, $xml_opts); - - $render_ids = PhDConfig::render_ids(); - if ($render_ids !== NULL) { - if (is_array($render_ids)) { - $this->partial = $render_ids; + public function __construct($opts, $encoding = "UTF-8", $xml_opts = NULL) { + parent::__construct($opts, $encoding, $xml_opts); + + if (isset($opts["render_ids"])) { + if (is_array($opts["render_ids"])) { + $this->partial = $opts["render_ids"]; } else { - $this->partial[$render_ids] = 1; + $this->partial[$opts["render_ids"]] = 1; } - $skip_ids = PhDConfig::skip_ids(); - if ($skip_ids !== NULL) { - if (is_array($skip_ids)) { - $this->skip = $skip_ids; + if (isset($opts["skip_ids"])) { + if (is_array($opts["skip_ids"])) { + $this->skip = $opts["skip_ids"]; } else { - $this->skip[$skip_ids] = 1; + $this->skip[$opts["skip_ids"]] = 1; } } } else { http://cvs.php.net/viewvc.cgi/phd/include/PhDReader.class.php?r1=1.15&r2=1.16&diff_format=u Index: phd/include/PhDReader.class.php diff -u phd/include/PhDReader.class.php:1.15 phd/include/PhDReader.class.php:1.16 --- phd/include/PhDReader.class.php:1.15 Sat May 24 14:30:00 2008 +++ phd/include/PhDReader.class.php Sat May 24 14:49:14 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDReader.class.php,v 1.15 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: PhDReader.class.php,v 1.16 2008/05/24 14:49:14 gwynne Exp $ */ //6271 class PhDReader extends XMLReader { @@ -60,19 +60,20 @@ 'set' => true, 'setindex' => true, ); /* }}} */ + protected $opts = array(); public $isChunk = false; - public function __construct($encoding = "UTF-8", $xml_opts = NULL) { /* {{{ */ - if (!XMLReader::open(PhDConfig::xml_file(), $encoding, $xml_opts)) { - throw new Exception("Cannot open " . PhDConfig::xml_file()); - } - $ce = PhDConfig::chunk_extra(); - if (is_array($ce)) { - foreach($ce as $el => $v) { + public function __construct($opts, $encoding = "UTF-8", $xml_opts = NULL) { /* {{{ */ + if (!XMLReader::open($opts["xml_file"], $encoding, $xml_opts)) { + throw new Exception("Cannot open {$opts["xml_file"]}"); + } + if (isset($opts["chunk_extra"]) && is_array($opts["chunk_extra"])) { + foreach($opts["chunk_extra"] as $el => $v) { $this->CHUNK_ME[$el] = $v; } } + $this->opts = $opts; } /* }}} */ public function notXPath($tag, $depth = 0) { /* {{{ */ http://cvs.php.net/viewvc.cgi/phd/themes/php/bightml.php?r1=1.10&r2=1.11&diff_format=u Index: phd/themes/php/bightml.php diff -u phd/themes/php/bightml.php:1.10 phd/themes/php/bightml.php:1.11 --- phd/themes/php/bightml.php:1.10 Sat May 24 14:30:00 2008 +++ phd/themes/php/bightml.php Sat May 24 14:49:14 2008 @@ -1,11 +1,11 @@ <?php -/* $Id: bightml.php,v 1.10 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: bightml.php,v 1.11 2008/05/24 14:49:14 gwynne Exp $ */ require_once $ROOT . '/themes/php/phpdotnet.php'; class bightml extends phpdotnet { public function __construct(array $IDs, $filename, $ext = "html") { parent::__construct($IDs, $filename, $ext, false); - $this->stream = fopen(PhDConfig::output_dir() . "bightml.html", "w"); + $this->stream = fopen($GLOBALS['OPTIONS']['output_dir'] . "bightml.html", "w"); self::header(); } public function appendData($data, $isChunk) { http://cvs.php.net/viewvc.cgi/phd/themes/php/chunkedhtml.php?r1=1.10&r2=1.11&diff_format=u Index: phd/themes/php/chunkedhtml.php diff -u phd/themes/php/chunkedhtml.php:1.10 phd/themes/php/chunkedhtml.php:1.11 --- phd/themes/php/chunkedhtml.php:1.10 Sat May 24 14:30:00 2008 +++ phd/themes/php/chunkedhtml.php Sat May 24 14:49:14 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: chunkedhtml.php,v 1.10 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: chunkedhtml.php,v 1.11 2008/05/24 14:49:14 gwynne Exp $ */ require_once $ROOT . '/themes/php/phpweb.php'; class chunkedhtml extends phpweb { @@ -7,7 +7,7 @@ public function __construct(array $IDs, $filename, $ext = "html") { phpdotnet::__construct($IDs, $filename, $ext, true); - $this->outputdir = PhDConfig::output_dir() . $this->ext . DIRECTORY_SEPARATOR; + $this->outputdir = $GLOBALS['OPTIONS']['output_dir'] . $this->ext . DIRECTORY_SEPARATOR; if(!file_exists($this->outputdir) || is_file($this->outputdir)) mkdir($this->outputdir) or die("Can't create the cache directory"); elseif (file_exists($this->outputdir . 'index.html')) unlink($this->outputdir . 'index.html'); // preserve back-compat } http://cvs.php.net/viewvc.cgi/phd/themes/php/phpweb.php?r1=1.26&r2=1.27&diff_format=u Index: phd/themes/php/phpweb.php diff -u phd/themes/php/phpweb.php:1.26 phd/themes/php/phpweb.php:1.27 --- phd/themes/php/phpweb.php:1.26 Sat May 24 14:30:00 2008 +++ phd/themes/php/phpweb.php Sat May 24 14:49:14 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: phpweb.php,v 1.26 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: phpweb.php,v 1.27 2008/05/24 14:49:14 gwynne Exp $ */ require_once $ROOT . '/themes/php/phpdotnet.php'; class phpweb extends phpdotnet { @@ -10,7 +10,7 @@ public function __construct($IDs, $filename, $ext = "php", $chunked = true) { parent::__construct($IDs, $filename, $ext, $chunked); - $this->outputdir = PhDConfig::output_dir() . $this->ext . DIRECTORY_SEPARATOR; + $this->outputdir = $GLOBALS['OPTIONS']['output_dir'] . $this->ext . DIRECTORY_SEPARATOR; if (!file_exists($this->outputdir) || is_file($this->outputdir)) { mkdir($this->outputdir) or die("Can't create the cache directory"); } else {
http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.53&r2=1.54&diff_format=u Index: phd/build.php diff -u phd/build.php:1.53 phd/build.php:1.54 --- phd/build.php:1.53 Sat May 24 14:30:00 2008 +++ phd/build.php Sat May 24 14:49:14 2008 @@ -1,6 +1,6 @@ #!@php_bin@ <?php -/* $Id: build.php,v 1.53 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: build.php,v 1.54 2008/05/24 14:49:14 gwynne Exp $ */ /* {{{ Find the $ROOT directory of PhD @php_dir@ will be replaced by the pear package manager @@ -12,48 +12,12 @@ } /* }}} */ -(include $ROOT . "/config.php") - or die("Configuration file not found.\nRe-run phd-setup.\n"); - -(include $ROOT . "/include/buildoptions.php") - && is_array(PhDConfig::output_theme()) - or die("Invalid configuration.\nThis should never happen, did you edit config.php yourself?\nRe-run phd-setup.\n"); - -/* {{{ BC for PhD 0.0.* (and PHP5.2 on Windows) - i.e. `phd path/to/.manual.xml */ -if (!$optParser->docbook && $argc > 1) { - $arg = $argv[$argc-1]; - if (is_dir($arg)) { - PhDConfig::set_xml_root($arg); - PhDConfig::set_xml_file($arg . DIRECTORY_SEPARATOR . ".manual.xml"); - } elseif (is_file($arg)) { - PhDConfig::set_xml_root(dirname($arg)); - PhDConfig::set_xml_file($arg); - } -} -/* }}} */ - -/* {{{ If no docbook file was passed, ask for it - This loop should be removed in PhD 0.3.0, and replaced with a fatal errormsg */ -while (!is_dir(PhDConfig::xml_root()) || !is_file(PhDConfig::xml_file())) { - print "I need to know where you keep your '.manual.xml' file (I didn't find it in " . PhDConfig::xml_root() . "): "; - $root = trim(fgets(STDIN)); - if (is_file($root)) { - PhDConfig::set_xml_file($root); - PhDConfig::set_xml_root(dirname($root)); - } else { - PhDConfig::set_xml_file($root . "/.manual.xml"); - PhDConfig::set_xml_root($root); - } -} -/* }}} */ - -/* This needs to be done in *all* cases! */ -PhDConfig::set_output_dir(realpath(PhDConfig::output_dir()) . DIRECTORY_SEPARATOR); - -// These files really should be moved into phd/ -PhDConfig::set_version_info(PhDConfig::xml_root()."/phpbook/phpbook-xsl/version.xml"); -PhDConfig::set_acronyms_file(PhDConfig::xml_root()."/entities/acronyms.xml"); +(@include $ROOT."/config.php") + && isset($OPTIONS) + && is_array($OPTIONS) + && isset($OPTIONS["output_format"], $OPTIONS["output_theme"]) + && is_array($OPTIONS["output_theme"]) + or die("Invalid configuration/file not found.\nThis should never happen, did you edit config.php yourself?\n"); require $ROOT. "/include/PhDReader.class.php"; require $ROOT. "/include/PhDPartialReader.class.php"; @@ -62,20 +26,20 @@ require $ROOT. "/include/PhDTheme.class.php"; /* {{{ Build the .ser file names to allow multiple sources for PHD. */ -PhDConfig::set_index_location(PhDConfig::xml_root() . DIRECTORY_SEPARATOR . '.index_' . basename(PhDConfig::xml_file(), '.xml') . '.ser'); -PhDConfig::set_refnames_location(PhDConfig::xml_root() . DIRECTORY_SEPARATOR . '.refnames_' . basename(PhDConfig::xml_file(), '.xml') . '.ser'); +$OPTIONS['index_location'] = $OPTIONS['xml_root'] . DIRECTORY_SEPARATOR . '.index_' . basename($OPTIONS['xml_file'], '.xml') . '.ser'; +$OPTIONS['refnames_location'] = $OPTIONS['xml_root'] . DIRECTORY_SEPARATOR . '.refnames_' . basename($OPTIONS['xml_file'], '.xml') . '.ser'; /* }}} */ /* {{{ Index the DocBook file or load from .ser cache files NOTE: There are two cache files (where * is the basename of the XML source file): - index_*.ser (containing the ID infos) - refnames_*.ser (containing <refname> => File ID) */ -if (!PhDConfig::index() && (file_exists(PhDConfig::index_location()) && file_exists(PhDConfig::refnames_location()))) { +if (!$OPTIONS["index"] && (file_exists($OPTIONS['index_location']) && file_exists($OPTIONS['refnames_location']))) { /* FIXME: Load from sqlite db? */ v("Unserializing cached index files...", VERBOSE_INDEXING); - $IDs = unserialize(file_get_contents(PhDConfig::index_location())); - $REFS = unserialize(file_get_contents(PhDConfig::refnames_location())); + $IDs = unserialize(file_get_contents($OPTIONS['index_location'])); + $REFS = unserialize(file_get_contents($OPTIONS['refnames_location'])); v("Unserialization done", VERBOSE_INDEXING); } else { @@ -84,8 +48,8 @@ /* This file will "return" an $IDs & $REFS array */ require $ROOT. "/mktoc.php"; - file_put_contents(PhDConfig::index_location(), $ids = serialize($IDs)); - file_put_contents(PhDConfig::refnames_location(), $refs = serialize($REFS)); + file_put_contents($OPTIONS['index_location'], $ids = serialize($IDs)); + file_put_contents($OPTIONS['refnames_location'], $refs = serialize($REFS)); $IDs2 = unserialize($ids); $REFS2 = unserialize($refs); @@ -97,7 +61,7 @@ } /* }}} */ -foreach(PhDConfig::output_format() as $output_format) { +foreach($OPTIONS["output_format"] as $output_format) { v("Starting %s rendering", $output_format, VERBOSE_FORMAT_RENDERING); switch($output_format) { @@ -115,7 +79,7 @@ /* {{{ initialize output themes and fetch the methodmaps */ $themes = $elementmaps = $textmaps = array(); - foreach(val(PhDConfig::output_theme(), $output_format) as $theme => $array) { + foreach($OPTIONS["output_theme"][$output_format] as $theme => $array) { is_dir($ROOT. "/themes/$theme") or die("Can't find the '$theme' theme"); v("Using the %s theme (%s)", $theme, join(", ", $array), VERBOSE_THEME_RENDERING); @@ -127,8 +91,8 @@ case "php": $themes[$themename] = new $themename(array($IDs, $REFS), array( - "version" => PhDConfig::version_info(), - "acronym" => PhDConfig::acronyms_file(), + "version" => $OPTIONS["version_info"], + "acronym" => $OPTIONS["acronyms_file"], ) ); break; @@ -157,8 +121,8 @@ /* }}} */ /* {{{ Initialize the PhD[Partial]Reader */ - $idlist = PhDConfig::render_ids()+PhDConfig::skip_ids(); - if (!empty($idlist)) { + if (!empty($OPTIONS["render_ids"]) || !empty($OPTIONS["skip_ids"])) { + $idlist = $OPTIONS["render_ids"]+$OPTIONS["skip_ids"]; v("Running partial build", VERBOSE_RENDER_STYLE); if (!is_array($idlist)) { @@ -170,11 +134,11 @@ } } - $reader = new PhDPartialReader(); + $reader = new PhDPartialReader($OPTIONS); } else { v("Running full build", VERBOSE_RENDER_STYLE); - $reader = new PhDReader(); + $reader = new PhDReader($OPTIONS); } /* }}} */ @@ -328,7 +292,7 @@ $reader->close(); v("Finished rendering", VERBOSE_FORMAT_RENDERING); -} // foreach(PhDConfig::output_themes()) +} // foreach($OPTIONS["output_thtemes"]) /* * vim600: sw=4 ts=4 syntax=php et http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.44&r2=1.45&diff_format=u Index: phd/config.php diff -u phd/config.php:1.44 phd/config.php:1.45 --- phd/config.php:1.44 Sat May 24 14:30:00 2008 +++ phd/config.php Sat May 24 14:49:14 2008 @@ -1,69 +1,186 @@ <?php -/* $Id: config.php,v 1.44 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: config.php,v 1.45 2008/05/24 14:49:14 gwynne Exp $ */ -require $ROOT . "/include/PhDErrors.php"; +/* {{{ PhD error & message handler */ -define("PHD_VERSION", "0.2.4-dev"); +// FC For PHP5.3 +if (!defined("E_DEPRECATED")) { + define("E_DEPRECATED", E_RECOVERABLE_ERROR << 1); +} + +// PhD verbose flags +define('VERBOSE_INDEXING', E_DEPRECATED << 1); +define('VERBOSE_FORMAT_RENDERING', VERBOSE_INDEXING << 1); +define('VERBOSE_THEME_RENDERING', VERBOSE_FORMAT_RENDERING << 1); +define('VERBOSE_RENDER_STYLE', VERBOSE_THEME_RENDERING << 1); +define('VERBOSE_PARTIAL_READING', VERBOSE_RENDER_STYLE << 1); +define('VERBOSE_PARTIAL_CHILD_READING', VERBOSE_PARTIAL_READING << 1); +define('VERBOSE_TOC_WRITING', VERBOSE_PARTIAL_CHILD_READING << 1); +define('VERBOSE_CHUNK_WRITING', VERBOSE_TOC_WRITING << 1); +define('VERBOSE_NOVERSION', VERBOSE_CHUNK_WRITING << 1); + +define('VERBOSE_ALL', (VERBOSE_NOVERSION << 1)-1); + + +/* {{{ Print info messages: v("printf-format-text" [, $arg1, ...], $verbose-level) */ +// trigger_error() only accepts E_USER_* errors :( +function v($msg, $errno) { + $args = func_get_args(); + $errno = array_pop($args); + + $msg = vsprintf(array_shift($args), $args); + + $bt = debug_backtrace(); + return errh($errno, $msg, $bt[0]["file"], $bt[0]["line"]); +} +/* }}} */ -class PhDConfig -{ - private static $optionArray = array( - 'output_format' => array( - 'xhtml' - ), - 'output_theme' => array( - 'xhtml' => array( - 'php' => array( - 'phpweb', - 'chunkedhtml', - 'bightml', - ), - ), - ), - 'chunk_extra' => array( - "legalnotice" => true, - ), - 'index' => true, - 'xml_root' => '.', - 'xml_file' => './.manual.xml', - 'language' => 'en', - 'verbose' => VERBOSE_DEFAULT, - 'date_format' => "H:i:s", - 'render_ids' => array( - ), - 'skip_ids' => array( - ), - 'color_output' => false, - 'output_dir' => '.', - 'php_error_output' => NULL, - 'php_error_color' => false, - 'user_error_output' => NULL, - 'user_error_color' => false, - 'phd_info_output' => NULL, - 'phd_info_color' => false, +/* {{{ The PhD errorhandler */ +function errh($errno, $msg, $file, $line, $ctx = null) { + global $OPTIONS; + static $err = array( + E_DEPRECATED => 'E_DEPRECATED', + E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', + E_STRICT => 'E_STRICT', + E_WARNING => 'E_WARNING', + E_NOTICE => 'E_NOTICE', + + E_USER_ERROR => 'E_USER_ERROR', + E_USER_WARNING => 'E_USER_WARNING', + E_USER_NOTICE => 'E_USER_NOTICE', + + VERBOSE_INDEXING => 'VERBOSE_INDEXING', + VERBOSE_FORMAT_RENDERING => 'VERBOSE_FORMAT_RENDERING', + VERBOSE_THEME_RENDERING => 'VERBOSE_THEME_RENDERING', + VERBOSE_RENDER_STYLE => 'VERBOSE_RENDER_STYLE', + VERBOSE_PARTIAL_READING => 'VERBOSE_PARTIAL_READING', + VERBOSE_PARTIAL_CHILD_READING => 'VERBOSE_PARTIAL_CHILD_READING', + VERBOSE_TOC_WRITING => 'VERBOSE_TOC_WRITING', + VERBOSE_CHUNK_WRITING => 'VERBOSE_CHUNK_WRITING', + VERBOSE_NOVERSION => 'VERBOSE_NOVERSION', ); - - public static function __callStatic($name, $params) - { - $name = strtolower($name); // FC if this becomes case-sensitive - if (strncmp($name, 'set', 3) === 0) { - $name = substr($name, 3); - if ($name[0] === '_') { - $name = substr($name, 1); - } - if (strlen($name) < 1 || count($params) !== 1) { // assert - trigger_error("Misuse of config option setter", E_USER_ERROR); - } - self::$optionArray[$name] = $params[0]; - // no return, intentional - } - return isset(self::$optionArray[$name]) ? self::$optionArray[$name] : NULL; + static $recursive = false; + + // Respect the error_reporting setting + if (!(error_reporting() & $errno)) { + return false; + } + + // Recursive protection + if ($recursive) { + // Fallback to the default errorhandler + return false; + } + $recursive = true; + + $time = date($OPTIONS["date_format"]); + switch($errno) { + case VERBOSE_INDEXING: + case VERBOSE_FORMAT_RENDERING: + case VERBOSE_THEME_RENDERING: + case VERBOSE_RENDER_STYLE: + case VERBOSE_PARTIAL_READING: + case VERBOSE_PARTIAL_CHILD_READING: + case VERBOSE_TOC_WRITING: + case VERBOSE_CHUNK_WRITING: + case VERBOSE_NOVERSION: + $cl1 = $OPTIONS['color_output'] ? "\033[01;{$OPTIONS['color_output']}m" : ''; + $cr = $OPTIONS['color_output'] ? "\033[m" : ''; + fprintf($OPTIONS["phd_info_output"], "{$cl1}[%s - %s]{$cr} %s\n", $time, $err[$errno], $msg); + break; + + // User triggered errors + case E_USER_ERROR: + case E_USER_WARNING: + case E_USER_NOTICE: + fprintf($OPTIONS["user_error_output"], "[%s - %s] %s:%d\n\t%s\n", $time, $err[$errno], $file, $line, $msg); + break; + + // PHP triggered errors + case E_DEPRECATED: + case E_RECOVERABLE_ERROR: + case E_STRICT: + case E_WARNING: + case E_NOTICE: + fprintf($OPTIONS["php_error_output"], "[%s - %s] %s:%d\n\t%s\n", $time, $err[$errno], $file, $line, $msg); + break; + + default: + // Unknown error level.. let PHP handle it + $recursive = false; + return false; + } + + // Abort on fatal errors + if ($errno & (E_USER_ERROR|E_RECOVERABLE_ERROR)) { + exit(1); } + + $recursive = false; + return true; } +/* }}} */ +set_error_handler("errh"); +/* }}} */ -PhDConfig::set_php_error_output(STDERR); -PhDConfig::set_user_error_output(STDERR); -PhDConfig::set_phd_info_output(STDOUT); +define("PHD_VERSION", "0.2.4-dev"); + +/* {{{ Default $OPTIONS */ +$OPTIONS = array ( + 'output_format' => array('xhtml'), + 'output_theme' => array( + 'xhtml' => array( + 'php' => array( + 'phpweb', + 'chunkedhtml', + 'bightml', + ), + ), + ), + 'chunk_extra' => array( + "legalnotice" => true, + ), + 'index' => true, + 'xml_root' => '.', + 'xml_file' => './.manual.xml', + 'language' => 'en', + 'fallback_language' => 'en', + 'enforce_revisions' => false, + 'compatibility_mode' => true, + 'build_log_file' => 'none', + 'verbose' => VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING|VERBOSE_NOVERSION), + 'date_format' => "H:i:s", + 'render_ids' => array( + ), + 'skip_ids' => array( + ), + 'color_output' => false, + 'output_dir' => '.', + 'php_error_output' => STDERR, + 'user_error_output' => STDERR, + 'phd_info_output' => STDOUT, +); +/* }}} */ + +$olderr = error_reporting(); +error_reporting($olderr | $OPTIONS["verbose"]); + +/* {{{ getopt() options */ +$opts = array( + "format:" => "f:", // The format to render (xhtml, pdf...) + "theme:" => "t:", // The theme to render (phpweb, bightml..) + "index:" => "i:", // Re-index or load from cache + "docbook:" => "d:", // The Docbook XML file to render from (.manual.xml) + "output:" => "o:", // The output directory + "partial:" => "p:", // The ID to render (optionally ignoring its children) + "skip:" => "s:", // The ID to skip (optionally skipping its children too) + "verbose:" => "v", // Adjust the verbosity level + "list::" => "l::", // List supported themes/formats + "color::" => "c::", // Use color output if possible + "version" => "V", // Print out version information + "help" => "h", // Print out help +); +/* }}} */ /* {{{ Workaround/fix for Windows prior to PHP5.3 */ if (!function_exists("getopt")) { @@ -77,6 +194,14 @@ } /* }}} */ +$args = getopt(implode("", array_values($opts)), array_keys($opts)); +if($args === false) { + trigger_error("Something happend with getopt(), please report a bug", E_USER_ERROR); +} + +$verbose = 0; +$docbook = false; + /* {{{ phd_bool($var) Returns boolean true/false on success, null on failure */ function phd_bool($val) { if (!is_string($val)) { @@ -104,46 +229,306 @@ } /* }}} */ -abstract class OptionParser -{ - abstract public function getOptionList(); - - public function handlerForOption($opt) - { - if (method_exists($this, "option_{$opt}")) { - return array($this, "option_{$opt}"); +foreach($args as $k => $v) { + switch($k) { + /* {{{ Docbook file */ + case "d": + case "docbook": + if (is_array($v)) { + trigger_error("Can only parse one file at a time", E_USER_ERROR); + } + if (!file_exists($v) || is_dir($v) || !is_readable($v)) { + trigger_error(sprintf("'%s' is not a readable docbook file", $v), E_USER_ERROR); + } + $OPTIONS["xml_root"] = dirname($v); + $OPTIONS["xml_file"] = $v; + $docbook = true; + break; + /* }}} */ + + /* {{{ Output location */ + case "o": + case "output": + if (is_array($v)) { + trigger_error("Only a single output location can be supplied", E_USER_ERROR); + } + @mkdir($v, 0777, true); + if (!is_dir($v) || !is_readable($v)) { + trigger_error(sprintf("'%s' is not a valid directory", $v), E_USER_ERROR); + } + $OPTIONS["output_dir"] = $v; + break; + /* }}} */ + + /* {{{ Build format */ + case "f": + case "format": + if ($v != "xhtml") { + trigger_error("Only xhtml is supported at this time", E_USER_ERROR); + } + break; + /* }}} */ + + /* {{{ Run indexer or not */ + case "i": + case "index": + if (is_array($v)) { + trigger_error(sprintf("You cannot pass %s more than once", $k), E_USER_ERROR); + } + $val = phd_bool($v); + if (is_bool($val)) { + $OPTIONS["index"] = $val; } else { - return NULL; + trigger_error("yes/no || on/off || true/false || 1/0 expected", E_USER_ERROR); } - } - - public function getopt() - { - $opts = $this->getOptionList(); - $args = getopt(implode("", array_values($opts)), array_keys($opts)); - if ($args === false) { - trigger_error("Something happend with getopt(), please report a bug", E_USER_ERROR); + break; + /* }}} */ + + /* {{{ Print out a list of formats/themes */ + case "l": + case "list": + /* FIXME: This list should be created dynamically */ + foreach((array)$v as $val) { + switch($val) { + case "f": + case "format": + case "formats": + echo "Supported formats:\n"; + echo "\txhtml\n"; + break; + + case "t": + case "theme": + case "themes": + echo "Supported themes:\n"; + echo "\tphpweb\n"; + echo "\tchunkedhtml\n"; + echo "\tbightml\n"; + break; + + default: + echo "Unknown list type '$val'\n"; + /* break omitted intentionally */ + + case false: + echo "Supported formats:\n"; + echo "\txhtml\n"; + echo "Supported themes:\n"; + echo "\tphpweb\n"; + echo "\tchunkedhtml\n"; + echo "\tbightml\n"; + break; + } + } + exit(0); + break; + /* }}} */ + + /* {{{ Partial rendering */ + case "p": + case "partial": + foreach((array)$v as $i => $val) { + $recursive = true; + if (strpos($val, "=") !== false) { + list($val, $recursive) = explode("=", $val); + + if (!is_numeric($recursive) && defined($recursive)) { + $recursive = constant($recursive); + } + $recursive = (bool) $recursive; + } + $OPTIONS["render_ids"][$val] = $recursive; + } + break; + /* }}} */ + + /* {{{ Skip list */ + case "s": + case "skip": + foreach((array)$v as $i => $val) { + $recursive = true; + if (strpos($val, "=") !== false) { + list($val, $recursive) = explode("=", $val); + + if (!is_numeric($recursive) && defined($recursive)) { + $recursive = constant($recursive); + } + $recursive = (bool) $recursive; + } + $OPTIONS["skip_ids"][$val] = $recursive; + } + break; + /* }}} */ + + /* {{{ Output themes */ + case "t": + case "theme": + /* Remove the default themes */ + $OPTIONS["output_theme"]["xhtml"]["php"] = array(); + + foreach((array)$v as $i => $val) { + switch($val) { + case "phpweb": + case "chunkedhtml": + case "bightml": + if (!in_array($val, $OPTIONS["output_theme"]["xhtml"]["php"])) { + $OPTIONS["output_theme"]["xhtml"]["php"][] = $val; + } + break; + default: + trigger_error(sprintf("Unknown theme '%s'", $val), E_USER_ERROR); + } } + break; + /* }}} */ - foreach ($args as $k => $v) { - $handler = $this->handlerForOption($k); - if (is_callable($handler)) { - call_user_func($handler, $k, $v); - } else { - var_dump($k, $v); - trigger_error("Hmh, something weird has happend, I don't know this option", E_USER_ERROR); + /* {{{ Verbosity level */ + case "verbose": + foreach((array)$v as $i => $val) { + foreach(explode("|", $val) as $const) { + if (defined($const)) { + $verbose |= (int)constant($const); + } elseif (is_numeric($const)) { + $verbose |= (int)$const; + } else { + trigger_error("Unknown option passed to --$k, $const", E_USER_ERROR); + } } } + $OPTIONS["verbose"] = $verbose; + break; + + case "v": + if (is_array($v)) { + foreach($v as $i => $val) { + $verbose |= pow(2, $i); + } + } else { + $verbose |= 1; + } + $OPTIONS["verbose"] = $verbose; + break; + /* }}} */ + + /* {{{ Color output */ + case "c": + case "color": + if (is_array($v)) { + trigger_error(sprintf("You cannot pass %s more than once", $k), E_USER_ERROR); + } + if (function_exists('posix_isatty') && !posix_isatty($OPTIONS['phd_info_output'])) { + // Terminal doesn't support colors + break; + } + + $bool = phd_bool($v); + // No option or color specified + if ($v === false || ($bool === true && $v != 1)) { + // Fallback to default + $OPTIONS["color_output"] = 34; + } elseif ($bool === false) { + // Explicitly turning coloring off + $OPTIONS["color_output"] = false; + } elseif (is_numeric($v)) { + // Color specified + $OPTIONS["color_output"] = (int)$v; + } else { + trigger_error("yes/no || on/off || true/false || 1/0 expected", E_USER_ERROR); + } + break; + /* }}} */ + + /* {{{ Version info */ + case "V": + case "version": + printf("PhD version: %s\n", PHD_VERSION); + printf("Copyright (c) 2008 The PHP Documentation Group\n"); + exit(0); + /* }}} */ + + /* {{{ Help/usage info */ + case "usage": + case "help": + case "h": + echo "PhD version: " .PHD_VERSION; + echo "\nCopyright (c) 2008 The PHP Documentation Group\n + -v + --verbose <int> Adjusts the verbosity level + -f <formatname> + --format <formatname> The build format to use + -t <themename> + --theme <themename> The theme to use + -i <bool> + --index <bool> Index before rendering (default) or load from cache (false) + -d <filename> + --docbook <filename> The Docbook file to render from + -p <id[=bool]> + --partial <id[=bool]> The ID to render, optionally skipping its children chunks (default to true; render children) + -s <id[=bool]> + --skip <id[=bool]> The ID to skip, optionally skipping its children chunks (default to true; skip children) + -l <formats/themes> + --list <formats/themes> Print out the supported formats/themes (default: both) + -o <directory> + --output <directory> The output directory (default: .) + -c <color> + --color <color> Enable color output when output is to a terminal, optionally specify numerical color value (default: false) + -V + --version Print the PhD version information + -h + --help This help + +Most options can be passed multiple times for greater affect. +NOTE: Long options are only supported using PHP5.3\n"; + exit(0); + break; + /* }}} */ + + /* {{{ Unsupported option this should *never* happen */ + default: + var_dump($k, $v); + trigger_error("Hmh, something weird has happend, I don't know this option", E_USER_ERROR); + /* }}} */ } } -/* {{{ Can't function_call()['key'], so val(function_call(), 'key') */ -function val($a, $k) -{ - return $a[$k]; +error_reporting($olderr | $OPTIONS["verbose"]); + +/* {{{ BC for PhD 0.0.* (and PHP5.2 on Windows) + i.e. `phd path/to/.manual.xml */ +if (!$docbook && $argc > 1) { + $arg = $argv[$argc-1]; + if (is_dir($arg)) { + $OPTIONS["xml_root"] = $arg; + $OPTIONS["xml_file"] = $arg . DIRECTORY_SEPARATOR . ".manual.xml"; + } elseif (is_file($arg)) { + $OPTIONS["xml_root"] = dirname($arg); + $OPTIONS["xml_file"] = $arg; + } } /* }}} */ +/* {{{ If no docbook file was passed, ask for it + This loop should be removed in PhD 0.3.0, and replaced with a fatal errormsg */ +while (!is_dir($OPTIONS["xml_root"]) || !is_file($OPTIONS["xml_file"])) { + print "I need to know where you keep your '.manual.xml' file (I didn't find it in " . $OPTIONS["xml_root"] . "): "; + $root = trim(fgets(STDIN)); + if (is_file($root)) { + $OPTIONS["xml_file"] = $root; + $OPTIONS["xml_root"] = dirname($root); + } else { + $OPTIONS["xml_file"] = $root . "/.manual.xml"; + $OPTIONS["xml_root"] = $root; + } +} +/* }}} */ + +/* This needs to be done in *all* cases! */ +$OPTIONS["output_dir"] = realpath($OPTIONS["output_dir"]) . DIRECTORY_SEPARATOR; + +// Those files really should be moved into phd/ +$OPTIONS["version_info"] = $OPTIONS["xml_root"]."/phpbook/phpbook-xsl/version.xml"; +$OPTIONS["acronyms_file"] = $OPTIONS["xml_root"]."/entities/acronyms.xml"; + /* * vim600: sw=4 ts=4 syntax=php et * vim<600: sw=4 ts=4 http://cvs.php.net/viewvc.cgi/phd/mktoc.php?r1=1.9&r2=1.10&diff_format=u Index: phd/mktoc.php diff -u phd/mktoc.php:1.9 phd/mktoc.php:1.10 --- phd/mktoc.php:1.9 Sat May 24 14:30:00 2008 +++ phd/mktoc.php Sat May 24 14:49:14 2008 @@ -1,6 +1,6 @@ <?php -/* $Id: mktoc.php,v 1.9 2008/05/24 14:30:00 gwynne Exp $ */ -$r = new PhDReader(); +/* $Id: mktoc.php,v 1.10 2008/05/24 14:49:14 gwynne Exp $ */ +$r = new PhDReader($OPTIONS); $REFS = $FILENAMES = array(); $CURRENT_FILENAME = $LAST_CHUNK = ""; http://cvs.php.net/viewvc.cgi/phd/package.xml?r1=1.72&r2=1.73&diff_format=u Index: phd/package.xml diff -u phd/package.xml:1.72 phd/package.xml:1.73 --- phd/package.xml:1.72 Sat May 24 14:30:00 2008 +++ phd/package.xml Sat May 24 14:49:14 2008 @@ -51,17 +51,11 @@ - Added Danish support (for autogenerated texts). (Kalle Sommer) - Added Swedish support (for autogenerated texts). (Kalle Sommer) - Added experimental option (-c/--color) for color in verbose output. (Gwynne) - - Rewrote option parsing, allows the same code to be reused for multiple scripts. (Gwynne) - - Rewrote config option access, avoids globals. (Gwynne) - - Cleaned up error handler. (Gwynne) - - --list option now glob()s the themes/ and formats/ directories. (Gwynne) </notes> <contents> <dir baseinstalldir="phd" name="/"> <file baseinstalldir="phd" name="formats/xhtml.php" role="php"/> - <file baseinstalldir="phd" name="include/buildoptions.php" role="php"/> - <file baseinstalldir="phd" name="include/PhDErrors.php" role="php"/> <file baseinstalldir="phd" name="include/PhDFormat.class.php" role="php"/> <file baseinstalldir="phd" name="include/PhDTheme.class.php" role="php"/> <file baseinstalldir="phd" name="include/PhDHelper.class.php" role="php"/> http://cvs.php.net/viewvc.cgi/phd/include/PhDPartialReader.class.php?r1=1.6&r2=1.7&diff_format=u Index: phd/include/PhDPartialReader.class.php diff -u phd/include/PhDPartialReader.class.php:1.6 phd/include/PhDPartialReader.class.php:1.7 --- phd/include/PhDPartialReader.class.php:1.6 Sat May 24 14:30:00 2008 +++ phd/include/PhDPartialReader.class.php Sat May 24 14:49:14 2008 @@ -1,26 +1,24 @@ <?php -/* $Id: PhDPartialReader.class.php,v 1.6 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: PhDPartialReader.class.php,v 1.7 2008/05/24 14:49:14 gwynne Exp $ */ class PhDPartialReader extends PhDReader { protected $partial = array(); protected $skip = array(); - public function __construct($encoding = "UTF-8", $xml_opts = NULL) { - parent::__construct($encoding, $xml_opts); - - $render_ids = PhDConfig::render_ids(); - if ($render_ids !== NULL) { - if (is_array($render_ids)) { - $this->partial = $render_ids; + public function __construct($opts, $encoding = "UTF-8", $xml_opts = NULL) { + parent::__construct($opts, $encoding, $xml_opts); + + if (isset($opts["render_ids"])) { + if (is_array($opts["render_ids"])) { + $this->partial = $opts["render_ids"]; } else { - $this->partial[$render_ids] = 1; + $this->partial[$opts["render_ids"]] = 1; } - $skip_ids = PhDConfig::skip_ids(); - if ($skip_ids !== NULL) { - if (is_array($skip_ids)) { - $this->skip = $skip_ids; + if (isset($opts["skip_ids"])) { + if (is_array($opts["skip_ids"])) { + $this->skip = $opts["skip_ids"]; } else { - $this->skip[$skip_ids] = 1; + $this->skip[$opts["skip_ids"]] = 1; } } } else { http://cvs.php.net/viewvc.cgi/phd/include/PhDReader.class.php?r1=1.15&r2=1.16&diff_format=u Index: phd/include/PhDReader.class.php diff -u phd/include/PhDReader.class.php:1.15 phd/include/PhDReader.class.php:1.16 --- phd/include/PhDReader.class.php:1.15 Sat May 24 14:30:00 2008 +++ phd/include/PhDReader.class.php Sat May 24 14:49:14 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDReader.class.php,v 1.15 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: PhDReader.class.php,v 1.16 2008/05/24 14:49:14 gwynne Exp $ */ //6271 class PhDReader extends XMLReader { @@ -60,19 +60,20 @@ 'set' => true, 'setindex' => true, ); /* }}} */ + protected $opts = array(); public $isChunk = false; - public function __construct($encoding = "UTF-8", $xml_opts = NULL) { /* {{{ */ - if (!XMLReader::open(PhDConfig::xml_file(), $encoding, $xml_opts)) { - throw new Exception("Cannot open " . PhDConfig::xml_file()); - } - $ce = PhDConfig::chunk_extra(); - if (is_array($ce)) { - foreach($ce as $el => $v) { + public function __construct($opts, $encoding = "UTF-8", $xml_opts = NULL) { /* {{{ */ + if (!XMLReader::open($opts["xml_file"], $encoding, $xml_opts)) { + throw new Exception("Cannot open {$opts["xml_file"]}"); + } + if (isset($opts["chunk_extra"]) && is_array($opts["chunk_extra"])) { + foreach($opts["chunk_extra"] as $el => $v) { $this->CHUNK_ME[$el] = $v; } } + $this->opts = $opts; } /* }}} */ public function notXPath($tag, $depth = 0) { /* {{{ */ http://cvs.php.net/viewvc.cgi/phd/themes/php/bightml.php?r1=1.10&r2=1.11&diff_format=u Index: phd/themes/php/bightml.php diff -u phd/themes/php/bightml.php:1.10 phd/themes/php/bightml.php:1.11 --- phd/themes/php/bightml.php:1.10 Sat May 24 14:30:00 2008 +++ phd/themes/php/bightml.php Sat May 24 14:49:14 2008 @@ -1,11 +1,11 @@ <?php -/* $Id: bightml.php,v 1.10 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: bightml.php,v 1.11 2008/05/24 14:49:14 gwynne Exp $ */ require_once $ROOT . '/themes/php/phpdotnet.php'; class bightml extends phpdotnet { public function __construct(array $IDs, $filename, $ext = "html") { parent::__construct($IDs, $filename, $ext, false); - $this->stream = fopen(PhDConfig::output_dir() . "bightml.html", "w"); + $this->stream = fopen($GLOBALS['OPTIONS']['output_dir'] . "bightml.html", "w"); self::header(); } public function appendData($data, $isChunk) { http://cvs.php.net/viewvc.cgi/phd/themes/php/chunkedhtml.php?r1=1.10&r2=1.11&diff_format=u Index: phd/themes/php/chunkedhtml.php diff -u phd/themes/php/chunkedhtml.php:1.10 phd/themes/php/chunkedhtml.php:1.11 --- phd/themes/php/chunkedhtml.php:1.10 Sat May 24 14:30:00 2008 +++ phd/themes/php/chunkedhtml.php Sat May 24 14:49:14 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: chunkedhtml.php,v 1.10 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: chunkedhtml.php,v 1.11 2008/05/24 14:49:14 gwynne Exp $ */ require_once $ROOT . '/themes/php/phpweb.php'; class chunkedhtml extends phpweb { @@ -7,7 +7,7 @@ public function __construct(array $IDs, $filename, $ext = "html") { phpdotnet::__construct($IDs, $filename, $ext, true); - $this->outputdir = PhDConfig::output_dir() . $this->ext . DIRECTORY_SEPARATOR; + $this->outputdir = $GLOBALS['OPTIONS']['output_dir'] . $this->ext . DIRECTORY_SEPARATOR; if(!file_exists($this->outputdir) || is_file($this->outputdir)) mkdir($this->outputdir) or die("Can't create the cache directory"); elseif (file_exists($this->outputdir . 'index.html')) unlink($this->outputdir . 'index.html'); // preserve back-compat } http://cvs.php.net/viewvc.cgi/phd/themes/php/phpweb.php?r1=1.26&r2=1.27&diff_format=u Index: phd/themes/php/phpweb.php diff -u phd/themes/php/phpweb.php:1.26 phd/themes/php/phpweb.php:1.27 --- phd/themes/php/phpweb.php:1.26 Sat May 24 14:30:00 2008 +++ phd/themes/php/phpweb.php Sat May 24 14:49:14 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: phpweb.php,v 1.26 2008/05/24 14:30:00 gwynne Exp $ */ +/* $Id: phpweb.php,v 1.27 2008/05/24 14:49:14 gwynne Exp $ */ require_once $ROOT . '/themes/php/phpdotnet.php'; class phpweb extends phpdotnet { @@ -10,7 +10,7 @@ public function __construct($IDs, $filename, $ext = "php", $chunked = true) { parent::__construct($IDs, $filename, $ext, $chunked); - $this->outputdir = PhDConfig::output_dir() . $this->ext . DIRECTORY_SEPARATOR; + $this->outputdir = $GLOBALS['OPTIONS']['output_dir'] . $this->ext . DIRECTORY_SEPARATOR; if (!file_exists($this->outputdir) || is_file($this->outputdir)) { mkdir($this->outputdir) or die("Can't create the cache directory"); } else {