cvs: php4 /pear/PHPDoc/core Phpdoc.php PhpdocSetupHandler.php /pear/PHPDoc/renderer PhpdocRendererObject.php /pear/PHPDoc/renderer/html
PhpdocHTMLClassRenderer.php PhpdocHTMLDocumentRenderer.php PhpdocHTMLIndexRenderer.php PhpdocHTMLModuleRenderer.php PhpdocHTMLRenderer.php
PhpdocHTMLRendererManager.php PhpdocHTMLWarningRenderer.php

From: Date: Sun, 15 Oct 2000 13:33:14 +0000
Subject: cvs: php4 /pear/PHPDoc/core Phpdoc.php PhpdocSetupHandler.php /pear/PHPDoc/renderer PhpdocRendererObject.php /pear/PHPDoc/renderer/html
PhpdocHTMLClassRenderer.php PhpdocHTMLDocumentRenderer.php PhpdocHTMLIndexRenderer.php PhpdocHTMLModuleRenderer.php PhpdocHTMLRenderer.php
PhpdocHTMLRendererManager.php PhpdocHTMLWarningRenderer.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-2061@lists.php.net to get a copy of this message
jan Sun Oct 15 06:33:14 2000 EDT Modified files: /php4/pear/PHPDoc/core Phpdoc.php PhpdocSetupHandler.php /php4/pear/PHPDoc/renderer PhpdocRendererObject.php /php4/pear/PHPDoc/renderer/html PhpdocHTMLClassRenderer.php PhpdocHTMLDocumentRenderer.php PhpdocHTMLIndexRenderer.php PhpdocHTMLModuleRenderer.php PhpdocHTMLRenderer.php PhpdocHTMLRendererManager.php PhpdocHTMLWarningRenderer.php Log: Again a commit for thomas weinert. now you can change the file extention of the genarated files to your needs. $doc->setTargetFileSuffix(".php"); to have .php e.g. Index: php4/pear/PHPDoc/core/Phpdoc.php diff -u php4/pear/PHPDoc/core/Phpdoc.php:1.1 php4/pear/PHPDoc/core/Phpdoc.php:1.2 --- php4/pear/PHPDoc/core/Phpdoc.php:1.1 Sun Oct 8 03:03:18 2000 +++ php4/pear/PHPDoc/core/Phpdoc.php Sun Oct 15 06:33:12 2000 @@ -1,228 +1,228 @@ -<?php -/** -* Coordinates several Phpdoc Object to parse and render source files. -* -* @access public -*/ -class Phpdoc extends PhpdocSetupHandler { - - /** - * Result from the indexer - * @var array $indexer - * @see render() - */ - var $indexer_result = array(); - - /** - * Print status messages - */ - var $flag_output = true; - - /** - * Calls the command line handler if necessary. - * - * @global $argc, $PHP_SELF - */ - function Phpdoc() { - global $argc, $PHP_SELF; - - $this->target = $PHP_SELF."apidoc/"; - - if ($argc>1) - $this->handleArgv(); - } // end constructor - - - /** - * Starts the parser. - * - * @return bool $ok - * @throws PhpdocError - * @access public - * @see - */ - function parse() { - - $this->warn = new PhpdocWarning; - - $errors = $this->checkStatus(); - if (0!=count($errors)) { - - reset($errors); - while (list($k, $error)=each($errors)) - $this->err[] = new PhpdocError($error["msg"]."Errno = ".$error["errno"], 9, __FILE__, __LINE__); - - return false; - } - - $this->outl("Parser starts..."); - - // create some objects - $fileHandler = new PhpdocFileHandler; - $parser = new PhpdocParser(true); - - $classAnalyser = new PhpdocClassAnalyser; - $moduleAnalyser = new PhpdocModuleAnalyser; - - $indexer = new PhpdocIndexer; - - $classExporter = new PhpdocXMLClassExporter(); - $classExporter->setPath($this->target); - - $moduleExporter = new PhpdocXMLModuleExporter(); - $moduleExporter->setPath($this->target); - - $indexExporter = new PhpdocXMLIndexExporter(); - $indexExporter->setPath($this->target); - - $warningExporter = new PhpdocXMLWarningExporter(); - $warningExporter->setPath($this->target); - - // This will change one fine day! - $parser->warn = $this->warn; - $classAnalyser->warn = $this->warn; - $moduleAnalyser->warn = $this->warn; - $classExporter->warn = $this->warn; - $moduleExporter->warn = $this->warn; - $indexer->warn = $this->warn; - - $sourcefiles = $fileHandler->getFilesInDirectory($this->sourceDirectory, $this->sourceFileSuffix); - $parser->setPhpSourcecodeFiles($fileHandler->get($sourcefiles)); - - $this->outl("... preparse to find modulegroups and classtrees."); - $parser->preparse(); - - $this->outl("... parsing classes."); - while ($classtree = $parser->getClassTree()) { - - $classAnalyser->setClasses( $classtree, $parser->current_baseclass ); - $classAnalyser->analyse(); - - while ($class = $classAnalyser->getClass()) { - $indexer->addClass($class); - $classExporter->export($class); - } - - if (floor(phpversion())>3) { - $indexExporter->exportClasstree($indexer->getClasstree(), $parser->current_baseclass); - } else { - $classtree = $indexer->getClasstree(); - $base = $parser->current_baseclass; - $indexExporter->exportClasstree($classtree, $base); - } - - } - - $this->outl("... parsing modules."); - while ($modulegroup = $parser->getModulegroup()) { - - $moduleAnalyser->setModulegroup( $modulegroup ); - $moduleAnalyser->analyse(); - - while ($module = $moduleAnalyser->getModule()) { - $indexer->addModule($module); - $moduleExporter->export($module); - } - - if (floor(phpversion())>3) { - $indexExporter->exportModulegroup($indexer->getModulegroup()); - } else { - $modulegroup = $indexer->getModulegroup(); - $indexExporter->exportModulegroup($modulegroup); - } - - } - - $this->outl("... writing packagelist."); - - if (floor(phpversion())>3) { - $indexExporter->exportPackagelist($indexer->getPackages()); - $indexExporter->exportElementlist($indexer->getElementlist()); - } else { - $packages = $indexer->getPackages(); - $indexExporter->exportPackagelist($packages); - $elements = $indexer->getElementlist(); - $indexExporter->exportElementlist($elements); - } - - $warningExporter->export($parser->warn->getWarnings(), "parser"); - $warningExporter->export($moduleAnalyser->warn->getWarnings(), "moduleanalyser"); - $warningExporter->export($classAnalyser->warn->getWarnings(), "classanalyser"); - $this->outl("Parser finished."); - - return true; - } // end func parse - - /** - * Renders the PHPDoc XML files as HTML files - * - * @param string Targetformat, currently only "html" is available. - * @param string Target directory for the html files - * @param string Directory with the html templates - * @return bool $ok - * @throws PhpdocError - * @access public - */ - function render($type="html", $target="", $template="") { - - $this->outl("Starting to render..."); - - $target = (""==$target) ? $this->target : $this->getCheckedDirname($target); - $template = (""==$template) ? $this->templateRoot : $this->getCheckedDirname($template); - - switch(strtolower($type)) { - - case "html": - default: - $renderer = new PhpdocHTMLRendererManager($target, $template, $this->application); - break; - } - - $fileHandler = new PhpdocFileHandler; - $files = $fileHandler->getFilesInDirectory($target, "xml"); - $len = strlen($target); - - $tpl = new IntegratedTemplate($this->templateRoot); - $tpl->loadTemplateFile("xmlfiles.html"); - $tpl->setCurrentBlock("file_loop"); - - // Do not change the file prefixes! - reset($files); - while (list($k, $file)=each($files)) { - - $tpl->setVariable("FILE", substr($file, $len)); - $tpl->parseCurrentBlock(); - - if ("class_" == substr($file, $len, 6)) { - - $renderer->render(substr($file, $len), "class"); - - } else if ("module_" == substr($file, $len, 7)) { - - $renderer->render(substr($file, $len), "module"); - - } else if ("classtree_" == substr($file, $len, 10)) { - - $renderer->render(substr($file, $len), "classtree"); - - } else if ("modulegroup_" == substr($file, $len, 12)) { - - $renderer->render(substr($file, $len), "modulegroup"); - - } else if ("warnings_" == substr($file, $len, 9)) { - - $renderer->render(substr($file, $len), "warning"); - - } - - } - - $renderer->finish(); - $fileHandler->createFile($target."phpdoc_xmlfiles.html", $tpl->get()); - - $this->outl($this->finishInstructions); - return true; - } // end func render - -} // end class Phpdoc +<?php +/** +* Coordinates several Phpdoc Object to parse and render source files. +* +* @access public +*/ +class Phpdoc extends PhpdocSetupHandler { + + /** + * Result from the indexer + * @var array $indexer + * @see render() + */ + var $indexer_result = array(); + + /** + * Print status messages + */ + var $flag_output = true; + + /** + * Calls the command line handler if necessary. + * + * @global $argc, $PHP_SELF + */ + function Phpdoc() { + global $argc, $PHP_SELF; + + $this->target = $PHP_SELF."apidoc/"; + + if ($argc>1) + $this->handleArgv(); + } // end constructor + + + /** + * Starts the parser. + * + * @return bool $ok + * @throws PhpdocError + * @access public + * @see + */ + function parse() { + + $this->warn = new PhpdocWarning; + + $errors = $this->checkStatus(); + if (0!=count($errors)) { + + reset($errors); + while (list($k, $error)=each($errors)) + $this->err[] = new PhpdocError($error["msg"]."Errno = ".$error["errno"], 9, __FILE__, __LINE__); + + return false; + } + + $this->outl("Parser starts..."); + + // create some objects + $fileHandler = new PhpdocFileHandler; + $parser = new PhpdocParser(true); + + $classAnalyser = new PhpdocClassAnalyser; + $moduleAnalyser = new PhpdocModuleAnalyser; + + $indexer = new PhpdocIndexer; + + $classExporter = new PhpdocXMLClassExporter(); + $classExporter->setPath($this->target); + + $moduleExporter = new PhpdocXMLModuleExporter(); + $moduleExporter->setPath($this->target); + + $indexExporter = new PhpdocXMLIndexExporter(); + $indexExporter->setPath($this->target); + + $warningExporter = new PhpdocXMLWarningExporter(); + $warningExporter->setPath($this->target); + + // This will change one fine day! + $parser->warn = $this->warn; + $classAnalyser->warn = $this->warn; + $moduleAnalyser->warn = $this->warn; + $classExporter->warn = $this->warn; + $moduleExporter->warn = $this->warn; + $indexer->warn = $this->warn; + + $sourcefiles = $fileHandler->getFilesInDirectory($this->sourceDirectory, $this->sourceFileSuffix); + $parser->setPhpSourcecodeFiles($fileHandler->get($sourcefiles)); + + $this->outl("... preparse to find modulegroups and classtrees."); + $parser->preparse(); + + $this->outl("... parsing classes."); + while ($classtree = $parser->getClassTree()) { + + $classAnalyser->setClasses( $classtree, $parser->current_baseclass ); + $classAnalyser->analyse(); + + while ($class = $classAnalyser->getClass()) { + $indexer->addClass($class); + $classExporter->export($class); + } + + if (floor(phpversion())>3) { + $indexExporter->exportClasstree($indexer->getClasstree(), $parser->current_baseclass); + } else { + $classtree = $indexer->getClasstree(); + $base = $parser->current_baseclass; + $indexExporter->exportClasstree($classtree, $base); + } + + } + + $this->outl("... parsing modules."); + while ($modulegroup = $parser->getModulegroup()) { + + $moduleAnalyser->setModulegroup( $modulegroup ); + $moduleAnalyser->analyse(); + + while ($module = $moduleAnalyser->getModule()) { + $indexer->addModule($module); + $moduleExporter->export($module); + } + + if (floor(phpversion())>3) { + $indexExporter->exportModulegroup($indexer->getModulegroup()); + } else { + $modulegroup = $indexer->getModulegroup(); + $indexExporter->exportModulegroup($modulegroup); + } + + } + + $this->outl("... writing packagelist."); + + if (floor(phpversion())>3) { + $indexExporter->exportPackagelist($indexer->getPackages()); + $indexExporter->exportElementlist($indexer->getElementlist()); + } else { + $packages = $indexer->getPackages(); + $indexExporter->exportPackagelist($packages); + $elements = $indexer->getElementlist(); + $indexExporter->exportElementlist($elements); + } + + $warningExporter->export($parser->warn->getWarnings(), "parser"); + $warningExporter->export($moduleAnalyser->warn->getWarnings(), "moduleanalyser"); + $warningExporter->export($classAnalyser->warn->getWarnings(), "classanalyser"); + $this->outl("Parser finished."); + + return true; + } // end func parse + + /** + * Renders the PHPDoc XML files as HTML files + * + * @param string Targetformat, currently only "html" is available. + * @param string Target directory for the html files + * @param string Directory with the html templates + * @return bool $ok + * @throws PhpdocError + * @access public + */ + function render($type="html", $target="", $template="") { + + $this->outl("Starting to render..."); + + $target = (""==$target) ? $this->target : $this->getCheckedDirname($target); + $template = (""==$template) ? $this->templateRoot : $this->getCheckedDirname($template); + + switch(strtolower($type)) { + + case "html": + default: + $renderer = new PhpdocHTMLRendererManager($target, $template, $this->application, $this->targetFileSuffix); + break; + } + + $fileHandler = new PhpdocFileHandler; + $files = $fileHandler->getFilesInDirectory($target, "xml"); + $len = strlen($target); + + $tpl = new IntegratedTemplate($this->templateRoot); + $tpl->loadTemplateFile("xmlfiles.html"); + $tpl->setCurrentBlock("file_loop"); + + // Do not change the file prefixes! + reset($files); + while (list($k, $file)=each($files)) { + + $tpl->setVariable("FILE", substr($file, $len)); + $tpl->parseCurrentBlock(); + + if ("class_" == substr($file, $len, 6)) { + + $renderer->render(substr($file, $len), "class"); + + } else if ("module_" == substr($file, $len, 7)) { + + $renderer->render(substr($file, $len), "module"); + + } else if ("classtree_" == substr($file, $len, 10)) { + + $renderer->render(substr($file, $len), "classtree"); + + } else if ("modulegroup_" == substr($file, $len, 12)) { + + $renderer->render(substr($file, $len), "modulegroup"); + + } else if ("warnings_" == substr($file, $len, 9)) { + + $renderer->render(substr($file, $len), "warning"); + + } + + } + + $renderer->finish(); + $fileHandler->createFile($target."phpdoc_xmlfiles".$this->targetFileSuffix, $tpl->get()); + + $this->outl($this->finishInstructions); + return true; + } // end func render + +} // end class Phpdoc ?> Index: php4/pear/PHPDoc/core/PhpdocSetupHandler.php diff -u php4/pear/PHPDoc/core/PhpdocSetupHandler.php:1.1 php4/pear/PHPDoc/core/PhpdocSetupHandler.php:1.2 --- php4/pear/PHPDoc/core/PhpdocSetupHandler.php:1.1 Sun Oct 8 03:03:18 2000 +++ php4/pear/PHPDoc/core/PhpdocSetupHandler.php Sun Oct 15 06:33:12 2000 @@ -1,189 +1,224 @@ -<?php -/** -* Handles the "setup". -* -* This class provides all methods neccessary to "setup" Phpdoc and check the -* current setup. -* -* @version 0.2alpha -* @author Ulf Wendel <ulf@redsys.de> -*/ -class PhpdocSetupHandler extends PhpdocArgvHandler { - - /** - * Name of the target directory. - * @var string $target - * @access private - */ - var $target = ""; - - /** - * Name of the application parsed - * @var string $application - * @see setApplication() - */ - var $application = "PHPDoc"; - - /** - * Basedir for all file operations - * @var string $basedir - * @see setApplication(), setBasedir() - */ - var $basedir = ""; - - /** - * Suffix of all source code files in the application - * If you used other file suffixes than ".php" in you have to override this - * variable using setSourceFileSuffix() - * @var array sourceFileSuffix - * @see setSourceFileSuffix() - */ - var $sourceFileSuffix = array ( "php" ); - - /** - * Directory with the php sources to parse. - * @var string - * @see setSourceDir() - */ - var $sourceDirectory = ""; - - /** - * Directory with the templates. - * @var string - * @see setTemplateDirectory() - */ - - /** - * Sets the name of the directory with the source to scan. - * @param string - * @access public - */ - function setSourceDirectory($sourcedir) { - $this->sourceDirectory = $this->getCheckedDirname($sourcedir); - } // end end func setSourceDirectory - - /** - * Sets the name of the directory with the templates. - * @param string - * @access public - */ - function setTemplateDirectory($sourcedir) { - $this->templateRoot = $this->getCheckedDirname($sourcedir); - } // end func setTemplateDirectory - - /** - * Sets the name of your application. - * - * The application name gets used on many places in the default templates. - * - * @param string $application name of the application - * @return bool $ok - * @throws PhpdocError - * @access public - */ - function setApplication($application) { - if (""==$application) { - $this->err[] = new PhpdocError("No application name given.", __FILE__, __LINE__); - return false; - } - - $this->application = $application; - return true; - } // end func setApplication - - /** - * Suffix of all source code files in the application - * By default only files with the suffix ".php" are recognized as - * php source code files and parsed. If you used other - * suffixes such as ".inc" you have to tell phpdoc to parse - * them. - * - * @param mixed $suffix string with one suffix or array of suffixes - * @return bool $ok - * @throws PhpdocError - * @access private - * @see sourceFileSuffix - */ - function setSourceFileSuffix($suffix) { - if ( (!is_array($suffix) && ""==$suffix) || (is_array($suffix) && 0==count($suffix)) ) { - $this->err[] = new PhpdocError("No suffix specified.", __FILE__, __LINE__); - return false; - } - if (!is_array($suffix)) - $suffix = array($suffix); - - $this->sourceFileSuffix = $suffix; - return true; - } // end func setSourceFileSuffix - - /** - * Sets the target where the generated files are saved. - * - * @param string $target - * @return bool $ok - * @throws PhpdocError - * @access public - */ - function setTarget($target) { - if (""==$target) { - $this->err[] = new PhpdocError("No target specified.", __FILE__, __LINE__); - return false; - } - - if (!is_dir($target)) { - $ok = @mkdir($target, 0755); - if (!$ok) { - $this->err[] = new PhpdocError("setTarget(), can't create a directory '$target'.", __FILE__, __LINE__); - return false; - } - } - - $this->target = $this->getCheckedDirname($target); - return true; - } // end func setTarget - - /** - * Checks the current status of the object. Are all necessary informations - * to start parsing available? - * @param array $errors - * @access private - * @return array $errors - */ - function checkStatus($errors="") { - if (!is_array($errors)) - $errors = array(); -/* - - if (0==count($this->files) && ""==$this->directory) - $errors[] = array ( - "msg" => "No source files or source directory specified.", - "type" => "misconfiguration", - "errno" => 6 - ); - - if (0!=count($this->files) && ""!=$this->directory) - $errors[] = array( - "msg" => "Define eighter some files or a diretory.", - "type" => "misconfiguration", - "errno" => 7 - ); - */ - return $errors; - } // end func checkStatus - - /** - * Adds a slash at the end of the given filename if neccessary. - * - * @param string Directoryname - * @return string Directoryname - */ - function getCheckedDirname($dirname) { - - if (""!=$dirname && "/"!=substr($dirname, -1)) - $dirname.="/"; - - return $dirname; - } // end func getCheckedDirname - -} // end class PhpdocSetupHandler +<?php +/** +* Handles the "setup". +* +* This class provides all methods neccessary to "setup" Phpdoc and check the +* current setup. +* +* @version 0.2alpha +* @author Ulf Wendel <ulf@redsys.de> +*/ +class PhpdocSetupHandler extends PhpdocArgvHandler { + + /** + * Name of the target directory. + * @var string $target + * @access private + */ + var $target = ""; + + /** + * Name of the application parsed + * @var string $application + * @see setApplication() + */ + var $application = "PHPDoc"; + + /** + * Basedir for all file operations + * @var string $basedir + * @see setApplication(), setBasedir() + */ + var $basedir = ""; + + /** + * Suffix for all rendered files in the application (not for the xml files) + * If you used an other file suffix than ".html" in you have to override this + * variable using setTargetFileSuffix() + * @var string targetFileSuffix + * @see setTargetFileSuffix() + */ + var $targetFileSuffix = ".html"; + + /** + * Suffix of all source code files in the application + * If you used other file suffixes than ".php" in you have to override this + * variable using setSourceFileSuffix() + * @var array sourceFileSuffix + * @see setSourceFileSuffix() + */ + var $sourceFileSuffix = array ( "php" ); + + /** + * Directory with the php sources to parse. + * @var string + * @see setSourceDir() + */ + var $sourceDirectory = ""; + + /** + * Directory with the templates. + * @var string + * @see setTemplateDirectory() + */ + + /** + * Sets the name of the directory with the source to scan. + * @param string + * @access public + */ + function setSourceDirectory($sourcedir) { + $this->sourceDirectory = $this->getCheckedDirname($sourcedir); + } // end end func setSourceDirectory + + /** + * Sets the name of the directory with the templates. + * @param string + * @access public + */ + function setTemplateDirectory($sourcedir) { + $this->templateRoot = $this->getCheckedDirname($sourcedir); + } // end func setTemplateDirectory + + /** + * Sets the name of your application. + * + * The application name gets used on many places in the default templates. + * + * @param string $application name of the application + * @return bool $ok + * @throws PhpdocError + * @access public + */ + function setApplication($application) { + if (""==$application) { + $this->err[] = new PhpdocError("No application name given.", __FILE__, __LINE__); + return false; + } + + $this->application = $application; + return true; + } // end func setApplication + + /** + * Suffix for all rendered files in the application (not for the xml files) + * By default the the suffix is set to ".html". + * + * @param string $suffix string with the suffix + * @return bool $ok + * @access private + * @see targetFileSuffix + * @author Thomas Weinert <subjective@subjective.de> + */ + + function setTargetFileSuffix($suffix) { + if (ereg("^\.[a-zA-Z0-9]+$",$suffix)) { + $this->targetFileSuffix = $suffix; + $ok = true; + } else { + if (ereg("^[a-zA-Z0-9]+$",$suffix)) { + $this->targetFileSuffix = ".".$suffix; + $ok = true; + } else { + $ok = false; + } + } + return $ok; + } + + /** + * Suffix of all source code files in the application + * By default only files with the suffix ".php" are recognized as + * php source code files and parsed. If you used other + * suffixes such as ".inc" you have to tell phpdoc to parse + * them. + * + * @param mixed $suffix string with one suffix or array of suffixes + * @return bool $ok + * @throws PhpdocError + * @access private + * @see sourceFileSuffix + */ + function setSourceFileSuffix($suffix) { + if ( (!is_array($suffix) && ""==$suffix) || (is_array($suffix) && 0==count($suffix)) ) { + $this->err[] = new PhpdocError("No suffix specified.", __FILE__, __LINE__); + return false; + } + if (!is_array($suffix)) + $suffix = array($suffix); + + $this->sourceFileSuffix = $suffix; + return true; + } // end func setSourceFileSuffix + + /** + * Sets the target where the generated files are saved. + * + * @param string $target + * @return bool $ok + * @throws PhpdocError + * @access public + */ + function setTarget($target) { + if (""==$target) { + $this->err[] = new PhpdocError("No target specified.", __FILE__, __LINE__); + return false; + } + + if (!is_dir($target)) { + $ok = @mkdir($target, 0755); + if (!$ok) { + $this->err[] = new PhpdocError("setTarget(), can't create a directory '$target'.", __FILE__, __LINE__); + return false; + } + } + + $this->target = $this->getCheckedDirname($target); + return true; + } // end func setTarget + + /** + * Checks the current status of the object. Are all necessary informations + * to start parsing available? + * @param array $errors + * @access private + * @return array $errors + */ + function checkStatus($errors="") { + if (!is_array($errors)) + $errors = array(); +/* + + if (0==count($this->files) && ""==$this->directory) + $errors[] = array ( + "msg" => "No source files or source directory specified.", + "type" => "misconfiguration", + "errno" => 6 + ); + + if (0!=count($this->files) && ""!=$this->directory) + $errors[] = array( + "msg" => "Define eighter some files or a diretory.", + "type" => "misconfiguration", + "errno" => 7 + ); + */ + return $errors; + } // end func checkStatus + + /** + * Adds a slash at the end of the given filename if neccessary. + * + * @param string Directoryname + * @return string Directoryname + */ + function getCheckedDirname($dirname) { + + if (""!=$dirname && "/"!=substr($dirname, -1)) + $dirname.="/"; + + return $dirname; + } // end func getCheckedDirname + +} // end class PhpdocSetupHandler ?> Index: php4/pear/PHPDoc/renderer/PhpdocRendererObject.php diff -u php4/pear/PHPDoc/renderer/PhpdocRendererObject.php:1.1 php4/pear/PHPDoc/renderer/PhpdocRendererObject.php:1.2 --- php4/pear/PHPDoc/renderer/PhpdocRendererObject.php:1.1 Sun Oct 8 03:03:20 2000 +++ php4/pear/PHPDoc/renderer/PhpdocRendererObject.php Sun Oct 15 06:33:13 2000 @@ -1,9 +1,15 @@ -<?php -class PhpdocRendererObject extends PhpdocObject { - - var $warn; - - var $accessor; - -} // end class PhpdocRendererObject +<?php +class PhpdocRendererObject extends PhpdocObject { + + var $warn; + + var $accessor; + + /** + * Extension for generated files. + * @var string $file_extension + */ + var $file_extension = ".html"; + +} // end class PhpdocRendererObject ?> Index: php4/pear/PHPDoc/renderer/html/PhpdocHTMLClassRenderer.php diff -u php4/pear/PHPDoc/renderer/html/PhpdocHTMLClassRenderer.php:1.1 php4/pear/PHPDoc/renderer/html/PhpdocHTMLClassRenderer.php:1.2 --- php4/pear/PHPDoc/renderer/html/PhpdocHTMLClassRenderer.php:1.1 Sun Oct 8 03:05:11 2000 +++ php4/pear/PHPDoc/renderer/html/PhpdocHTMLClassRenderer.php Sun Oct 15 06:33:13 2000 @@ -1,367 +1,368 @@ -<?php -/** -* Renders classes. -*/ -class PhpdocHTMLClassRenderer extends PhpdocHTMLDocumentRenderer { - - /** - * Internal array of "&nbsp;" strings to format HTML output. - * @var array $indent - */ - var $indent = array(); - - /** - * Array of variables found in the xml document. - * @var array $variables - */ - var $variables = array(); - - /** - * Sets the xml and template root directory. - * - * @param string XML file path - * @param string Template file path - * @param string Name of the current application - * @see setPath(), setTemplateRoot() - */ - function PhpdocHTMLClassRenderer($path, $templateRoot, $application) { - - $this->setPath($path); - $this->setTemplateRoot($templateRoot); - $this->application = $application; - - $this->accessor = new PhpdocClassAccessor; - $this->tpl = new IntegratedTemplate($this->templateRoot); - $this->fileHandler = new PhpdocFileHandler; - - } // end constructor - - /** - * Renders a class - * @param string XML source file - * @param string Name of the HTML target file. - * @access public - */ - function renderClass($xmlfile, $htmlfile="") { - - $this->tpl->loadTemplatefile("class.html"); - - if (""==$htmlfile) - $htmlfile = substr($xmlfile, 6, -4).".html"; - - $this->accessor->loadXMLFile($this->path.$xmlfile); - - $this->renderSubclasses(); - $this->renderInherited(); - $this->renderFunctions(); - $this->renderVariables(); - $this->renderUses(); - $this->renderConstants(); - - $class = $this->accessor->getClassdata(); - - $tplvars = array(); - - $tplvars["CLASS_FILE"] = $class["file"]["value"]; - $tplvars["CLASS_NAME"] = $class["name"]; - $tplvars["CLASS_ACCESS"] = $class["access"]; - $tplvars["CLASS_PACKAGE"] = $class["package"]; - - if (""!=$class["extends"]) - $tplvars["CLASS_EXTENDS"] = sprintf('extends <a href="%s.html">%s</a>', - $class["extends"], - $class["extends"] - ); - - $tplvars["CLASS_UNDOC"] = ("true" == $class["undoc"]) ? $this->undocumented : ""; - - $tplvars["CLASS_ABSTRACT"]= ("true" == $class["abstract"]) ? "abstract" : ""; - $tplvars["CLASS_STATIC"] = ("true" == $class["static"]) ? "static" : ""; - $tplvars["CLASS_FINAL"] = ("true" == $class["final"]) ? "final" : ""; - - $tplvars["CLASS_TREE"] = $this->getClasstree($class["name"]); - - if (isset($class["doc"]["link"])) - $this->renderLinks($class["doc"]["link"], "class_"); - - if (isset($class["doc"]["author"])) - $this->renderAuthors($class["doc"]["author"], "class_"); - - if (isset($class["doc"]["see"])) - $this->renderSee($class["doc"]["see"], "class_"); - - $fields = array( "version", "deprecated", "copyright" , - "since", "magic"); - reset($fields); - while (list($k, $field)=each($fields)) - if (isset($class["doc"][$field])) { - $this->tpl->setCurrentBlock("class_".strtolower($field)); - $this->tpl->setVariable(strtoupper($field), $class["doc"][$field]["value"]); - $this->tpl->parseCurrentBlock(); - } - - $fields = array( "description", "shortdescription" ); - reset($fields); - while (list($k, $field)=each($fields)) - if (isset($class["doc"][$field])) - $tplvars["CLASS_".strtoupper($field)] = $this->encode($class["doc"][$field]["value"]); - - $this->tpl->setCurrentBlock("__global__"); - $this->tpl->setVariable($tplvars); - $this->tpl->setVariable("APPNAME", $this->application); - - $this->fileHandler->createFile($this->path.$htmlfile, $this->tpl->get() ); - $this->tpl->free(); - - } // end func renderClass - - /** - * Renders a list of inherited elements. - * @see renderInheritedElements() - */ - function renderInherited() { - - $this->renderInheritedElements( $this->accessor->getInheritedFunctions(), - "inheritedfunctions", - "function" - ); - - $this->renderInheritedElements( $this->accessor->getInheritedVariables(), - "inheritedvariables", - "variable" - ); - - $this->renderInheritedElements( $this->accessor->getInheritedConstants(), - "inheritedconstants", - "constant" - ); - - $this->renderInheritedElements( $this->accessor->getInheritedUses(), - "inheriteduses", - "uses" - ); - - } // end func renderInherited - - /** - * Renders a list of a certain inherited element. - * @see renderInheritedElements() - */ - function renderInheritedElements($inherited, $block, $type) { - - if (0==count($inherited)) - return; - - $this->tpl->setCurrentBlock($block); - reset($inherited); - while (list($source, $elements)=each($inherited)) { - - $value = ""; - reset($elements); - while (list($k, $element)=each($elements)) - $value.= sprintf('<a href="%s.html#%s_%s">%s</a>, ', - $source, - $type, - $element, - $element - ); - $value = substr($value, 0, -2); - - $this->tpl->setVariable("SOURCE", $source); - $this->tpl->setVariable("ELEMENTS", $value); - $this->tpl->parseCurrentBlock(); - } - - } // end func renderInheritedElements - - /** - * Renders a list of direct known subclasses. - */ - function renderSubclasses() { - - $subclasses = $this->accessor->getSubclasses(); - if (0==count($subclasses)) - return; - - $elements = ""; - reset($subclasses); - while (list($k, $subclass)=each($subclasses)) - $elements.= sprintf('<a href="%s.html">%s</a>, ', $subclass, $subclass); - - $elements = substr($elements, 0, -2); - - if (""!=$elements) { - - $this->tpl->setCurrentBlock("subclasses"); - $this->tpl->setVariable("ELEMENTS", $elements); - $this->tpl->parseCurrentBlock(); - - } - } // end func renderSubclasses - - /** - * Adds a summary and a detailed list of all variables to the template. - * @see renderVariableSummary(), renderVariableDetail() - */ - function renderVariables() { - - $this->variables["private"] = $this->accessor->getVariablesByAccess("private"); - $this->variables["public"] = $this->accessor->getVariablesByAccess("public"); - - if (0==count($this->variables["private"]) && 0==count($this->variables["public"])) - return; - - $this->renderVariableSummary(); - $this->renderVariableDetail(); - - $this->variables = array(); - - } // end func renderVariables - - /** - * Adds a summary of all variables to the template. - * - * The function assumes that there is a block named "variablesummary" and - * within it a block names "variablesummay_loop" in the template. - * - * @see renderVariableDetail() - */ - function renderVariableSummary() { - - reset($this->accessModifiers); - while (list($k, $access)=each($this->accessModifiers)) { - if (0==count($this->variables[$access])) - continue; - - $this->tpl->setCurrentBlock("variablesummary_loop"); - - reset($this->variables[$access]); - while (list($name, $variable)=each($this->variables[$access])) { - - $this->tpl->setVariable("NAME", $name); - $this->tpl->setVariable("TYPE", $variable["type"]); - - if (isset($variable["doc"]["shortdescription"])) - $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($variable["doc"]["shortdescription"]["value"])); - - $this->tpl->parseCurrentBlock(); - - } - - $this->tpl->setCurrentBlock("variablesummary"); - $this->tpl->setVariable("ACCESS", ucfirst($access)); - $this->tpl->parseCurrentBlock(); - - } - - } // end func renderVariableSummary - - /** - * Adds a detailed list of all variables to the template. - * - * The function assumes that there is a block named "variabledetails" - * and within it a block names "variablesdetails_loop" in the template. - * - * @see renderVariableSummary() - */ - function renderVariableDetail() { - - reset($this->accessModifiers); - while (list($k, $access)=each($this->accessModifiers)) { - if (0==count($this->variables[$access])) - continue; - - reset($this->variables[$access]); - while (list($name, $variable)=each($this->variables[$access])) { - - $tplvars = array(); - $tplvars["NAME"] = $variable["name"]; - $tplvars["ACCESS"] = $variable["access"]; - $tplvars["TYPE"] = $variable["type"]; - $tplvars["VALUE"] = htmlentities($variable["value"]); - - if ("true"==$variable["undoc"]) - $tplvars["UNDOC"] = $this->undocumented; - - if ("true"==$variable["static"]) - $tplvars["STATIC"] = "static"; - - if ("true"==$variable["final"]) - $tplvars["FINAL"] = "final"; - - if (isset($variable["doc"]["shortdescription"])) - $tplvars["SHORTDESCRIPTION"] = $this->encode($variable["doc"]["shortdescription"]["value"]); - if (isset($variable["doc"]["description"])) - $tplvars["DESCRIPTION"] = $this->encode($variable["doc"]["description"]["value"]); - - $this->renderCommonDocfields("variabledetails_", $variable); - - $this->tpl->setCurrentBlock("variabledetails_loop"); - $this->tpl->setVariable($tplvars); - $this->tpl->parseCurrentBlock(); - } - - $this->tpl->setCurrentBlock("variabledetails"); - $this->tpl->setVariable("ACCESS", ucfirst($access) ); - $this->tpl->parseCurrentBlock(); - } - - } // end func renderVariableDetail - - /** - * Returns a html string that shows the class tree. - * @param string name of the current class - * @return string HTML that shows the tree - */ - function getClasstree($class) { - - $path = $this->accessor->getClasstree(); - - $level = 0; - $num = count($path)-1; - - for ($i = $num; $i>=0; $i--) { - - $indent = $this->getIndent($level); - if ($level>0) - $value.= sprintf("%s |<br>%s+-- ", $indent, $indent); - $value.= sprintf('<a href="%s.html">%s</a><br>', - $path[$i], - $path[$i] - ); - $level++; - - } - - $indent = $this->getIndent($level); - if ($level>0) - $value.= sprintf("%s |<br>%s+-- ", $indent, $indent); - $value.= sprintf('%s<br>', $class); - - return $value; - } // end func getClasstree - - /** - * Returns a certain number of "&nbsp;"s. - * @param int number of "&nbsp;" required. - * @see $indent - * @return string A string with the requested number of nunbreakable html spaces - */ - function getIndent($level) { - - if (!isset($this->indent[$level])) { - - $html = ""; - for ($i=0; $i<$level; $i++) - $html.= "&nbsp;&nbsp;"; - - $this->indent[$level] = $html; - - } - - return $this->indent[$level]; - - } // end func getIndent - -} // end class PhpdocHTMLClassRenderer -?> \ No newline at end of file +<?php +/** +* Renders classes. +*/ +class PhpdocHTMLClassRenderer extends PhpdocHTMLDocumentRenderer { + + /** + * Internal array of "&nbsp;" strings to format HTML output. + * @var array $indent + */ + var $indent = array(); + + /** + * Array of variables found in the xml document. + * @var array $variables + */ + var $variables = array(); + + /** + * Sets the xml and template root directory. + * + * @param string XML file path + * @param string Template file path + * @param string Name of the current application + * @see setPath(), setTemplateRoot() + */ + function PhpdocHTMLClassRenderer($path, $templateRoot, $application, $extension = ".html") { + + $this->setPath($path); + $this->setTemplateRoot($templateRoot); + $this->application = $application; + $this->file_extension = $extension; + + $this->accessor = new PhpdocClassAccessor; + $this->tpl = new IntegratedTemplate($this->templateRoot); + $this->fileHandler = new PhpdocFileHandler; + + } // end constructor + + /** + * Renders a class + * @param string XML source file + * @param string Name of the HTML target file. + * @access public + */ + function renderClass($xmlfile, $htmlfile="") { + + $this->tpl->loadTemplatefile("class.html"); + + if (""==$htmlfile) + $htmlfile = substr($xmlfile, 6, -4).$this->file_extension; + + $this->accessor->loadXMLFile($this->path.$xmlfile); + + $this->renderSubclasses(); + $this->renderInherited(); + $this->renderFunctions(); + $this->renderVariables(); + $this->renderUses(); + $this->renderConstants(); + + $class = $this->accessor->getClassdata(); + + $tplvars = array(); + + $tplvars["CLASS_FILE"] = $class["file"]["value"]; + $tplvars["CLASS_NAME"] = $class["name"]; + $tplvars["CLASS_ACCESS"] = $class["access"]; + $tplvars["CLASS_PACKAGE"] = $class["package"]; + + if (""!=$class["extends"]) + $tplvars["CLASS_EXTENDS"] = sprintf('extends <a href="%s">%s</a>', + $class["extends"].$this->file_extension, + $class["extends"] + ); + + $tplvars["CLASS_UNDOC"] = ("true" == $class["undoc"]) ? $this->undocumented : ""; + + $tplvars["CLASS_ABSTRACT"]= ("true" == $class["abstract"]) ? "abstract" : ""; + $tplvars["CLASS_STATIC"] = ("true" == $class["static"]) ? "static" : ""; + $tplvars["CLASS_FINAL"] = ("true" == $class["final"]) ? "final" : ""; + + $tplvars["CLASS_TREE"] = $this->getClasstree($class["name"]); + + if (isset($class["doc"]["link"])) + $this->renderLinks($class["doc"]["link"], "class_"); + + if (isset($class["doc"]["author"])) + $this->renderAuthors($class["doc"]["author"], "class_"); + + if (isset($class["doc"]["see"])) + $this->renderSee($class["doc"]["see"], "class_"); + + $fields = array( "version", "deprecated", "copyright" , + "since", "magic"); + reset($fields); + while (list($k, $field)=each($fields)) + if (isset($class["doc"][$field])) { + $this->tpl->setCurrentBlock("class_".strtolower($field)); + $this->tpl->setVariable(strtoupper($field), $class["doc"][$field]["value"]); + $this->tpl->parseCurrentBlock(); + } + + $fields = array( "description", "shortdescription" ); + reset($fields); + while (list($k, $field)=each($fields)) + if (isset($class["doc"][$field])) + $tplvars["CLASS_".strtoupper($field)] = $this->encode($class["doc"][$field]["value"]); + + $this->tpl->setCurrentBlock("__global__"); + $this->tpl->setVariable($tplvars); + $this->tpl->setVariable("APPNAME", $this->application); + + $this->fileHandler->createFile($this->path.$htmlfile, $this->tpl->get() ); + $this->tpl->free(); + + } // end func renderClass + + /** + * Renders a list of inherited elements. + * @see renderInheritedElements() + */ + function renderInherited() { + + $this->renderInheritedElements( $this->accessor->getInheritedFunctions(), + "inheritedfunctions", + "function" + ); + + $this->renderInheritedElements( $this->accessor->getInheritedVariables(), + "inheritedvariables", + "variable" + ); + + $this->renderInheritedElements( $this->accessor->getInheritedConstants(), + "inheritedconstants", + "constant" + ); + + $this->renderInheritedElements( $this->accessor->getInheritedUses(), + "inheriteduses", + "uses" + ); + + } // end func renderInherited + + /** + * Renders a list of a certain inherited element. + * @see renderInheritedElements() + */ + function renderInheritedElements($inherited, $block, $type) { + + if (0==count($inherited)) + return; + + $this->tpl->setCurrentBlock($block); + reset($inherited); + while (list($source, $elements)=each($inherited)) { + + $value = ""; + reset($elements); + while (list($k, $element)=each($elements)) + $value.= sprintf('<a href="%s#%s_%s">%s</a>, ', + $source.$this->file_extension, + $type, + $element, + $element + ); + $value = substr($value, 0, -2); + + $this->tpl->setVariable("SOURCE", $source); + $this->tpl->setVariable("ELEMENTS", $value); + $this->tpl->parseCurrentBlock(); + } + + } // end func renderInheritedElements + + /** + * Renders a list of direct known subclasses. + */ + function renderSubclasses() { + + $subclasses = $this->accessor->getSubclasses(); + if (0==count($subclasses)) + return; + + $elements = ""; + reset($subclasses); + while (list($k, $subclass)=each($subclasses)) + $elements.= sprintf('<a href="%s">%s</a>, ', $subclass.$this->file_extension, $subclass); + + $elements = substr($elements, 0, -2); + + if (""!=$elements) { + + $this->tpl->setCurrentBlock("subclasses"); + $this->tpl->setVariable("ELEMENTS", $elements); + $this->tpl->parseCurrentBlock(); + + } + } // end func renderSubclasses + + /** + * Adds a summary and a detailed list of all variables to the template. + * @see renderVariableSummary(), renderVariableDetail() + */ + function renderVariables() { + + $this->variables["private"] = $this->accessor->getVariablesByAccess("private"); + $this->variables["public"] = $this->accessor->getVariablesByAccess("public"); + + if (0==count($this->variables["private"]) && 0==count($this->variables["public"])) + return; + + $this->renderVariableSummary(); + $this->renderVariableDetail(); + + $this->variables = array(); + + } // end func renderVariables + + /** + * Adds a summary of all variables to the template. + * + * The function assumes that there is a block named "variablesummary" and + * within it a block names "variablesummay_loop" in the template. + * + * @see renderVariableDetail() + */ + function renderVariableSummary() { + + reset($this->accessModifiers); + while (list($k, $access)=each($this->accessModifiers)) { + if (0==count($this->variables[$access])) + continue; + + $this->tpl->setCurrentBlock("variablesummary_loop"); + + reset($this->variables[$access]); + while (list($name, $variable)=each($this->variables[$access])) { + + $this->tpl->setVariable("NAME", $name); + $this->tpl->setVariable("TYPE", $variable["type"]); + + if (isset($variable["doc"]["shortdescription"])) + $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($variable["doc"]["shortdescription"]["value"])); + + $this->tpl->parseCurrentBlock(); + + } + + $this->tpl->setCurrentBlock("variablesummary"); + $this->tpl->setVariable("ACCESS", ucfirst($access)); + $this->tpl->parseCurrentBlock(); + + } + + } // end func renderVariableSummary + + /** + * Adds a detailed list of all variables to the template. + * + * The function assumes that there is a block named "variabledetails" + * and within it a block names "variablesdetails_loop" in the template. + * + * @see renderVariableSummary() + */ + function renderVariableDetail() { + + reset($this->accessModifiers); + while (list($k, $access)=each($this->accessModifiers)) { + if (0==count($this->variables[$access])) + continue; + + reset($this->variables[$access]); + while (list($name, $variable)=each($this->variables[$access])) { + + $tplvars = array(); + $tplvars["NAME"] = $variable["name"]; + $tplvars["ACCESS"] = $variable["access"]; + $tplvars["TYPE"] = $variable["type"]; + $tplvars["VALUE"] = htmlentities($variable["value"]); + + if ("true"==$variable["undoc"]) + $tplvars["UNDOC"] = $this->undocumented; + + if ("true"==$variable["static"]) + $tplvars["STATIC"] = "static"; + + if ("true"==$variable["final"]) + $tplvars["FINAL"] = "final"; + + if (isset($variable["doc"]["shortdescription"])) + $tplvars["SHORTDESCRIPTION"] = $this->encode($variable["doc"]["shortdescription"]["value"]); + if (isset($variable["doc"]["description"])) + $tplvars["DESCRIPTION"] = $this->encode($variable["doc"]["description"]["value"]); + + $this->renderCommonDocfields("variabledetails_", $variable); + + $this->tpl->setCurrentBlock("variabledetails_loop"); + $this->tpl->setVariable($tplvars); + $this->tpl->parseCurrentBlock(); + } + + $this->tpl->setCurrentBlock("variabledetails"); + $this->tpl->setVariable("ACCESS", ucfirst($access) ); + $this->tpl->parseCurrentBlock(); + } + + } // end func renderVariableDetail + + /** + * Returns a html string that shows the class tree. + * @param string name of the current class + * @return string HTML that shows the tree + */ + function getClasstree($class) { + + $path = $this->accessor->getClasstree(); + + $level = 0; + $num = count($path)-1; + + for ($i = $num; $i>=0; $i--) { + + $indent = $this->getIndent($level); + if ($level>0) + $value.= sprintf("%s |<br>%s+-- ", $indent, $indent); + $value.= sprintf('<a href="%s">%s</a><br>', + $path[$i].$this->file_extension, + $path[$i] + ); + $level++; + + } + + $indent = $this->getIndent($level); + if ($level>0) + $value.= sprintf("%s |<br>%s+-- ", $indent, $indent); + $value.= sprintf('%s<br>', $class); + + return $value; + } // end func getClasstree + + /** + * Returns a certain number of "&nbsp;"s. + * @param int number of "&nbsp;" required. + * @see $indent + * @return string A string with the requested number of nunbreakable html spaces + */ + function getIndent($level) { + + if (!isset($this->indent[$level])) { + + $html = ""; + for ($i=0; $i<$level; $i++) + $html.= "&nbsp;&nbsp;"; + + $this->indent[$level] = $html; + + } + + return $this->indent[$level]; + + } // end func getIndent + +} // end class PhpdocHTMLClassRenderer +?> Index: php4/pear/PHPDoc/renderer/html/PhpdocHTMLDocumentRenderer.php diff -u php4/pear/PHPDoc/renderer/html/PhpdocHTMLDocumentRenderer.php:1.1 php4/pear/PHPDoc/renderer/html/PhpdocHTMLDocumentRenderer.php:1.2 --- php4/pear/PHPDoc/renderer/html/PhpdocHTMLDocumentRenderer.php:1.1 Sun Oct 8 03:05:11 2000 +++ php4/pear/PHPDoc/renderer/html/PhpdocHTMLDocumentRenderer.php Sun Oct 15 06:33:13 2000 @@ -1,741 +1,741 @@ -<?php -/** -* Provides functioninality to render modules and classes. -*/ -class PhpdocHTMLDocumentRenderer extends PhpdocHTMLRenderer { - - /** - * Message displayed if an object lacks documentation. - * @var string $undocumented - * @access public - */ - var $undocmented = "Warning: documentation is missing."; - - /** - * Array of functions found in the xml document. - * @var array $functions - */ - var $functions = array(); - - /** - * Array of included files. - * @var array $uses - */ - var $uses = array(); - - /** - * Array of constants. - * @var array $constants - */ - var $constants = array(); - - /** - * Array of access modifiers. - * @var array $accessModifiers - */ - var $accessModifiers = array("public", "private"); - - /** - * Array of doc container fields that get mapped directly to templateblocks. - * @var array $simpleDocfields - * @see renderVariableDetail() - */ - var $simpleDocfields = array( - "VERSION" => "version", - "SINCE" => "since", - "DEPRECATED" => "deprecated", - "COPYRIGHT" => "copyright", - "MAGIC" => "magic" - ); - - /** - * Known types for @include. - * @var array $usesTypes - * @see renderUses() - */ - var $usesTypes = array( "include", "include_once", "require", "require_once" ); - - /** - * Adds a summary and a detailed list of all constants to the template. - * @see renderConstantSummary(), renderConstantDetail() - */ - function renderConstants() { - - $this->constants["public"] = $this->accessor->getConstantsByAccess("public"); - $this->constants["private"] = $this->accessor->getConstantsByAccess("private"); - - if (0==count($this->constants["public"]) && 0==count($this->constants["private"])) - return; - - $this->renderConstantSummary(); - $this->renderConstantDetail(); - - $this->constants = array(); - - } // end func renderConstants - - /** - * Adds a summary of all constants to the template. - * - * The function assumes that there is a block called "constantssummary" and - * withing this block a bock called "constantssummary_loop" in the template. - * - * @see renderConstantDetail() - */ - function renderConstantSummary() { - - reset($this->accessModifiers); - while (list($k, $access)=each($this->accessModifiers)) { - if (0==count($this->constants[$access])) - continue; - - $this->tpl->setCurrentBlock("constantssummary_loop"); - - reset($this->constants[$access]); - while (list($name, $const)=each($this->constants[$access])) { - - $this->tpl->setVariable("NAME", $name); - $this->tpl->setVariable("VALUE", htmlentities($const["value"])); - if (isset($const["doc"]["shortdescription"])) - $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($const["doc"]["shortdescription"]["value"])); - - if ("true" == $const["undoc"]) - $this->tpl->setVariable("UNDOC", $this->undocumented); - - $this->tpl->parseCurrentBlock(); - - } - - $this->tpl->setCurrentBlock("constantssummary"); - $this->tpl->setVariable("ACCESS", ucfirst($access)); - $this->tpl->parseCurrentBlock(); - - } - - } // end func renderConstantSummary - - /** - * Adds a detailed list of all constants to the template. - * - * The function assumes that there is a block named "constantdetails" and - * withing it another block named "constantdetails_loop". - * - * @see renderConstantSummary() - */ - function renderConstantDetail() { - - reset($this->accessModifiers); - while (list($k, $access)=each($this->accessModifiers)) { - if (0==count($this->constants[$access])) - continue; - - reset($this->constants[$access]); - while (list($name, $constant)=each($this->constants[$access])) { - - $tplvars = array(); - - $tplvars["NAME"] = $name; - $tplvars["CASE"] = $constant["case"]; - $tplvars["VALUE"] = htmlentities($constant["value"]); - - if ("true" == $constant["undoc"]) - $tplvars["UNDOC"] = $this->undocumented; - - if (isset($constant["doc"]["shortdescription"])) - $tplvars["SHORTDESCRIPTION"] = $this->encode($constant["doc"]["shortdescription"]["value"]); - if (isset($constant["doc"]["description"])) - $tplvars["DESCRIPTION"] = $this->encode($constant["doc"]["description"]["value"]); - - $this->renderCommonDocfields("constantdetails_", $constant); - - $this->tpl->setCurrentBlock("constantdetails_loop"); - $this->tpl->setVariable($tplvars); - $this->tpl->parseCurrentBlock(); - } - - $this->tpl->setCurrentBlock("constantdetails"); - $this->tpl->setVariable("ACCESS", ucfirst($access)); - $this->tpl->parseCurrentBlock(); - } - } // end func renderConstantsDetail - - /** - * Adds a summary and a detailed list of included files to the template. - * @see renderUsesSummary(), renderUsesDetail() - */ - function renderUses() { - - $found = false; - - reset($this->usesTypes); - while (list($k, $type)=each($this->usesTypes)) { - - $this->uses[$type] = $this->accessor->getUsesByType($type); - if (!$found && 0!=count($this->uses[$type])) - $found = true; - - } - - if (!$found) - return; - - $this->renderUsesSummary(); - $this->renderUsesDetail(); - - $this->uses = array(); - - } // end func renderUses - - /** - * Adds a detailed list of all @included files to the template. - * - * The function assumes that there is a block names "usesdetail" and within the block - * a block names "usesdetail_loop" in the template. - * - * @see renderUsesSummary() - */ - function renderUsesDetail() { - - reset($this->usesTypes); - while (list($k, $type)=each($this->usesTypes)) { - if (0==count($this->uses[$type])) - continue; - - reset($this->uses[$type]); - while (list($file, $uses)=each($this->uses[$type])) { - - $tplvars = array(); - $tplvars["FILE"] = $uses["file"]; - $tplvars["TYPE"] = $type; - - if ("true"==$uses["undoc"]) - $tplvars["UNDOC"] = $this->undocumented; - - if (isset($uses["doc"]["shortdescription"])) - $tplvars["SHORTDESCRIPTION"] = $this->encode($uses["doc"]["shortdescription"]["value"]); - if (isset($uses["doc"]["description"])) - $tplvars["DESCRIPTION"] = $this->encode($uses["doc"]["description"]["value"]); - - $this->renderCommonDocfields("usesdetails_", $uses); - - $this->tpl->setCurrentBlock("usesdetails_loop"); - $this->tpl->setVariable($tplvars); - $this->tpl->parseCurrentBlock(); - } - - $this->tpl->setCurrentBlock("usesdetails"); - $this->tpl->setVariable("TYPE", $type); - $this->tpl->parseCurrentBlock(); - - } - - } // end func renderUsesDetail - - /** - * Adds a summary of all @included files to the template. - * - * The function assumes that there is a block names "usessummary" and within - * the block another block names "usessummary_loop" in the template. - * - * @see renderUsesDetail() - */ - function renderUsesSummary() { - - reset($this->usesTypes); - while (list($k, $type)=each($this->usesTypes)) { - if (0==count($this->uses[$type])) - continue; - - $this->tpl->setCurrentBlock("usessummary_loop"); - - reset($this->uses[$type]); - while (list($file, $uses)=each($this->uses[$type])) { - - $this->tpl->setVariable("FILE", $file); - - if (isset($uses["doc"]["shortdescription"])) - $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($uses["doc"]["shortdescription"]["value"])); - - if ("true"==$uses["undoc"]) - $this->tpl->setVariable("UNDOC", $this->undocumented); - - $this->tpl->parseCurrentBlock(); - - } - - $this->tpl->setCurrentBlock("usessummary"); - $this->tpl->setVariable("TYPE", $type); - $this->tpl->parseCurrentBlock(); - - } - - } // end func renderUsesSummary - - /** - * Adds a summary and a detailed list of all functions to the template. - * @see renderFunctionSummary(), renderFunctionDetail(), $functions - */ - function renderFunctions() { - - $this->functions["private"] = $this->accessor->getFunctionsByAccess("private"); - $this->functions["public"] = $this->accessor->getFunctionsByAccess("public"); - - if (0==count($this->functions["private"]) && 0==count($this->functions["public"])) - return; - - $this->renderFunctionSummary(); - $this->renderFunctionDetail(); - - $this->functions = array(); - - } // end func renderFunctions - - /** - * Adds a function summary to the template. - * - * The function assumes that there is ablock names "functionsummary" and - * within it a block names "functionsummary_loop" in the template. - * - * @see renderFunctionDetail(), renderFunctions(), $functions, $accessModifiers - */ - function renderFunctionSummary() { - - reset($this->accessModifiers); - while (list($k, $access)=each($this->accessModifiers)) { - if (0==count($this->functions[$access])) - continue; - - $this->tpl->setCurrentBlock("functionsummary_loop"); - - reset($this->functions[$access]); - while (list($name, $function)=each($this->functions[$access])) { - - $this->tpl->setVariable("NAME", $name); - - if (isset($function["doc"]["parameter"])) - $this->tpl->setVariable("PARAMETER", $this->getParameter($function["doc"]["parameter"])); - - if (isset($function["doc"]["shortdescription"])) - $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($function["doc"]["shortdescription"]["value"])); - - if (isset($function["doc"]["return"])) - $this->tpl->setVariable("RETURNTYPE", $function["doc"]["return"]["type"]); - else - $this->tpl->setVariable("RETURNTYPE", "void"); - - if ("true"==$function["undoc"]) - $this->tpl->setVariable("UNDOC", $this->undocumented); - - $this->tpl->parseCurrentBlock(); - - } - - $this->tpl->setCurrentBlock("functionsummary"); - $this->tpl->setVariable("ACCESS", ucfirst($access) ); - $this->tpl->parseCurrentBlock(); - } - - } // end func renderFunctionSummary - - /** - * Adds a detailed list of functions to the template. - * - * The function assumes that there is a block named "functiondetails" and - * within it a bloc "functiondetails_loop" in the template. - * - * @see renderFunctions(), renderFunctionSummary(), $functions, $accessModifiers - */ - function renderFunctionDetail() { - - reset($this->accessModifiers); - while (list($k, $access)=each($this->accessModifiers)) { - if (0==count($this->functions[$access])) - continue; - - reset($this->functions[$access]); - while (list($name, $function)=each($this->functions[$access])) { - - $tplvars = array(); - $tplvars["NAME"] = $function["name"]; - $tplvars["ACCESS"] = $function["access"]; - - if ("true"==$function["undoc"]) - $tplvars["UNDOC"] = $this->undocumented; - - if ("true"==$function["abstract"]) - $tplvars["ABSTRACT"] = "abstract"; - - if ("true"==$function["static"]) - $tplvars["STATIC"] = "static"; - - if (isset($function["doc"]["shortdescription"])) - $tplvars["SHORTDESCRIPTION"] = $this->encode($function["doc"]["shortdescription"]["value"]); - if (isset($function["doc"]["description"])) - $tplvars["DESCRIPTION"] = $this->encode($function["doc"]["description"]["value"]); - - $this->renderCommonDocfields("functiondetails_", $function); - - if (isset($function["doc"]["parameter"])) { - $tplvars["PARAMETER"] = $this->getParameter($function["doc"]["parameter"]); - $this->renderParameterDetail($function["doc"]["parameter"]); - } - - if (isset($function["doc"]["throws"])) - $this->renderThrows($function["doc"]["throws"], "functiondetails_"); - - if (isset($function["doc"]["global"])) - $this->renderGlobals($function["doc"]["global"], "functiondetails_"); - - if (isset($function["doc"]["return"])) { - - $tplvars["RETURNTYPE"] = $function["doc"]["return"]["type"]; - - $this->tpl->setCurrentBlock("functiondetails_return"); - - $this->tpl->setVariable("TYPE", $function["doc"]["return"]["type"]); - $this->tpl->setVariable("DESCRIPTION", $this->encode($function["doc"]["return"]["value"])); - if (isset($function["doc"]["return"]["name"])) - $this->tpl->setVariable("NAME", $function["doc"]["return"]["name"]); - - $this->tpl->parseCurrentBlock(); - - } else { - - $tplvars["RETURNTYPE"] = "void"; - - } - - $this->tpl->setCurrentBlock("functiondetails_loop"); - $this->tpl->setVariable($tplvars); - $this->tpl->parseCurrentBlock(); - } - - $this->tpl->setCurrentBlock("functiondetails"); - $this->tpl->setVariable("ACCESS", ucfirst($access) ); - $this->tpl->parseCurrentBlock(); - - } - - } // end func renderFunctionDetail - - /** - * Renders a detailed list of function parameters. - * - * The function assumes that there is a block named "functiondetails_parameter" in - * the template and within it a block named "functiondetails_parameter_loop". - * - * @param array Parameter - */ - function renderParameterDetail($parameter) { - - if (!isset($parameter[0])) - $parameter = array($parameter); - - $this->tpl->setCurrentBlock("functiondetails_parameter_loop"); - - reset($parameter); - while (list($k, $param)=each($parameter)) { - - $this->tpl->setVariable("NAME", $param["name"]); - $this->tpl->setVariable("DESCRIPTION", $this->encode($param["value"])); - - if (isset($param["type"])) - $this->tpl->setVariable("TYPE", $param["type"]); - - if (isset($param["default"])) - $this->tpl->setVariable("DEFAULT", "= >>".htmlentities($param["default"])."<<"); - - if ("true" == $param["undoc"]) - $this->tpl->setVariable("UNDOC", $this->undocumented); - - $this->tpl->parseCurrentBlock(); - } - - } // end func renderParameterDetail - - /** - * Converts the XML parameter array into formatted string. - * @param array XML parameter array - * @return string Formatted parameter string - */ - function getParameter($parameter) { - - if (!is_array($parameter)) - return "void"; - - $value = ""; - - if (!isset($parameter[0])) { - - if (!isset($parameter["default"])) - $value.= $parameter["type"]." ".$parameter["name"]; - else - $value.= "[ ".$parameter["type"]." ".$parameter["name"]." ]"; - - } else { - - $flag_optional = false; - - reset($parameter); - while (list($k, $param)=each($parameter)) { - - if (!isset($param["default"])) { - - if ($flag_optional) { - $value = substr($value, 0, -2)." ], "; - $flag_optional = false; - } - - } else { - - if (!$flag_optional) { - $value.= "[ "; - $flag_optional = true; - } - } - - $value.= $param["type"]." ".$param["name"].", "; - } - - $value = substr($value, 0, -2); - if ($flag_optional) - $value.= " ]"; - - } - - return $value; - } // end func getParameter - - /** - * Renders a block with references to other source elements, @see. - * @param array XML references array - * @param string optional template blockname prefix - */ - function renderSee($references, $prefix="") { - - $value = ""; - - if (!isset($references[0])) { - - if (isset($references["group"])) - $value.= sprintf('<a href="%s.html#%s_%s">%s::%s</a>', - $this->nameToUrl($references["group"]), - $references["type"], - $references["value"], - $references["group"], - $references["value"] - ); - else - $value.= sprintf('<a href="#%s_%s">%s</a>', - $references["type"], - $references["value"], - $references["value"] - ); - - } else { - - reset($references); - while (list($k, $reference)=each($references)) { - - if (isset($reference["group"])) - $value.= sprintf('<a href="%s.html#%s_%s">%s::%s</a>, ', - $this->nameToUrl($reference["group"]), - $reference["type"], - $reference["value"], - $reference["group"], - $reference["value"] - ); - else - $value.= sprintf('<a href="#%s_%s">%s</a>, ', - $reference["type"], - $reference["value"], - $reference["value"] - ); - - } - - $value = substr($value, 0, -2); - - } - - $this->tpl->setCurrentBlock(strtolower($prefix)."see"); - $this->tpl->setVariable("SEE", $value); - $this->tpl->parseCurrentBlock(); - - } // end func renderSee - - /** - * Renders an author list, @author. - * @param array XML author array - * @param string optional template blockname prefix - */ - function renderAuthors($authors, $prefix="") { - - $value = ""; - - if (!isset($authors[0])) { - - if (isset($authors["email"])) - $value.= sprintf('%s &lt;<a href="mailto:%s">%s</a>&gt;, ', $authors["value"], $authors["email"], $authors["email"]); - else - $value.= $authors["email"].", "; - - } else { - - reset($authors); - while (list($k, $author)=each($authors)) { - - if (isset($author["email"])) - $value.= sprintf('%s &lt;<a href="mailto:%s">%s</a>&gt;, ', $author["value"], $author["email"], $author["email"]); - else - $value.= $author["email"].", "; - - } - - } - - $value = substr($value, 0, -2); - $this->tpl->setCurrentBlock(strtolower($prefix)."authors"); - $this->tpl->setVariable("AUTHOR", $value); - $this->tpl->parseCurrentBlock(); - - } // end func renderAuthors - - /** - * Renders a list of external links, @link. - * @param array XML link array - * @param string optional template blockname prefix - */ - function renderLinks($links, $prefix="") { - - $value= ""; - - if (!isset($links[0])) { - - $value.= sprintf('<a href="%s">%s</a>%s, ', - $links["url"], - $links["url"], - (""!=$links["description"]) ? " - ".$links["description"] : "" - ); - - } else { - - reset($links); - while (list($k, $link)=each($links)) { - - $value.= sprintf('<a href="%s">%s</a>%s, ', - $link["url"], - $link["url"], - (""!=$link["description"]) ? " - ".$links["description"] : "" - ); - - } - - } - - $value = substr($value, 0, 2); - - $this->tpl->setCurrentBlock(strtolower($prefix)."links"); - $this->tpl->setVariable("LINK", $value); - $this->tpl->parseCurrentBlock(); - - } // end func renderLinks - - /** - * Renders a list of exceptions, @throws. - * @param array XML array - * @param string optional template blockname prefix - */ - function renderThrows($throws, $prefix="") { - - $value = ""; - - if (!isset($throws[0])) { - - $value = $throws["value"]; - - } else { - - reset($throws); - while (list($k, $exception)=each($throws)) - $value.= sprintf("%s, ", $exception["value"]); - - $value = substr($value, 0, -2); - - } - - $this->tpl->setCurrentBlock(strtolower($prefix)."throws"); - $this->tpl->setVariable("EXCEPTIONS", $value); - $this->tpl->parseCurrentBlock(); - - } // end func renderThrows - - /** - * Renders a list of global elements, @global - * @param array XML globals array - * @param string optional template blockname prefix - */ - function renderGlobals($globals, $prefix="") { - - $prefix = strtolower($prefix); - $this->tpl->setCurrentBlock($prefix."globals_loop"); - - if (!isset($globals[0])) { - - $this->tpl->setVariable("NAME", $globals["name"]); - $this->tpl->setVariable("DESCRIPTION", $this->encode($globals["value"])); - if (isset($globals["type"])) - $this->tpl->setVariable("TYPE", $globals["type"]); - - $this->tpl->parseCurrentBlock(); - - } else { - - reset($globals); - while (list($k, $global)=each($globals)) { - - $this->tpl->setVariable("NAME", $global["name"]); - $this->tpl->setVariable("DESCRIPTION", $this->encode($global["value"])); - if (isset($globals["type"])) - $this->tpl->setVariable("TYPE", $globals["type"]); - - $this->tpl->parseCurrentBlock(); - - } - - } - - } // end func renderGlobals - - /** - * Adds some tags to the template that are allowed nearly everywhere. - * @param string template blockname prefixs - * @param array - * @see $simpleDocfields, renderLinks(), renderAuthors(), renderSee() - */ - function renderCommonDocfields($block, &$data) { - - reset($this->simpleDocfields); - while (list($varname, $field)=each($this->simpleDocfields)) { - - if (isset($data["doc"][$field])) { - $this->tpl->setCurrentBlock($block.$field); - $this->tpl->setVariable($varname, htmlentities($data["doc"][$field]["value"])); - $this->tpl->parseCurrentBlock(); - } - - } - - if (isset($data["doc"]["link"])) - $this->renderLinks($data["doc"]["link"], $block); - - if (isset($data["doc"]["author"])) - $this->renderAuthors($data["doc"]["author"], $block); - - if (isset($data["doc"]["see"])) - $this->renderSee($data["doc"]["see"], $block); - - } // end func renderCommonDocfields - -} // end func PhpdocHTMLDocumentRenderer -?> \ No newline at end of file +<?php +/** +* Provides functioninality to render modules and classes. +*/ +class PhpdocHTMLDocumentRenderer extends PhpdocHTMLRenderer { + + /** + * Message displayed if an object lacks documentation. + * @var string $undocumented + * @access public + */ + var $undocmented = "Warning: documentation is missing."; + + /** + * Array of functions found in the xml document. + * @var array $functions + */ + var $functions = array(); + + /** + * Array of included files. + * @var array $uses + */ + var $uses = array(); + + /** + * Array of constants. + * @var array $constants + */ + var $constants = array(); + + /** + * Array of access modifiers. + * @var array $accessModifiers + */ + var $accessModifiers = array("public", "private"); + + /** + * Array of doc container fields that get mapped directly to templateblocks. + * @var array $simpleDocfields + * @see renderVariableDetail() + */ + var $simpleDocfields = array( + "VERSION" => "version", + "SINCE" => "since", + "DEPRECATED" => "deprecated", + "COPYRIGHT" => "copyright", + "MAGIC" => "magic" + ); + + /** + * Known types for @include. + * @var array $usesTypes + * @see renderUses() + */ + var $usesTypes = array( "include", "include_once", "require", "require_once" ); + + /** + * Adds a summary and a detailed list of all constants to the template. + * @see renderConstantSummary(), renderConstantDetail() + */ + function renderConstants() { + + $this->constants["public"] = $this->accessor->getConstantsByAccess("public"); + $this->constants["private"] = $this->accessor->getConstantsByAccess("private"); + + if (0==count($this->constants["public"]) && 0==count($this->constants["private"])) + return; + + $this->renderConstantSummary(); + $this->renderConstantDetail(); + + $this->constants = array(); + + } // end func renderConstants + + /** + * Adds a summary of all constants to the template. + * + * The function assumes that there is a block called "constantssummary" and + * withing this block a bock called "constantssummary_loop" in the template. + * + * @see renderConstantDetail() + */ + function renderConstantSummary() { + + reset($this->accessModifiers); + while (list($k, $access)=each($this->accessModifiers)) { + if (0==count($this->constants[$access])) + continue; + + $this->tpl->setCurrentBlock("constantssummary_loop"); + + reset($this->constants[$access]); + while (list($name, $const)=each($this->constants[$access])) { + + $this->tpl->setVariable("NAME", $name); + $this->tpl->setVariable("VALUE", htmlentities($const["value"])); + if (isset($const["doc"]["shortdescription"])) + $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($const["doc"]["shortdescription"]["value"])); + + if ("true" == $const["undoc"]) + $this->tpl->setVariable("UNDOC", $this->undocumented); + + $this->tpl->parseCurrentBlock(); + + } + + $this->tpl->setCurrentBlock("constantssummary"); + $this->tpl->setVariable("ACCESS", ucfirst($access)); + $this->tpl->parseCurrentBlock(); + + } + + } // end func renderConstantSummary + + /** + * Adds a detailed list of all constants to the template. + * + * The function assumes that there is a block named "constantdetails" and + * withing it another block named "constantdetails_loop". + * + * @see renderConstantSummary() + */ + function renderConstantDetail() { + + reset($this->accessModifiers); + while (list($k, $access)=each($this->accessModifiers)) { + if (0==count($this->constants[$access])) + continue; + + reset($this->constants[$access]); + while (list($name, $constant)=each($this->constants[$access])) { + + $tplvars = array(); + + $tplvars["NAME"] = $name; + $tplvars["CASE"] = $constant["case"]; + $tplvars["VALUE"] = htmlentities($constant["value"]); + + if ("true" == $constant["undoc"]) + $tplvars["UNDOC"] = $this->undocumented; + + if (isset($constant["doc"]["shortdescription"])) + $tplvars["SHORTDESCRIPTION"] = $this->encode($constant["doc"]["shortdescription"]["value"]); + if (isset($constant["doc"]["description"])) + $tplvars["DESCRIPTION"] = $this->encode($constant["doc"]["description"]["value"]); + + $this->renderCommonDocfields("constantdetails_", $constant); + + $this->tpl->setCurrentBlock("constantdetails_loop"); + $this->tpl->setVariable($tplvars); + $this->tpl->parseCurrentBlock(); + } + + $this->tpl->setCurrentBlock("constantdetails"); + $this->tpl->setVariable("ACCESS", ucfirst($access)); + $this->tpl->parseCurrentBlock(); + } + } // end func renderConstantsDetail + + /** + * Adds a summary and a detailed list of included files to the template. + * @see renderUsesSummary(), renderUsesDetail() + */ + function renderUses() { + + $found = false; + + reset($this->usesTypes); + while (list($k, $type)=each($this->usesTypes)) { + + $this->uses[$type] = $this->accessor->getUsesByType($type); + if (!$found && 0!=count($this->uses[$type])) + $found = true; + + } + + if (!$found) + return; + + $this->renderUsesSummary(); + $this->renderUsesDetail(); + + $this->uses = array(); + + } // end func renderUses + + /** + * Adds a detailed list of all @included files to the template. + * + * The function assumes that there is a block names "usesdetail" and within the block + * a block names "usesdetail_loop" in the template. + * + * @see renderUsesSummary() + */ + function renderUsesDetail() { + + reset($this->usesTypes); + while (list($k, $type)=each($this->usesTypes)) { + if (0==count($this->uses[$type])) + continue; + + reset($this->uses[$type]); + while (list($file, $uses)=each($this->uses[$type])) { + + $tplvars = array(); + $tplvars["FILE"] = $uses["file"]; + $tplvars["TYPE"] = $type; + + if ("true"==$uses["undoc"]) + $tplvars["UNDOC"] = $this->undocumented; + + if (isset($uses["doc"]["shortdescription"])) + $tplvars["SHORTDESCRIPTION"] = $this->encode($uses["doc"]["shortdescription"]["value"]); + if (isset($uses["doc"]["description"])) + $tplvars["DESCRIPTION"] = $this->encode($uses["doc"]["description"]["value"]); + + $this->renderCommonDocfields("usesdetails_", $uses); + + $this->tpl->setCurrentBlock("usesdetails_loop"); + $this->tpl->setVariable($tplvars); + $this->tpl->parseCurrentBlock(); + } + + $this->tpl->setCurrentBlock("usesdetails"); + $this->tpl->setVariable("TYPE", $type); + $this->tpl->parseCurrentBlock(); + + } + + } // end func renderUsesDetail + + /** + * Adds a summary of all @included files to the template. + * + * The function assumes that there is a block names "usessummary" and within + * the block another block names "usessummary_loop" in the template. + * + * @see renderUsesDetail() + */ + function renderUsesSummary() { + + reset($this->usesTypes); + while (list($k, $type)=each($this->usesTypes)) { + if (0==count($this->uses[$type])) + continue; + + $this->tpl->setCurrentBlock("usessummary_loop"); + + reset($this->uses[$type]); + while (list($file, $uses)=each($this->uses[$type])) { + + $this->tpl->setVariable("FILE", $file); + + if (isset($uses["doc"]["shortdescription"])) + $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($uses["doc"]["shortdescription"]["value"])); + + if ("true"==$uses["undoc"]) + $this->tpl->setVariable("UNDOC", $this->undocumented); + + $this->tpl->parseCurrentBlock(); + + } + + $this->tpl->setCurrentBlock("usessummary"); + $this->tpl->setVariable("TYPE", $type); + $this->tpl->parseCurrentBlock(); + + } + + } // end func renderUsesSummary + + /** + * Adds a summary and a detailed list of all functions to the template. + * @see renderFunctionSummary(), renderFunctionDetail(), $functions + */ + function renderFunctions() { + + $this->functions["private"] = $this->accessor->getFunctionsByAccess("private"); + $this->functions["public"] = $this->accessor->getFunctionsByAccess("public"); + + if (0==count($this->functions["private"]) && 0==count($this->functions["public"])) + return; + + $this->renderFunctionSummary(); + $this->renderFunctionDetail(); + + $this->functions = array(); + + } // end func renderFunctions + + /** + * Adds a function summary to the template. + * + * The function assumes that there is ablock names "functionsummary" and + * within it a block names "functionsummary_loop" in the template. + * + * @see renderFunctionDetail(), renderFunctions(), $functions, $accessModifiers + */ + function renderFunctionSummary() { + + reset($this->accessModifiers); + while (list($k, $access)=each($this->accessModifiers)) { + if (0==count($this->functions[$access])) + continue; + + $this->tpl->setCurrentBlock("functionsummary_loop"); + + reset($this->functions[$access]); + while (list($name, $function)=each($this->functions[$access])) { + + $this->tpl->setVariable("NAME", $name); + + if (isset($function["doc"]["parameter"])) + $this->tpl->setVariable("PARAMETER", $this->getParameter($function["doc"]["parameter"])); + + if (isset($function["doc"]["shortdescription"])) + $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($function["doc"]["shortdescription"]["value"])); + + if (isset($function["doc"]["return"])) + $this->tpl->setVariable("RETURNTYPE", $function["doc"]["return"]["type"]); + else + $this->tpl->setVariable("RETURNTYPE", "void"); + + if ("true"==$function["undoc"]) + $this->tpl->setVariable("UNDOC", $this->undocumented); + + $this->tpl->parseCurrentBlock(); + + } + + $this->tpl->setCurrentBlock("functionsummary"); + $this->tpl->setVariable("ACCESS", ucfirst($access) ); + $this->tpl->parseCurrentBlock(); + } + + } // end func renderFunctionSummary + + /** + * Adds a detailed list of functions to the template. + * + * The function assumes that there is a block named "functiondetails" and + * within it a bloc "functiondetails_loop" in the template. + * + * @see renderFunctions(), renderFunctionSummary(), $functions, $accessModifiers + */ + function renderFunctionDetail() { + + reset($this->accessModifiers); + while (list($k, $access)=each($this->accessModifiers)) { + if (0==count($this->functions[$access])) + continue; + + reset($this->functions[$access]); + while (list($name, $function)=each($this->functions[$access])) { + + $tplvars = array(); + $tplvars["NAME"] = $function["name"]; + $tplvars["ACCESS"] = $function["access"]; + + if ("true"==$function["undoc"]) + $tplvars["UNDOC"] = $this->undocumented; + + if ("true"==$function["abstract"]) + $tplvars["ABSTRACT"] = "abstract"; + + if ("true"==$function["static"]) + $tplvars["STATIC"] = "static"; + + if (isset($function["doc"]["shortdescription"])) + $tplvars["SHORTDESCRIPTION"] = $this->encode($function["doc"]["shortdescription"]["value"]); + if (isset($function["doc"]["description"])) + $tplvars["DESCRIPTION"] = $this->encode($function["doc"]["description"]["value"]); + + $this->renderCommonDocfields("functiondetails_", $function); + + if (isset($function["doc"]["parameter"])) { + $tplvars["PARAMETER"] = $this->getParameter($function["doc"]["parameter"]); + $this->renderParameterDetail($function["doc"]["parameter"]); + } + + if (isset($function["doc"]["throws"])) + $this->renderThrows($function["doc"]["throws"], "functiondetails_"); + + if (isset($function["doc"]["global"])) + $this->renderGlobals($function["doc"]["global"], "functiondetails_"); + + if (isset($function["doc"]["return"])) { + + $tplvars["RETURNTYPE"] = $function["doc"]["return"]["type"]; + + $this->tpl->setCurrentBlock("functiondetails_return"); + + $this->tpl->setVariable("TYPE", $function["doc"]["return"]["type"]); + $this->tpl->setVariable("DESCRIPTION", $this->encode($function["doc"]["return"]["value"])); + if (isset($function["doc"]["return"]["name"])) + $this->tpl->setVariable("NAME", $function["doc"]["return"]["name"]); + + $this->tpl->parseCurrentBlock(); + + } else { + + $tplvars["RETURNTYPE"] = "void"; + + } + + $this->tpl->setCurrentBlock("functiondetails_loop"); + $this->tpl->setVariable($tplvars); + $this->tpl->parseCurrentBlock(); + } + + $this->tpl->setCurrentBlock("functiondetails"); + $this->tpl->setVariable("ACCESS", ucfirst($access) ); + $this->tpl->parseCurrentBlock(); + + } + + } // end func renderFunctionDetail + + /** + * Renders a detailed list of function parameters. + * + * The function assumes that there is a block named "functiondetails_parameter" in + * the template and within it a block named "functiondetails_parameter_loop". + * + * @param array Parameter + */ + function renderParameterDetail($parameter) { + + if (!isset($parameter[0])) + $parameter = array($parameter); + + $this->tpl->setCurrentBlock("functiondetails_parameter_loop"); + + reset($parameter); + while (list($k, $param)=each($parameter)) { + + $this->tpl->setVariable("NAME", $param["name"]); + $this->tpl->setVariable("DESCRIPTION", $this->encode($param["value"])); + + if (isset($param["type"])) + $this->tpl->setVariable("TYPE", $param["type"]); + + if (isset($param["default"])) + $this->tpl->setVariable("DEFAULT", "= >>".htmlentities($param["default"])."<<"); + + if ("true" == $param["undoc"]) + $this->tpl->setVariable("UNDOC", $this->undocumented); + + $this->tpl->parseCurrentBlock(); + } + + } // end func renderParameterDetail + + /** + * Converts the XML parameter array into formatted string. + * @param array XML parameter array + * @return string Formatted parameter string + */ + function getParameter($parameter) { + + if (!is_array($parameter)) + return "void"; + + $value = ""; + + if (!isset($parameter[0])) { + + if (!isset($parameter["default"])) + $value.= $parameter["type"]." ".$parameter["name"]; + else + $value.= "[ ".$parameter["type"]." ".$parameter["name"]." ]"; + + } else { + + $flag_optional = false; + + reset($parameter); + while (list($k, $param)=each($parameter)) { + + if (!isset($param["default"])) { + + if ($flag_optional) { + $value = substr($value, 0, -2)." ], "; + $flag_optional = false; + } + + } else { + + if (!$flag_optional) { + $value.= "[ "; + $flag_optional = true; + } + } + + $value.= $param["type"]." ".$param["name"].", "; + } + + $value = substr($value, 0, -2); + if ($flag_optional) + $value.= " ]"; + + } + + return $value; + } // end func getParameter + + /** + * Renders a block with references to other source elements, @see. + * @param array XML references array + * @param string optional template blockname prefix + */ + function renderSee($references, $prefix="") { + + $value = ""; + + if (!isset($references[0])) { + + if (isset($references["group"])) + $value.= sprintf('<a href="%s#%s_%s">%s::%s</a>', + $this->nameToUrl($references["group"]).$this->file_extension, + $references["type"], + $references["value"], + $references["group"], + $references["value"] + ); + else + $value.= sprintf('<a href="#%s_%s">%s</a>', + $references["type"], + $references["value"], + $references["value"] + ); + + } else { + + reset($references); + while (list($k, $reference)=each($references)) { + + if (isset($reference["group"])) + $value.= sprintf('<a href="%s#%s_%s">%s::%s</a>, ', + $this->nameToUrl($reference["group"]).$this->file_extension, + $reference["type"], + $reference["value"], + $reference["group"], + $reference["value"] + ); + else + $value.= sprintf('<a href="#%s_%s">%s</a>, ', + $reference["type"], + $reference["value"], + $reference["value"] + ); + + } + + $value = substr($value, 0, -2); + + } + + $this->tpl->setCurrentBlock(strtolower($prefix)."see"); + $this->tpl->setVariable("SEE", $value); + $this->tpl->parseCurrentBlock(); + + } // end func renderSee + + /** + * Renders an author list, @author. + * @param array XML author array + * @param string optional template blockname prefix + */ + function renderAuthors($authors, $prefix="") { + + $value = ""; + + if (!isset($authors[0])) { + + if (isset($authors["email"])) + $value.= sprintf('%s &lt;<a href="mailto:%s">%s</a>&gt;, ', $authors["value"], $authors["email"], $authors["email"]); + else + $value.= $authors["email"].", "; + + } else { + + reset($authors); + while (list($k, $author)=each($authors)) { + + if (isset($author["email"])) + $value.= sprintf('%s &lt;<a href="mailto:%s">%s</a>&gt;, ', $author["value"], $author["email"], $author["email"]); + else + $value.= $author["email"].", "; + + } + + } + + $value = substr($value, 0, -2); + $this->tpl->setCurrentBlock(strtolower($prefix)."authors"); + $this->tpl->setVariable("AUTHOR", $value); + $this->tpl->parseCurrentBlock(); + + } // end func renderAuthors + + /** + * Renders a list of external links, @link. + * @param array XML link array + * @param string optional template blockname prefix + */ + function renderLinks($links, $prefix="") { + + $value= ""; + + if (!isset($links[0])) { + + $value.= sprintf('<a href="%s">%s</a>%s, ', + $links["url"], + $links["url"], + (""!=$links["description"]) ? " - ".$links["description"] : "" + ); + + } else { + + reset($links); + while (list($k, $link)=each($links)) { + + $value.= sprintf('<a href="%s">%s</a>%s, ', + $link["url"], + $link["url"], + (""!=$link["description"]) ? " - ".$links["description"] : "" + ); + + } + + } + + $value = substr($value, 0, 2); + + $this->tpl->setCurrentBlock(strtolower($prefix)."links"); + $this->tpl->setVariable("LINK", $value); + $this->tpl->parseCurrentBlock(); + + } // end func renderLinks + + /** + * Renders a list of exceptions, @throws. + * @param array XML array + * @param string optional template blockname prefix + */ + function renderThrows($throws, $prefix="") { + + $value = ""; + + if (!isset($throws[0])) { + + $value = $throws["value"]; + + } else { + + reset($throws); + while (list($k, $exception)=each($throws)) + $value.= sprintf("%s, ", $exception["value"]); + + $value = substr($value, 0, -2); + + } + + $this->tpl->setCurrentBlock(strtolower($prefix)."throws"); + $this->tpl->setVariable("EXCEPTIONS", $value); + $this->tpl->parseCurrentBlock(); + + } // end func renderThrows + + /** + * Renders a list of global elements, @global + * @param array XML globals array + * @param string optional template blockname prefix + */ + function renderGlobals($globals, $prefix="") { + + $prefix = strtolower($prefix); + $this->tpl->setCurrentBlock($prefix."globals_loop"); + + if (!isset($globals[0])) { + + $this->tpl->setVariable("NAME", $globals["name"]); + $this->tpl->setVariable("DESCRIPTION", $this->encode($globals["value"])); + if (isset($globals["type"])) + $this->tpl->setVariable("TYPE", $globals["type"]); + + $this->tpl->parseCurrentBlock(); + + } else { + + reset($globals); + while (list($k, $global)=each($globals)) { + + $this->tpl->setVariable("NAME", $global["name"]); + $this->tpl->setVariable("DESCRIPTION", $this->encode($global["value"])); + if (isset($globals["type"])) + $this->tpl->setVariable("TYPE", $globals["type"]); + + $this->tpl->parseCurrentBlock(); + + } + + } + + } // end func renderGlobals + + /** + * Adds some tags to the template that are allowed nearly everywhere. + * @param string template blockname prefixs + * @param array + * @see $simpleDocfields, renderLinks(), renderAuthors(), renderSee() + */ + function renderCommonDocfields($block, &$data) { + + reset($this->simpleDocfields); + while (list($varname, $field)=each($this->simpleDocfields)) { + + if (isset($data["doc"][$field])) { + $this->tpl->setCurrentBlock($block.$field); + $this->tpl->setVariable($varname, htmlentities($data["doc"][$field]["value"])); + $this->tpl->parseCurrentBlock(); + } + + } + + if (isset($data["doc"]["link"])) + $this->renderLinks($data["doc"]["link"], $block); + + if (isset($data["doc"]["author"])) + $this->renderAuthors($data["doc"]["author"], $block); + + if (isset($data["doc"]["see"])) + $this->renderSee($data["doc"]["see"], $block); + + } // end func renderCommonDocfields + +} // end func PhpdocHTMLDocumentRenderer +?> Index: php4/pear/PHPDoc/renderer/html/PhpdocHTMLIndexRenderer.php diff -u php4/pear/PHPDoc/renderer/html/PhpdocHTMLIndexRenderer.php:1.1 php4/pear/PHPDoc/renderer/html/PhpdocHTMLIndexRenderer.php:1.2 --- php4/pear/PHPDoc/renderer/html/PhpdocHTMLIndexRenderer.php:1.1 Sun Oct 8 03:05:11 2000 +++ php4/pear/PHPDoc/renderer/html/PhpdocHTMLIndexRenderer.php Sun Oct 15 06:33:13 2000 @@ -1,446 +1,447 @@ -<?php -/** -* Renders Index lists. -*/ -class PhpdocHTMLIndexRenderer extends PhpdocHTMLRenderer { - - /** - * Some container in the package list. - * @var array - * @see renderPackagelist() - */ - var $packageFields = array("class", "module"); - - /** - * Packagelist from the PhpdocIndexAccessor - * @var array - */ - var $packages = array(); - - /** - * Array with classtree informations - * @var array - */ - var $classtree = array(); - - /** - * IntegratedTemplate Object used be renderClasstree() - * - * @var object IntegratedTemplate - * @see renderClasstree() - */ - var $treeTpl; - - /** - * IntegratedTemplateObject used by renderModulegroup() - * - * @var object IntegratedTemplate - * @see renderModulegroup() - */ - var $moduleTpl; - - /** - * Sets the xml and template root directory. - * - * @param string XML file path - * @param string Template file path - * @param string Name of the application - * @see setPath(), setTemplateRoot() - */ - function PhpdocHTMLIndexRenderer($path, $templateRoot, $application) { - - $this->setPath($path); - $this->setTemplateRoot($templateRoot); - $this->application = $application; - - $this->accessor = new PhpdocIndexAccessor; - $this->tpl = new IntegratedTemplate($this->templateRoot); - $this->fileHandler = new PhpdocFileHandler; - - } // end constructor - - /** - * Builds all index files phpdoc needs assuming that the xml files have default names - * - * @access public - * @see renderElementlist(), renderPackagelist(), renderFramelementlist(), renderFramePackageSummary() - */ - function generate() { - - $this->renderElementlist("elementlist.xml"); - $this->renderFrameElementlist("elementlist.xml"); - - $this->renderPackagelist("packagelist.xml"); - $this->renderFramePackageSummary("packagelist.xml"); - $this->renderFrameElementlist("packagelist.xml"); - - } // end function generate - - /** - * Saves the generated classtree summary to disk. - * - * @see renderClasstree() - * @access public - */ - function finishClasstree() { - - if (!is_object($this->treeTpl)) - return; - - $this->treeTpl->setVariable("APPNAME", $this->application); - $this->fileHandler->createFile($this->path."phpdoc_classtree.html", $this->treeTpl->get() ); - $this->treeTpl = ""; - - } // end func finishClasstree - - /** - * Adds a classtree to the classtree summary template. - * - * @param string XML Classtree file - * @see finishClasstree() - * @access public - */ - function addClasstree($xmlfile) { - - $this->accessor->loadXMLFile($this->path.$xmlfile); - - if (!is_object($this->treeTpl)) { - - $this->treeTpl = new IntegratedTemplate($this->templateRoot); - $this->treeTpl->loadTemplatefile("classtree.html"); - - } - - $this->classtree = $this->accessor->getClasstree(); - - $this->treeTpl->setCurrentBlock("classtree"); - $this->treeTpl->setVariable("BASECLASS", $this->classtree["baseclass"]); - $this->treeTpl->setVariable("TREE", "<ul>".$this->buildClasstreeHTML($this->classtree["baseclass"])."</ul>"); - $this->treeTpl->parseCurrentBlock(); - - return true; - } // end func addClasstree - - function finishModulegroup() { - - if (!is_object($this->moduleTpl)) - return; - - $this->moduleTpl->setVariable("APPNAME", $this->application); - $this->fileHandler->createFile($this->path."phpdoc_modulegroup.html", $this->moduleTpl->get() ); - $this->moduleTpl = ""; - - } // end func finishModulegroups - /** - * Renders a modulegroup xml file. - * @param string XML File - */ - function addModulegroup($xmlfile) { - - $this->accessor->loadXMLFile($this->path.$xmlfile); - - if (!is_object($this->moduleTpl)) { - - $this->moduleTpl = new IntegratedTemplate($this->templateRoot); - $this->moduleTpl->loadTemplateFile("modulegroup.html"); - - } - - $modulegroup = $this->accessor->getModulegroup(); - - $modules = "<ul>"; - reset($modulegroup["modules"]); - while (list($k, $module)=each($modulegroup["modules"])) - $modules.= sprintf('<li><a href="%s.html">%s</a>', $this->nameToUrl($module), $module); - $modules.= "</ul>"; - - $this->moduleTpl->setCurrentBlock("modulegroup"); - $this->moduleTpl->setVariable("MODULEGROUP", $modulegroup["group"]); - $this->moduleTpl->setVariable("MODULES", $modules); - $this->moduleTpl->parseCurrentBlock(); - - } // end func addModulegroup - - /** - * Renders the element index list. - * - * @param string XML file - * @access public - * @see generate() - */ - function renderElementlist($xmlfile) { - - $this->accessor->loadXMLFile($this->path.$xmlfile); - $this->tpl->loadTemplatefile("elementlist.html"); - - $chapters = $this->accessor->getChapternames(); - - if (0!=count($chapters)) { - - $this->tpl->setCurrentBlock("chaptersummary_loop"); - reset($chapters); - while (list($k, $chapter)=each($chapters)) { - $this->tpl->setVariable("CHAPTER", $chapter); - $this->tpl->parseCurrentBlock(); - } - - $chapters = $this->accessor->getChapters(); - - reset($chapters); - while (list($name, $elements)=each($chapters)) { - - if (!isset($elements["element"][0])) - $elements["element"] = array($elements["element"]); - - $this->tpl->setCurrentBlock("chapter_loop"); - - reset($elements["element"]); - while (list($k, $element)=each($elements["element"])) { - - switch($element["type"]) { - case "package": - $desc = "Package"; - break; - - case "class": - $desc = sprintf('Class <a href="%s.html">%s</a>.', - $this->nameToUrl($element["name"]), - $element["name"] - ); - break; - - case "module": - $desc = sprintf('Module <a href="%s.html">%s</a>.', - $this->nameToUrl($element["name"]), - $element["name"] - ); - break; - - case "functions": - $desc = sprintf('Function in %s <a href="%s.html">%s</a>', - $element["sourcetype"], - $this->nameToUrl($element["source"]), - $element["source"] - ); - break; - - case "variables": - $desc = sprintf('Variable in Class <a href="%s.html">%s</a>', - $this->nameToUrl($element["source"]), - $element["source"] - ); - break; - - case "uses": - $desc = sprintf('Included file in %s <a href="%s.html">%s</a>', - $element["sourcetype"], - $this->nameToUrl($element["source"]), - $element["source"] - ); - break; - break; - - case "consts": - $desc = sprintf('Constant defined in %s <a href="%s.html">%s</a>', - $element["sourcetype"], - $this->nameToUrl($element["source"]), - $element["source"] - ); - break; - } - - $this->tpl->setVariable("ELEMENTNAME", $element["name"]); - $this->tpl->setVariable("ELEMENT", $desc); - $this->tpl->setVariable("SHORTDESCRIPTION", $element["value"]); - $this->tpl->parseCurrentBlock(); - - } - - $this->tpl->setCurrentBlock("chapter"); - $this->tpl->setVariable("CHAPTER", $name); - $this->tpl->parseCurrentBlock(); - } - - - } - - $this->tpl->setVariable("APPNAME", $this->application); - $this->fileHandler->createFile($this->path."phpdoc_elementlist.html", $this->tpl->get() ); - $this->tpl->free(); - - } // end func renderElementlist - - /** - * Renders a complete packagelist. - * - * @param string XML file - * @access public - * @see renderFrameElementlist(), renderFramePackagesummary() - */ - function renderPackagelist($xmlfile) { - - $this->loadPackagelist($xmlfile); - $this->tpl->loadTemplatefile("packagelist.html"); - - reset($this->packages); - while (list($packagename, $package)=each($this->packages)) { - - reset($this->packageFields); - while (list($k, $field)=each($this->packageFields)) { - if (!isset($package[$field])) - continue; - - $this->tpl->setCurrentBlock("package_".$field."_loop"); - reset($package[$field]); - while (list($k, $element)=each($package[$field])) { - $this->tpl->setVariable("ELEMENT", sprintf('<a href="%s.html">%s</a>', - $this->nameToUrl($element), - $element - ) - ); - $this->tpl->parseCurrentBlock(); - } - - $this->tpl->setCurrentBlock("package_".$field); - $this->tpl->setVariable("EMPTY", ""); - $this->tpl->parseCurrentBlock(); - - } - - $this->tpl->setCurrentBlock("package"); - $this->tpl->setVariable("PACKAGE_NAME", $packagename); - $this->tpl->parseCurrentBlock(); - - } - - $this->tpl->setVariable("APPNAME", $this->application); - $this->fileHandler->createFile($this->path."phpdoc_packagelist.html", $this->tpl->get() ); - $this->tpl->free(); - - } // end func renderPackagelist - - /** - * Renders files for the lower left frame with the elements of a certain file. - * - * @param string This function needs the packagelist.xml to work! - * @access public - * @see renderFramePackagesummary(), renderPackagelist() - */ - function renderFrameElementlist($xmlfile) { - - $this->loadPackagelist($xmlfile); - - reset($this->packages); - while (list($packagename, $package)=each($this->packages)) { - - $this->tpl->loadTemplatefile("frame_packageelementlist.html"); - - reset($this->packageFields); - while (list($k, $field)=each($this->packageFields)) { - if (!isset($package[$field])) - continue; - - $this->tpl->setCurrentBlock("package_".$field."_loop"); - reset($package[$field]); - while (list($k, $element)=each($package[$field])) { - - $this->tpl->setVariable("ELEMENT", sprintf('<a href="%s.html" target="main">%s</a>', - $this->nameToUrl($element), - $element - ) - ); - $this->tpl->parseCurrentBlock(); - } - - $this->tpl->setCurrentBlock("package_".$field); - $this->tpl->setVariable("EMPTY", ""); - $this->tpl->parseCurrentBlock(); - - } - - $this->tpl->setCurrentBlock("package"); - $this->tpl->setVariable("PACKAGE_NAME", $packagename); - $this->tpl->parseCurrentBlock(); - - $this->tpl->setVariable("APPNAME", $this->application); - $packagename = $this->nameToUrl($packagename); - $this->fileHandler->createFile($this->path."packageelementlist_".$packagename.".html", $this->tpl->get() ); - } - - $this->tpl->free(); - - } // end func renderFrameElementlist - - /** - * Renders a Packagesummary for the frameset. - * - * @param string XML file. - * @access public - * @see renderPackagelist(), renderFrameElementlist() - */ - function renderFramePackagesummary($xmlfile) { - - $this->loadPackagelist($xmlfile); - $this->tpl->loadTemplatefile("frame_packagelist.html"); - $this->tpl->setCurrentBlock("package"); - - reset($this->packages); - while (list($packagename, $v)=each($this->packages)) { - $this->tpl->setVariable("PACKAGE", sprintf('<a href="packageelementlist_%s.html" target="packageelements">%s</a>', - $this->nameToUrl($packagename), - $packagename ) - ); - $this->tpl->parseCurrentBlock(); - } - - $this->tpl->setVariable("APPNAME", $this->application); - $this->fileHandler->createFile($this->path."frame_packagelist.html", $this->tpl->get() ); - $this->tpl->free(); - - } // end func renderFramePackagesummary - - /** - * Imports the packagelist from the PhpdocIndexAccessor if not done previously. - * - * @param string XMl file. - * @see $packages - */ - function loadPackagelist($xmlfile) { - - if (0==count($this->packages)) { - $this->accessor->loadXMLFile($this->path.$xmlfile); - $this->packages = $this->accessor->getPackagelist(); - } - - } // end func loadPackagelist - - /** - * Recursivly builds an HTML class tree using <ul><li></ul>. - * - * @param string Name of the class the recursive loop starts with - * @see renderClasstree() - */ - function buildClasstreeHTML($class) { - - $html = ""; - - if (0==count($this->classtree["classes"][$class])) { - - $html.= sprintf('<li><a href="%s.html">%s</a>', $this->nameToUrl($class), $class); - - } else { - - $html.= sprintf('<li><a href="%s.html">%s</a>', $this->nameToUrl($class), $class); - - $html.= "<ul>"; - reset($this->classtree["classes"][$class]); - while (list($k, $subclass)=each($this->classtree["classes"][$class])) - $html.= $this->buildClasstreeHTML($subclass); - $html.= "</ul>"; - } - - return $html; - } // end func buildClasstreeHTML - -} // end class PhpdocHTMLIndexRenderer -?> \ No newline at end of file +<?php +/** +* Renders Index lists. +*/ +class PhpdocHTMLIndexRenderer extends PhpdocHTMLRenderer { + + /** + * Some container in the package list. + * @var array + * @see renderPackagelist() + */ + var $packageFields = array("class", "module"); + + /** + * Packagelist from the PhpdocIndexAccessor + * @var array + */ + var $packages = array(); + + /** + * Array with classtree informations + * @var array + */ + var $classtree = array(); + + /** + * IntegratedTemplate Object used be renderClasstree() + * + * @var object IntegratedTemplate + * @see renderClasstree() + */ + var $treeTpl; + + /** + * IntegratedTemplateObject used by renderModulegroup() + * + * @var object IntegratedTemplate + * @see renderModulegroup() + */ + var $moduleTpl; + + /** + * Sets the xml and template root directory. + * + * @param string XML file path + * @param string Template file path + * @param string Name of the application + * @see setPath(), setTemplateRoot() + */ + function PhpdocHTMLIndexRenderer($path, $templateRoot, $application, $extension = ".html") { + + $this->setPath($path); + $this->setTemplateRoot($templateRoot); + $this->application = $application; + $this->file_extension = $extension; + + $this->accessor = new PhpdocIndexAccessor; + $this->tpl = new IntegratedTemplate($this->templateRoot); + $this->fileHandler = new PhpdocFileHandler; + + } // end constructor + + /** + * Builds all index files phpdoc needs assuming that the xml files have default names + * + * @access public + * @see renderElementlist(), renderPackagelist(), renderFramelementlist(), renderFramePackageSummary() + */ + function generate() { + + $this->renderElementlist("elementlist.xml"); + $this->renderFrameElementlist("elementlist.xml"); + + $this->renderPackagelist("packagelist.xml"); + $this->renderFramePackageSummary("packagelist.xml"); + $this->renderFrameElementlist("packagelist.xml"); + + } // end function generate + + /** + * Saves the generated classtree summary to disk. + * + * @see renderClasstree() + * @access public + */ + function finishClasstree() { + + if (!is_object($this->treeTpl)) + return; + + $this->treeTpl->setVariable("APPNAME", $this->application); + $this->fileHandler->createFile($this->path."phpdoc_classtree".$this->file_extension, $this->treeTpl->get() ); + $this->treeTpl = ""; + + } // end func finishClasstree + + /** + * Adds a classtree to the classtree summary template. + * + * @param string XML Classtree file + * @see finishClasstree() + * @access public + */ + function addClasstree($xmlfile) { + + $this->accessor->loadXMLFile($this->path.$xmlfile); + + if (!is_object($this->treeTpl)) { + + $this->treeTpl = new IntegratedTemplate($this->templateRoot); + $this->treeTpl->loadTemplatefile("classtree.html"); + + } + + $this->classtree = $this->accessor->getClasstree(); + + $this->treeTpl->setCurrentBlock("classtree"); + $this->treeTpl->setVariable("BASECLASS", $this->classtree["baseclass"]); + $this->treeTpl->setVariable("TREE", "<ul>".$this->buildClasstreeHTML($this->classtree["baseclass"])."</ul>"); + $this->treeTpl->parseCurrentBlock(); + + return true; + } // end func addClasstree + + function finishModulegroup() { + + if (!is_object($this->moduleTpl)) + return; + + $this->moduleTpl->setVariable("APPNAME", $this->application); + $this->fileHandler->createFile($this->path."phpdoc_modulegroup".$this->file_extension, $this->moduleTpl->get() ); + $this->moduleTpl = ""; + + } // end func finishModulegroups + /** + * Renders a modulegroup xml file. + * @param string XML File + */ + function addModulegroup($xmlfile) { + + $this->accessor->loadXMLFile($this->path.$xmlfile); + + if (!is_object($this->moduleTpl)) { + + $this->moduleTpl = new IntegratedTemplate($this->templateRoot); + $this->moduleTpl->loadTemplateFile("modulegroup.html"); + + } + + $modulegroup = $this->accessor->getModulegroup(); + + $modules = "<ul>"; + reset($modulegroup["modules"]); + while (list($k, $module)=each($modulegroup["modules"])) + $modules.= sprintf('<li><a href="%s">%s</a>', $this->nameToUrl($module).$this->file_extension, $module); + $modules.= "</ul>"; + + $this->moduleTpl->setCurrentBlock("modulegroup"); + $this->moduleTpl->setVariable("MODULEGROUP", $modulegroup["group"]); + $this->moduleTpl->setVariable("MODULES", $modules); + $this->moduleTpl->parseCurrentBlock(); + + } // end func addModulegroup + + /** + * Renders the element index list. + * + * @param string XML file + * @access public + * @see generate() + */ + function renderElementlist($xmlfile) { + + $this->accessor->loadXMLFile($this->path.$xmlfile); + $this->tpl->loadTemplatefile("elementlist.html"); + + $chapters = $this->accessor->getChapternames(); + + if (0!=count($chapters)) { + + $this->tpl->setCurrentBlock("chaptersummary_loop"); + reset($chapters); + while (list($k, $chapter)=each($chapters)) { + $this->tpl->setVariable("CHAPTER", $chapter); + $this->tpl->parseCurrentBlock(); + } + + $chapters = $this->accessor->getChapters(); + + reset($chapters); + while (list($name, $elements)=each($chapters)) { + + if (!isset($elements["element"][0])) + $elements["element"] = array($elements["element"]); + + $this->tpl->setCurrentBlock("chapter_loop"); + + reset($elements["element"]); + while (list($k, $element)=each($elements["element"])) { + + switch($element["type"]) { + case "package": + $desc = "Package"; + break; + + case "class": + $desc = sprintf('Class <a href="%s">%s</a>.', + $this->nameToUrl($element["name"]).$this->file_extension, + $element["name"] + ); + break; + + case "module": + $desc = sprintf('Module <a href="%s">%s</a>.', + $this->nameToUrl($element["name"]).$this->file_extension, + $element["name"] + ); + break; + + case "functions": + $desc = sprintf('Function in %s <a href="%s">%s</a>', + $element["sourcetype"], + $this->nameToUrl($element["source"]).$this->file_extension, + $element["source"] + ); + break; + + case "variables": + $desc = sprintf('Variable in Class <a href="%s">%s</a>', + $this->nameToUrl($element["source"]).$this->file_extension, + $element["source"] + ); + break; + + case "uses": + $desc = sprintf('Included file in %s <a href="%s">%s</a>', + $element["sourcetype"], + $this->nameToUrl($element["source"]).$this->file_extension, + $element["source"] + ); + break; + break; + + case "consts": + $desc = sprintf('Constant defined in %s <a href="%s">%s</a>', + $element["sourcetype"], + $this->nameToUrl($element["source"]).$this->file_extension, + $element["source"] + ); + break; + } + + $this->tpl->setVariable("ELEMENTNAME", $element["name"]); + $this->tpl->setVariable("ELEMENT", $desc); + $this->tpl->setVariable("SHORTDESCRIPTION", $element["value"]); + $this->tpl->parseCurrentBlock(); + + } + + $this->tpl->setCurrentBlock("chapter"); + $this->tpl->setVariable("CHAPTER", $name); + $this->tpl->parseCurrentBlock(); + } + + + } + + $this->tpl->setVariable("APPNAME", $this->application); + $this->fileHandler->createFile($this->path."phpdoc_elementlist".$this->file_extension, $this->tpl->get() ); + $this->tpl->free(); + + } // end func renderElementlist + + /** + * Renders a complete packagelist. + * + * @param string XML file + * @access public + * @see renderFrameElementlist(), renderFramePackagesummary() + */ + function renderPackagelist($xmlfile) { + + $this->loadPackagelist($xmlfile); + $this->tpl->loadTemplatefile("packagelist.html"); + + reset($this->packages); + while (list($packagename, $package)=each($this->packages)) { + + reset($this->packageFields); + while (list($k, $field)=each($this->packageFields)) { + if (!isset($package[$field])) + continue; + + $this->tpl->setCurrentBlock("package_".$field."_loop"); + reset($package[$field]); + while (list($k, $element)=each($package[$field])) { + $this->tpl->setVariable("ELEMENT", sprintf('<a href="%s">%s</a>', + $this->nameToUrl($element).$this->file_extension, + $element + ) + ); + $this->tpl->parseCurrentBlock(); + } + + $this->tpl->setCurrentBlock("package_".$field); + $this->tpl->setVariable("EMPTY", ""); + $this->tpl->parseCurrentBlock(); + + } + + $this->tpl->setCurrentBlock("package"); + $this->tpl->setVariable("PACKAGE_NAME", $packagename); + $this->tpl->parseCurrentBlock(); + + } + + $this->tpl->setVariable("APPNAME", $this->application); + $this->fileHandler->createFile($this->path."phpdoc_packagelist".$this->file_extension, $this->tpl->get() ); + $this->tpl->free(); + + } // end func renderPackagelist + + /** + * Renders files for the lower left frame with the elements of a certain file. + * + * @param string This function needs the packagelist.xml to work! + * @access public + * @see renderFramePackagesummary(), renderPackagelist() + */ + function renderFrameElementlist($xmlfile) { + + $this->loadPackagelist($xmlfile); + + reset($this->packages); + while (list($packagename, $package)=each($this->packages)) { + + $this->tpl->loadTemplatefile("frame_packageelementlist.html"); + + reset($this->packageFields); + while (list($k, $field)=each($this->packageFields)) { + if (!isset($package[$field])) + continue; + + $this->tpl->setCurrentBlock("package_".$field."_loop"); + reset($package[$field]); + while (list($k, $element)=each($package[$field])) { + + $this->tpl->setVariable("ELEMENT", sprintf('<a href="%s" target="main">%s</a>', + $this->nameToUrl($element).$this->file_extension, + $element + ) + ); + $this->tpl->parseCurrentBlock(); + } + + $this->tpl->setCurrentBlock("package_".$field); + $this->tpl->setVariable("EMPTY", ""); + $this->tpl->parseCurrentBlock(); + + } + + $this->tpl->setCurrentBlock("package"); + $this->tpl->setVariable("PACKAGE_NAME", $packagename); + $this->tpl->parseCurrentBlock(); + + $this->tpl->setVariable("APPNAME", $this->application); + $packagename = $this->nameToUrl($packagename); + $this->fileHandler->createFile($this->path."packageelementlist_".$packagename.$this->file_extension, $this->tpl->get() ); + } + + $this->tpl->free(); + + } // end func renderFrameElementlist + + /** + * Renders a Packagesummary for the frameset. + * + * @param string XML file. + * @access public + * @see renderPackagelist(), renderFrameElementlist() + */ + function renderFramePackagesummary($xmlfile) { + + $this->loadPackagelist($xmlfile); + $this->tpl->loadTemplatefile("frame_packagelist.html"); + $this->tpl->setCurrentBlock("package"); + + reset($this->packages); + while (list($packagename, $v)=each($this->packages)) { + $this->tpl->setVariable("PACKAGE", sprintf('<a href="packageelementlist_%s" target="packageelements">%s</a>', + $this->nameToUrl($packagename).$this->file_extension, + $packagename ) + ); + $this->tpl->parseCurrentBlock(); + } + + $this->tpl->setVariable("APPNAME", $this->application); + $this->fileHandler->createFile($this->path."frame_packagelist".$this->file_extension, $this->tpl->get() ); + $this->tpl->free(); + + } // end func renderFramePackagesummary + + /** + * Imports the packagelist from the PhpdocIndexAccessor if not done previously. + * + * @param string XMl file. + * @see $packages + */ + function loadPackagelist($xmlfile) { + + if (0==count($this->packages)) { + $this->accessor->loadXMLFile($this->path.$xmlfile); + $this->packages = $this->accessor->getPackagelist(); + } + + } // end func loadPackagelist + + /** + * Recursivly builds an HTML class tree using <ul><li></ul>. + * + * @param string Name of the class the recursive loop starts with + * @see renderClasstree() + */ + function buildClasstreeHTML($class) { + + $html = ""; + + if (0==count($this->classtree["classes"][$class])) { + + $html.= sprintf('<li><a href="%s">%s</a>', $this->nameToUrl($class).$this->file_extension, $class); + + } else { + + $html.= sprintf('<li><a href="%s">%s</a>', $this->nameToUrl($class).$this->file_extension, $class); + + $html.= "<ul>"; + reset($this->classtree["classes"][$class]); + while (list($k, $subclass)=each($this->classtree["classes"][$class])) + $html.= $this->buildClasstreeHTML($subclass); + $html.= "</ul>"; + } + + return $html; + } // end func buildClasstreeHTML + +} // end class PhpdocHTMLIndexRenderer +?> Index: php4/pear/PHPDoc/renderer/html/PhpdocHTMLModuleRenderer.php diff -u php4/pear/PHPDoc/renderer/html/PhpdocHTMLModuleRenderer.php:1.1 php4/pear/PHPDoc/renderer/html/PhpdocHTMLModuleRenderer.php:1.2 --- php4/pear/PHPDoc/renderer/html/PhpdocHTMLModuleRenderer.php:1.1 Sun Oct 8 03:05:11 2000 +++ php4/pear/PHPDoc/renderer/html/PhpdocHTMLModuleRenderer.php Sun Oct 15 06:33:13 2000 @@ -1,91 +1,92 @@ -<?php -/** -* Renders modules. -*/ -class PhpdocHTMLModuleRenderer extends PhpdocHTMLDocumentRenderer { - - /** - * Sets the xml and template root directory. - * - * @param string XML file path - * @param string Template file path - * @param string Name of the current application - * @see setPath(), setTemplateRoot() - */ - function PhpdocHTMLModuleRenderer($path, $templateRoot, $application) { - - $this->setPath($path); - $this->setTemplateRoot($templateRoot); - $this->application = $application; - - $this->accessor = new PhpdocModuleAccessor; - $this->tpl = new IntegratedTemplate($this->templateRoot); - $this->fileHandler = new PhpdocFileHandler; - - } // end constructor - - /** - * Renders a module - * @param string XML source file - * @param string Name of the HTML target file. - * @access public - */ - function renderModule($xmlfile, $htmlfile="") { - - $this->tpl->loadTemplatefile("module.html"); - - if (""==$htmlfile) - $htmlfile = substr($xmlfile, 7, -4).".html"; - - $this->accessor->loadXMLFile($this->path.$xmlfile); - $module = $this->accessor->getModuledata(); - - $this->renderFunctions(); - $this->renderUses(); - $this->renderConstants(); - - $tplvars = array(); - - $tplvars["MODULE_FILE"] = $module["file"]["value"]; - $tplvars["MODULE_NAME"] = $module["name"]; - $tplvars["MODULE_GROUP"] = $module["group"]; - $tplvars["MODULE_ACCESS"] = $module["access"]; - $tplvars["MODULE_PACKAGE"] = $module["package"]; - $tplvars["MODULE_UNDOC"] = ("true" == $module["undoc"]) ? $this->undocumented : ""; - - if (isset($module["doc"]["link"])) - $this->renderLinks($module["doc"]["link"], "class_"); - - if (isset($module["doc"]["author"])) - $this->renderAuthors($module["doc"]["author"], "class_"); - - if (isset($module["doc"]["see"])) - $this->renderSee($module["doc"]["see"], "class_"); - - $fields = array( "version", "deprecated", "copyright" , - "since", "magic"); - reset($fields); - while (list($k, $field)=each($fields)) - if (isset($module["doc"][$field])) { - $this->tpl->setCurrentBlock("module_".strtolower($field)); - $this->tpl->setVariable(strtoupper($field), $module["doc"][$field]["value"]); - $this->tpl->parseCurrentBlock(); - } - - $fields = array( "description", "shortdescription" ); - reset($fields); - while (list($k, $field)=each($fields)) - if (isset($module["doc"][$field])) - $tplvars["MODULE_".strtoupper($field)] = $this->encode($module["doc"][$field]["value"]); - - $this->tpl->setCurrentBlock("__global__"); - $this->tpl->setVariable($tplvars); - $this->tpl->setVariable("APPNAME", $this->application); - - $this->fileHandler->createFile($this->path.$htmlfile, $this->tpl->get() ); - $this->tpl->free(); - - } // end func renderModule - -} // end class PhpdocHTMLModuleRenderer -?> \ No newline at end of file +<?php +/** +* Renders modules. +*/ +class PhpdocHTMLModuleRenderer extends PhpdocHTMLDocumentRenderer { + + /** + * Sets the xml and template root directory. + * + * @param string XML file path + * @param string Template file path + * @param string Name of the current application + * @see setPath(), setTemplateRoot() + */ + function PhpdocHTMLModuleRenderer($path, $templateRoot, $application, $extension = ".html") { + + $this->setPath($path); + $this->setTemplateRoot($templateRoot); + $this->application = $application; + $this->file_extension = $extension; + + $this->accessor = new PhpdocModuleAccessor; + $this->tpl = new IntegratedTemplate($this->templateRoot); + $this->fileHandler = new PhpdocFileHandler; + + } // end constructor + + /** + * Renders a module + * @param string XML source file + * @param string Name of the HTML target file. + * @access public + */ + function renderModule($xmlfile, $htmlfile="") { + + $this->tpl->loadTemplatefile("module.html"); + + if (""==$htmlfile) + $htmlfile = substr($xmlfile, 7, -4).$this->file_extension; + + $this->accessor->loadXMLFile($this->path.$xmlfile); + $module = $this->accessor->getModuledata(); + + $this->renderFunctions(); + $this->renderUses(); + $this->renderConstants(); + + $tplvars = array(); + + $tplvars["MODULE_FILE"] = $module["file"]["value"]; + $tplvars["MODULE_NAME"] = $module["name"]; + $tplvars["MODULE_GROUP"] = $module["group"]; + $tplvars["MODULE_ACCESS"] = $module["access"]; + $tplvars["MODULE_PACKAGE"] = $module["package"]; + $tplvars["MODULE_UNDOC"] = ("true" == $module["undoc"]) ? $this->undocumented : ""; + + if (isset($module["doc"]["link"])) + $this->renderLinks($module["doc"]["link"], "class_"); + + if (isset($module["doc"]["author"])) + $this->renderAuthors($module["doc"]["author"], "class_"); + + if (isset($module["doc"]["see"])) + $this->renderSee($module["doc"]["see"], "class_"); + + $fields = array( "version", "deprecated", "copyright" , + "since", "magic"); + reset($fields); + while (list($k, $field)=each($fields)) + if (isset($module["doc"][$field])) { + $this->tpl->setCurrentBlock("module_".strtolower($field)); + $this->tpl->setVariable(strtoupper($field), $module["doc"][$field]["value"]); + $this->tpl->parseCurrentBlock(); + } + + $fields = array( "description", "shortdescription" ); + reset($fields); + while (list($k, $field)=each($fields)) + if (isset($module["doc"][$field])) + $tplvars["MODULE_".strtoupper($field)] = $this->encode($module["doc"][$field]["value"]); + + $this->tpl->setCurrentBlock("__global__"); + $this->tpl->setVariable($tplvars); + $this->tpl->setVariable("APPNAME", $this->application); + + $this->fileHandler->createFile($this->path.$htmlfile, $this->tpl->get() ); + $this->tpl->free(); + + } // end func renderModule + +} // end class PhpdocHTMLModuleRenderer +?> Index: php4/pear/PHPDoc/renderer/html/PhpdocHTMLRenderer.php diff -u php4/pear/PHPDoc/renderer/html/PhpdocHTMLRenderer.php:1.1 php4/pear/PHPDoc/renderer/html/PhpdocHTMLRenderer.php:1.2 --- php4/pear/PHPDoc/renderer/html/PhpdocHTMLRenderer.php:1.1 Sun Oct 8 03:05:11 2000 +++ php4/pear/PHPDoc/renderer/html/PhpdocHTMLRenderer.php Sun Oct 15 06:33:13 2000 @@ -1,74 +1,74 @@ -<?php -/** -* Default HTML Renderer based on templates. -*/ -class PhpdocHTMLRenderer extends PhpdocRendererObject { - - /** - * Template object - * @var object IntegratedTemplates $tpl - */ - var $tpl; - - /** - * XML data accessor object. - * @var object PhpdocAccessor - */ - var $accessor; - - /** - * Rootpath for Templatefiles. - * @var string $templateRoot - * @see setTemplateRoot() - */ - var $templateRoot = ""; - - /** - * Directory path prefix. - * @var string $path - */ - var $path = ""; - - /** - * Sets a directory path prefix. - * - * @param string - */ - function setPath($path) { - - if (""!=$path && "/"!=substr($path, -1)) - $path.="/"; - - $this->path = $path; - } // end func path - - /** - * Sets the template directory. - * - * @param string - */ - function setTemplateRoot($templateRoot) { - - if (""!=$path && "/"!=substr($templateRoot, -1)) - $templateRoot.="/"; - - $this->templateRoot = $templateRoot; - } // end func setTemplateRoot - - /** - * Encodes the given string. - * - * This function gets used to encode all userdependend - * elements of the phpdoc xml files. Use it to - * customize your rendering result: beware newlines (nl2br()), - * strip tags etc. - * - * @param string String to encode - * @return string $string Encoded string - */ - function encode($string) { - return nl2br(htmlspecialchars($string)); - } // end func encode - -} // end class PhpdocHTMLRenderer +<?php +/** +* Default HTML Renderer based on templates. +*/ +class PhpdocHTMLRenderer extends PhpdocRendererObject { + + /** + * Template object + * @var object IntegratedTemplates $tpl + */ + var $tpl; + + /** + * XML data accessor object. + * @var object PhpdocAccessor + */ + var $accessor; + + /** + * Rootpath for Templatefiles. + * @var string $templateRoot + * @see setTemplateRoot() + */ + var $templateRoot = ""; + + /** + * Directory path prefix. + * @var string $path + */ + var $path = ""; + + /** + * Sets a directory path prefix. + * + * @param string + */ + function setPath($path) { + + if (""!=$path && "/"!=substr($path, -1)) + $path.="/"; + + $this->path = $path; + } // end func path + + /** + * Sets the template directory. + * + * @param string + */ + function setTemplateRoot($templateRoot) { + + if (""!=$path && "/"!=substr($templateRoot, -1)) + $templateRoot.="/"; + + $this->templateRoot = $templateRoot; + } // end func setTemplateRoot + + /** + * Encodes the given string. + * + * This function gets used to encode all userdependend + * elements of the phpdoc xml files. Use it to + * customize your rendering result: beware newlines (nl2br()), + * strip tags etc. + * + * @param string String to encode + * @return string $string Encoded string + */ + function encode($string) { + return nl2br(htmlspecialchars($string)); + } // end func encode + +} // end class PhpdocHTMLRenderer ?> Index: php4/pear/PHPDoc/renderer/html/PhpdocHTMLRendererManager.php diff -u php4/pear/PHPDoc/renderer/html/PhpdocHTMLRendererManager.php:1.1 php4/pear/PHPDoc/renderer/html/PhpdocHTMLRendererManager.php:1.2 --- php4/pear/PHPDoc/renderer/html/PhpdocHTMLRendererManager.php:1.1 Sun Oct 8 03:05:11 2000 +++ php4/pear/PHPDoc/renderer/html/PhpdocHTMLRendererManager.php Sun Oct 15 06:33:13 2000 @@ -1,98 +1,98 @@ -<?php -/** -* Controls the HTML Renderer objects. -* -*/ -class PhpdocHTMLRendererManager extends PhpdocObject { - - /** - * @var object PhpdocHTMLIndexRenderer - */ - var $indexrenderer; - - /** - * @var object PhpdocHTMLClassRenderer - */ - var $classrenderer; - - /** - * @var object PhpdocHTMLModuleRenderer - */ - var $modulerenderer; - - /** - * @var object PhpdocHTMLWarningRenderer - */ - var $warningrenderer; - - /** - * Creates all necessary renderer objects - * - * @param string Name of the target directory - * @param string Name of the directory with the templates. - * @param string Name of the current application - */ - function PhpdocHTMLRendererManager($target, $template, $application) { - - $this->indexrenderer = new PhpdocHTMLIndexRenderer($target, $template, $application); - $this->indexrenderer->generate(); - - $this->classrenderer = new PhpdocHTMLClassRenderer($target, $template, $application); - $this->modulerenderer = new PhpdocHTMLModuleRenderer($target, $template, $application); - $this->warningrenderer = new PhpdocHTMLWarningRenderer($target, $template, $application); - - } // end constructor - - /** - * Renders the given xml file. - * - * @param string XML file. - * @param string Content of the XML file: class, classtree, - * module, modulegroup, warnings, indexdata - * @access public - */ - function render($xmlfile, $type) { - - switch(strtolower($type)) { - - case "class": - $this->classrenderer->renderClass($xmlfile); - break; - - case "classtree": - $this->indexrenderer->addClasstree($xmlfile); - break; - - case "module": - $this->modulerenderer->renderModule($xmlfile); - break; - - case "modulegroup": - $this->indexrenderer->addModulegroup($xmlfile); - break; - - case "warning": - $this->warningrenderer->addWarnings($xmlfile); - break; - - } - - } // end func render - - /** - * Finishes the rendering process. - * - * Finish means here: write the classtree and modulegroup overview to disk. - * - * @access public - */ - function finish() { - - $this->indexrenderer->finishClasstree(); - $this->indexrenderer->finishModulegroup(); - $this->warningrenderer->finishWarnings(); - - } // end func finish - -} // end class PhpdocHTMLRendererManager +<?php +/** +* Controls the HTML Renderer objects. +* +*/ +class PhpdocHTMLRendererManager extends PhpdocObject { + /** + * @var object PhpdocHTMLIndexRenderer + */ + var $indexrenderer; + + /** + * @var object PhpdocHTMLClassRenderer + */ + var $classrenderer; + + /** + * @var object PhpdocHTMLModuleRenderer + */ + var $modulerenderer; + + /** + * @var object PhpdocHTMLWarningRenderer + */ + var $warningrenderer; + + /** + * Creates all necessary renderer objects + * + * @param string Name of the target directory + * @param string Name of the directory with the templates. + * @param string Name of the current application + * @param string Extension of generated files + */ + function PhpdocHTMLRendererManager($target, $template, $application, $extension = ".html") { + + $this->indexrenderer = new PhpdocHTMLIndexRenderer($target, $template, $application, $extension); + $this->indexrenderer->generate(); + + $this->classrenderer = new PhpdocHTMLClassRenderer($target, $template, $application, $extension); + $this->modulerenderer = new PhpdocHTMLModuleRenderer($target, $template, $application, $extension); + $this->warningrenderer = new PhpdocHTMLWarningRenderer($target, $template, $application, $extension); + + } // end constructor + + /** + * Renders the given xml file. + * + * @param string XML file. + * @param string Content of the XML file: class, classtree, + * module, modulegroup, warnings, indexdata + * @access public + */ + function render($xmlfile, $type) { + + switch(strtolower($type)) { + + case "class": + $this->classrenderer->renderClass($xmlfile); + break; + + case "classtree": + $this->indexrenderer->addClasstree($xmlfile); + break; + + case "module": + $this->modulerenderer->renderModule($xmlfile); + break; + + case "modulegroup": + $this->indexrenderer->addModulegroup($xmlfile); + break; + + case "warning": + $this->warningrenderer->addWarnings($xmlfile); + break; + + } + + } // end func render + + /** + * Finishes the rendering process. + * + * Finish means here: write the classtree and modulegroup overview to disk. + * + * @access public + */ + function finish() { + + $this->indexrenderer->finishClasstree(); + $this->indexrenderer->finishModulegroup(); + $this->warningrenderer->finishWarnings(); + + } // end func finish + +} // end class PhpdocHTMLRendererManager ?> Index: php4/pear/PHPDoc/renderer/html/PhpdocHTMLWarningRenderer.php diff -u php4/pear/PHPDoc/renderer/html/PhpdocHTMLWarningRenderer.php:1.1 php4/pear/PHPDoc/renderer/html/PhpdocHTMLWarningRenderer.php:1.2 --- php4/pear/PHPDoc/renderer/html/PhpdocHTMLWarningRenderer.php:1.1 Sun Oct 8 03:05:12 2000 +++ php4/pear/PHPDoc/renderer/html/PhpdocHTMLWarningRenderer.php Sun Oct 15 06:33:13 2000 @@ -1,82 +1,83 @@ -<?php -/** -* Renders files with warnings. -*/ -class PhpdocHTMLWarningRenderer extends PhpdocHTMLRenderer { - - /** - * Sets the xml and template root directory. - * - * @param string XML file path - * @param string Template file path - * @param string Name of the application - * @see setPath(), setTemplateRoot() - */ - function PhpdocHTMLWarningRenderer($path, $templateRoot, $application) { - - $this->setPath($path); - $this->setTemplateRoot($templateRoot); - $this->application = $application; - - $this->accessor = new PhpdocWarningAccessor; - $this->fileHandler = new PhpdocFileHandler; - - } // end constructor - - /** - * Saves the generated report. - * - * @see addWarnings() - * @access public - */ - function finishWarnings() { - - if (!is_object($this->tpl)) - return; - - $this->tpl->setVariable("APPNAME", $this->application); - $this->fileHandler->createFile($this->path."phpdoc_warnings.html", $this->tpl->get() ); - $this->tpl = ""; - - } // end func finishWarnings - - /** - * Adds file with warnings to the warning list. - * - * @param string XML file - * @see finishWarnings() - * @access public - */ - function addWarnings($xmlfile) { - - $data = $this->accessor->getWarnings($this->path.$xmlfile); - - if (!is_object($this->tpl)) { - $this->tpl = new IntegratedTemplate($this->templateRoot); - $this->tpl->loadTemplateFile("warnings.html"); - } - reset($data); - while (list($file, $warnings)=each($data)) { - - $this->tpl->setCurrentBlock("warning_loop"); - reset($warnings); - while (list($k, $warning)=each($warnings)) { - $this->tpl->setVariable("WARNINGTYPE", $warning["type"]); - $this->tpl->setVariable("WARNING", $this->encode($warning["value"])); - $this->tpl->setVariable("ELEMENT", htmlentities($warning["name"])); - $this->tpl->setVariable("ELEMENTTYPE", $warning["elementtype"]); - $this->tpl->parseCurrentBlock(); - } - - - $this->tpl->setCurrentBlock("warning"); - $this->tpl->setVariable("FILE", $file); - $this->tpl->setVariable("NUMWARNINGS", count($warnings)); - $this->tpl->parseCurrentBlock(); - } - - return true; - } // end func addWarnings - -} // end class PhpdocHTMLIndexRenderer -?> \ No newline at end of file +<?php +/** +* Renders files with warnings. +*/ +class PhpdocHTMLWarningRenderer extends PhpdocHTMLRenderer { + + /** + * Sets the xml and template root directory. + * + * @param string XML file path + * @param string Template file path + * @param string Name of the application + * @see setPath(), setTemplateRoot() + */ + function PhpdocHTMLWarningRenderer($path, $templateRoot, $application, $extension = ".html") { + + $this->setPath($path); + $this->setTemplateRoot($templateRoot); + $this->application = $application; + $this->file_extension = $extension; + + $this->accessor = new PhpdocWarningAccessor; + $this->fileHandler = new PhpdocFileHandler; + + } // end constructor + + /** + * Saves the generated report. + * + * @see addWarnings() + * @access public + */ + function finishWarnings() { + + if (!is_object($this->tpl)) + return; + + $this->tpl->setVariable("APPNAME", $this->application); + $this->fileHandler->createFile($this->path."phpdoc_warnings".$this->file_extension, $this->tpl->get() ); + $this->tpl = ""; + + } // end func finishWarnings + + /** + * Adds file with warnings to the warning list. + * + * @param string XML file + * @see finishWarnings() + * @access public + */ + function addWarnings($xmlfile) { + + $data = $this->accessor->getWarnings($this->path.$xmlfile); + + if (!is_object($this->tpl)) { + $this->tpl = new IntegratedTemplate($this->templateRoot); + $this->tpl->loadTemplateFile("warnings.html"); + } + reset($data); + while (list($file, $warnings)=each($data)) { + + $this->tpl->setCurrentBlock("warning_loop"); + reset($warnings); + while (list($k, $warning)=each($warnings)) { + $this->tpl->setVariable("WARNINGTYPE", $warning["type"]); + $this->tpl->setVariable("WARNING", $this->encode($warning["value"])); + $this->tpl->setVariable("ELEMENT", htmlentities($warning["name"])); + $this->tpl->setVariable("ELEMENTTYPE", $warning["elementtype"]); + $this->tpl->parseCurrentBlock(); + } + + + $this->tpl->setCurrentBlock("warning"); + $this->tpl->setVariable("FILE", $file); + $this->tpl->setVariable("NUMWARNINGS", count($warnings)); + $this->tpl->parseCurrentBlock(); + } + + return true; + } // end func addWarnings + +} // end class PhpdocHTMLIndexRenderer +?>

« previous php.cvs (#2061) next »