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: Date: Sat, 24 May 2008 15:04:51 +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-1683@lists.php.net to get a copy of this message
gwynne Sat May 24 15:04:51 2008 UTC Modified files: /phd build.php config.php mktoc.php package.xml /phd/include PhDErrors.php buildoptions.php PhDPartialReader.class.php PhDReader.class.php /phd/themes/php bightml.php chunkedhtml.php phpweb.php Log: - Rewrote option parsing, allows the same code to be reused for multiple scripts - Rewrote config option access, avoids globals - Cleaned up error handler - Color output is now on all three output streams if user selects for it - --list option now glob()s the themes/ and formats/ directories - Whitespace fix in chunkedhtml.php

http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.54&r2=1.55&diff_format=u Index: phd/build.php diff -u phd/build.php:1.54 phd/build.php:1.55 --- phd/build.php:1.54 Sat May 24 14:49:14 2008 +++ phd/build.php Sat May 24 15:04:50 2008 @@ -1,6 +1,6 @@ #!@php_bin@ <?php -/* $Id: build.php,v 1.54 2008/05/24 14:49:14 gwynne Exp $ */ +/* $Id: build.php,v 1.55 2008/05/24 15:04:50 gwynne Exp $ */ /* {{{ Find the $ROOT directory of PhD @php_dir@ will be replaced by the pear package manager @@ -12,12 +12,48 @@ } /* }}} */ -(@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"); +(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"); require $ROOT. "/include/PhDReader.class.php"; require $ROOT. "/include/PhDPartialReader.class.php"; @@ -26,20 +62,20 @@ require $ROOT. "/include/PhDTheme.class.php"; /* {{{ Build the .ser file names to allow multiple sources for PHD. */ -$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'; +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'); /* }}} */ /* {{{ 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 (!$OPTIONS["index"] && (file_exists($OPTIONS['index_location']) && file_exists($OPTIONS['refnames_location']))) { +if (!PhDConfig::index() && (file_exists(PhDConfig::index_location()) && file_exists(PhDConfig::refnames_location()))) { /* FIXME: Load from sqlite db? */ v("Unserializing cached index files...", VERBOSE_INDEXING); - $IDs = unserialize(file_get_contents($OPTIONS['index_location'])); - $REFS = unserialize(file_get_contents($OPTIONS['refnames_location'])); + $IDs = unserialize(file_get_contents(PhDConfig::index_location())); + $REFS = unserialize(file_get_contents(PhDConfig::refnames_location())); v("Unserialization done", VERBOSE_INDEXING); } else { @@ -48,8 +84,8 @@ /* This file will "return" an $IDs & $REFS array */ require $ROOT. "/mktoc.php"; - file_put_contents($OPTIONS['index_location'], $ids = serialize($IDs)); - file_put_contents($OPTIONS['refnames_location'], $refs = serialize($REFS)); + file_put_contents(PhDConfig::index_location(), $ids = serialize($IDs)); + file_put_contents(PhDConfig::refnames_location(), $refs = serialize($REFS)); $IDs2 = unserialize($ids); $REFS2 = unserialize($refs); @@ -61,7 +97,7 @@ } /* }}} */ -foreach($OPTIONS["output_format"] as $output_format) { +foreach(PhDConfig::output_format() as $output_format) { v("Starting %s rendering", $output_format, VERBOSE_FORMAT_RENDERING); switch($output_format) { @@ -79,7 +115,7 @@ /* {{{ initialize output themes and fetch the methodmaps */ $themes = $elementmaps = $textmaps = array(); - foreach($OPTIONS["output_theme"][$output_format] as $theme => $array) { + foreach(val(PhDConfig::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); @@ -91,8 +127,8 @@ case "php": $themes[$themename] = new $themename(array($IDs, $REFS), array( - "version" => $OPTIONS["version_info"], - "acronym" => $OPTIONS["acronyms_file"], + "version" => PhDConfig::version_info(), + "acronym" => PhDConfig::acronyms_file(), ) ); break; @@ -121,8 +157,8 @@ /* }}} */ /* {{{ Initialize the PhD[Partial]Reader */ - if (!empty($OPTIONS["render_ids"]) || !empty($OPTIONS["skip_ids"])) { - $idlist = $OPTIONS["render_ids"]+$OPTIONS["skip_ids"]; + $idlist = PhDConfig::render_ids()+PhDConfig::skip_ids(); + if (!empty($idlist)) { v("Running partial build", VERBOSE_RENDER_STYLE); if (!is_array($idlist)) { @@ -134,11 +170,11 @@ } } - $reader = new PhDPartialReader($OPTIONS); + $reader = new PhDPartialReader(); } else { v("Running full build", VERBOSE_RENDER_STYLE); - $reader = new PhDReader($OPTIONS); + $reader = new PhDReader(); } /* }}} */ @@ -292,7 +328,7 @@ $reader->close(); v("Finished rendering", VERBOSE_FORMAT_RENDERING); -} // foreach($OPTIONS["output_thtemes"]) +} // foreach(PhDConfig::output_themes()) /* * vim600: sw=4 ts=4 syntax=php et http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.45&r2=1.46&diff_format=u Index: phd/config.php diff -u phd/config.php:1.45 phd/config.php:1.46 --- phd/config.php:1.45 Sat May 24 14:49:14 2008 +++ phd/config.php Sat May 24 15:04:50 2008 @@ -1,186 +1,69 @@ <?php -/* $Id: config.php,v 1.45 2008/05/24 14:49:14 gwynne Exp $ */ +/* $Id: config.php,v 1.46 2008/05/24 15:04:50 gwynne Exp $ */ -/* {{{ PhD error & message handler */ +require $ROOT . "/include/PhDErrors.php"; -// 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"]); -} -/* }}} */ +define("PHD_VERSION", "0.2.4-dev"); -/* {{{ 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', +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, ); - 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); + + 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; } - - $recursive = false; - return true; } -/* }}} */ -set_error_handler("errh"); -/* }}} */ -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 -); -/* }}} */ +PhDConfig::set_php_error_output(STDERR); +PhDConfig::set_user_error_output(STDERR); +PhDConfig::set_phd_info_output(STDOUT); /* {{{ Workaround/fix for Windows prior to PHP5.3 */ if (!function_exists("getopt")) { @@ -194,14 +77,6 @@ } /* }}} */ -$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)) { @@ -229,306 +104,46 @@ } /* }}} */ -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 { - trigger_error("yes/no || on/off || true/false || 1/0 expected", 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; - /* }}} */ - - /* {{{ 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); - } +abstract class OptionParser +{ + abstract public function getOptionList(); + + public function handlerForOption($opt) + { + if (method_exists($this, "option_{$opt}")) { + return array($this, "option_{$opt}"); } else { - $verbose |= 1; + return NULL; } - $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; + 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); } - $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); + 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); + } } - 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); - /* }}} */ } } -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; - } +/* {{{ Can't function_call()['key'], so val(function_call(), 'key') */ +function val($a, $k) +{ + return $a[$k]; } /* }}} */ -/* {{{ 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.10&r2=1.11&diff_format=u Index: phd/mktoc.php diff -u phd/mktoc.php:1.10 phd/mktoc.php:1.11 --- phd/mktoc.php:1.10 Sat May 24 14:49:14 2008 +++ phd/mktoc.php Sat May 24 15:04:50 2008 @@ -1,6 +1,6 @@ <?php -/* $Id: mktoc.php,v 1.10 2008/05/24 14:49:14 gwynne Exp $ */ -$r = new PhDReader($OPTIONS); +/* $Id: mktoc.php,v 1.11 2008/05/24 15:04:50 gwynne Exp $ */ +$r = new PhDReader(); $REFS = $FILENAMES = array(); $CURRENT_FILENAME = $LAST_CHUNK = ""; http://cvs.php.net/viewvc.cgi/phd/package.xml?r1=1.75&r2=1.76&diff_format=u Index: phd/package.xml diff -u phd/package.xml:1.75 phd/package.xml:1.76 --- phd/package.xml:1.75 Sat May 24 15:00:39 2008 +++ phd/package.xml Sat May 24 15:04:50 2008 @@ -40,11 +40,17 @@ </stability> <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license> <notes> + - 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/PhDErrors.php?r1=1.2&r2=1.3&diff_format=u Index: phd/include/PhDErrors.php diff -u /dev/null phd/include/PhDErrors.php:1.3 --- /dev/null Sat May 24 15:04:50 2008 +++ phd/include/PhDErrors.php Sat May 24 15:04:50 2008 @@ -0,0 +1,141 @@ +<?php +/* $Id: PhDErrors.php,v 1.3 2008/05/24 15:04:50 gwynne Exp $ */ + +/* {{{ PhD error & message handler */ + +// 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); +define('VERBOSE_DEFAULT', (VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING|VERBOSE_NOVERSION))); + +$olderrrep = error_reporting(); +error_reporting($olderrrep | VERBOSE_DEFAULT); + +/* {{{ 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"]); +} +/* }}} */ + +/* {{{ Function to get a color escape sequence */ +function term_color($text, $color) +{ + return $color === false ? $text : "\033[" . $color . "m" . $text . "\033[m"; +} +/* }}} */ + +/* {{{ The PhD errorhandler */ +function errh($errno, $msg, $file, $line, $ctx = null) { + 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', + ); + 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(PhDConfig::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: + $color = PhDConfig::phd_info_color(); + $output = PhDConfig::phd_info_output(); + $data = $msg; + break; + + // User triggered errors + case E_USER_ERROR: + case E_USER_WARNING: + case E_USER_NOTICE: + $color = PhDConfig::user_error_color(); + $output = PhDConfig::user_error_output(); + $data = sprintf("%s:%d\n\t%s", $file, $line, $msg); + break; + + // PHP triggered errors + case E_DEPRECATED: + case E_RECOVERABLE_ERROR: + case E_STRICT: + case E_WARNING: + case E_NOTICE: + $color = PhDConfig::php_error_color(); + $output = PhDConfig::php_error_output(); + $data = sprintf("%s:%d\n\t%s", $file, $line, $msg); + break; + + default: + $recursive = false; + return false; + } + + $timestamp = term_color(sprintf("[%s - %s]", $time, $err[$errno]), $color); + fprintf($output, "%s %s\n", $timestamp, $data); + + // Abort on fatal errors + if ($errno & (E_USER_ERROR|E_RECOVERABLE_ERROR)) { + exit(1); + } + + $recursive = false; + return true; +} +/* }}} */ +set_error_handler("errh"); +/* }}} */ + +?> http://cvs.php.net/viewvc.cgi/phd/include/buildoptions.php?r1=1.4&r2=1.5&diff_format=u Index: phd/include/buildoptions.php diff -u /dev/null phd/include/buildoptions.php:1.5 --- /dev/null Sat May 24 15:04:51 2008 +++ phd/include/buildoptions.php Sat May 24 15:04:50 2008 @@ -0,0 +1,328 @@ +<?php +/* $Id: buildoptions.php,v 1.5 2008/05/24 15:04:50 gwynne Exp $ */ + +class BuildOptionsParser extends OptionParser +{ + public $docbook = false; + public $verbose = 0; + + public function getOptionList() + { + return 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 + ); + } + + public function option_f($k, $v) + { + $this->option_format($k, $v); + } + public function option_format($k, $v) + { + if ($v != "xhtml") { + trigger_error("Only xhtml is supported at this time", E_USER_ERROR); + } + } + + public function option_t($k, $v) + { + $this->option_theme($k, $v); + } + public function option_theme($k, $v) + { + /* Remove the default themes */ + $themes = PhDConfig::output_theme(); + $themes['xhtml']['php'] = array(); + + foreach((array)$v as $i => $val) { + switch($val) { + case "phpweb": + case "chunkedhtml": + case "bightml": + if (!in_array($val, $themes["xhtml"]["php"])) { + $theses["xhtml"]["php"][] = $val; + } + break; + default: + trigger_error(sprintf("Unknown theme '%s'", $val), E_USER_ERROR); + } + } + PhDConfig::set_output_theme($themes); + } + + public function option_i($k, $v) + { + $this->option_index($k, $v); + } + public function option_index($k, $v) + { + 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)) { + PhDConfig::set_index($val); + } else { + trigger_error("yes/no || on/off || true/false || 1/0 expected", E_USER_ERROR); + } + } + + public function option_d($k, $v) + { + $this->option_docbook($k, $v); + } + public function option_docbook($k, $v) + { + 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); + } + PhDConfig::set_xml_root(dirname($v)); + PhDConfig::set_xml_file($v); + $this->docbook = true; + } + + public function option_o($k, $v) + { + $this->option_output($k, $v); + } + public function option_output($k, $v) + { + 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); + } + PhDConfig::set_output_dir($v); + break; + } + + public function option_p($k, $v) + { + $this->option_partial($k, $v); + } + public function option_partial($k, $v) + { + $render_ids = PhDConfig::render_ids(); + 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; + } + $render_ids[$val] = $recursive; + } + PhDConfig::set_render_ids($render_ids); + } + + public function option_s($k, $v) + { + $this->option_skip($k, $v); + } + public function option_skip($k, $v) + { + $skip_ids = PhDConfig::skip_ids(); + 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; + } + $skip_ids[$val] = $recursive; + } + PhDConfig::set_skip_ids($skip_ids); + } + + public function option_v($k, $v) + { + if ($k[0] === 'V') { + $this->option_version($k, $v); + return; + } + + if (is_array($v)) { + foreach($v as $i => $val) { + $this->verbose |= pow(2, $i); + } + } else { + $this->verbose |= 1; + } + PhDConfig::set_verbose($this->verbose); + error_reporting($GLOBALS['olderrrep'] | $this->verbose); + } + + public function option_verbose($k, $v) + { + foreach((array)$v as $i => $val) { + foreach(explode("|", $val) as $const) { + if (defined($const)) { + $this->verbose |= (int)constant($const); + } elseif (is_numeric($const)) { + $this->verbose |= (int)$const; + } else { + trigger_error("Unknown option passed to --$k, $const", E_USER_ERROR); + } + } + } + PhDConfig::set_verbose($this->verbose); + error_reporting($GLOBALS['olderrrep'] | $this->verbose); + } + + public function option_l($k, $v) + { + $this->option_list($k, $v); + } + public function option_list($k, $v) + { + static $formatList = NULL; + static $themeList = NULL; + + if (is_null($formatList)) { + $formatList = array(); + foreach (glob($GLOBALS['ROOT'] . "/formats/*.php") as $item) { + $formatList[] = substr(basename($item), 0, -4); + } + } + if (is_null($themeList)) { + $themeList = array(); + foreach (glob($GLOBALS['ROOT'] . "/themes/*", GLOB_ONLYDIR) as $item) { + if (!in_array(basename($item), array('CVS', '.', '..'))) { + $maintheme = basename($item); + $subthemes = array(); + foreach (glob($item . "/*.php") as $subitem) { + $subthemes[] = substr(basename($subitem), 0, -4); + } + $themeList[$maintheme] = $subthemes; + } + } + } + + if ($v === false) { + $v = array('f', 't'); + } + + foreach((array)$v as $val) { + switch($val) { + case "f": + case "format": + case "formats": { + echo "Supported formats:\n"; + echo "\t" . implode("\n\t", $formatList) . "\n"; + break; + } + + case "t": + case "theme": + case "themes": + echo "Supported themes:\n"; + foreach ($themeList as $theme => $subthemes) { + echo "\t" . $theme . "\n\t\t" . implode("\n\t\t", $subthemes) . "\n"; + } + break; + + default: + echo "Unknown list type '$val'\n"; + break; + } + } + exit(0); + } + + public function option_c($k, $v) + { + $this->option_color($k, $v); + } + public function option_color($k, $v) + { + 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)) { + if ($val && function_exists('posix_isatty')) { + PhDConfig::set_phd_info_color(posix_isatty(PhDConfig::phd_info_output()) ? '01;32' : false); // Bright (bold) green + PhDConfig::set_user_error_color(posix_isatty(PhDConfig::user_error_output()) ? '01;33' : false); // Bright (bold) yellow + PhDConfig::set_php_error_color(posix_isatty(PhDConfig::php_error_output()) ? '01;31' : false); // Bright (bold) red + } else { + PhDConfig::set_phd_info_color(false); + PhDConfig::set_user_error_color(false); + PhDConfig::set_php_error_color(false); + } + } else { + trigger_error("yes/no || on/off || true/false || 1/0 expected", E_USER_ERROR); + } + } + + public function option_version($k, $v) + { + printf("PhD version: %s\n", PHD_VERSION); + printf("Copyright (c) 2008 The PHP Documentation Group\n"); + exit(0); + } + + public function option_h($k, $v) + { + $this->option_help($k, $v); + } + public function option_help($k, $v) + { + 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 <bool> + --color <bool> Enable color output when output is to a terminal (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); + } +} + +$optParser = new BuildOptionsParser; +$optParser->getopt(); + +?> http://cvs.php.net/viewvc.cgi/phd/include/PhDPartialReader.class.php?r1=1.7&r2=1.8&diff_format=u Index: phd/include/PhDPartialReader.class.php diff -u phd/include/PhDPartialReader.class.php:1.7 phd/include/PhDPartialReader.class.php:1.8 --- phd/include/PhDPartialReader.class.php:1.7 Sat May 24 14:49:14 2008 +++ phd/include/PhDPartialReader.class.php Sat May 24 15:04:50 2008 @@ -1,24 +1,26 @@ <?php -/* $Id: PhDPartialReader.class.php,v 1.7 2008/05/24 14:49:14 gwynne Exp $ */ +/* $Id: PhDPartialReader.class.php,v 1.8 2008/05/24 15:04:50 gwynne Exp $ */ class PhDPartialReader extends PhDReader { protected $partial = array(); protected $skip = array(); - 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"]; + 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; } else { - $this->partial[$opts["render_ids"]] = 1; + $this->partial[$render_ids] = 1; } - if (isset($opts["skip_ids"])) { - if (is_array($opts["skip_ids"])) { - $this->skip = $opts["skip_ids"]; + $skip_ids = PhDConfig::skip_ids(); + if ($skip_ids !== NULL) { + if (is_array($skip_ids)) { + $this->skip = $skip_ids; } else { - $this->skip[$opts["skip_ids"]] = 1; + $this->skip[$skip_ids] = 1; } } } else { http://cvs.php.net/viewvc.cgi/phd/include/PhDReader.class.php?r1=1.16&r2=1.17&diff_format=u Index: phd/include/PhDReader.class.php diff -u phd/include/PhDReader.class.php:1.16 phd/include/PhDReader.class.php:1.17 --- phd/include/PhDReader.class.php:1.16 Sat May 24 14:49:14 2008 +++ phd/include/PhDReader.class.php Sat May 24 15:04:50 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDReader.class.php,v 1.16 2008/05/24 14:49:14 gwynne Exp $ */ +/* $Id: PhDReader.class.php,v 1.17 2008/05/24 15:04:50 gwynne Exp $ */ //6271 class PhDReader extends XMLReader { @@ -60,20 +60,19 @@ 'set' => true, 'setindex' => true, ); /* }}} */ - protected $opts = array(); public $isChunk = false; - 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) { + 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) { $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.11&r2=1.12&diff_format=u Index: phd/themes/php/bightml.php diff -u phd/themes/php/bightml.php:1.11 phd/themes/php/bightml.php:1.12 --- phd/themes/php/bightml.php:1.11 Sat May 24 14:49:14 2008 +++ phd/themes/php/bightml.php Sat May 24 15:04:50 2008 @@ -1,11 +1,11 @@ <?php -/* $Id: bightml.php,v 1.11 2008/05/24 14:49:14 gwynne Exp $ */ +/* $Id: bightml.php,v 1.12 2008/05/24 15:04:50 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($GLOBALS['OPTIONS']['output_dir'] . "bightml.html", "w"); + $this->stream = fopen(PhDConfig::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.11&r2=1.12&diff_format=u Index: phd/themes/php/chunkedhtml.php diff -u phd/themes/php/chunkedhtml.php:1.11 phd/themes/php/chunkedhtml.php:1.12 --- phd/themes/php/chunkedhtml.php:1.11 Sat May 24 14:49:14 2008 +++ phd/themes/php/chunkedhtml.php Sat May 24 15:04:50 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: chunkedhtml.php,v 1.11 2008/05/24 14:49:14 gwynne Exp $ */ +/* $Id: chunkedhtml.php,v 1.12 2008/05/24 15:04:50 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 = $GLOBALS['OPTIONS']['output_dir'] . $this->ext . DIRECTORY_SEPARATOR; + $this->outputdir = PhDConfig::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.27&r2=1.28&diff_format=u Index: phd/themes/php/phpweb.php diff -u phd/themes/php/phpweb.php:1.27 phd/themes/php/phpweb.php:1.28 --- phd/themes/php/phpweb.php:1.27 Sat May 24 14:49:14 2008 +++ phd/themes/php/phpweb.php Sat May 24 15:04:50 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: phpweb.php,v 1.27 2008/05/24 14:49:14 gwynne Exp $ */ +/* $Id: phpweb.php,v 1.28 2008/05/24 15:04:50 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 = $GLOBALS['OPTIONS']['output_dir'] . $this->ext . DIRECTORY_SEPARATOR; + $this->outputdir = PhDConfig::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 {
« previous php.doc.cvs (#1683) next »