goba Thu Sep 2 12:45:33 2004 EDT
Modified files: /livedocs livedoc.php Log: make a function out of the aliases array, so we can mass alias things like the function reference groups (which have no corresponding files) http://cvs.php.net/diff.php/livedocs/livedoc.php?r1=1.108&r2=1.109&ty=u Index: livedocs/livedoc.php diff -u livedocs/livedoc.php:1.108 livedocs/livedoc.php:1.109 --- livedocs/livedoc.php:1.108 Sat Aug 14 17:43:08 2004 +++ livedocs/livedoc.php Thu Sep 2 12:45:33 2004 @@ -18,7 +18,7 @@ // | Generate an HTML version of a phpdoc/docbook page on the fly | // +----------------------------------------------------------------------+ // -// $Id: livedoc.php,v 1.108 2004/08/14 21:43:08 iliaa Exp $ +// $Id: livedoc.php,v 1.109 2004/09/02 16:45:33 goba Exp $ define('LIVEDOC_SOURCE', dirname(__FILE__)); include LIVEDOC_SOURCE . '/livedoc_funcs.php'; @@ -49,48 +49,51 @@ /***************************************************************************** * Aliases and XML -> style mapping - * Please keep the arrays sorted by keys + * Please keep the stuff sorted by keys */ -if (BUILD_TYPE == 'smarty') { - $aliases = array( - // For Smarty - 'smarty.for.programmers' => 'smarty.constants', - 'smarty.for.designers' => 'language.basic.syntax', - 'api.functions' => 'handle_appendixes_funcref', - 'language.custom.functions' => 'handle_appendixes_funcref', - 'language.basic.syntax' => 'handle_appendixes_funcref', - 'language.variables' => 'handle_appendixes_funcref', - 'manual' => 'handle_contents' - ); -} elseif (BUILD_TYPE == 'phpdoc') { - $aliases = array( - // For PHPdoc - 'api' => 'streams', - 'appendixes' => 'handle_appendixes_funcref', - 'faq' => 'handle_appendixes_funcref', - 'features' => 'handle_appendixes_funcref', - 'funcref' => 'handle_appendixes_funcref', - 'getting-started' => 'introduction', - 'install' => 'handle_appendixes_funcref', - 'langref' => 'handle_appendixes_funcref', - 'manual' => 'handle_contents', - 'security' => 'handle_appendixes_funcref', - 'indexes' => 'handle_index' - ); -} else { - $aliases = array(); +function manual_page_alias($key) { + if (BUILD_TYPE == 'smarty') { + switch($key) { + case 'smarty.for.programmers': return 'smarty.constants'; + case 'smarty.for.designers': return 'language.basic.syntax'; + case 'api.functions': + case 'language.custom.functions': + case 'language.basic.syntax': + case 'language.variables': return 'handle_appendixes_funcref'; + case 'manual': return 'handle_contents'; + } + } elseif (BUILD_TYPE == 'phpdoc') { + switch($key) { + case 'api': return 'streams'; + case 'appendixes': + case 'faq': + case 'features': + case 'funcref': return 'handle_appendixes_funcref'; + case 'getting-started': return 'introduction'; + case 'install': + case 'langref': return 'handle_appendixes_funcref'; + case 'manual': return 'handle_contents'; + case 'security': return 'handle_appendixes_funcref'; + case 'indexes': return 'handle_index'; + } + // Handle all reference groups + if (strncmp($key, "refs.", 5) == 0) { + return 'handle_appendixes_funcref'; + } + } + return false; } /***************************************************************************** * Handle some special pages in a special way with special code */ $special_content = false; -if (isset($aliases[$current_page])) { - if (is_callable($aliases[$current_page])) { +if (($current_alias = manual_page_alias($current_page)) !== false) { + if (is_callable($current_alias)) { $special_content = true; } else { - $current_page = $aliases[$current_page]; + $current_page = $current_alias; } } @@ -118,7 +121,7 @@ echo manual_page_header(); if ($special_content) { - echo call_user_func($aliases[$current_page]); + echo call_user_func($current_alias); } else { echo $page->transform($map, $current_page); if ($NOTESDB) {