diff --git a/README.REDESIGN b/README.REDESIGN new file mode 100644 index 000000000..953268cd2 --- /dev/null +++ b/README.REDESIGN @@ -0,0 +1,38 @@ +The redesign affects both PhD itself and the phpdoc/ checkout structure. The +changes in phpdoc/ and their reasons are listed here. + +- Pregenerated files like functable.xml removed from CVS + These can be one-timed from phd-setup as necessitated by the php.net theme + selection. + +- Intermediate manual.xml completely removed + phd-compile only needs this internally; generating it isn't time-consuming + enough to warrant a permanent file. Because it's changed on a per-language + basis, and language is determined by phd-compile, phd-setup should not + pregenerate it. + +- Remove install-win.xml and install-unix.xml + Easily generated by phd-compile --partial=install.windows or similar. + +- Remove htmlhelp/ + Replaced by CHM output format in PhD. + +- phpdoc-howto really should be its own CVS/SVN module + +- phpbook/ and docbook/ removed, replaced by docbook-xml/ + No longer necessary or used, especially not DSSSL or XSL. Only docbook-xml/ + is used by PhD for DTD validation of manual.xml. + +- PhD, all three phases, must support saving *all* output outside a CVS/SVN + checkout. PhD should not depend on the presence of any files inside a CVS/SVN + checkout save manual.xml, and allow manual.xml and specific output themes to + define anything else. PhD may also depend on the use of language + subdirectories according to theme settings. + +- Output format and theme should be defined and saved by phd-setup, but *not* + language! Also under phd-setup's responsibility are: + - input checkout directory (though it should not have to be a CVS/SVN + checkout!), + - output directory for build files + - list of available themes/formats + - *not* output directory for final results diff --git a/compile.php b/compile.php new file mode 100644 index 000000000..e7eefa0b0 --- /dev/null +++ b/compile.php @@ -0,0 +1,18 @@ +#!@php_bin@ + diff --git a/config.php b/config.php index 1fc01b7fc..6ed030a7b 100644 --- a/config.php +++ b/config.php @@ -35,7 +35,9 @@ class PhDConfig 'skip_ids' => array( ), 'color_output' => false, + 'source_dir' => '.', 'output_dir' => '.', + 'intermediate_output_dir' => '.', 'php_error_output' => NULL, 'php_error_color' => false, 'user_error_output' => NULL, @@ -66,18 +68,6 @@ public static function __callStatic($name, $params) PhDConfig::set_user_error_output(STDERR); PhDConfig::set_phd_info_output(STDOUT); -/* {{{ Workaround/fix for Windows prior to PHP5.3 */ -if (!function_exists("getopt")) { - function getopt($short, $long) { - global $argv; - printf("I'm sorry, you are running an operating system that does not support getopt()\n"); - printf("Please either upgrade to PHP5.3 or try '%s /path/to/your/docbook.xml'\n", $argv[0]); - - return array(); - } -} -/* }}} */ - /* {{{ phd_bool($var) Returns boolean true/false on success, null on failure */ function phd_bool($val) { if (!is_string($val)) { @@ -85,22 +75,22 @@ function phd_bool($val) { } switch ($val) { - case "on": - case "yes": - case "true": - case "1": - return true; - break; + case "on": + case "yes": + case "true": + case "1": + return true; + break; - case "off": - case "no": - case "false": - case "0": - return false; - break; + case "off": + case "no": + case "false": + case "0": + return false; + break; - default: - return null; + default: + return null; } } /* }}} */ @@ -123,7 +113,7 @@ 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); + trigger_error("Something happened with getopt(), please report a bug", E_USER_ERROR); } foreach ($args as $k => $v) { @@ -132,20 +122,18 @@ public function getopt() 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); + trigger_error("Hmh, something weird has happened, I don't know this option", E_USER_ERROR); } } } } -/* {{{ Can't function_call()['key'], so val(function_call(), 'key') */ +/* {{{ Can't function_call()['key'], so val(function_call(), 'key') + See */ function val($a, $k) { return $a[$k]; } /* }}} */ -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ +?> diff --git a/include/PhDBuildOptions.class.php b/include/PhDBuildOptions.class.php deleted file mode 100644 index 3a7f42ca4..000000000 --- a/include/PhDBuildOptions.class.php +++ /dev/null @@ -1,328 +0,0 @@ - "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": - case "chmsource": - if (!in_array($val, $themes["xhtml"]["php"])) { - $themes["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); - } - - 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 Adjusts the verbosity level - -f - --format The build format to use - -t - --theme The theme to use - -i - --index Index before rendering (default) or load from cache (false) - -d - --docbook The Docbook file to render from - -p - --partial The ID to render, optionally skipping its children chunks (default to true; render children) - -s - --skip The ID to skip, optionally skipping its children chunks (default to true; skip children) - -l - --list Print out the supported formats/themes (default: both) - -o - --output The output directory (default: .) - -c - --color 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 PhDBuildOptionsParser; -$optParser->getopt(); - -?> diff --git a/include/PhDCommonOptions.class.php b/include/PhDCommonOptions.class.php new file mode 100644 index 000000000..b469e064e --- /dev/null +++ b/include/PhDCommonOptions.class.php @@ -0,0 +1,138 @@ + "s:", // Input data + "color:" => "c:", // Use color output if possible + "verbose:" => "v", // Adjust the verbosity level + "version" => "V", // Print out version information + "help" => "h", // Print out help + ); + } + + public function option_s($k, $v) + { + $this->option_source($k, $v); + } + public function option_source($k, $v) + { + if (is_array($v)) { + trigger_error("Only a single input location can be supplied", E_USER_ERROR); + } + if (!is_dir($v) || !is_readable($v)) { + trigger_error(sprintf("'%s' is not a valid directory", $v), E_USER_ERROR); + } + PhDConfig::set_source_dir($v); + } + + 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_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) + { + $color = PhDConfig::phd_info_color(); + $output = PhDConfig::phd_info_output(); + $rev = preg_replace('/\$Re[v](?:ision)?(: ([\d.]+) ?)?\$$/e', "'\\1' == '' ? '??' : '\\2'", $GLOBALS['base_revision']); + fprintf($output, "%s\n", term_color($this->getTitleText(), $color)); + fprintf($output, "%s\n", term_color("PhD Version: " . PHD_VERSION . " (" . $rev . ")", $color)); + fprintf($output, "%s\n", term_color("Copyright(c) 2008 The PHP Documentation Group", $color)); + exit(0); + } + + public function option_h($k, $v) + { + $this->option_help($k, $v); + } + public function option_help($k, $v) + { + echo $this->getTitleText() . "\n"; + echo "PhD version: " . PHD_VERSION . "\n"; + echo <<getHelpText()} + -s + --source The source documentation checkout or build area (default: .) + -v + --verbose Adjusts the verbosity level + -c + --color 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 effect. + +ENDBLOB; + exit(0); + } +} + +?> diff --git a/include/PhDCompileOptions.class.php b/include/PhDCompileOptions.class.php new file mode 100644 index 000000000..cc7ba05b2 --- /dev/null +++ b/include/PhDCompileOptions.class.php @@ -0,0 +1,35 @@ + "f:", // Force DOM save on validation fail + "partial:" => "p:", // Root ID + )); + } + + protected function getTitleText() + { + return "PhD XML Compiler"; + } + + protected function getHelpText() + { + return <<<'ENDBLOB' + -f + --force Save (true) invalid XML with errors or discard (default). + -p + --partial The root ID to render (default all). +ENDBLOB; + } +} + +$optParser = new PhDCompileOptionsParser; +$optParser->getopt(); + +?> diff --git a/include/PhDErrors.php b/include/PhDErrors.php index 43dcdfccb..4b0cf4317 100644 --- a/include/PhDErrors.php +++ b/include/PhDErrors.php @@ -3,24 +3,38 @@ /* {{{ PhD error & message handler */ -// FC For PHP5.3 -if (!defined("E_DEPRECATED")) { - define("E_DEPRECATED", E_RECOVERABLE_ERROR << 1); +$error_map = array( + E_RECOVERABLE_ERROR => 'PHP Error', + E_WARNING => 'PHP Warning', + E_NOTICE => 'PHP Notice', + E_STRICT => 'PHP Strict Standards Warning', + E_DEPRECATED => 'PHP Deprecated Construct Warning', + E_USER_ERROR => 'User Error', + E_USER_WARNING => 'User Warning', + E_USER_NOTICE => 'User Notice', +); + +function define_error($name, $explanation) { + static $lastErrorValue = E_DEPRECATED; + + define($name, $lastErrorValue <<= 1); + $GLOBALS['error_map'][$lastErrorValue] = $explanation; } // 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))); +define_error('VERBOSE_INDEXING', 'PhD Indexer'); +define_error('VERBOSE_FORMAT_RENDERING', 'PhD Output Format'); +define_error('VERBOSE_THEME_RENDERING', 'PhD Output Theme'); +define_error('VERBOSE_RENDER_STYLE', 'PhD Rendering Style'); +define_error('VERBOSE_PARTIAL_READING', 'PhD Partial Reader'); +define_error('VERBOSE_PARTIAL_CHILD_READING', 'PhD Partial Child Reader'); +define_error('VERBOSE_TOC_WRITING', 'PhD TOC Writer'); +define_error('VERBOSE_CHUNK_WRITING', 'PhD Chunk Writer'); +define_error('VERBOSE_NOVERSION', 'Missing Version Information'); +define_error('VERBOSE_DONE', 'PhD Processing Completion'); + +define('VERBOSE_ALL', (VERBOSE_NOVERSION << 1)-1); +define('VERBOSE_DEFAULT', (VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING|VERBOSE_NOVERSION|VERBOSE_DONE))); $olderrrep = error_reporting(); error_reporting($olderrrep | VERBOSE_DEFAULT); @@ -47,27 +61,6 @@ function term_color($text, $color) /* {{{ 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 @@ -93,6 +86,7 @@ function errh($errno, $msg, $file, $line, $ctx = null) { case VERBOSE_TOC_WRITING: case VERBOSE_CHUNK_WRITING: case VERBOSE_NOVERSION: + case VERBOSE_DONE: $color = PhDConfig::phd_info_color(); $output = PhDConfig::phd_info_output(); $data = $msg; @@ -123,7 +117,7 @@ function errh($errno, $msg, $file, $line, $ctx = null) { return false; } - $timestamp = term_color(sprintf("[%s - %s]", $time, $err[$errno]), $color); + $timestamp = term_color(sprintf("[%s - %s]", $time, $GLOBALS['error_map'][$errno]), $color); fprintf($output, "%s %s\n", $timestamp, $data); // Abort on fatal errors diff --git a/include/PhDRenderOptions.class.php b/include/PhDRenderOptions.class.php new file mode 100644 index 000000000..b30a481c4 --- /dev/null +++ b/include/PhDRenderOptions.class.php @@ -0,0 +1,140 @@ + "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:" => "k:", // The ID to skip (optionally skipping its children too) + )); + } + + 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); + } + + 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_k($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); + } + + protected function getTitleText() + { + return "PhD Renderer"; + } + + protected function getHelpText() + { + return <<<'ENDBLOB' + -i + --index Index before rendering (default) or load from cache (false) + -d + --docbook The Docbook file to render from + -p + --partial The ID to render, optionally skipping its children chunks (default to true; render children) + -s + --skip The ID to skip, optionally skipping its children chunks (default to true; skip children) + -o + --output The output directory for final generated files (default: .) +ENDBLOB; + } +} + +$optParser = new PhDRenderOptionsParser; +$optParser->getopt(); + +?> diff --git a/include/PhDSetupOptions.class.php b/include/PhDSetupOptions.class.php new file mode 100644 index 000000000..b1d25b4a4 --- /dev/null +++ b/include/PhDSetupOptions.class.php @@ -0,0 +1,155 @@ + "f:", // The format to render (xhtml, pdf...) + "theme:" => "t:", // The theme to render (phpweb, bightml..) + "list::" => "l::", // List supported themes/formats + "output:" => "o:", // Intermediate output directory + )); + } + + 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) || !is_writable($v)) { + trigger_error(sprintf("'%s' is not a valid directory", $v), E_USER_ERROR); + } + PhDConfig::set_intermediate_output_dir($v); + } + + 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": + case "chmsource": + if (!in_array($val, $themes["xhtml"]["php"])) { + $themes["xhtml"]["php"][] = $val; + } + break; + default: + trigger_error(sprintf("Unknown theme '%s'", $val), E_USER_ERROR); + } + } + PhDConfig::set_output_theme($themes); + } + + 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); + } + + protected function getTitleText() + { + return "PhD Setup"; + } + + protected function getHelpText() + { + return <<<'ENDBLOB' + -o + --output The output directory for intermediate build files (default: .) + -f + --format The output format to use + -t + --theme The theme to use + -l + --list Print out the supported formats/themes (default: both) +ENDBLOB; + } +} + +$optParser = new PhDSetupOptionsParser; +$optParser->getopt(); + +?> diff --git a/phpdotnet/phd/BuildOptionsParser.php b/phpdotnet/phd/BuildOptionsParser.php deleted file mode 100644 index 3a7f42ca4..000000000 --- a/phpdotnet/phd/BuildOptionsParser.php +++ /dev/null @@ -1,328 +0,0 @@ - "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": - case "chmsource": - if (!in_array($val, $themes["xhtml"]["php"])) { - $themes["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); - } - - 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 Adjusts the verbosity level - -f - --format The build format to use - -t - --theme The theme to use - -i - --index Index before rendering (default) or load from cache (false) - -d - --docbook The Docbook file to render from - -p - --partial The ID to render, optionally skipping its children chunks (default to true; render children) - -s - --skip The ID to skip, optionally skipping its children chunks (default to true; skip children) - -l - --list Print out the supported formats/themes (default: both) - -o - --output The output directory (default: .) - -c - --color 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 PhDBuildOptionsParser; -$optParser->getopt(); - -?> diff --git a/phpdotnet/phd/Config.php b/phpdotnet/phd/Config.php index 1fc01b7fc..6ed030a7b 100644 --- a/phpdotnet/phd/Config.php +++ b/phpdotnet/phd/Config.php @@ -35,7 +35,9 @@ class PhDConfig 'skip_ids' => array( ), 'color_output' => false, + 'source_dir' => '.', 'output_dir' => '.', + 'intermediate_output_dir' => '.', 'php_error_output' => NULL, 'php_error_color' => false, 'user_error_output' => NULL, @@ -66,18 +68,6 @@ public static function __callStatic($name, $params) PhDConfig::set_user_error_output(STDERR); PhDConfig::set_phd_info_output(STDOUT); -/* {{{ Workaround/fix for Windows prior to PHP5.3 */ -if (!function_exists("getopt")) { - function getopt($short, $long) { - global $argv; - printf("I'm sorry, you are running an operating system that does not support getopt()\n"); - printf("Please either upgrade to PHP5.3 or try '%s /path/to/your/docbook.xml'\n", $argv[0]); - - return array(); - } -} -/* }}} */ - /* {{{ phd_bool($var) Returns boolean true/false on success, null on failure */ function phd_bool($val) { if (!is_string($val)) { @@ -85,22 +75,22 @@ function phd_bool($val) { } switch ($val) { - case "on": - case "yes": - case "true": - case "1": - return true; - break; + case "on": + case "yes": + case "true": + case "1": + return true; + break; - case "off": - case "no": - case "false": - case "0": - return false; - break; + case "off": + case "no": + case "false": + case "0": + return false; + break; - default: - return null; + default: + return null; } } /* }}} */ @@ -123,7 +113,7 @@ 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); + trigger_error("Something happened with getopt(), please report a bug", E_USER_ERROR); } foreach ($args as $k => $v) { @@ -132,20 +122,18 @@ public function getopt() 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); + trigger_error("Hmh, something weird has happened, I don't know this option", E_USER_ERROR); } } } } -/* {{{ Can't function_call()['key'], so val(function_call(), 'key') */ +/* {{{ Can't function_call()['key'], so val(function_call(), 'key') + See */ function val($a, $k) { return $a[$k]; } /* }}} */ -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ +?> diff --git a/phpdotnet/phd/functions.php b/phpdotnet/phd/functions.php index 43dcdfccb..4b0cf4317 100644 --- a/phpdotnet/phd/functions.php +++ b/phpdotnet/phd/functions.php @@ -3,24 +3,38 @@ /* {{{ PhD error & message handler */ -// FC For PHP5.3 -if (!defined("E_DEPRECATED")) { - define("E_DEPRECATED", E_RECOVERABLE_ERROR << 1); +$error_map = array( + E_RECOVERABLE_ERROR => 'PHP Error', + E_WARNING => 'PHP Warning', + E_NOTICE => 'PHP Notice', + E_STRICT => 'PHP Strict Standards Warning', + E_DEPRECATED => 'PHP Deprecated Construct Warning', + E_USER_ERROR => 'User Error', + E_USER_WARNING => 'User Warning', + E_USER_NOTICE => 'User Notice', +); + +function define_error($name, $explanation) { + static $lastErrorValue = E_DEPRECATED; + + define($name, $lastErrorValue <<= 1); + $GLOBALS['error_map'][$lastErrorValue] = $explanation; } // 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))); +define_error('VERBOSE_INDEXING', 'PhD Indexer'); +define_error('VERBOSE_FORMAT_RENDERING', 'PhD Output Format'); +define_error('VERBOSE_THEME_RENDERING', 'PhD Output Theme'); +define_error('VERBOSE_RENDER_STYLE', 'PhD Rendering Style'); +define_error('VERBOSE_PARTIAL_READING', 'PhD Partial Reader'); +define_error('VERBOSE_PARTIAL_CHILD_READING', 'PhD Partial Child Reader'); +define_error('VERBOSE_TOC_WRITING', 'PhD TOC Writer'); +define_error('VERBOSE_CHUNK_WRITING', 'PhD Chunk Writer'); +define_error('VERBOSE_NOVERSION', 'Missing Version Information'); +define_error('VERBOSE_DONE', 'PhD Processing Completion'); + +define('VERBOSE_ALL', (VERBOSE_NOVERSION << 1)-1); +define('VERBOSE_DEFAULT', (VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING|VERBOSE_NOVERSION|VERBOSE_DONE))); $olderrrep = error_reporting(); error_reporting($olderrrep | VERBOSE_DEFAULT); @@ -47,27 +61,6 @@ function term_color($text, $color) /* {{{ 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 @@ -93,6 +86,7 @@ function errh($errno, $msg, $file, $line, $ctx = null) { case VERBOSE_TOC_WRITING: case VERBOSE_CHUNK_WRITING: case VERBOSE_NOVERSION: + case VERBOSE_DONE: $color = PhDConfig::phd_info_color(); $output = PhDConfig::phd_info_output(); $data = $msg; @@ -123,7 +117,7 @@ function errh($errno, $msg, $file, $line, $ctx = null) { return false; } - $timestamp = term_color(sprintf("[%s - %s]", $time, $err[$errno]), $color); + $timestamp = term_color(sprintf("[%s - %s]", $time, $GLOBALS['error_map'][$errno]), $color); fprintf($output, "%s %s\n", $timestamp, $data); // Abort on fatal errors diff --git a/build.php b/render.php similarity index 88% rename from build.php rename to render.php index 639507f17..a939e5409 100644 --- a/build.php +++ b/render.php @@ -1,6 +1,7 @@ #!@php_bin@ 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); - } -} -/* }}} */ +require_once $ROOT . "/config.php"; +require_once $ROOT . "/include/PhDRenderOptions.class.php"; -/* {{{ 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); - } +is_array(PhDConfig::output_theme()) + or trigger_error("Invalid configuration. This should never happen, was config.php edited manually? Please re-run phd-setup.", E_USER_ERROR); + +/* If no docbook file was passed, die */ +if (!is_dir(PhDConfig::xml_root()) || !is_file(PhDConfig::xml_file())) { + trigger_error("No '.manual.xml' file was given. Specify it on the command line with --docbook.", E_USER_ERROR); } -/* }}} */ /* This needs to be done in *all* cases! */ PhDConfig::set_output_dir(realpath(PhDConfig::output_dir()) . DIRECTORY_SEPARATOR); @@ -332,8 +308,4 @@ } // foreach(PhDConfig::output_themes()) -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ - +?> diff --git a/setup.php b/setup.php new file mode 100644 index 000000000..aaa58bde7 --- /dev/null +++ b/setup.php @@ -0,0 +1,58 @@ +#!@php_bin@ + PhDConfig::output_format(), + 'output_theme' => PhDConfig::output_theme(), + 'intermediate_output_dir' => realpath(PhDConfig::intermediate_output_dir()), + 'source_dir' => realpath(PhDConfig::source_dir()), + 'date_format' => PhDConfig::date_format(), +); +$now = date(DATE_RFC2822); + +$options_file = << $option_value) { + $v = var_export($option_value, 1); + $options_file .= << +BLOB; + +$config_file_path = PhDConfig::intermediate_output_dir() . DIRECTORY_SEPARATOR . "phd-config.php"; + +if (file_put_contents($config_file_path, $options_file) === FALSE) { + trigger_error("Unable to write the configuration file to the output directory.", E_USER_ERROR); +} + +v("Configuration successfully written to " . $config_file_path, VERBOSE_DONE); + +?>