+++ /dev/null
-<?php\r
-/**\r
-* Renders classes.\r
-*\r
-* @version $Id: PhpdocHTMLClassRenderer.php,v 1.4 2000/12/03 22:37:37 uw Exp $\r
-*/\r
-class PhpdocHTMLClassRenderer extends PhpdocHTMLDocumentRenderer {\r
-\r
- /**\r
- * Internal array of " " strings to format HTML output.\r
- *\r
- * @var array $indent\r
- */\r
- var $indent = array();\r
-\r
- /**\r
- * Array of variables found in the xml document.\r
- *\r
- * @var array $variables\r
- */\r
- var $variables = array();\r
-\r
- /**\r
- * Sets the xml and template root directory.\r
- * \r
- * @param string XML file path\r
- * @param string Template file path\r
- * @param string Name of the current application\r
- * @param string Filename extension\r
- * @see setPath(), setTemplateRoot()\r
- */\r
- function PhpdocHTMLClassRenderer($path, $templateRoot, $application, $extension = ".html") {\r
-\r
- $this->setPath($path);\r
- $this->setTemplateRoot($templateRoot);\r
- $this->application = $application;\r
- $this->file_extension = $extension;\r
- \r
- $this->accessor = new PhpdocClassAccessor;\r
- $this->tpl = new IntegratedTemplate($this->templateRoot);\r
- $this->fileHandler = new PhpdocFileHandler;\r
-\r
- } // end constructor\r
-\r
- /**\r
- * Renders a class.\r
- *\r
- * @param string XML source file\r
- * @param string Name of the HTML target file.\r
- * @access public\r
- */ \r
- function renderClass($xmlfile, $htmlfile = "") {\r
-\r
- $this->tpl->loadTemplatefile("class.html"); \r
- if ("" == $htmlfile)\r
- $htmlfile = substr($xmlfile, 6, -4) . $this->file_extension;\r
-\r
- $this->accessor->loadXMLFile($this->path.$xmlfile);\r
- \r
- $this->renderSubclasses();\r
- $this->renderInherited();\r
- $this->renderFunctions();\r
- $this->renderVariables();\r
- $this->renderUses();\r
- $this->renderConstants();\r
- \r
- $class = $this->accessor->getClassdata();\r
- $tplvars = array();\r
-\r
- $tplvars["CLASS_FILE"] = $class["file"]["value"];\r
- $tplvars["CLASS_NAME"] = $class["name"];\r
- $tplvars["CLASS_ACCESS"] = $class["access"];\r
- $tplvars["CLASS_PACKAGE"] = $class["package"];\r
-\r
- if ("" != $class["extends"])\r
- $tplvars["CLASS_EXTENDS"] = sprintf('extends <a href="%s">%s</a>', \r
- $class["extends"].$this->file_extension, \r
- $class["extends"]\r
- );\r
- \r
- $tplvars["CLASS_UNDOC"] = ("true" == $class["undoc"]) ? $this->undocumented : "";\r
- \r
- $tplvars["CLASS_ABSTRACT"] = ("true" == $class["abstract"]) ? "abstract" : "";\r
- $tplvars["CLASS_STATIC"] = ("true" == $class["static"]) ? "static" : "";\r
- $tplvars["CLASS_FINAL"] = ("true" == $class["final"]) ? "final" : "";\r
- \r
- $tplvars["CLASS_TREE"] = $this->getClasstree($class["name"]);\r
- \r
- if (isset($class["doc"]["link"]))\r
- $this->renderLinks($class["doc"]["link"], "class_");\r
- \r
- if (isset($class["doc"]["author"]))\r
- $this->renderAuthors($class["doc"]["author"], "class_");\r
- \r
- if (isset($class["doc"]["see"]))\r
- $this->renderSee($class["doc"]["see"], "class_");\r
- \r
- $fields = array( "version", "deprecated", "copyright", "since", "magic");\r
- reset($fields);\r
- while (list($k, $field) = each($fields)) \r
- if (isset($class["doc"][$field])) {\r
- $this->tpl->setCurrentBlock("class_".strtolower($field));\r
- $this->tpl->setVariable(strtoupper($field), $class["doc"][$field]["value"]);\r
- $this->tpl->parseCurrentBlock();\r
- }\r
-\r
- $fields = array( "description", "shortdescription" );\r
-\r
- reset($fields);\r
- while (list($k, $field)=each($fields)) \r
- if (isset($class["doc"][$field]))\r
- $tplvars["CLASS_".strtoupper($field)] = $this->encode($class["doc"][$field]["value"]);\r
-\r
- $this->tpl->setCurrentBlock("__global__");\r
- $this->tpl->setVariable($tplvars);\r
- $this->tpl->setVariable("APPNAME", $this->application);\r
-\r
- $this->fileHandler->createFile($this->path.$htmlfile, $this->tpl->get() );\r
- $this->tpl->free(); \r
-\r
- } // end func renderClass\r
-\r
- \r
-\r
- /**\r
- * Renders a list of inherited elements.\r
- *\r
- * @see renderInheritedElements()\r
- */\r
- function renderInherited() {\r
-\r
- $this->renderInheritedElements( $this->accessor->getInheritedFunctions(),\r
- "inheritedfunctions",\r
- "function"\r
- );\r
- \r
- $this->renderInheritedElements( $this->accessor->getInheritedVariables(),\r
- "inheritedvariables",\r
- "variable"\r
- );\r
-\r
- $this->renderInheritedElements( $this->accessor->getInheritedConstants(),\r
- "inheritedconstants",\r
- "constant"\r
- );\r
-\r
- $this->renderInheritedElements( $this->accessor->getInheritedUses(),\r
- "inheriteduses",\r
- "uses"\r
- );\r
-\r
- } // end func renderInherited\r
-\r
- /**\r
- * Renders a list of a certain inherited element.\r
- *\r
- * @param array List of inherited elements.\r
- * @param string Templateblockname\r
- * @param string Element type: function, variable...\r
- * @see renderInherited()\r
- */\r
- function renderInheritedElements($inherited, $block, $type) {\r
- \r
- if (0 == count($inherited))\r
- return;\r
-\r
- $this->tpl->setCurrentBlock($block);\r
-\r
- reset($inherited);\r
- while (list($source, $elements) = each($inherited)) {\r
- \r
- $value = "";\r
- \r
- reset($elements);\r
- while (list($k, $element) = each($elements))\r
- $value .= sprintf('<a href="%s#%s_%s">%s</a>, ', \r
- $source.$this->file_extension,\r
- $type, \r
- $element, \r
- $element\r
- );\r
- $value = substr($value, 0, -2);\r
- \r
- $this->tpl->setVariable("SOURCE", $source);\r
- $this->tpl->setVariable("ELEMENTS", $value);\r
- $this->tpl->parseCurrentBlock();\r
- }\r
-\r
- } // end func renderInheritedElements\r
-\r
- /**\r
- * Renders a list of direct known subclasses.\r
- */\r
- function renderSubclasses() {\r
- \r
- $subclasses = $this->accessor->getSubclasses();\r
- if (0 == count($subclasses)) \r
- return;\r
- \r
- $elements = "";\r
- reset($subclasses);\r
- while (list($k, $subclass) = each($subclasses))\r
- $elements .= sprintf('<a href="%s">%s</a>, ', $subclass.$this->file_extension, $subclass);\r
- \r
- $elements = substr($elements, 0, -2);\r
- \r
- if ("" != $elements) {\r
- \r
- $this->tpl->setCurrentBlock("subclasses");\r
- $this->tpl->setVariable("ELEMENTS", $elements);\r
- $this->tpl->parseCurrentBlock();\r
- }\r
-\r
- } // end func renderSubclasses\r
-\r
- /**\r
- * Adds a summary and a detailed list of all variables to the template.\r
- *\r
- * @see renderVariableSummary(), renderVariableDetail()\r
- */\r
- function renderVariables() {\r
- \r
- $this->variables["private"] = $this->accessor->getVariablesByAccess("private");\r
- $this->variables["public"] = $this->accessor->getVariablesByAccess("public");\r
- \r
- if (0 == count($this->variables["private"]) && 0 == count($this->variables["public"]))\r
- return;\r
- \r
- $this->renderVariableSummary();\r
- $this->renderVariableDetail();\r
-\r
- $this->variables = array();\r
-\r
- } // end func renderVariables\r
-\r
- /**\r
- * Adds a summary of all variables to the template.\r
- * \r
- * The function assumes that there is a block named "variablesummary" and\r
- * within it a block names "variablesummay_loop" in the template.\r
- *\r
- * @see renderVariableDetail()\r
- */ \r
- function renderVariableSummary() {\r
-\r
- reset($this->accessModifiers);\r
- while (list($k, $access) = each($this->accessModifiers)) {\r
-\r
- if (0 == count($this->variables[$access]))\r
- continue;\r
- \r
- $this->tpl->setCurrentBlock("variablesummary_loop");\r
- \r
- reset($this->variables[$access]);\r
- while (list($name, $variable) = each($this->variables[$access])) {\r
- \r
- $this->tpl->setVariable("NAME", $name);\r
- $this->tpl->setVariable("TYPE", $variable["type"]);\r
- \r
- if (isset($variable["doc"]["shortdescription"]))\r
- $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($variable["doc"]["shortdescription"]["value"]));\r
- \r
- $this->tpl->parseCurrentBlock(); \r
- \r
- }\r
- \r
- $this->tpl->setCurrentBlock("variablesummary");\r
- $this->tpl->setVariable("ACCESS", ucfirst($access));\r
- $this->tpl->parseCurrentBlock();\r
- \r
- }\r
-\r
- } // end func renderVariableSummary\r
-\r
- /**\r
- * Adds a detailed list of all variables to the template.\r
- * \r
- * The function assumes that there is a block named "variabledetails"\r
- * and within it a block names "variablesdetails_loop" in the template.\r
- *\r
- * @see renderVariableSummary()\r
- */ \r
- function renderVariableDetail() {\r
- \r
- reset($this->accessModifiers);\r
- while (list($k, $access) = each($this->accessModifiers)) {\r
-\r
- if (0 == count($this->variables[$access]))\r
- continue;\r
-\r
- reset($this->variables[$access]);\r
- while (list($name, $variable)=each($this->variables[$access])) {\r
- \r
- $tplvars = array();\r
- $tplvars["NAME"] = $variable["name"];\r
- $tplvars["ACCESS"] = $variable["access"];\r
- $tplvars["TYPE"] = $variable["type"];\r
- $tplvars["VALUE"] = htmlentities($variable["value"]);\r
-\r
- if ("true" == $variable["undoc"]) \r
- $tplvars["UNDOC"] = $this->undocumented;\r
-\r
- if ("true" == $variable["static"])\r
- $tplvars["STATIC"] = "static";\r
-\r
- if ("true" == $variable["final"])\r
- $tplvars["FINAL"] = "final";\r
-\r
- if (isset($variable["doc"]["shortdescription"]))\r
- $tplvars["SHORTDESCRIPTION"] = $this->encode($variable["doc"]["shortdescription"]["value"]);\r
-\r
- if (isset($variable["doc"]["description"]))\r
- $tplvars["DESCRIPTION"] = $this->encode($variable["doc"]["description"]["value"]);\r
-\r
- $this->renderCommonDocfields("variabledetails_", $variable);\r
-\r
- $this->tpl->setCurrentBlock("variabledetails_loop"); \r
- $this->tpl->setVariable($tplvars);\r
- $this->tpl->parseCurrentBlock(); \r
-\r
- }\r
-\r
- $this->tpl->setCurrentBlock("variabledetails");\r
- $this->tpl->setVariable("ACCESS", ucfirst($access) );\r
- $this->tpl->parseCurrentBlock();\r
-\r
- }\r
-\r
- } // end func renderVariableDetail\r
-\r
- /**\r
- * Returns a html string that shows the class tree.\r
- *\r
- * @param string name of the current class\r
- * @return string HTML that shows the tree\r
- */\r
- function getClasstree($class) {\r
- \r
- $path = $this->accessor->getClasstree();\r
- $level = 0;\r
- $num = count($path) - 1;\r
- \r
- for ($i = $num; $i >= 0; --$i) {\r
-\r
- $indent = $this->getIndent($level);\r
-\r
- if ($level > 0)\r
- $value.= sprintf("%s |<br>%s+-- ", $indent, $indent);\r
-\r
- $value.= sprintf('<a href="%s">%s</a><br>', \r
- $path[$i].$this->file_extension,\r
- $path[$i]\r
- );\r
- ++$level;\r
- \r
- }\r
-\r
- $indent = $this->getIndent($level);\r
-\r
- if ($level > 0)\r
- $value.= sprintf("%s |<br>%s+-- ", $indent, $indent);\r
-\r
- $value.= sprintf('%s<br>', $class);\r
-\r
- return $value;\r
- } // end func getClasstree\r
-\r
- /**\r
- * Returns a certain number of " "s.\r
- *\r
- * @param int number of " " required.\r
- * @see $indent\r
- * @return string A string with the requested number of nunbreakable html spaces\r
- */\r
- function getIndent($level) {\r
-\r
- if (!isset($this->indent[$level])) {\r
-\r
- $html = "";\r
- for ($i = 0; $i < $level; ++$i)\r
- $html .= " ";\r
-\r
- $this->indent[$level] = $html;\r
-\r
- }\r
-\r
- return $this->indent[$level];\r
- } // end func getIndent\r
-\r
-} // end class PhpdocHTMLClassRenderer\r
-\r
-?>
\ No newline at end of file