+++ /dev/null
-<?php\r
-/**\r
- * HTML original framed output converter, modified to use Smarty Template.\r
- * This Converter takes output from the {@link Parser} and converts it to HTML-ready output for use with {@link Smarty}.\r
- *\r
- * phpDocumentor :: automatic documentation generator\r
- * \r
- * PHP versions 4 and 5\r
- *\r
- * Copyright (c) 2002-2006 Gregory Beaver\r
- * \r
- * LICENSE:\r
- * \r
- * This library is free software; you can redistribute it\r
- * and/or modify it under the terms of the GNU Lesser General\r
- * Public License as published by the Free Software Foundation;\r
- * either version 2.1 of the License, or (at your option) any\r
- * later version.\r
- * \r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- * \r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * @package Converters\r
- * @subpackage HTMLframes\r
- * @author Gregory Beaver <cellog@php.net>\r
- * @copyright 2002-2006 Gregory Beaver\r
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL\r
- * @version CVS: $Id: HTMLframesConverter.inc,v 1.16 2007/04/19 20:20:57 ashnazg Exp $\r
- * @filesource\r
- * @link http://www.phpdoc.org\r
- * @link http://pear.php.net/PhpDocumentor\r
- * @see parserDocBlock, parserInclude, parserPage, parserClass\r
- * @see parserDefine, parserFunction, parserMethod, parserVar\r
- * @since 1.2\r
- */\r
-/**\r
- * HTML output converter.\r
- * This Converter takes output from the {@link Parser} and converts it to HTML-ready output for use with {@link Smarty}.\r
- *\r
- * @package Converters\r
- * @subpackage HTMLframes\r
- * @see parserDocBlock, parserInclude, parserPage, parserClass, parserDefine, parserFunction, parserMethod, parserVar\r
- * @author Greg Beaver <cellog@php.net>\r
- * @since 1.2\r
- * @version $Id: HTMLframesConverter.inc,v 1.16 2007/04/19 20:20:57 ashnazg Exp $\r
- */\r
-class HTMLframesConverter extends Converter\r
-{\r
- /**\r
- * This converter knows about the new root tree processing\r
- * In order to fix PEAR Bug #6389\r
- * @var boolean\r
- */\r
- var $processSpecialRoots = true;\r
- /**\r
- * Smarty Converter wants elements sorted by type as well as alphabetically\r
- * @see Converter::$sort_page_contents_by_type\r
- * @var boolean\r
- */\r
- var $sort_page_contents_by_type = true;\r
- /** @var string */\r
- var $outputformat = 'HTML';\r
- /** @var string */\r
- var $name = 'frames';\r
- /**\r
- * indexes of elements by package that need to be generated\r
- * @var array\r
- */\r
- var $leftindex = array('classes' => true, 'pages' => true, 'functions' => true, 'defines' => false, 'globals' => false);\r
- \r
- /**\r
- * output directory for the current procedural page being processed\r
- * @var string\r
- */\r
- var $page_dir;\r
- \r
- /**\r
- * target directory passed on the command-line.\r
- * {@link $targetDir} is malleable, always adding package/ and package/subpackage/ subdirectories onto it.\r
- * @var string\r
- */\r
- var $base_dir;\r
- \r
- /**\r
- * output directory for the current class being processed\r
- * @var string\r
- */\r
- var $class_dir;\r
- \r
- /**\r
- * array of converted package page names.\r
- * Used to link to the package page in the left index\r
- * @var array Format: array(package => 1)\r
- */\r
- var $package_pages = array();\r
- \r
- /**\r
- * controls formatting of parser informative output\r
- * \r
- * Converter prints:\r
- * "Converting /path/to/file.php... Procedural Page Elements... Classes..."\r
- * Since HTMLdefaultConverter outputs files while converting, it needs to send a \n to start a new line. However, if there\r
- * is more than one class, output is messy, with multiple \n's just between class file output. This variable prevents that\r
- * and is purely cosmetic\r
- * @var boolean\r
- */\r
- var $juststarted = false;\r
- \r
- /**\r
- * contains all of the template procedural page element loop data needed for the current template\r
- * @var array\r
- */\r
- var $current;\r
- \r
- /**\r
- * contains all of the template class element loop data needed for the current template\r
- * @var array\r
- */\r
- var $currentclass;\r
- var $wrote = false;\r
- var $ric_set = array();\r
- \r
- /**\r
- * sets {@link $base_dir} to $targetDir\r
- * @see Converter()\r
- */\r
- function HTMLframesConverter(&$allp, &$packp, &$classes, &$procpages, $po, $pp, $qm, $targetDir, $templateDir, $title)\r
- {\r
- Converter::Converter($allp, $packp, $classes, $procpages,$po, $pp, $qm, $targetDir, $templateDir, $title);\r
- $this->base_dir = $targetDir;\r
- }\r
- \r
- /**\r
- * @deprecated in favor of PHP 4.3.0+ tokenizer-based source highlighting\r
- */\r
- function unmangle($sourcecode)\r
- {\r
- $sourcecode = str_replace('<code>','<pre>',$sourcecode);\r
- $sourcecode = str_replace('</code>','</pre>',$sourcecode);\r
- $sourcecode = str_replace('<br />',"\n",$sourcecode);\r
- $sourcecode = str_replace(' ',' ',$sourcecode);\r
- $sourcecode = str_replace('<','<',$sourcecode);\r
- $sourcecode = str_replace('>','>',$sourcecode);\r
- $sourcecode = str_replace('&','&',$sourcecode);\r
- return $sourcecode;\r
- }\r
-\r
- /**\r
- * @param string full path to the source file\r
- * @param string fully highlighted source code\r
- */\r
- function writeSource($path, $value)\r
- {\r
- $templ = &$this->newSmarty();\r
- $pathinfo = $this->proceduralpages->getPathInfo($path, $this);\r
- $templ->assign('source',$value);\r
- $templ->assign('package',$pathinfo['package']);\r
- $templ->assign('subpackage',$pathinfo['subpackage']);\r
- $templ->assign('name',$pathinfo['name']);\r
- $templ->assign('source_loc',$pathinfo['source_loc']);\r
- $templ->assign('docs',$pathinfo['docs']);\r
- $templ->assign("subdir",'../');\r
- $templ->register_outputfilter('HTMLframes_outputfilter');\r
- $this->setTargetDir($this->getFileSourcePath($this->base_dir));\r
- phpDocumentor_out("\n");\r
- $this->setSourcePaths($path);\r
- $this->writefile($this->getFileSourceName($path).'.html',$templ->fetch('filesource.tpl'));\r
- }\r
- \r
- function writeExample($title, $path, $source)\r
- {\r
- $templ = &$this->newSmarty();\r
- $templ->assign('source',$source);\r
- if (empty($title))\r
- {\r
- $title = 'example';\r
- addWarning(PDERROR_EMPTY_EXAMPLE_TITLE, $path, $title);\r
- }\r
- $templ->assign('title',$title);\r
- $templ->assign('file',$path);\r
- $templ->assign("subdir",'../');\r
- $templ->register_outputfilter('HTMLframes_outputfilter');\r
- $this->setTargetDir($this->base_dir . PATH_DELIMITER . '__examplesource');\r
- phpDocumentor_out("\n");\r
- $this->writefile('exsource_'.$path.'.html',$templ->fetch('examplesource.tpl'));\r
- }\r
-\r
- function getExampleLink($path, $title)\r
- {\r
- return $this->returnLink('{$subdir}__examplesource' . PATH_DELIMITER . 'exsource_'.$path.'.html',$title);\r
- }\r
- \r
- function getSourceLink($path)\r
- {\r
- return $this->returnLink('{$subdir}__filesource/' .\r
- $this->getFileSourceName($path).'.html','Source Code for this file');\r
- }\r
-\r
- /**\r
- * Retrieve a Converter-specific anchor to a segment of a source code file\r
- * parsed via a {@tutorial tags.filesource.pkg} tag.\r
- * @param string full path to source file\r
- * @param string name of anchor\r
- * @param string link text, if this is a link\r
- * @param boolean returns either a link or a destination based on this\r
- * parameter\r
- * @return string link to an anchor, or the anchor\r
- */\r
- function getSourceAnchor($sourcefile,$anchor,$text = '',$link = false)\r
- {\r
- if ($link) {\r
- return $this->returnLink('{$subdir}__filesource/' .\r
- $this->getFileSourceName($sourcefile) . '.html#a' . $anchor, $text);\r
- } else {\r
- return '<a name="a'.$anchor.'"></a>';\r
- }\r
- }\r
-\r
- /**\r
- * Return a line of highlighted source code with formatted line number\r
- *\r
- * If the $path is a full path, then an anchor to the line number will be\r
- * added as well\r
- * @param integer line number\r
- * @param string highlighted source code line\r
- * @param false|string full path to @filesource file this line is a part of,\r
- * if this is a single line from a complete file.\r
- * @return string formatted source code line with line number\r
- */\r
- function sourceLine($linenumber, $line, $path = false)\r
- {\r
- $extra = '';\r
- if (strlen(str_replace("\n", '', $line)) == 0) {\r
- $extra = ' ';\r
- }\r
- if ($path)\r
- {\r
- return '<li><div class="src-line">' . $this->getSourceAnchor($path, $linenumber) .\r
- str_replace("\n",'',$line) . $extra .\r
- "</div></li>\n";\r
- } else\r
- {\r
- return '<li><div class="src-line">' . str_replace("\n",'',$line) .\r
- "$extra</div></li>\n";\r
- }\r
- }\r
- \r
- /**\r
- * Used to convert the <<code>> tag in a docblock\r
- * @param string\r
- * @param boolean\r
- * @return string\r
- */\r
- function ProgramExample($example, $tutorial = false, $inlinesourceparse = null/*false*/,\r
- $class = null/*false*/, $linenum = null/*false*/, $filesourcepath = null/*false*/)\r
- {\r
- return '<div class="src-code"><ol>' . parent::ProgramExample($example, $tutorial, $inlinesourceparse, $class, $linenum, $filesourcepath)\r
- .'</ol></div>';\r
- }\r
- \r
- /**\r
- * @param string\r
- */\r
- function TutorialExample($example)\r
- {\r
- $trans = $this->template_options['desctranslate'];\r
- $this->template_options['desctranslate'] = array();\r
- $example = '<ol>' . parent::TutorialExample($example)\r
- .'</ol>';\r
- $this->template_options['desctranslate'] = $trans;\r
- if (!isset($this->template_options['desctranslate'])) return $example;\r
- if (!isset($this->template_options['desctranslate']['code'])) return $example;\r
- $example = $this->template_options['desctranslate']['code'] . $example;\r
- if (!isset($this->template_options['desctranslate']['/code'])) return $example;\r
- return $example . $this->template_options['desctranslate']['/code'];\r
- }\r
- \r
- function getCurrentPageLink()\r
- {\r
- return $this->curname . '.html';\r
- }\r
-\r
- /**\r
- * Uses htmlspecialchars() on the input\r
- */\r
- function postProcess($text)\r
- {\r
- if ($this->highlightingSource) {\r
- return str_replace(array(' ',"\t"), array(' ', ' '),\r
- htmlspecialchars($text));\r
- }\r
- return htmlspecialchars($text);\r
- }\r
- \r
- /**\r
- * Use the template tutorial_toc.tpl to generate a table of contents for HTML\r
- * @return string table of contents formatted for use in the current output format\r
- * @param array format: array(array('tagname' => section, 'link' => returnsee link, 'id' => anchor name, 'title' => from title tag),...)\r
- */\r
- function formatTutorialTOC($toc)\r
- {\r
- $template = &$this->newSmarty();\r
- $template->assign('toc',$toc);\r
- return $template->fetch('tutorial_toc.tpl');\r
- }\r
- \r
- function &SmartyInit(&$templ)\r
- {\r
- if (!isset($this->package_index))\r
- foreach($this->all_packages as $key => $val)\r
- {\r
- if (isset($this->pkg_elements[$key]))\r
- {\r
- if (!isset($start)) $start = $key;\r
- $this->package_index[] = array('link' => "li_$key.html", 'title' => $key);\r
- }\r
- }\r
- $templ->assign("packageindex",$this->package_index);\r
- $templ->assign("subdir",'');\r
- return $templ;\r
- }\r
- \r
- /**\r
- * Writes out the template file of {@link $class_data} and unsets the template to save memory\r
- * @see registerCurrentClass()\r
- * @see parent::endClass()\r
- */\r
- function endClass()\r
- {\r
- $a = '../';\r
- if (!empty($this->subpackage)) $a .= '../';\r
- if ($this->juststarted)\r
- {\r
- $this->juststarted = false;\r
- phpDocumentor_out("\n");\r
- flush();\r
- }\r
- $this->setTargetDir($this->base_dir . PATH_DELIMITER . $this->class_dir);\r
- $this->class_data->assign("subdir",$a);\r
- $this->class_data->register_outputfilter('HTMLframes_outputfilter');\r
- $this->writefile($this->class . '.html',$this->class_data->fetch('class.tpl'));\r
- unset($this->class_data);\r
- }\r
- \r
- /**\r
- * Writes out the template file of {@link $page_data} and unsets the template to save memory\r
- * @see registerCurrent()\r
- * @see parent::endPage()\r
- */\r
- function endPage()\r
- {\r
- $this->package = $this->curpage->package;\r
- $this->subpackage = $this->curpage->subpackage;\r
- $a = '../';\r
- if (!empty($this->subpackage)) $a .= '../';\r
- $this->setTargetDir($this->base_dir . PATH_DELIMITER . $this->page_dir);\r
- $this->page_data->assign("package",$this->package);\r
- $this->page_data->assign("subdir",$a);\r
- $this->page_data->register_outputfilter('HTMLframes_outputfilter');\r
- $this->writefile($this->page . '.html',$this->page_data->fetch('page.tpl'));\r
- unset($this->page_data);\r
- }\r
- \r
- /**\r
- * @param string\r
- * @param string\r
- * @return string <a href="'.$link.'">'.$text.'</a>\r
- */\r
- function returnLink($link,$text)\r
- {\r
- return '<a href="'.$link.'">'.$text.'</a>';\r
- }\r
- \r
- function makeLeft()\r
- {\r
- foreach($this->page_elements as $package => $o1)\r
- {\r
- foreach($o1 as $subpackage => $links)\r
- {\r
- for($i=0;$i<count($links);$i++)\r
- {\r
- $left[$package][$subpackage]['files'][] =\r
- array("link" => $this->getId($links[$i]), "title" => $links[$i]->name);\r
- }\r
- }\r
- }\r
- $interfaces = $classes = false;\r
- foreach($this->class_elements as $package => $o1)\r
- {\r
- foreach($o1 as $subpackage => $links)\r
- {\r
- for($i=0;$i<count($links);$i++)\r
- {\r
- $class = $this->classes->getClassByPackage($links[$i]->name, $links[$i]->package);\r
- $isinterface = $isclass = false;\r
- if ($class->isInterface()) {\r
- $isinterface = true;\r
- $interfaces = true;\r
- } else {\r
- $isclass = true;\r
- $classes = true;\r
- }\r
- if ($class && isset($class->docblock) && $class->docblock->hasaccess) {\r
- $left[$package][$subpackage]['classes'][] =\r
- array("link" => $this->getId($links[$i]), \r
- "title" => $links[$i]->name,\r
- 'is_interface' => $isinterface,\r
- 'is_class' => $isclass,\r
- "access" => $class->docblock->tags['access'][0]->value,\r
- "abstract" => isset ($class->docblock->tags['abstract'][0]));\r
- } else {\r
- $left[$package][$subpackage]['classes'][] =\r
- array("link" => $this->getId($links[$i]), \r
- "title" => $links[$i]->name,\r
- 'is_interface' => $isinterface,\r
- 'is_class' => $isclass,\r
- "access" => 'public',\r
- "abstract" => isset ($class->docblock->tags['abstract'][0]));\r
- }\r
- }\r
- }\r
- }\r
- foreach($this->function_elements as $package => $o1)\r
- {\r
- foreach($o1 as $subpackage => $links)\r
- {\r
- for($i=0;$i<count($links);$i++)\r
- {\r
- $left[$package][$subpackage]['functions'][] =\r
- array("link" => $this->getId($links[$i]), "title" => $links[$i]->name);\r
- }\r
- }\r
- }\r
- $ret = array();\r
- foreach($left as $package => $r)\r
- {\r
- $pd = 'blank';\r
- if (isset($this->package_pages[$package])) $pd = $package.'/package_'.$package.'.html';\r
- if (!isset($r['']))\r
- {\r
- $pt = false;\r
- $ptnoa = false;\r
- $ptt = $package;\r
- if ($t = $this->hasTutorial('pkg',$package,$package,''))\r
- {\r
- $pt = $t->getLink($this);\r
- $ptnoa = $this->getId($t->getLink($this,true));\r
- $ptt = $t->getTitle($this);\r
- }\r
- $tutes = array();\r
- foreach($this->tutorial_tree as $root => $tr)\r
- {\r
- if ($tr['tutorial']->package == $package && $tr['tutorial']->subpackage == '') {\r
- $tutes[$tr['tutorial']->tutorial_type][] =\r
- $this->getTutorialTree($tr['tutorial']);\r
- }\r
- }\r
- if (isset($this->childless_tutorials[$package][$subpackage]))\r
- {\r
- foreach($this->childless_tutorials[$package][$subpackage] as $ext => $other)\r
- {\r
- foreach($other as $tutorial)\r
- {\r
- $tutes[$tutorial->tutorial_type][] = $this->getTutorialTree($tutorial);\r
- }\r
- }\r
- }\r
- $ret[$package][] =\r
- array(\r
- 'package' => $package,\r
- 'subpackage' => '',\r
- 'packagedoc' => $pd,\r
- 'packagetutorial' => $pt,\r
- 'packagetutorialnoa' => $ptnoa,\r
- 'packagetutorialtitle' => $ptt,\r
- 'files' => array(),\r
- 'functions' => array(),\r
- 'classes' => array(),\r
- 'tutorials' => $tutes,\r
- );\r
- }\r
- foreach($r as $subpackage => $info)\r
- {\r
- $my = array();\r
- $my['package'] = $package;\r
- if (isset($this->package_pages[$package]))\r
- $my['packagedoc'] = $pd;\r
- else\r
- $my['packagedoc'] = 'blank';\r
- $my['subpackage'] = $subpackage;\r
- if (empty($subpackage))\r
- {\r
- if ($t = $this->hasTutorial('pkg',$package,$package,$subpackage))\r
- {\r
- $my['packagetutorial'] = $t->getLink($this);\r
- $my['packagetutorialnoa'] = $this->getId($t->getLink($this,true));\r
- $my['packagetutorialtitle'] = $t->getTitle($this);\r
- } else\r
- {\r
- $my['packagetutorial'] = '<a href="blank.html">No Package-Level Tutorial</a>';\r
- $my['packagetutorialnoa'] = 'blank.html';\r
- $my['packagetutorialtitle'] = $package;\r
- }\r
- } else\r
- {\r
- if ($t = $this->hasTutorial('pkg',$subpackage,$package,$subpackage))\r
- {\r
- $my['subpackagetutorial'] = $this->returnSee($this->getTutorialLink($t));\r
- $my['subpackagetutorialnoa'] = $this->getId($t->getLink($this,true));\r
- $my['subpackagetutorialtitle'] = $t->getTitle($this);\r
- } else\r
- {\r
- $my['subpackagetutorial'] = false;\r
- $my['subpackagetutorialnoa'] = false;\r
- $my['subpackagetutorialtitle'] = $subpackage;\r
- }\r
- }\r
- $tutes = array();\r
- foreach($this->tutorial_tree as $root => $tr)\r
- {\r
- if ($tr['tutorial']->package == $package && $tr['tutorial']->subpackage == $subpackage)\r
- {\r
- $tutes[$tr['tutorial']->tutorial_type][] = $this->getTutorialTree($tr['tutorial']);\r
- }\r
- }\r
- $my['tutorials'] = $tutes;\r
- $my['files'] = $my['classes'] = $my['functions'] = array();\r
- if (isset($info['files']))\r
- $my['files'] = $info['files'];\r
- if (isset($info['classes']))\r
- $my['classes'] = $info['classes'];\r
- $my['hasclasses'] = $classes;\r
- $my['hasinterfaces'] = $interfaces;\r
- if (isset($info['functions']))\r
- $my['functions'] = $info['functions'];\r
- $ret[$package][] = $my;\r
- }\r
- }\r
- return $ret;\r
- }\r
- \r
- function getTutorialTree($tutorial,$k = false)\r
- {\r
- $ret = '';\r
- if (is_object($tutorial)) $tree = parent::getTutorialTree($tutorial); else $tree = $tutorial;\r
-// debug($this->vardump_tree($tree));exit;\r
- if (!$tree)\r
- {\r
- $template = &$this->newSmarty();\r
- $template->assign('subtree',false);\r
- $template->assign('name',str_replace('.','',$tutorial->name));\r
- $template->assign('parent',false);\r
- $template->assign('haskids',false);\r
- $template->assign('kids','');\r
- $link = new tutorialLink;\r
- $t = $tutorial;\r
- $link->addLink('',$t->path,$t->name,$t->package,$t->subpackage,$t->getTitle($this));\r
- $main = array('link' => $this->getId($link), 'title' => $link->title);\r
- $template->assign('main',$main);\r
- return $template->fetch('tutorial_tree.tpl');\r
- }\r
- if (isset($tree['kids']))\r
- {\r
- foreach($tree['kids'] as $subtree)\r
- {\r
- $ret .= $this->getTutorialTree($subtree, true);\r
- }\r
- }\r
- $template = &$this->newSmarty();\r
- $template->assign('subtree',$k);\r
- $template->assign('name',str_replace('.','',$tree['tutorial']->name));\r
- $template->assign('parent',($k ? str_replace('.','',$tree['tutorial']->parent->name) : false));\r
- $template->assign('haskids',strlen($ret));\r
- $template->assign('kids',$ret);\r
- $link = new tutorialLink;\r
- $t = $tree['tutorial'];\r
- $link->addLink('',$t->path,$t->name,$t->package,$t->subpackage,$t->getTitle($this));\r
- $main = array('link' => $this->getId($link), 'title' => $link->title);\r
- $template->assign('main',$main);\r
- $ret = $template->fetch('tutorial_tree.tpl');\r
- return $ret;\r
- }\r
- \r
- /**\r
- * HTMLdefaultConverter chooses to format both package indexes and the complete index here\r
- *\r
- * This function formats output for the elementindex.html and pkgelementindex.html template files. It then\r
- * writes them to the target directory\r
- * @see generateElementIndex(), generatePkgElementIndex()\r
- */\r
- function formatPkgIndex()\r
- {\r
- list($package_indexes,$packages,$mletters) = $this->generatePkgElementIndexes();\r
- for($i=0;$i<count($package_indexes);$i++)\r
- {\r
- $template = &$this->newSmarty();\r
- $this->package = $package_indexes[$i]['package'];\r
- $this->subpackage = '';\r
- $template->assign("index",$package_indexes[$i]['pindex']);\r
- $template->assign("package",$package_indexes[$i]['package']);\r
- $template->assign("letters",$mletters[$package_indexes[$i]['package']]);\r
- $template->register_outputfilter('HTMLframes_outputfilter');\r
- $this->setTargetDir($this->base_dir);\r
- $this->writefile('elementindex_'.$package_indexes[$i]['package'].'.html',$template->fetch('pkgelementindex.tpl'));\r
- }\r
- phpDocumentor_out("\n");\r
- flush();\r
- }\r
- \r
- /**\r
- * HTMLdefaultConverter uses this function to format template index.html and packages.html\r
- *\r
- * This function generates the package list from {@link $all_packages}, eliminating any\r
- * packages that don't have any entries in their package index (no files at all, due to @ignore\r
- * or other factors). Then it uses the default package name as the first package index to display.\r
- * It sets the right pane to be either a blank file with instructions on making package-level docs,\r
- * or the package-level docs for the default package.\r
- * @global string Used to set the starting package to display\r
- */\r
- function formatIndex()\r
- {\r
- global $phpDocumentor_DefaultPackageName;\r
- list($elindex,$mletters) = $this->generateElementIndex();\r
- $template = &$this->newSmarty();\r
- $template->assign("index",$elindex);\r
- $template->assign("letters",$mletters);\r
- $template->register_outputfilter('HTMLframes_outputfilter');\r
- phpDocumentor_out("\n");\r
- flush();\r
- $this->setTargetDir($this->base_dir);\r
- $this->writefile('elementindex.html',$template->fetch('elementindex.tpl'));\r
- usort($this->package_index,"HTMLframes_pindexcmp");\r
- $index = &$this->newSmarty();\r
- foreach($this->all_packages as $key => $val)\r
- {\r
- if (isset($this->pkg_elements[$key]))\r
- {\r
- if (!isset($start)) $start = $key;\r
- if (!isset($this->package_pages[$key])) $this->writeNewPPage($key);\r
- }\r
- }\r
- // Created index.html\r
- if (isset($this->pkg_elements[$phpDocumentor_DefaultPackageName])) $start = $phpDocumentor_DefaultPackageName;\r
- $this->package = $start;\r
- $this->subpackage = '';\r
- $index->assign("package_count",count($this->pkg_elements));\r
- if (count($this->ric_set))\r
- $index->assign("package_count",2);\r
- $index->assign("date",date("r",time()));\r
- $index->assign("title",$this->title);\r
- $index->assign("start","li_$start.html");\r
- $index->register_outputfilter('HTMLframes_outputfilter');\r
- if (isset($this->tutorials[$start]['']['pkg'][$start . '.pkg']))\r
- {\r
- $index->assign("blank",$start.'/tutorial_'.$start.'.pkg');\r
- } elseif (isset($this->package_pages[$start]))\r
- {\r
- $index->assign("blank",$start.'/package_'.$start);\r
- }\r
- else\r
- {\r
- $index->assign("blank","blank");\r
- $blank = &$this->newSmarty();\r
- $blank->assign('package',$this->package);\r
- $this->setTargetDir($this->base_dir);\r
- $this->writefile("blank.html",$blank->fetch('blank.tpl'));\r
- }\r
- phpDocumentor_out("\n");\r
- flush();\r
- $this->setTargetDir($this->base_dir);\r
- $this->writefile("index.html",$index->fetch('index.tpl'));\r
-\r
- // Create package index\r
- $package = &$this->newSmarty();\r
- $package->assign('ric',array());\r
- if (isset($this->ric_set))\r
- {\r
- foreach($this->ric_set as $name => $u)\r
- {\r
- $package->append('ric',array('file' => 'ric_'.$name.'.html','name' => $name));\r
- }\r
- }\r
- $package->assign("packages",$this->package_index);\r
- $package->register_outputfilter('HTMLframes_outputfilter');\r
- $this->writefile("packages.html",$package->fetch('top_frame.tpl'));\r
- unset($index);\r
- }\r
- \r
- function writeNewPPage($key)\r
- {\r
- return;\r
- $template = &$this->newSmarty();\r
- $this->package = $key;\r
- $this->subpackage = '';\r
- $template->assign("date",date("r",time()));\r
- $template->assign("title",$this->title);\r
- $template->assign("package",$key);\r
- $template->register_outputfilter('HTMLframes_outputfilter');\r
- phpDocumentor_out("\n");\r
- flush();\r
- $this->setTargetDir($this->base_dir);\r
- \r
- $this->writefile("li_$key.html",$template->fetch('index.tpl'));\r
- unset($template);\r
- }\r
- \r
- /**\r
- * Generate indexes for li_package.html and classtree output files\r
- *\r
- * This function generates the li_package.html files from the template file left.html. It does this by\r
- * iterating through each of the $page_elements, $class_elements and $function_elements arrays to retrieve\r
- * the pre-sorted {@link abstractLink} descendants needed for index generation. Conversion of these links to\r
- * text is done by {@link returnSee()}. The {@link $local} parameter is set to false to ensure that paths are correct.\r
- * \r
- * Then it uses {@link generateFormattedClassTrees()} to create class trees from the template file classtrees.html. Output\r
- * filename is classtrees_packagename.html. This function also unsets {@link $elements} and {@link $pkg_elements} to free\r
- * up the considerable memory these two class vars use\r
- * @see $page_elements, $class_elements, $function_elements\r
- */\r
- function formatLeftIndex()\r
- {\r
- phpDocumentor_out("\n");\r
- flush();\r
- $this->setTargetDir($this->base_dir);\r
- if (0)//!isset($this->left))\r
- {\r
- debug("Nothing parsed, check the command-line");\r
- die();\r
- }\r
- $x = $this->makeLeft();\r
- foreach($this->all_packages as $package => $rest)\r
- {\r
- if (!isset($this->pkg_elements[$package])) continue;\r
- $template = &$this->newSmarty();\r
- $template->assign("info",$x[$package]);\r
- $template->assign('package',$package);\r
- $template->assign("hastutorials",isset($this->tutorials[$package]));\r
- $template->assign('hastodos',count($this->todoList));\r
- $template->assign('todolink','todolist.html');\r
- $template->assign("classtreepage","classtrees_$package");\r
- $template->assign("elementindex","elementindex_$package");\r
- $template->register_outputfilter('HTMLframes_outputfilter');\r
- if (isset($this->package_pages[$package]))\r
- {\r
- $template->assign("packagedoc",$package.'/package_' . $package . '.html');\r
- } else\r
- {\r
- $template->assign("packagedoc",false);\r
- }\r
- $this->writefile("li_$package.html",$template->fetch('left_frame.tpl'));\r
- \r
- // Create class tree page\r
- $template = &$this->newSmarty();\r
- $template->assign("classtrees",$this->generateFormattedClassTrees($package));\r
- $template->assign("interfaces",$this->generateFormattedInterfaceTrees($package));\r
- $template->assign("package",$package);\r
- $template->register_outputfilter('HTMLframes_outputfilter');\r
- $this->writefile("classtrees_$package.html",$template->fetch('classtrees.tpl'));\r
- phpDocumentor_out("\n");\r
- flush();\r
- }\r
- // free up considerable memory\r
- unset($this->elements);\r
- unset($this->pkg_elements);\r
- }\r
- \r
- /**\r
- * This function takes an {@link abstractLink} descendant and returns an html link\r
- *\r
- * @param abstractLink a descendant of abstractlink should be passed, and never text\r
- * @param string text to display in the link\r
- * @param boolean this parameter is not used, and is deprecated\r
- * @param boolean determines whether the returned text is enclosed in an <a> tag\r
- */\r
- function returnSee(&$element, $eltext = false, $with_a = true)\r
- {\r
- if (!is_object($element) || !$element) return false;\r
- if (!$with_a) return $this->getId($element, false);\r
- if (!$eltext)\r
- {\r
- $eltext = '';\r
- switch($element->type)\r
- {\r
- case 'tutorial' :\r
- $eltext = strip_tags($element->title);\r
- break;\r
- case 'method' :\r
- case 'var' :\r
- case 'const' :\r
- $eltext .= $element->class.'::';\r
- case 'page' :\r
- case 'define' :\r
- case 'class' :\r
- case 'function' :\r
- case 'global' :\r
- default :\r
- $eltext .= $element->name;\r
- if ($element->type == 'function' || $element->type == 'method') $eltext .= '()';\r
- break;\r
- }\r
- }\r
- return '<a href="'.$this->getId($element).'">'.$eltext.'</a>';\r
- }\r
- \r
- function getId($element, $fullpath = true)\r
- {\r
- if (phpDocumentor_get_class($element) == 'parserdata')\r
- {\r
- $element = $this->addLink($element->parent);\r
- $elp = $element->parent;\r
- } elseif (is_a($element, 'parserbase'))\r
- {\r
- $elp = $element;\r
- $element = $this->addLink($element);\r
- }\r
- $c = '';\r
- if (!empty($element->subpackage))\r
- {\r
- $c = '/'.$element->subpackage;\r
- }\r
- $b = '{$subdir}';\r
- switch ($element->type)\r
- {\r
- case 'page' :\r
- if ($fullpath)\r
- return $b.$element->package.$c.'/'.$element->fileAlias.'.html';\r
- return 'top';\r
- break;\r
- case 'define' :\r
- case 'global' :\r
- case 'function' :\r
- if ($fullpath)\r
- return $b.$element->package.$c.'/'.$element->fileAlias.'.html#'.$element->type.$element->name;\r
- return $element->type.$element->name;\r
- break;\r
- case 'class' :\r
- if ($fullpath)\r
- return $b.$element->package.$c.'/'.$element->name.'.html';\r
- return 'top';\r
- break;\r
- case 'method' :\r
- case 'var' :\r
- case 'const' :\r
- if ($fullpath)\r
- return $b.$element->package.$c.'/'.$element->class.'.html#'.$element->type.$element->name;\r
- return $element->type.$element->name;\r
- break;\r
- case 'tutorial' :\r
- $d = '';\r
- if ($element->section)\r
- {\r
- $d = '#'.$element->section;\r
- }\r
- return $b.$element->package.$c.'/tutorial_'.$element->name.'.html'.$d;\r
- }\r
- }\r
- \r
- /**\r
- * Convert README/INSTALL/CHANGELOG file contents to output format\r
- * @param README|INSTALL|CHANGELOG\r
- * @param string contents of the file\r
- */\r
- function Convert_RIC($name, $contents)\r
- {\r
- $template = &$this->newSmarty();\r
- $template->assign('contents',$contents);\r
- $template->assign('name',$name);\r
- $this->setTargetDir($this->base_dir);\r
- $this->writefile('ric_'.$name . '.html',$template->fetch('ric.tpl'));\r
- $this->ric_set[$name] = true;\r
- }\r
- \r
- function ConvertTodoList()\r
- {\r
- $todolist = array();\r
- foreach($this->todoList as $package => $alltodos)\r
- {\r
- foreach($alltodos as $todos)\r
- {\r
- $converted = array();\r
- $converted['link'] = $this->returnSee($todos[0]);\r
- if (!is_array($todos[1]))\r
- {\r
- $converted['todos'][] = $todos[1]->Convert($this);\r
- } else\r
- {\r
- foreach($todos[1] as $todo)\r
- {\r
- $converted['todos'][] = $todo->Convert($this);\r
- }\r
- }\r
- $todolist[$package][] = $converted;\r
- }\r
- }\r
- $templ = &$this->newSmarty();\r
- $templ->assign('todos',$todolist);\r
- $templ->register_outputfilter('HTMLframes_outputfilter');\r
- $this->setTargetDir($this->base_dir);\r
- $this->writefile('todolist.html',$templ->fetch('todolist.tpl'));\r
- }\r
- \r
- /**\r
- * Create errors.html template file output\r
- *\r
- * This method takes all parsing errors and warnings and spits them out ordered by file and line number.\r
- * @global ErrorTracker We'll be using it's output facility\r
- */\r
- function ConvertErrorLog()\r
- {\r
- global $phpDocumentor_errors;\r
- $allfiles = array();\r
- $files = array();\r
- $warnings = $phpDocumentor_errors->returnWarnings();\r
- $errors = $phpDocumentor_errors->returnErrors();\r
- $template = &$this->newSmarty();\r
- foreach($warnings as $warning)\r
- {\r
- $file = '##none';\r
- $linenum = 'Warning';\r
- if ($warning->file)\r
- {\r
- $file = $warning->file;\r
- $allfiles[$file] = 1;\r
- $linenum .= ' on line '.$warning->linenum;\r
- }\r
- $files[$file]['warnings'][] = array('name' => $linenum, 'listing' => $warning->data);\r
- }\r
- foreach($errors as $error)\r
- {\r
- $file = '##none';\r
- $linenum = 'Error';\r
- if ($error->file)\r
- {\r
- $file = $error->file;\r
- $allfiles[$file] = 1;\r
- $linenum .= ' on line '.$error->linenum;\r
- }\r
- $files[$file]['errors'][] = array('name' => $linenum, 'listing' => $error->data);\r
- }\r
- $i=1;\r
- $af = array();\r
- foreach($allfiles as $file => $num)\r
- {\r
- $af[$i++] = $file;\r
- }\r
- $allfiles = $af;\r
- usort($allfiles,'strnatcasecmp');\r
- $allfiles[0] = "Post-parsing";\r
- foreach($allfiles as $i => $a)\r
- {\r
- $allfiles[$i] = array('file' => $a);\r
- }\r
- $out = array();\r
- foreach($files as $file => $data)\r
- {\r
- if ($file == '##none') $file = 'Post-parsing';\r
- $out[$file] = $data;\r
- }\r
- $template->assign("files",$allfiles);\r
- $template->assign("all",$out);\r
- $template->assign("title","phpDocumentor Parser Errors and Warnings");\r
- $this->setTargetDir($this->base_dir);\r
- $this->writefile("errors.html",$template->fetch('errors.tpl'));\r
- unset($template);\r
- phpDocumentor_out("\n\nTo view errors and warnings, look at ".$this->base_dir. PATH_DELIMITER . "errors.html\n");\r
- flush();\r
- }\r
- \r
- function getTutorialId($package,$subpackage,$tutorial,$id)\r
- {\r
- return $id;\r
- }\r
- \r
- function getCData($value)\r
- {\r
- return '<pre>'.htmlentities($value).'</pre>';\r
- }\r
- \r
- /**\r
- * Converts package page and sets its package as used in {@link $package_pages}\r
- * @param parserPackagePage\r
- */\r
- function convertPackagepage(&$element)\r
- {\r
- phpDocumentor_out("\n");\r
- flush();\r
- $this->package = $element->package;\r
- $this->subpackage = '';\r
- $contents = $element->Convert($this);\r
- $this->package_pages[$element->package] = str_replace('{$subdir}','../',$contents);\r
- phpDocumentor_out("\n");\r
- flush();\r
- $this->setTargetDir($this->base_dir . PATH_DELIMITER . $element->package);\r
- $this->writeFile('package_'.$element->package.'.html',str_replace('{$subdir}','../',$contents));\r
- }\r
- \r
- /**\r
- * @param parserTutorial\r
- */\r
- function convertTutorial(&$element)\r
- {\r
- phpDocumentor_out("\n");\r
- flush();\r
- $template = &parent::convertTutorial($element);\r
- $a = '../';\r
- if ($element->subpackage) $a .= '../';\r
- $template->assign('subdir',$a);\r
- $template->register_outputfilter('HTMLframes_outputfilter');\r
- $contents = $template->fetch('tutorial.tpl');\r
- $a = '';\r
- if ($element->subpackage) $a = PATH_DELIMITER . $element->subpackage;\r
- phpDocumentor_out("\n");\r
- flush();\r
- $this->setTargetDir($this->base_dir . PATH_DELIMITER . $element->package . $a);\r
- $this->writeFile('tutorial_'.$element->name.'.html',$contents);\r
- }\r
- \r
- /**\r
- * Converts class for template output\r
- * @see prepareDocBlock(), generateChildClassList(), generateFormattedClassTree(), getFormattedConflicts()\r
- * @see getFormattedInheritedMethods(), getFormattedInheritedVars()\r
- * @param parserClass\r
- */\r
- function convertClass(&$element)\r
- {\r
- parent::convertClass($element);\r
- $this->class_dir = $element->docblock->package;\r
- if (!empty($element->docblock->subpackage)) $this->class_dir .= PATH_DELIMITER . $element->docblock->subpackage;\r
- $a = '../';\r
- if ($element->docblock->subpackage != '') $a = "../$a";\r
- \r
- $this->class_data->assign('subdir',$a);\r
- $this->class_data->assign("title","Docs For Class " . $element->getName());\r
- $this->class_data->assign("page",$element->getName() . '.html');\r
- }\r
-\r
- /**\r
- * Converts class variables for template output\r
- * @see prepareDocBlock(), getFormattedConflicts()\r
- * @param parserDefine\r
- */\r
- function convertVar(&$element)\r
- {\r
- parent::convertVar($element, array('var_dest' => $this->getId($element,false)));\r
- }\r
-\r
- /**\r
- * Converts class variables for template output\r
- * @see prepareDocBlock(), getFormattedConflicts()\r
- * @param parserDefine\r
- */\r
- function convertConst(&$element)\r
- {\r
- parent::convertConst($element, array('const_dest' => $this->getId($element,false)));\r
- }\r
-\r
- /**\r
- * Converts class methods for template output\r
- * @see prepareDocBlock(), getFormattedConflicts()\r
- * @param parserDefine\r
- */\r
- function convertMethod(&$element)\r
- {\r
- parent::convertMethod($element, array('method_dest' => $this->getId($element,false)));\r
- }\r
- \r
- /**\r
- * Converts function for template output\r
- * @see prepareDocBlock(), parserFunction::getFunctionCall(), getFormattedConflicts()\r
- * @param parserFunction\r
- */\r
- function convertFunction(&$element)\r
- {\r
- $funcloc = $this->getId($this->addLink($element));\r
- parent::convertFunction($element,array('function_dest' => $this->getId($element,false)));\r
- }\r
- \r
- /**\r
- * Converts include elements for template output\r
- * @see prepareDocBlock()\r
- * @param parserInclude\r
- */\r
- function convertInclude(&$element)\r
- {\r
- parent::convertInclude($element, array('include_file' => '_'.strtr($element->getValue(),array('"' => '', "'" => '','.' => '_'))));\r
- }\r
- \r
- /**\r
- * Converts defines for template output\r
- * @see prepareDocBlock(), getFormattedConflicts()\r
- * @param parserDefine\r
- */\r
- function convertDefine(&$element)\r
- {\r
- parent::convertDefine($element, array('define_link' => $this->getId($element,false)));\r
- }\r
- \r
- /**\r
- * Converts global variables for template output\r
- * @param parserGlobal\r
- */\r
- function convertGlobal(&$element)\r
- {\r
- parent::convertGlobal($element, array('global_link' => $this->getId($element,false)));\r
- }\r
- \r
- /**\r
- * converts procedural pages for template output\r
- * @see prepareDocBlock(), getClassesOnPage()\r
- * @param parserData\r
- */\r
- function convertPage(&$element)\r
- {\r
- parent::convertPage($element);\r
- $this->juststarted = true;\r
- $this->page_dir = $element->parent->package;\r
- if (!empty($element->parent->subpackage)) $this->page_dir .= PATH_DELIMITER . $element->parent->subpackage;\r
- // registering stuff on the template\r
- $this->page_data->assign("page",$this->getPageName($element) . '.html');\r
- $this->page_data->assign("title","Docs for page ".$element->parent->getFile());\r
- }\r
- \r
- function getPageName(&$element)\r
- {\r
- if (phpDocumentor_get_class($element) == 'parserpage') return '_'.$element->getName();\r
- return '_'.$element->parent->getName();\r
- }\r
-\r
- /**\r
- * returns an array containing the class inheritance tree from the root object to the class\r
- *\r
- * @param parserClass class variable\r
- * @return array Format: array(root,child,child,child,...,$class)\r
- * @uses parserClass::getParentClassTree()\r
- */\r
- \r
- function generateFormattedClassTree($class)\r
- {\r
- $tree = $class->getParentClassTree($this);\r
- $out = '';\r
- if (count($tree) - 1)\r
- {\r
- $result = array($class->getName());\r
- $parent = $tree[$class->getName()];\r
- $distance[] = '';\r
- while ($parent)\r
- {\r
- $x = $parent;\r
- if (is_object($parent))\r
- {\r
- $subpackage = $parent->docblock->subpackage;\r
- $package = $parent->docblock->package;\r
- $x = $parent;\r
- $x = $parent->getLink($this);\r
- if (!$x) $x = $parent->getName();\r
- }\r
- $result[] = \r
- $x;\r
- $distance[] =\r
- "\n%s|\n" .\r
- "%s--";\r
- if (is_object($parent))\r
- $parent = $tree[$parent->getName()];\r
- elseif (isset($tree[$parent]))\r
- $parent = $tree[$parent];\r
- }\r
- $nbsp = ' ';\r
- for($i=count($result) - 1;$i>=0;$i--)\r
- {\r
- $my_nbsp = '';\r
- for($j=0;$j<count($result) - $i;$j++) $my_nbsp .= $nbsp;\r
- $distance[$i] = sprintf($distance[$i],$my_nbsp,$my_nbsp);\r
- }\r
- return array('classes'=>array_reverse($result),'distance'=>array_reverse($distance));\r
- } else\r
- {\r
- return array('classes'=>$class->getName(),'distance'=>array(''));\r
- }\r
- }\r
- \r
- /** @access private */\r
- function sortVar($a, $b)\r
- {\r
- return strnatcasecmp($a->getName(),$b->getName());\r
- }\r
- \r
- /** @access private */\r
- function sortMethod($a, $b)\r
- {\r
- if ($a->isConstructor) return -1;\r
- if ($b->isConstructor) return 1;\r
- return strnatcasecmp($a->getName(),$b->getName());\r
- }\r
-\r
- /**\r
- * returns a template-enabled array of class trees\r
- * \r
- * @param string $package package to generate a class tree for\r
- * @see $roots, HTMLConverter::getRootTree()\r
- */\r
- function generateFormattedClassTrees($package)\r
- {\r
- if (!isset($this->roots['normal'][$package]) &&\r
- !isset($this->roots['special'][$package])) {\r
- return array();\r
- }\r
- $trees = array();\r
- if (isset($this->roots['normal'][$package])) {\r
- $roots = $this->roots['normal'][$package];\r
- for($i=0;$i<count($roots);$i++)\r
- {\r
- $root = $this->classes->getClassByPackage($roots[$i], $package);\r
- if ($root && $root->isInterface()) {\r
- continue;\r
- }\r
- $trees[] = array('class' => $roots[$i],'class_tree' => "<ul>\n".$this->getRootTree($this->getSortedClassTreeFromClass($roots[$i],$package,''),$package)."</ul>\n");\r
- }\r
- }\r
- if (isset($this->roots['special'][$package])) {\r
- $roots = $this->roots['special'][$package];\r
- foreach ($roots as $parent => $classes) {\r
- $thistree = '';\r
- foreach ($classes as $classinfo) {\r
- $root = $this->classes->getClassByPackage($classinfo, $package);\r
- if ($root && $root->isInterface()) {\r
- continue;\r
- }\r
- $thistree .=\r
- $this->getRootTree(\r
- $this->getSortedClassTreeFromClass(\r
- $classinfo,\r
- $package,\r
- ''),\r
- $package,\r
- true);\r
- }\r
- if (!$thistree) {\r
- continue;\r
- }\r
- $trees[] = array(\r
- 'class' => $parent,\r
- 'class_tree' => "<ul>\n" . $thistree . "</ul>\n"\r
- );\r
- }\r
- }\r
- return $trees;\r
- }\r
-\r
- /**\r
- * returns a template-enabled array of interface inheritance trees\r
- * \r
- * @param string $package package to generate a class tree for\r
- * @see $roots, HTMLConverter::getRootTree()\r
- */\r
- function generateFormattedInterfaceTrees($package)\r
- {\r
- if (!isset($this->roots['normal'][$package]) &&\r
- !isset($this->roots['special'][$package])) {\r
- return array();\r
- }\r
- $trees = array();\r
- if (isset($this->roots['normal'][$package])) {\r
- $roots = $this->roots['normal'][$package];\r
- for($i=0;$i<count($roots);$i++)\r
- {\r
- $root = $this->classes->getClassByPackage($roots[$i], $package);\r
- if ($root && !$root->isInterface()) {\r
- continue;\r
- }\r
- $trees[] = array('class' => $roots[$i],'class_tree' => "<ul>\n".$this->getRootTree($this->getSortedClassTreeFromClass($roots[$i],$package,''),$package)."</ul>\n");\r
- }\r
- }\r
- if (isset($this->roots['special'][$package])) {\r
- $roots = $this->roots['special'][$package];\r
- foreach ($roots as $parent => $classes) {\r
- $thistree = '';\r
- foreach ($classes as $classinfo) {\r
- $root = $this->classes->getClassByPackage($classinfo, $package);\r
- if ($root && !$root->isInterface()) {\r
- continue;\r
- }\r
- $thistree .=\r
- $this->getRootTree(\r
- $this->getSortedClassTreeFromClass(\r
- $classinfo,\r
- $package,\r
- ''),\r
- $package,\r
- true);\r
- }\r
- if (!$thistree) {\r
- continue;\r
- }\r
- $trees[] = array(\r
- 'class' => $parent,\r
- 'class_tree' => "<ul>\n" . $thistree . "</ul>\n"\r
- );\r
- }\r
- }\r
- return $trees;\r
- }\r
- \r
- /**\r
- * return formatted class tree for the Class Trees page\r
- *\r
- * @param array $tree output from {@link getSortedClassTreeFromClass()}\r
- * @param string $package package\r
- * @param boolean $nounknownparent if true, an object's parent will not be checked\r
- * @see Classes::$definitechild, generateFormattedClassTrees()\r
- * @return string\r
- */\r
- function getRootTree($tree, $package, $noparent = false)\r
- {\r
- if (!$tree) return '';\r
- $my_tree = '';\r
- $cur = '#root';\r
- $lastcur = array(false);\r
- $kids = array();\r
- $dopar = false;\r
- if (!$noparent && $tree[$cur]['parent'])\r
- {\r
- $dopar = true;\r
- if (!is_object($tree[$cur]['parent']))\r
- {\r
-// debug("parent ".$tree[$cur]['parent']." not found");\r
- $my_tree .= '<li>' . $tree[$cur]['parent'] .'<ul>';\r
- }\r
- else\r
- {\r
-// debug("parent ".$this->returnSee($tree[$cur]['parent'])." in other package");\r
- $root = $this->classes->getClassByPackage($tree[$cur]['parent']->name,\r
- $package);\r
- $my_tree .= '<li>' . $this->returnSee($tree[$cur]['parent']);\r
- if ($tree[$cur]['parent']->package != $package) $my_tree .= ' <b>(Different package)</b><ul>';\r
- }\r
- }\r
- do\r
- {\r
-// fancy_debug($cur,$lastcur,$kids);\r
- if (count($tree[$cur]['children']))\r
- {\r
-// debug("$cur has children");\r
- if (!isset($kids[$cur]))\r
- {\r
-// debug("set $cur kids");\r
- $kids[$cur] = 1;\r
- $root = $this->classes->getClassByPackage(\r
- $tree[$cur]['link']->name,\r
- $tree[$cur]['link']->package);\r
- if ($implements = $root->getImplements()) {\r
- $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link']) .\r
- ' (implements ';\r
- foreach ($implements as $i => $interface) {\r
- if ($i && $i != count($implements) - 1) $my_tree .= ', ';\r
- if ($link = $this->getLink('object ' . $interface)) {\r
- $my_tree .= $this->returnSee($link);\r
- } else {\r
- $my_tree .= $interface;\r
- }\r
- }\r
- $my_tree .= ')';\r
- } else {\r
- $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link']);\r
- }\r
- $my_tree .= '<ul>'."\n";\r
- }\r
- array_push($lastcur,$cur);\r
- list(,$cur) = each($tree[$cur]['children']);\r
-// var_dump('listed',$cur);\r
- if ($cur)\r
- {\r
- $cur = $cur['package'] . '#' . $cur['class'];\r
-// debug("set cur to child $cur");\r
-// $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link']);\r
- continue;\r
- } else\r
- {\r
-// debug("end of children for $cur");\r
- $cur = array_pop($lastcur);\r
- $cur = array_pop($lastcur);\r
- $my_tree .= '</ul></li>'."\n";\r
- if ($dopar && ($cur == '#root' || !$cur)) $my_tree .= '</ul></li>';\r
- }\r
- } else \r
- {\r
-// debug("$cur has no children");\r
- $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link'])."</li>";\r
- if ($dopar && $cur == '#root') $my_tree .= '</ul></li>';\r
- $cur = array_pop($lastcur);\r
- }\r
- } while ($cur);\r
- return $my_tree;\r
- }\r
-\r
- /**\r
- * Generate indexing information for given element\r
- * \r
- * @param parserElement descendant of parserElement\r
- * @see generateElementIndex()\r
- * @return array\r
- */\r
- function getIndexInformation($elt)\r
- {\r
- $Result['type'] = $elt->type;\r
- $Result['file_name'] = $elt->file;\r
- $Result['path'] = $elt->getPath();\r
- \r
- if (isset($elt->docblock))\r
- {\r
- $Result['description'] = $elt->docblock->getSDesc($this);\r
- \r
- if ($elt->docblock->hasaccess)\r
- $Result['access'] = $elt->docblock->tags['access'][0]->value;\r
- else\r
- $Result['access'] = 'public';\r
-\r
- $Result['abstract'] = isset ($elt->docblock->tags['abstract'][0]);\r
- }\r
- else\r
- $Result['description'] = '';\r
- \r
- $aa = $Result['description'];\r
- if (!empty($aa)) $aa = "<br> $aa";\r
-\r
- switch($elt->type)\r
- {\r
- case 'class':\r
- $Result['name'] = $elt->getName();\r
- $Result['title'] = 'Class';\r
- $Result['link'] = $this->getClassLink($elt->getName(),\r
- $elt->docblock->package,\r
- $elt->getPath(),\r
- $elt->getName());\r
- $Result['listing'] = 'in file '.$elt->file.', class '.$Result['link']."$aa";\r
- break;\r
- case 'define':\r
- $Result['name'] = $elt->getName();\r
- $Result['title'] = 'Constant';\r
- $Result['link'] = $this->getDefineLink($elt->getName(),\r
- $elt->docblock->package,\r
- $elt->getPath(),\r
- $elt->getName());\r
- $Result['listing'] = 'in file '.$elt->file.', constant '.$Result['link']."$aa";\r
- break;\r
- case 'global':\r
- $Result['name'] = $elt->getName();\r
- $Result['title'] = 'Global';\r
- $Result['link'] = $this->getGlobalLink($elt->getName(),\r
- $elt->docblock->package,\r
- $elt->getPath(),\r
- $elt->getName());\r
- $Result['listing'] = 'in file '.$elt->file.', global variable '.$Result['link']."$aa";\r
- break;\r
- case 'function':\r
- $Result['name'] = $elt->getName();\r
- $Result['title'] = 'Function';\r
- $Result['link'] = $this->getFunctionLink($elt->getName(),\r
- $elt->docblock->package,\r
- $elt->getPath(),\r
- $elt->getName().'()');\r
- $Result['listing'] = 'in file '.$elt->file.', function '.$Result['link']."$aa";\r
- break;\r
- case 'method':\r
- $Result['name'] = $elt->getName();\r
- $Result['title'] = 'Method';\r
- $Result['link'] = $this->getMethodLink($elt->getName(),\r
- $elt->class,\r
- $elt->docblock->package,\r
- $elt->getPath(),\r
- $elt->class.'::'.$elt->getName().'()'\r
- );\r
- if ($elt->isConstructor) $Result['constructor'] = 1;\r
- $Result['listing'] = 'in file '.$elt->file.', method '.$Result['link']."$aa";\r
- break;\r
- case 'var':\r
- $Result['name'] = $elt->getName();\r
- $Result['title'] = 'Variable';\r
- $Result['link'] = $this->getVarLink($elt->getName(),\r
- $elt->class,\r
- $elt->docblock->package,\r
- $elt->getPath(),\r
- $elt->class.'::'.$elt->getName());\r
- $Result['listing'] = 'in file '.$elt->file.', variable '.$Result['link']."$aa";\r
- break;\r
- case 'const':\r
- $Result['name'] = $elt->getName();\r
- $Result['title'] = 'Class Constant';\r
- $Result['link'] = $this->getConstLink($elt->getName(),\r
- $elt->class,\r
- $elt->docblock->package,\r
- $elt->getPath(),\r
- $elt->class.'::'.$elt->getName());\r
- $Result['listing'] = 'in file '.$elt->file.', class constant '.$Result['link']."$aa";\r
- break;\r
- case 'page':\r
- $Result['name'] = $elt->getFile();\r
- $Result['title'] = 'Page';\r
- $Result['link'] = $this->getPageLink($elt->getFile(),\r
- $elt->package,\r
- $elt->getPath(),\r
- $elt->getFile());\r
- $Result['listing'] = 'procedural page '.$Result['link'];\r
- break;\r
- case 'include':\r
- $Result['name'] = $elt->getName();\r
- $Result['title'] = 'Include';\r
- $Result['link'] = $elt->getValue();\r
- $Result['listing'] = 'include '.$Result['name'];\r
- break;\r
- }\r
-\r
- return $Result;\r
- }\r
- /**\r
- * Generate alphabetical index of all elements\r
- *\r
- * @see $elements, walk()\r
- */\r
- function generateElementIndex()\r
- {\r
- $elementindex = array();\r
- $letters = array();\r
- $used = array();\r
- foreach($this->elements as $letter => $nutoh)\r
- {\r
- foreach($this->elements[$letter] as $i => $yuh)\r
- {\r
- if ($this->elements[$letter][$i]->type != 'include')\r
- {\r
- if (!isset($used[$letter]))\r
- {\r
- $letters[]['letter'] = $letter;\r
- $elindex['letter'] = $letter;\r
- $used[$letter] = 1;\r
- }\r
-\r
- $elindex['index'][] = $this->getIndexInformation($this->elements[$letter][$i]);\r
- }\r
- }\r
- if (isset($elindex['index']))\r
- {\r
- $elementindex[] = $elindex;\r
- } else\r
- {\r
- unset($letters[count($letters) - 1]);\r
- }\r
- $elindex = array();\r
- }\r
- return array($elementindex,$letters);\r
- }\r
- \r
- function copyMediaRecursively($media,$targetdir,$subdir = '')\r
- {\r
- $versionControlDirectories = array ('CVS', 'media/CVS', 'media\\CVS', '.svn', 'media/.svn', 'media\\.svn');\r
- if (!is_array($media)) {\r
- return;\r
- }\r
- foreach($media as $dir => $files)\r
- {\r
- if ($dir === '/')\r
- {\r
- $this->copyMediaRecursively($files,$targetdir);\r
- } else\r
- {\r
- if (!is_numeric($dir))\r
- {\r
- if (in_array($dir, $versionControlDirectories))\r
- {\r
- // skip it entirely\r
- }\r
- else\r
- {\r
- // create the subdir\r
- phpDocumentor_out("creating $targetdir" . PATH_DELIMITER . "$dir\n");\r
- Converter::setTargetDir($targetdir . PATH_DELIMITER . $dir);\r
- if (!empty($subdir)) \r
- {\r
- $subdir .= PATH_DELIMITER;\r
- }\r
- $this->copyMediaRecursively($files,"$targetdir/$dir",$subdir . $dir);\r
- }\r
- } \r
- else\r
- {\r
- // copy the file\r
- phpDocumentor_out("copying $targetdir" . PATH_DELIMITER . $files['file']."\n");\r
- $this->copyFile($files['file'],$subdir);\r
- }\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * calls the converter setTargetDir, and then copies any template images and the stylesheet if they haven't been copied\r
- * @see Converter::setTargetDir()\r
- */\r
- function setTargetDir($dir)\r
- {\r
- Converter::setTargetDir($dir);\r
- if ($this->wrote) return;\r
- $this->wrote = true;\r
- $template_images = array();\r
- $stylesheets = array();\r
- $tdir = $dir;\r
- $dir = $this->templateDir;\r
- $this->templateDir = $this->templateDir.'templates/';\r
- $info = new Io;\r
- $this->copyMediaRecursively($info->getDirTree($this->templateDir.'media',$this->templateDir),$tdir);\r
- }\r
- \r
- /**\r
- * Generate alphabetical index of all elements by package and subpackage\r
- *\r
- * @param string $package name of a package\r
- * @see $pkg_elements, walk(), generatePkgElementIndexes()\r
- */\r
- function generatePkgElementIndex($package)\r
- {\r
-// var_dump($this->pkg_elements[$package]);\r
- $elementindex = array();\r
- $letters = array();\r
- $letterind = array();\r
- $used = array();\r
- $subp = '';\r
- foreach($this->pkg_elements[$package] as $subpackage => $els)\r
- {\r
- if (empty($els)) continue;\r
- if (!empty($subpackage)) $subp = " (<b>subpackage:</b> $subpackage)"; else $subp = '';\r
- foreach($els as $letter => $yuh)\r
- {\r
- foreach($els[$letter] as $i => $yuh)\r
- {\r
- if ($els[$letter][$i]->type != 'include')\r
- {\r
- if (!isset($used[$letter]))\r
- {\r
- $letters[]['letter'] = $letter;\r
- $letterind[$letter] = count($letters) - 1;\r
- $used[$letter] = 1;\r
- }\r
- $elindex[$letter]['letter'] = $letter;\r
-\r
- $elindex[$letter]['index'][] = $this->getIndexInformation($els[$letter][$i]);\r
- }\r
- }\r
- }\r
- }\r
- ksort($elindex);\r
- usort($letters,'HTMLframes_lettersort');\r
- if (isset($elindex))\r
- {\r
- while(list($letter,$tempel) = each($elindex))\r
- {\r
- if (!isset($tempel))\r
- {\r
- unset($letters[$letterind[$tempel['letter']]]);\r
- } else\r
- $elementindex[] = $tempel;\r
- }\r
- } else $letters = array();\r
- return array($elementindex,$letters);\r
- }\r
- \r
- /**\r
- *\r
- * @see generatePkgElementIndex()\r
- */\r
- function generatePkgElementIndexes()\r
- {\r
- $packages = array();\r
- $package_names = array();\r
- $pkg = array();\r
- $letters = array();\r
- foreach($this->pkg_elements as $package => $trash)\r
- {\r
- $pkgs['package'] = $package;\r
- $pkg['package'] = $package;\r
- list($pkg['pindex'],$letters[$package]) = $this->generatePkgElementIndex($package);\r
- if (count($pkg['pindex']))\r
- {\r
- $packages[] = $pkg;\r
- $package_names[] = $pkgs;\r
- }\r
- unset($pkgs);\r
- unset($pkg);\r
- }\r
- foreach($packages as $i => $package)\r
- {\r
- $pnames = array();\r
- for($j=0;$j<count($package_names);$j++)\r
- {\r
- if ($package_names[$j]['package'] != $package['package']) $pnames[] = $package_names[$j];\r
- }\r
- $packages[$i]['packageindexes'] = $pnames;\r
- }\r
- return array($packages,$package_names,$letters);\r
- }\r
- \r
- /**\r
- * @param string name of class\r
- * @param string package name\r
- * @param string full path to look in (used in index generation)\r
- * @param boolean deprecated\r
- * @param boolean return just the URL, or enclose it in an html a tag\r
- * @return mixed false if not found, or an html a link to the class's documentation\r
- * @see parent::getClassLink()\r
- */\r
- function getClassLink($expr,$package, $file = false,$text = false, $with_a = true)\r
- {\r
- $a = Converter::getClassLink($expr,$package,$file);\r
- if (!$a) return false;\r
- return $this->returnSee($a, $text, $with_a);\r
- }\r
-\r
- /**\r
- * @param string name of function\r
- * @param string package name\r
- * @param string full path to look in (used in index generation)\r
- * @param boolean deprecated\r
- * @param boolean return just the URL, or enclose it in an html a tag\r
- * @return mixed false if not found, or an html a link to the function's documentation\r
- * @see parent::getFunctionLink()\r
- */\r
- function getFunctionLink($expr,$package, $file = false,$text = false)\r
- {\r
- $a = Converter::getFunctionLink($expr,$package,$file);\r
- if (!$a) return false;\r
- return $this->returnSee($a, $text);\r
- }\r
-\r
- /**\r
- * @param string name of define\r
- * @param string package name\r
- * @param string full path to look in (used in index generation)\r
- * @param boolean deprecated\r
- * @param boolean return just the URL, or enclose it in an html a tag\r
- * @return mixed false if not found, or an html a link to the define's documentation\r
- * @see parent::getDefineLink()\r
- */\r
- function getDefineLink($expr,$package, $file = false,$text = false)\r
- {\r
- $a = Converter::getDefineLink($expr,$package,$file);\r
- if (!$a) return false;\r
- return $this->returnSee($a, $text);\r
- }\r
-\r
- /**\r
- * @param string name of global variable\r
- * @param string package name\r
- * @param string full path to look in (used in index generation)\r
- * @param boolean deprecated\r
- * @param boolean return just the URL, or enclose it in an html a tag\r
- * @return mixed false if not found, or an html a link to the global variable's documentation\r
- * @see parent::getGlobalLink()\r
- */\r
- function getGlobalLink($expr,$package, $file = false,$text = false)\r
- {\r
- $a = Converter::getGlobalLink($expr,$package,$file);\r
- if (!$a) return false;\r
- return $this->returnSee($a, $text);\r
- }\r
-\r
- /**\r
- * @param string name of procedural page\r
- * @param string package name\r
- * @param string full path to look in (used in index generation)\r
- * @param boolean deprecated\r
- * @param boolean return just the URL, or enclose it in an html a tag\r
- * @return mixed false if not found, or an html a link to the procedural page's documentation\r
- * @see parent::getPageLink()\r
- */\r
- function getPageLink($expr,$package, $path = false,$text = false)\r
- {\r
- $a = Converter::getPageLink($expr,$package,$path);\r
- if (!$a) return false;\r
- return $this->returnSee($a, $text);\r
- }\r
-\r
- /**\r
- * @param string name of method\r
- * @param string class containing method\r
- * @param string package name\r
- * @param string full path to look in (used in index generation)\r
- * @param boolean deprecated\r
- * @param boolean return just the URL, or enclose it in an html a tag\r
- * @return mixed false if not found, or an html a link to the method's documentation\r
- * @see parent::getMethodLink()\r
- */\r
- function getMethodLink($expr,$class,$package, $file = false,$text = false)\r
- {\r
- $a = Converter::getMethodLink($expr,$class,$package,$file);\r
- if (!$a) return false;\r
- return $this->returnSee($a, $text);\r
- }\r
-\r
- /**\r
- * @param string name of var\r
- * @param string class containing var\r
- * @param string package name\r
- * @param string full path to look in (used in index generation)\r
- * @param boolean deprecated\r
- * @param boolean return just the URL, or enclose it in an html a tag\r
- * @return mixed false if not found, or an html a link to the var's documentation\r
- * @see parent::getVarLink()\r
- */\r
- function getVarLink($expr,$class,$package, $file = false,$text = false)\r
- {\r
- $a = Converter::getVarLink($expr,$class,$package,$file);\r
- if (!$a) return false;\r
- return $this->returnSee($a, $text);\r
- }\r
-\r
- /**\r
- * @param string name of class constant\r
- * @param string class containing class constant\r
- * @param string package name\r
- * @param string full path to look in (used in index generation)\r
- * @param boolean deprecated\r
- * @param boolean return just the URL, or enclose it in an html a tag\r
- * @return mixed false if not found, or an html a link to the var's documentation\r
- * @see parent::getVarLink()\r
- */\r
- function getConstLink($expr,$class,$package, $file = false,$text = false)\r
- {\r
- $a = Converter::getConstLink($expr,$class,$package,$file);\r
- if (!$a) return false;\r
- return $this->returnSee($a, $text);\r
- }\r
- \r
- /**\r
- * does a nat case sort on the specified second level value of the array\r
- *\r
- * @param mixed $a\r
- * @param mixed $b\r
- * @return int\r
- */\r
- function rcNatCmp ($a, $b)\r
- {\r
- $aa = strtoupper($a[$this->rcnatcmpkey]);\r
- $bb = strtoupper($b[$this->rcnatcmpkey]);\r
- \r
- return strnatcasecmp($aa, $bb);\r
- }\r
- \r
- /**\r
- * does a nat case sort on the specified second level value of the array.\r
- * this one puts constructors first\r
- *\r
- * @param mixed $a\r
- * @param mixed $b\r
- * @return int\r
- */\r
- function rcNatCmp1 ($a, $b)\r
- {\r
- $aa = strtoupper($a[$this->rcnatcmpkey]);\r
- $bb = strtoupper($b[$this->rcnatcmpkey]);\r
- \r
- if (strpos($aa,'CONSTRUCTOR') === 0)\r
- {\r
- return -1;\r
- }\r
- if (strpos($bb,'CONSTRUCTOR') === 0)\r
- {\r
- return 1;\r
- }\r
- if (strpos($aa,strtoupper($this->class)) === 0)\r
- {\r
- return -1;\r
- }\r
- if (strpos($bb,strtoupper($this->class)) === 0)\r
- {\r
- return -1;\r
- }\r
- return strnatcasecmp($aa, $bb);\r
- }\r
- \r
- /**\r
- * This function is not used by HTMLdefaultConverter, but is required by Converter\r
- */\r
- function Output()\r
- {\r
- }\r
-}\r
-\r
-/**\r
- * @access private\r
- * @global string name of the package to set as the first package\r
- */\r
-function HTMLframes_pindexcmp($a, $b)\r
-{\r
- global $phpDocumentor_DefaultPackageName;\r
- if ($a['title'] == $phpDocumentor_DefaultPackageName) return -1;\r
- if ($b['title'] == $phpDocumentor_DefaultPackageName) return 1;\r
- return strnatcasecmp($a['title'],$b['title']);\r
-}\r
-\r
-/** @access private */\r
-function HTMLframes_lettersort($a, $b)\r
-{\r
- return strnatcasecmp($a['letter'],$b['letter']);\r
-}\r
-\r
-/** @access private */\r
-function HTMLframes_outputfilter($src, &$smarty)\r
-{\r
- return str_replace('{$subdir}',$smarty->_tpl_vars['subdir'],$src);\r
-}\r
-?>\r