home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / HTMLSmartyConverter.inc < prev    next >
Encoding:
Text File  |  2004-03-24  |  70.4 KB  |  1,759 lines

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | phpDocumentor                                                          |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2000-2003 Joshua Eichorn, Gregory Beaver                 |
  7. // | Email         jeichorn@phpdoc.org, cellog@phpdoc.org                   |
  8. // | Web           http://www.phpdoc.org                                    |
  9. // | Mirror        http://phpdocu.sourceforge.net/                          |
  10. // | PEAR          http://pear.php.net/package-info.php?pacid=137           |
  11. // +------------------------------------------------------------------------+
  12. // | This source file is subject to version 3.00 of the PHP License,        |
  13. // | that is available at http://www.php.net/license/3_0.txt.               |
  14. // | If you did not receive a copy of the PHP license and are unable to     |
  15. // | obtain it through the world-wide-web, please send a note to            |
  16. // | license@php.net so we can mail you a copy immediately.                 |
  17. // +------------------------------------------------------------------------+
  18. //
  19. /**
  20.  * HTML output converter for Smarty Template.
  21.  * This Converter takes output from the {@link Parser} and converts it to HTML-ready output for use with {@link Smarty}.
  22.  *
  23.  * @package Converters
  24.  * @subpackage HTMLSmarty
  25.  * @see parserDocBlock, parserInclude, parserPage, parserClass, parserDefine, parserFunction, parserMethod, parserVar
  26.  * @author Greg Beaver <cellog@users.sourceforge.net>
  27.  * @since 1.0rc1
  28.  * @version $Revision: 1.69.2.7 $
  29.  */
  30. /**
  31.  * HTML output converter.
  32.  * This Converter takes output from the {@link Parser} and converts it to HTML-ready output for use with {@link Smarty}.
  33.  *
  34.  * @package Converters
  35.  * @subpackage HTMLSmarty
  36.  * @see parserDocBlock, parserInclude, parserPage, parserClass, parserDefine, parserFunction, parserMethod, parserVar
  37.  * @author Greg Beaver <cellog@users.sourceforge.net>
  38.  * @since 1.0rc1
  39.  * @version $Revision: 1.69.2.7 $
  40.  */
  41. class HTMLSmartyConverter extends Converter
  42. {
  43.     /**
  44.      * Smarty Converter wants elements sorted by type as well as alphabetically
  45.      * @see Converter::$sort_page_contents_by_type
  46.      * @var boolean
  47.      */
  48.     var $sort_page_contents_by_type = true;
  49.     /** @var string */
  50.     var $outputformat = 'HTML';
  51.     /** @var string */
  52.     var $name = 'Smarty';
  53.     /**
  54.      * indexes of elements by package that need to be generated
  55.      * @var array
  56.      */
  57.     var $leftindex = array('classes' => true, 'pages' => true, 'functions' => false, 'defines' => false, 'globals' => false);
  58.     
  59.     /**
  60.      * name of current page being converted
  61.      * @var string
  62.      */
  63.     var $page;
  64.     
  65.     /**
  66.      * path of current page being converted
  67.      * @var string
  68.      */
  69.     var $path;
  70.     
  71.     /**
  72.      * name of current class being converted
  73.      * @var string
  74.      */
  75.     var $class;
  76.     
  77.     /**
  78.      * template for the procedural page currently being processed
  79.      * @var Template
  80.      */
  81.     var $page_data;
  82.     
  83.     /**
  84.      * output directory for the current procedural page being processed
  85.      * @var string
  86.      */
  87.     var $page_dir;
  88.     
  89.     /**
  90.      * target directory passed on the command-line.
  91.      * {@link $targetDir} is malleable, always adding package/ and package/subpackage/ subdirectories onto it.
  92.      * @var string
  93.      */
  94.     var $base_dir;
  95.     
  96.     /**
  97.      * output directory for the current class being processed
  98.      * @var string
  99.      */
  100.     var $class_dir;
  101.     
  102.     /**
  103.      * template for the class currently being processed
  104.      * @var Template
  105.      */
  106.     var $class_data;
  107.     
  108.     /**
  109.      * array of converted package page names.
  110.      * Used to link to the package page in the left index
  111.      * @var array Format: array(package => 1)
  112.      */
  113.     var $package_pages = array();
  114.     
  115.     /**
  116.      * controls formatting of parser informative output
  117.      * 
  118.      * Converter prints:
  119.      * "Converting /path/to/file.php... Procedural Page Elements... Classes..."
  120.      * Since HTMLdefaultConverter outputs files while converting, it needs to send a \n to start a new line.  However, if there
  121.      * is more than one class, output is messy, with multiple \n's just between class file output.  This variable prevents that
  122.      * and is purely cosmetic
  123.      * @var boolean
  124.      */
  125.     var $juststarted = false;
  126.     
  127.     /**
  128.      * contains all of the template procedural page element loop data needed for the current template
  129.      * @var array
  130.      */
  131.     var $current;
  132.     
  133.     /**
  134.      * contains all of the template class element loop data needed for the current template
  135.      * @var array
  136.      */
  137.     var $currentclass;
  138.     /**
  139.      * sets {@link $base_dir} to $targetDir
  140.      * @see Converter()
  141.      */
  142.     
  143.     /**#@+
  144.      * @access private
  145.      */
  146.     var $_classleft_cache = false;
  147.     var $_classcontents_cache = false;
  148.     var $_pagecontents_cache = false;
  149.     var $_pageleft_cache = false;
  150.     var $_done_package_index = false;
  151.     var $_ric_done = false;
  152.     var $_wrote_tdir = false;
  153.     var $ric_set = array();
  154.     var $ric_contents = array();
  155.     /**#@-*/
  156.     
  157.     function HTMLSmartyConverter(&$allp, &$packp, &$classes, &$procpages, $po, $pp, $qm, $targetDir, $templateDir, $title)
  158.     {
  159.         Converter::Converter($allp, $packp, $classes, $procpages,$po, $pp, $qm, $targetDir, $templateDir, $title);
  160.         $this->base_dir = $targetDir;
  161.     }
  162.     
  163.     function writeSource($path, $value)
  164.     {
  165.         $templ = &$this->newSmarty();
  166.         $pathinfo = $this->proceduralpages->getPathInfo($path, $this);
  167.         $templ->assign('source',$value);
  168.         $templ->assign('package',$pathinfo['package']);
  169.         $templ->assign('subpackage',$pathinfo['subpackage']);
  170.         $templ->assign('name',$pathinfo['name']);
  171.         $templ->assign('source_loc',$pathinfo['source_loc']);
  172.         $templ->assign('docs',$pathinfo['docs']);
  173.         $templ->assign("subdir",'../');
  174.         $templ->register_outputfilter('HTMLSmarty_outputfilter');
  175.         $this->setTargetDir($this->getFileSourcePath($this->base_dir));
  176.         phpDocumentor_out("\n");
  177.         $this->setSourcePaths($path);
  178.         $this->writefile($this->getFileSourceName($path).'.html',$templ->fetch('filesource.tpl'));
  179.     }
  180.     
  181.     function writeExample($title, $path, $source)
  182.     {
  183.         $templ = &$this->newSmarty();
  184.         $templ->assign('source',$source);
  185.         if (empty($title))
  186.         {
  187.             $title = 'example';
  188.             addWarning(PDERROR_EMPTY_EXAMPLE_TITLE, $path, $title);
  189.         }
  190.         $templ->assign('title',$title);
  191.         $templ->assign('file',$path);
  192.         $templ->assign("subdir",'../');
  193.         $templ->register_outputfilter('HTMLSmarty_outputfilter');
  194.         $this->setTargetDir($this->base_dir . PATH_DELIMITER . '__examplesource');
  195.         phpDocumentor_out("\n");
  196.         $this->writefile('exsource_'.$path.'.html',$templ->fetch('examplesource.tpl'));
  197.     }
  198.     
  199.     function getExampleLink($path, $title)
  200.     {
  201.         return $this->returnLink('{$subdir}__examplesource' . PATH_DELIMITER . 'exsource_'.$path.'.html',$title);
  202.     }
  203.     
  204.     function getSourceLink($path)
  205.     {
  206.         return $this->returnLink($this->getFileSourcePath('{$subdir}') .
  207.         PATH_DELIMITER . $this->getFileSourceName($path).'.html','Source Code for this file');
  208.     }
  209.     
  210.     /**
  211.      * Used to convert the <<code>> tag in a docblock
  212.      * @param string
  213.      * @return string
  214.      */
  215.     function ProgramExample($example, $tutorial = false, $inlinesourceparse = null/*false*/,
  216.                             $class = null/*false*/, $linenum = null/*false*/, $filesourcepath = null/*false*/)
  217.     {
  218.         return $this->PreserveWhiteSpace(parent::ProgramExample($example, $tutorial, $inlinesourceparse, $class, $linenum, $filesourcepath));
  219.     }
  220.     
  221.     /**
  222.      * Retrieve a Converter-specific anchor to a segment of a source code file
  223.      * parsed via a {@tutorial tags.filesource.pkg} tag.
  224.      * @param string full path to source file
  225.      * @param string name of anchor
  226.      * @param string link text, if this is a link
  227.      * @param boolean returns either a link or a destination based on this
  228.      *                parameter
  229.      * @return string link to an anchor, or the anchor
  230.      */
  231.     function getSourceAnchor($sourcefile,$anchor,$text = '',$link = false)
  232.     {
  233.         if ($link)
  234.         return $this->returnLink($this->getFileSourcePath('{$subdir}') .
  235.         PATH_DELIMITER . $this->getFileSourceName($sourcefile).'.html#a'.$anchor, $text);
  236.         else
  237.         return '<a name="a'.$anchor.'"></a>';
  238.     }
  239.     
  240.     function getCurrentPageLink()
  241.     {
  242.         return $this->curname . '.html';
  243.     }
  244.  
  245.     function unmangle($sourcecode)
  246.     {
  247.         $sourcecode = str_replace(' ',' ',$sourcecode);
  248.         $sourcecode = str_replace('&','&',$sourcecode);
  249.         $sourcecode = str_replace('<br />',"<br>",$sourcecode);
  250.         $sourcecode = str_replace('<code>','<pre>',$sourcecode);
  251.         $sourcecode = str_replace('</code>','</pre>',$sourcecode);
  252.         $sourcecode = str_replace('<','<',$sourcecode);
  253.         $sourcecode = str_replace('>','>',$sourcecode);
  254.         return $sourcecode;
  255.     }
  256.     
  257.     /**
  258.      * Uses htmlspecialchars() on the input
  259.      */
  260.     function postProcess($text)
  261.     {
  262.         return htmlspecialchars($text);
  263.     }
  264.     
  265.     /**
  266.      * Use the template tutorial_toc.tpl to generate a table of contents for HTML
  267.      * @return string table of contents formatted for use in the current output format
  268.      * @param array format: array(array('tagname' => section, 'link' => returnsee link, 'id' => anchor name, 'title' => from title tag),...)
  269.      */
  270.     function formatTutorialTOC($toc)
  271.     {
  272.         $template = &$this->newSmarty();
  273.         $template->assign('toc',$toc);
  274.         return $template->fetch('tutorial_toc.tpl');
  275.     }
  276.     
  277.     function &SmartyInit(&$templ)
  278.     {
  279.         $this->makeLeft();
  280.         $templ->assign("ric",$this->ric_set);
  281.         $templ->assign("packageindex",$this->package_index);
  282.         $templ->assign('hastodos',count($this->todoList));
  283.         $templ->assign('todolink','todolist.html');
  284.         $templ->assign("subdir",'');
  285.         return $templ;
  286.     }
  287.     
  288.     /**
  289.      * Writes out the template file of {@link $class_data} and unsets the template to save memory
  290.      * @see registerCurrentClass()
  291.      * @see parent::endClass()
  292.      */
  293.     function endClass()
  294.     {
  295.         $a = '../';
  296.         if (!empty($this->subpackage)) $a .= '../';
  297.         if ($this->juststarted)
  298.         {
  299.             $this->juststarted = false;
  300.             phpDocumentor_out("\n");
  301.             flush();
  302.         }
  303.         $this->setTargetDir($this->base_dir . PATH_DELIMITER . $this->class_dir);
  304.         $this->class_data->assign("compiledclassindex",$this->getClassLeft());
  305.         $this->class_data->assign("compiledfileindex",$this->getPageLeft());
  306.         $this->class_data->assign("tutorials",$this->getTutorialList());
  307.         $this->class_data->assign("contents",$this->getClassContents());
  308.         $this->class_data->assign("packageindex",$this->package_index);
  309.         $this->class_data->assign("package",$this->package);
  310.         $this->class_data->assign("subdir",$a);
  311.         $this->class_data->register_outputfilter('HTMLSmarty_outputfilter');
  312.         $this->writefile($this->class . '.html',$this->class_data->fetch('class.tpl'));
  313.         unset($this->class_data);
  314.     }
  315.     
  316.     function getTutorialList()
  317.     {
  318.         static $cache = false;
  319.         if ($cache)
  320.         {
  321.             if (isset($cache[$this->package])) return $cache[$this->package];
  322.         }
  323.         $package = $this->package;
  324.         if (!isset($this->tutorials[$package])) return false;
  325.         foreach($this->tutorials[$package] as $subpackage => $blah)
  326.         {
  327.             $subpackages[] = $subpackage;
  328.         }
  329.         $tutes = array();
  330.         foreach($subpackages as $subpackage)
  331.         {
  332.             if (isset($this->tutorial_tree) && is_array($this->tutorial_tree))
  333.             foreach($this->tutorial_tree as $root => $tr)
  334.             {
  335.                 if ($tr['tutorial']->package == $package && $tr['tutorial']->subpackage == $subpackage)
  336.                 $tutes[$tr['tutorial']->tutorial_type][] = $this->getTutorialTree($tr['tutorial']);
  337.             }
  338.         }
  339.         $cache[$this->package] = $tutes;
  340.         return $tutes;
  341.     }
  342.     
  343.     function getTutorialTree($tutorial,$k = false)
  344.     {
  345.         $ret = '';
  346.         if (is_object($tutorial)) $tree = parent::getTutorialTree($tutorial); else $tree = $tutorial;
  347.         if (!$tree)
  348.         {
  349.             $template = &$this->newSmarty();
  350.             $template->assign('subtree',false);
  351.             $template->assign('name',str_replace('.','',$tutorial->name));
  352.             $template->assign('parent',false);
  353.             $template->assign('haskids',false);
  354.             $template->assign('kids','');
  355.             $link = new tutorialLink;
  356.             $t = $tutorial;
  357.             $link->addLink('',$t->path,$t->name,$t->package,$t->subpackage,$t->getTitle($this));
  358.             $main = array('link' => $this->getId($link), 'title' => $link->title);
  359.             $template->assign('main',$main);
  360.             return $template->fetch('tutorial_tree.tpl');
  361.         }
  362.         if (isset($tree['kids']))
  363.         {
  364.             foreach($tree['kids'] as $subtree)
  365.             {
  366.                 $ret .= $this->getTutorialTree($subtree, true);
  367.             }
  368.         }
  369.         $template = &$this->newSmarty();
  370.         $template->assign('subtree',$k);
  371.         $template->assign('name',str_replace('.','',$tree['tutorial']->name));
  372.         $template->assign('parent',($k ? str_replace('.','',$tree['tutorial']->parent->name) : false));
  373.         $template->assign('haskids',strlen($ret));
  374.         $template->assign('kids',$ret);
  375.         $link = new tutorialLink;
  376.         $t = $tree['tutorial'];
  377.         $link->addLink('',$t->path,$t->name,$t->package,$t->subpackage,$t->getTitle($this));
  378.         $main = array('link' => $this->getId($link), 'title' => $link->title);
  379.         $template->assign('main',$main);
  380.         return $template->fetch('tutorial_tree.tpl');
  381.     }
  382.     
  383.     function getClassLeft()
  384.     {
  385.         if ($this->_classleft_cache)
  386.         {
  387.             if (isset($this->_classleft_cache[$this->package][$this->subpackage])) return $this->_classleft_cache[$this->package][$this->subpackage];
  388.         }
  389.         $arr = array();
  390.         if (isset($this->left['#class'][$this->package]))
  391.         foreach($this->left['#class'][$this->package] as $subpackage => $pages)
  392.         {
  393.             $arr[$subpackage] = $pages;
  394.         }
  395.         $templ = &$this->newSmarty();
  396.         $templ->assign('classleftindex',$arr);
  397.         $arr = $templ->fetch('classleft.tpl');
  398.         $this->_classleft_cache[$this->package][$this->subpackage] = $arr;
  399.         return $arr;
  400.     }
  401.     
  402.     function getClassContents()
  403.     {
  404.         if ($this->_classcontents_cache)
  405.         {
  406.             if (isset($this->_classcontents_cache[$this->package][$this->subpackage][$this->class])) return $this->_classcontents_cache[$this->package][$this->subpackage][$this->class];
  407.         }
  408.         $arr = array();
  409.         foreach($this->class_contents[$this->package][$this->subpackage][$this->class] as $i => $link)
  410.         {
  411.             if (is_object($link))
  412.             $arr[$link->type][] = $this->returnSee($link,$link->name);
  413.         }
  414.         $this->_classcontents_cache[$this->package][$this->subpackage][$this->class] = $arr;
  415.         return $arr;
  416.     }
  417.     
  418.     function getPageContents()
  419.     {
  420.         if (!isset($this->path)) $this->path = '#####';
  421.         if ($this->_pagecontents_cache)
  422.         {
  423.             if (isset($this->_pagecontents_cache[$this->package][$this->subpackage][$this->path])) return $this->_pagecontents_cache[$this->package][$this->subpackage][$this->path];
  424.         }
  425.         $arr = array();
  426.         foreach($this->page_contents[$this->curpage->package][$this->curpage->subpackage] as $i => $link)
  427.         {
  428.             if (is_object($link))
  429.             $arr[$link->type][$i] = $this->returnSee($link);
  430.         }
  431.         $this->_pagecontents_cache[$this->package][$this->subpackage][$this->path] = $arr;
  432.         return $arr;
  433.     }
  434.     
  435.     function getPageLeft()
  436.     {
  437.         if ($this->_pageleft_cache)
  438.         {
  439.             if (isset($this->_pageleft_cache[$this->package][$this->subpackage])) return $this->_pageleft_cache[$this->package][$this->subpackage];
  440.         }
  441.         $arr = array();
  442.         if (isset($this->left[$this->package]))
  443.         foreach($this->left[$this->package] as $subpackage => $pages)
  444.         {
  445.             $arr[$subpackage] = $pages;
  446.         }
  447.         $templ = &$this->newSmarty();
  448.         $templ->assign('fileleftindex',$arr);
  449.         $arr = $templ->fetch('fileleft.tpl');
  450.         $this->_pageleft_cache[$this->package][$this->subpackage] = $arr;
  451.         return $arr;
  452.     }
  453.     
  454.     /**
  455.      * Writes out the template file of {@link $page_data} and unsets the template to save memory
  456.      * @see registerCurrent()
  457.      * @see parent::endPage()
  458.      */
  459.     function endPage()
  460.     {
  461.         $this->package = $this->curpage->package;
  462.         $this->subpackage = $this->curpage->subpackage;
  463.         $a = '../';
  464.         if (!empty($this->subpackage)) $a .= '../';
  465.         $this->setTargetDir($this->base_dir . PATH_DELIMITER . $this->page_dir);
  466.         $this->page_data->assign("contents",$this->getPageContents());
  467.         $this->page_data->assign("compiledfileindex",$this->getPageLeft());
  468.         $this->page_data->assign("compiledclassindex",$this->getClassLeft());
  469.         $this->page_data->assign("tutorials",$this->getTutorialList());
  470.         $this->page_data->assign("packageindex",$this->package_index);
  471.         $this->page_data->assign("package",$this->package);
  472.         $this->page_data->assign("subdir",$a);
  473.         $this->page_data->register_outputfilter('HTMLSmarty_outputfilter');
  474.         $this->writefile($this->page . '.html',$this->page_data->fetch('page.tpl'));
  475.         unset($this->page_data);
  476.     }
  477.     
  478.     /**
  479.      * @param string
  480.      * @param string
  481.      * @return string <a href="'.$link.'">'.$text.'</a>
  482.      */
  483.     function returnLink($link,$text)
  484.     {
  485.         return '<a href="'.$link.'">'.$text.'</a>';
  486.     }
  487.     
  488.     function makeLeft()
  489.     {
  490.         if ($this->_done_package_index) return;
  491.         $this->_done_package_index = true;
  492.         if (!isset($this->package_index))
  493.         foreach($this->all_packages as $key => $val)
  494.         {
  495.             if (isset($this->pkg_elements[$key]))
  496.             {
  497.                 if (!isset($start)) $start = $key;
  498.                 $this->package_index[] = array('link' => "li_$key.html", 'title' => $key);
  499.             }
  500.         }
  501.         foreach($this->page_elements as $package => $o1)
  502.         {
  503.             foreach($o1 as $subpackage => $links)
  504.             {
  505.                 for($i=0;$i<count($links);$i++)
  506.                 {
  507.                     $this->left[$package][$subpackage][] =
  508.                         array("link" => $this->getId($links[$i]), "title" => $links[$i]->name);
  509.                 }
  510.             }
  511.         }
  512.         foreach($this->class_elements as $package => $o1)
  513.         {
  514.             foreach($o1 as $subpackage => $links)
  515.             {
  516.                 for($i=0;$i<count($links);$i++)
  517.                 {
  518.                     $this->left['#class'][$package][$subpackage][] =
  519.                         array("link" => $this->getId($links[$i]), "title" => $links[$i]->name);
  520.                 }
  521.             }
  522.         }
  523.     }
  524.     
  525.     /**
  526.      * HTMLdefaultConverter chooses to format both package indexes and the complete index here
  527.      *
  528.      * This function formats output for the elementindex.html and pkgelementindex.html template files.  It then
  529.      * writes them to the target directory
  530.      * @see generateElementIndex(), generatePkgElementIndex()
  531.      */
  532.     function formatPkgIndex()
  533.     {
  534.         list($package_indexes,$packages,$mletters) = $this->generatePkgElementIndexes();
  535.         for($i=0;$i<count($package_indexes);$i++)
  536.         {
  537.             $template = &$this->newSmarty();
  538.             $this->package = $package_indexes[$i]['package'];
  539.             $this->subpackage = '';
  540.             $template->assign("compiledclassindex",$this->getClassLeft());
  541.             $template->assign("compiledfileindex",$this->getPageLeft());
  542.             $template->assign("tutorials",$this->getTutorialList());
  543.             $template->assign("index",$package_indexes[$i]['pindex']);
  544.             $template->assign("package",$package_indexes[$i]['package']);
  545.             $template->assign("letters",$mletters[$package_indexes[$i]['package']]);
  546.             $template->assign("title","Package ".$package_indexes[$i]['package']." Element Index");
  547.             $template->assign("date",date("r",time()));
  548.             $template->register_outputfilter('HTMLSmarty_outputfilter');
  549.             $this->setTargetDir($this->base_dir);
  550.             $this->writefile('elementindex_'.$package_indexes[$i]['package'].'.html',$template->fetch('pkgelementindex.tpl'));
  551.         }
  552.         phpDocumentor_out("\n");
  553.         flush();
  554.         }
  555.     
  556.     /**
  557.      * HTMLdefaultConverter uses this function to format template index.html and packages.html
  558.      *
  559.      * This function generates the package list from {@link $all_packages}, eliminating any
  560.      * packages that don't have any entries in their package index (no files at all, due to @ignore
  561.      * or other factors).  Then it uses the default package name as the first package index to display.
  562.      * It sets the right pane to be either a blank file with instructions on making package-level docs,
  563.      * or the package-level docs for the default package.
  564.      * @global string Used to set the starting package to display
  565.      */
  566.     function formatIndex()
  567.     {
  568.         global $phpDocumentor_DefaultPackageName;
  569.         if (!isset($this->package_index))
  570.         {
  571.             debug("\nERROR: Nothing parsed, check the command-line");
  572.             die();
  573.         }
  574.         list($elindex,$mletters) = $this->generateElementIndex();
  575.         $template = &$this->newSmarty();
  576.         $template->assign("index",$elindex);
  577.         $template->assign("letters",$mletters);
  578.         $template->assign("title","Element Index");
  579.         $template->assign("date",date("r",time()));
  580.         phpDocumentor_out("\n");
  581.         flush();
  582.         $this->setTargetDir($this->base_dir);
  583.         $template->register_outputfilter('HTMLSmarty_outputfilter');
  584.         $this->writefile('elementindex.html',$template->fetch('elementindex.tpl'));
  585.         usort($this->package_index,"HTMLSmarty_pindexcmp");
  586.         $index = &$this->newSmarty();
  587.         foreach($this->all_packages as $key => $val)
  588.         {
  589.             if (isset($this->pkg_elements[$key]))
  590.             {
  591.                 if (!isset($start)) $start = $key;
  592.                 if (!isset($this->package_pages[$key])) $this->writeNewPPage($key);
  593.             }
  594.         }
  595.         // Created index.html
  596.         $start = $phpDocumentor_DefaultPackageName;
  597.         if (!isset($this->pkg_elements[$key]))
  598.         {
  599.             // if there are no elements, use a random package as the default
  600.             $start = array_shift(array_keys($this->pkg_elements));
  601.         }
  602.         $this->package = $start;
  603.         $this->subpackage = '';
  604.         $index->assign("compiledclassindex",$this->getClassLeft());
  605.         $index->assign("compiledfileindex",$this->getPageLeft());
  606.         $index->assign('hastodos',count($this->todoList));
  607.         $index->assign('todolink','todolist.html');
  608.         $index->assign("tutorials",$this->getTutorialList());
  609.         $index->assign("date",date("r",time()));
  610.         $index->assign("package",$this->package);
  611.         $index->assign("title",$this->title);
  612.         $index->assign("start","li_$start.html");
  613.         if (isset($this->package_pages[$start]))
  614.         {
  615.             $index->assign("contents",$this->package_pages[$start]);
  616.         }
  617.         $index->register_outputfilter('HTMLSmarty_outputfilter');
  618.         phpDocumentor_out("\n");
  619.         flush();
  620.         $this->setTargetDir($this->base_dir);
  621.         $this->writefile("index.html",$index->fetch('index.tpl'));
  622.         unset($index);
  623.  
  624.     }
  625.     
  626.     function writeNewPPage($key)
  627.     {
  628.         $template = &$this->newSmarty();
  629.         $this->package = $key;
  630.         $this->subpackage = '';
  631.         $template->assign("compiledclassindex",$this->getClassLeft());
  632.         $template->assign("compiledfileindex",$this->getPageLeft());
  633.         $template->assign("tutorials",$this->getTutorialList());
  634.         $template->assign("date",date("r",time()));
  635.         $template->assign("title",$this->title);
  636.         $template->assign("package",$key);
  637.         $template->register_outputfilter('HTMLSmarty_outputfilter');
  638.         phpDocumentor_out("\n");
  639.         flush();
  640.         $this->setTargetDir($this->base_dir);
  641.         $this->writefile("li_$key.html",$template->fetch('index.tpl'));
  642.         unset($template);
  643.     }
  644.     
  645.     /**
  646.      * Generate indexes for li_package.html and classtree output files
  647.      *
  648.      * This function generates the li_package.html files from the template file left.html.  It does this by
  649.      * iterating through each of the $page_elements, $class_elements and  $function_elements arrays to retrieve
  650.      * the pre-sorted {@link abstractLink} descendants needed for index generation.  Conversion of these links to
  651.      * text is done by {@link returnSee()}.
  652.      * 
  653.      * Then it uses {@link generateFormattedClassTrees()} to create class trees from the template file classtrees.html.  Output
  654.      * filename is classtrees_packagename.html.  This function also unsets {@link $elements} and {@link $pkg_elements} to free
  655.      * up the considerable memory these two class vars use
  656.      * @see $page_elements, $class_elements, $function_elements
  657.      */
  658.     function formatLeftIndex()
  659.     {
  660.         phpDocumentor_out("\n");
  661.         flush();
  662.         $this->setTargetDir($this->base_dir);
  663.         if (!isset($this->left))
  664.         {
  665.             debug("Nothing parsed, check the command-line");
  666.             die();
  667.         }
  668.         foreach($this->all_packages as $package => $rest)
  669.         {
  670.             if (!isset($this->pkg_elements[$package])) continue;
  671.             // Create class tree page
  672.             $template = &$this->newSmarty();
  673.             $template->assign("compiledclassindex",$this->getClassLeft());
  674.             $template->assign("compiledfileindex",$this->getPageLeft());
  675.             $template->assign("classtrees",$this->generateFormattedClassTrees($package));
  676.             $template->assign("package",$package);
  677.             $template->assign("date",date("r",time()));
  678.             $template->assign("title","Class Trees for Package $package");
  679.             $template->register_outputfilter('HTMLSmarty_outputfilter');
  680.             $this->writefile("classtrees_$package.html",$template->fetch('classtrees.tpl'));
  681.             phpDocumentor_out("\n");
  682.             flush();
  683.         }
  684.         $this->writeRIC();
  685.         // free up considerable memory
  686.         unset($this->elements);
  687.         unset($this->pkg_elements);
  688.     }
  689.     
  690.     
  691.     /**
  692.      * This function takes an {@link abstractLink} descendant and returns an html link
  693.      *
  694.      * @param abstractLink a descendant of abstractlink should be passed, and never text
  695.      * @param string text to display in the link
  696.      * @param boolean this parameter is not used, and is deprecated
  697.      * @param boolean determines whether the returned text is enclosed in an <a> tag
  698.      */
  699.     function returnSee(&$element, $eltext = false, $with_a = true)
  700.     {
  701.         if (!$element) return false;
  702.         if (!$with_a) return $this->getId($element, false);
  703.         if (!$eltext)
  704.         {
  705.             $eltext = '';
  706.             switch($element->type)
  707.             {
  708.                 case 'tutorial' :
  709.                 $eltext = strip_tags($element->title);
  710.                 break;
  711.                 case 'method' :
  712.                 case 'var' :
  713.                 $eltext .= $element->class.'::';
  714.                 case 'page' :
  715.                 case 'define' :
  716.                 case 'class' :
  717.                 case 'function' :
  718.                 case 'global' :
  719.                 default :
  720.                 $eltext .= $element->name;
  721.                 if ($element->type == 'function' || $element->type == 'method') $eltext .= '()';
  722.                 break;
  723.             }
  724.         }
  725.         return '<a href="'.$this->getId($element).'">'.$eltext.'</a>';
  726.     }
  727.     
  728.     function getId($element, $fullpath = true)
  729.     {
  730.         if (get_class($element) == 'parserdata')
  731.         {
  732.             $element = $this->addLink($element->parent);
  733.             $elp = $element->parent;
  734.         } elseif (is_a($element, 'parserbase'))
  735.         {
  736.             $elp = $element;
  737.             $element = $this->addLink($element);
  738.         }
  739.         $c = '';
  740.         if (!empty($element->subpackage))
  741.         {
  742.             $c = '/'.$element->subpackage;
  743.         }
  744.         $b = '{$subdir}';
  745.         switch ($element->type)
  746.         {
  747.             case 'page' :
  748.             if ($fullpath)
  749.             return $b.$element->package.$c.'/'.$element->fileAlias.'.html';
  750.             return 'top';
  751.             break;
  752.             case 'define' :
  753.             case 'global' :
  754.             case 'function' :
  755.             if ($fullpath)
  756.             return $b.$element->package.$c.'/'.$element->fileAlias.'.html#'.$element->type.$element->name;
  757.             return $element->type.$element->name;
  758.             break;
  759.             case 'class' :
  760.             if ($fullpath)
  761.             return $b.$element->package.$c.'/'.$element->name.'.html';
  762.             return 'top';
  763.             break;
  764.             case 'method' :
  765.             case 'var' :
  766.             if ($fullpath)
  767.             return $b.$element->package.$c.'/'.$element->class.'.html#'.$element->type.$element->name;
  768.             return $element->type.$element->name;
  769.             break;
  770.             case 'tutorial' :
  771.             $d = '';
  772.             if ($element->section)
  773.             {
  774.                 $d = '#'.$element->section;
  775.             }
  776.             return $b.$element->package.$c.'/tutorial_'.$element->name.'.html'.$d;
  777.         }
  778.     }
  779.     
  780.     /**
  781.      * Convert README/INSTALL/CHANGELOG file contents to output format
  782.      * @param README|INSTALL|CHANGELOG
  783.      * @param string contents of the file
  784.      */
  785.     function Convert_RIC($name, $contents)
  786.     {
  787.         $this->ric_contents[$name] = $contents;
  788.         $this->ric_set[] = array('file' => 'ric_'.$name . '.html','name' => $name);
  789.     }
  790.     
  791.     function writeRIC()
  792.     {
  793.         if ($this->_ric_done) return;
  794.         $this->_ric_done = true;
  795.         foreach($this->ric_contents as $name => $contents)
  796.         {
  797.             $template = &$this->newSmarty();
  798.             $template->assign('contents',$contents);
  799.             $template->assign('name',$name);
  800.             $template->assign('title',$name);
  801.             $this->setTargetDir($this->base_dir);
  802.             $this->writefile('ric_'.$name . '.html',$template->fetch('ric.tpl'));
  803.         }
  804.     }
  805.     
  806.     function ConvertTodoList()
  807.     {
  808.         $todolist = array();
  809.         foreach($this->todoList as $package => $alltodos)
  810.         {
  811.             foreach($alltodos as $todos)
  812.             {
  813.                 $converted = array();
  814.                 $converted['link'] = $this->returnSee($todos[0]);
  815.                 if (!is_array($todos[1]))
  816.                 {
  817.                     $converted['todos'][] = $todos[1]->Convert($this);
  818.                 } else
  819.                 {
  820.                     foreach($todos[1] as $todo)
  821.                     {
  822.                         $converted['todos'][] = $todo->Convert($this);
  823.                     }
  824.                 }
  825.                 $todolist[$package][] = $converted;
  826.             }
  827.         }
  828.         $templ = &$this->newSmarty();
  829.         $templ->assign('todos',$todolist);
  830.         $templ->register_outputfilter('HTMLSmarty_outputfilter');
  831.         $this->setTargetDir($this->base_dir);
  832.         $this->writefile('todolist.html',$templ->fetch('todolist.tpl'));
  833.     }
  834.     
  835.     /**
  836.      * Create errors.html template file output
  837.      *
  838.      * This method takes all parsing errors and warnings and spits them out ordered by file and line number.
  839.      * @global ErrorTracker We'll be using it's output facility
  840.      */
  841.     function ConvertErrorLog()
  842.     {
  843.         global $phpDocumentor_errors;
  844.         $allfiles = array();
  845.         $files = array();
  846.         $warnings = $phpDocumentor_errors->returnWarnings();
  847.         $errors = $phpDocumentor_errors->returnErrors();
  848.         $template = &$this->newSmarty();
  849.         foreach($warnings as $warning)
  850.         {
  851.             $file = '##none';
  852.             $linenum = 'Warning';
  853.             if ($warning->file)
  854.             {
  855.                 $file = $warning->file;
  856.                 $allfiles[$file] = 1;
  857.                 $linenum .= ' on line '.$warning->linenum;
  858.             }
  859.             $files[$file]['warnings'][] = array('name' => $linenum, 'listing' => $warning->data);
  860.         }
  861.         foreach($errors as $error)
  862.         {
  863.             $file = '##none';
  864.             $linenum = 'Error';
  865.             if ($error->file)
  866.             {
  867.                 $file = $error->file;
  868.                 $allfiles[$file] = 1;
  869.                 $linenum .= ' on line '.$error->linenum;
  870.             }
  871.             $files[$file]['errors'][] = array('name' => $linenum, 'listing' => $error->data);
  872.         }
  873.         $i=1;
  874.         $af = array();
  875.         foreach($allfiles as $file => $num)
  876.         {
  877.             $af[$i++] = $file;
  878.         }
  879.         $allfiles = $af;
  880.         usort($allfiles,'strnatcasecmp');
  881.         $allfiles[0] = "Post-parsing";
  882.         foreach($allfiles as $i => $a)
  883.         {
  884.             $allfiles[$i] = array('file' => $a);
  885.         }
  886.         $out = array();
  887.         foreach($files as $file => $data)
  888.         {
  889.             if ($file == '##none') $file = 'Post-parsing';
  890.             $out[$file] = $data;
  891.         }
  892.         $template->assign("files",$allfiles);
  893.         $template->assign("all",$out);
  894.         $template->assign("title","phpDocumentor Parser Errors and Warnings");
  895.         $template->register_outputfilter('HTMLSmarty_outputfilter');
  896.         $this->setTargetDir($this->base_dir);
  897.         $this->writefile("errors.html",$template->fetch('errors.tpl'));
  898.         unset($template);
  899.         phpDocumentor_out("\n\nTo view errors and warnings, look at ".$this->base_dir. PATH_DELIMITER . "errors.html\n");
  900.         flush();
  901.     }
  902.     
  903.     function getCData($value)
  904.     {
  905.         return '<pre>'.htmlentities($value).'</pre>';
  906.     }
  907.     
  908.     function getTutorialId($package,$subpackage,$tutorial,$id)
  909.     {
  910.         return $id;
  911.     }
  912.  
  913.     /**
  914.      * Converts package page and sets its package as used in {@link $package_pages}
  915.      * @param parserPackagePage
  916.      */
  917.     function convertPackagepage(&$element)
  918.     {
  919.         phpDocumentor_out("\n");
  920.         flush();
  921.         $template = &$this->newSmarty();
  922.         $this->package = $element->package;
  923.         $this->subpackage = '';
  924.         $template->assign("compiledclassindex",$this->getClassLeft());
  925.         $template->assign("compiledfileindex",$this->getPageLeft());
  926.         $template->assign("tutorials",$this->getTutorialList());
  927.         $template->assign("date",date("r",time()));
  928.         $template->assign("title",$this->title);
  929.         $template->assign("package",$element->package);
  930.         $x = $element->Convert($this);
  931.         $x = substr($x,strpos($x,'<body'));
  932.         $template->assign("contents",trim(substr($x,strpos($x,'>') + 1)));
  933.         $this->package_pages[$element->package] = trim(substr($x,strpos($x,'>') + 1));
  934.         $template->register_outputfilter('HTMLSmarty_outputfilter');
  935.         phpDocumentor_out("\n");
  936.         flush();
  937.         $this->setTargetDir($this->base_dir);
  938.         $this->writefile("li_".$element->package.".html",$template->fetch('index.tpl'));
  939.         unset($template);
  940.     }
  941.     
  942.     /**
  943.      * @param parserTutorial
  944.      */
  945.     function convertTutorial(&$element)
  946.     {
  947.         phpDocumentor_out("\n");
  948.         flush();
  949.         $template = &parent::convertTutorial($element);
  950.         $this->package = $element->package;
  951.         $this->subpackage = $element->subpackage;
  952.         $template->assign("compiledclassindex",$this->getClassLeft());
  953.         $template->assign("compiledfileindex",$this->getPageLeft());
  954.         $template->assign("tutorials",$this->getTutorialList());
  955.         $template->assign("title",strip_tags($element->getTitle($this)));
  956.         $contents = $element->Convert($this);
  957.         if ($element->name == $this->package . '.pkg')
  958.         {
  959.             $this->package_pages[$element->package] = $contents;
  960.         }
  961.         $a = '../';
  962.         if (!empty($element->subpackage)) $a .= $a;
  963.         $template->assign("subdir",$a);
  964.         $a = '';
  965.         if ($element->subpackage) $a = PATH_DELIMITER . $element->subpackage;
  966.         $template->register_outputfilter('HTMLSmarty_outputfilter');
  967.         $this->setTargetDir($this->base_dir . PATH_DELIMITER . $element->package . $a);
  968.         $this->writeFile('tutorial_'.$element->name.'.html',$template->fetch('tutorial.tpl'));
  969.         if ($element->name == $element->package . '.pkg')
  970.         {
  971.             phpDocumentor_out("\n");
  972.             flush();
  973.             // package-level docs
  974.             $this->setTargetDir($this->base_dir);
  975.             $template->assign("subdir",'');
  976.             $this->writeFile('li_'.$element->package.'.html',$template->fetch('tutorial.tpl'));
  977.         }
  978.         unset($template);
  979.     }
  980.  
  981.     /**
  982.      * Converts class for template output
  983.      * @see prepareDocBlock(), generateChildClassList(), generateFormattedClassTree(), getFormattedConflicts()
  984.      * @see getFormattedInheritedMethods(), getFormattedInheritedVars()
  985.      * @param parserClass
  986.      */
  987.     function convertClass(&$element)
  988.     {
  989.         parent::convertClass($element);
  990.         $this->class_dir = $element->docblock->package;
  991.         if (!empty($element->docblock->subpackage)) $this->class_dir .= PATH_DELIMITER . $element->docblock->subpackage;
  992.         $a = '../classtrees_';
  993.         if ($element->docblock->subpackage != '') $a = "../$a";
  994.         
  995.         $this->class_data->assign('subdir',$a);
  996.         $this->class_data->assign("title","Docs For Class " . $element->getName());
  997.         $this->class_data->assign("page",$element->getName() . '.html');
  998.     }
  999.  
  1000.     /**
  1001.      * Converts class variables for template output
  1002.      * @see prepareDocBlock(), getFormattedConflicts()
  1003.      * @param parserDefine
  1004.      */
  1005.     function convertVar(&$element)
  1006.     {
  1007.         parent::convertVar($element, array('var_dest' => $this->getId($element,false)));
  1008.     }
  1009.  
  1010.     /**
  1011.      * Converts class methods for template output
  1012.      * @see prepareDocBlock(), getFormattedConflicts()
  1013.      * @param parserDefine
  1014.      */
  1015.     function convertMethod(&$element)
  1016.     {
  1017.         parent::convertMethod($element, array('method_dest' => $this->getId($element,false)));
  1018.     }
  1019.     
  1020.     /**
  1021.      * Converts function for template output
  1022.      * @see prepareDocBlock(), parserFunction::getFunctionCall(), getFormattedConflicts()
  1023.      * @param parserFunction
  1024.      */
  1025.     function convertFunction(&$element)
  1026.     {
  1027.         $funcloc = $this->getId($this->addLink($element));
  1028.         parent::convertFunction($element,array('function_dest' => $this->getId($element,false)));
  1029.     }
  1030.     
  1031.     /**
  1032.      * Converts include elements for template output
  1033.      * @see prepareDocBlock()
  1034.      * @param parserInclude
  1035.      */
  1036.     function convertInclude(&$element)
  1037.     {
  1038.         parent::convertInclude($element, array('include_file'    => '_'.strtr($element->getValue(),array('"' => '', "'" => '','.' => '_'))));
  1039.     }
  1040.     
  1041.     /**
  1042.      * Converts defines for template output
  1043.      * @see prepareDocBlock(), getFormattedConflicts()
  1044.      * @param parserDefine
  1045.      */
  1046.     function convertDefine(&$element)
  1047.     {
  1048.         parent::convertDefine($element, array('define_link' => $this->getId($element,false)));
  1049.     }
  1050.     
  1051.     /**
  1052.      * Converts global variables for template output
  1053.      * @param parserGlobal
  1054.      * @see prepareDocBlock(), getFormattedConflicts()
  1055.      */
  1056.     function convertGlobal(&$element)
  1057.     {
  1058.         parent::convertGlobal($element, array('global_link' => $this->getId($element,false)));
  1059.     }
  1060.     
  1061.     /**
  1062.      * converts procedural pages for template output
  1063.      * @see prepareDocBlock(), getClassesOnPage()
  1064.      * @param parserData
  1065.      */
  1066.     function convertPage(&$element)
  1067.     {
  1068.         parent::convertPage($element);
  1069.         $this->juststarted = true;
  1070.         $this->page_dir = $element->parent->package;
  1071.         if (!empty($element->parent->subpackage)) $this->page_dir .= PATH_DELIMITER . $element->parent->subpackage;
  1072.         // registering stuff on the template
  1073.         $a = '../';
  1074.         if (!empty($element->docblock->subpackage)) $a = $a . $a;
  1075.         $this->page_data->assign('subdir',$a);
  1076.         $this->page_data->assign("page",$this->getPageName($element) . '.html');
  1077.         $this->page_data->assign("title","Docs for page ".$element->parent->getFile());
  1078.     }
  1079.     
  1080.     function getPageName(&$element)
  1081.     {
  1082.         if (get_class($element) == 'parserpage') return '_'.$element->getName();
  1083.         return '_'.$element->parent->getName();
  1084.     }
  1085.  
  1086.     /**
  1087.      * returns an array containing the class inheritance tree from the root object to the class
  1088.      *
  1089.      * @param parserClass    class variable
  1090.      * @return array Format: array(root,child,child,child,...,$class)
  1091.      * @uses parserClass::getParentClassTree()
  1092.      */
  1093.     
  1094.     function generateFormattedClassTree($class)
  1095.     {
  1096.         $tree = $class->getParentClassTree($this);
  1097.         $out = '';
  1098.         if (count($tree) - 1)
  1099.         {
  1100.             $result = array($class->getName());
  1101.             $parent = $tree[$class->getName()];
  1102.             $distance[] = '';
  1103.             while ($parent)
  1104.             {
  1105.                 $subpackage = $parent->docblock->subpackage;
  1106.                 $package = $parent->docblock->package;
  1107.                 $x = $parent;
  1108.                 if (is_object($parent))
  1109.                 $x = $parent->getLink($this);
  1110.                 if (!$x) $x = $parent->getName();
  1111.                 $result[] = 
  1112.                     $x;
  1113.                 $distance[] =
  1114.                     "\n%s|\n" .
  1115.                     "%s--";
  1116.                 if (is_object($parent))
  1117.                 $parent = $tree[$parent->getName()];
  1118.                 elseif (isset($tree[$parent]))
  1119.                 $parent = $tree[$parent];
  1120.             }
  1121.             $nbsp = '   ';
  1122.             for($i=count($result) - 1;$i>=0;$i--)
  1123.             {
  1124.                 $my_nbsp = '';
  1125.                 for($j=0;$j<count($result) - $i;$j++) $my_nbsp .= $nbsp;
  1126.                 $distance[$i] = sprintf($distance[$i],$my_nbsp,$my_nbsp);
  1127.             }
  1128.             return array('classes'=>array_reverse($result),'distance'=>array_reverse($distance));
  1129.         } else
  1130.         {
  1131.             return array('classes'=>$class->getName(),'distance'=>array(''));
  1132.         }
  1133.     }
  1134.     
  1135.     /** @access private */
  1136.     function sortVar($a, $b)
  1137.     {
  1138.         return strnatcasecmp($a->getName(),$b->getName());
  1139.     }
  1140.     
  1141.     /** @access private */
  1142.     function sortMethod($a, $b)
  1143.     {
  1144.         if ($a->isConstructor) return -1;
  1145.         if ($b->isConstructor) return 1;
  1146.         return strnatcasecmp($a->getName(),$b->getName());
  1147.     }
  1148.  
  1149.     /**
  1150.      * returns a template-enabled array of class trees
  1151.      * 
  1152.      * @param    string    $package    package to generate a class tree for
  1153.      * @see $roots, HTMLConverter::getRootTree()
  1154.      */
  1155.     function generateFormattedClassTrees($package)
  1156.     {
  1157.         if (!isset($this->roots[$package])) return array();
  1158.         $roots = $trees = array();
  1159.         $roots = $this->roots[$package];
  1160.         for($i=0;$i<count($roots);$i++)
  1161.         {
  1162.             $trees[] = array('class' => $roots[$i],'class_tree' => "<ul>\n".$this->getRootTree($this->getSortedClassTreeFromClass($roots[$i],$package,''),$package)."</ul>\n");
  1163.         }
  1164.         return $trees;
  1165.     }
  1166.     
  1167.     /**
  1168.      * return formatted class tree for the Class Trees page
  1169.      *
  1170.      * @param array $tree output from {@link getSortedClassTreeFromClass()}
  1171.      * @see Classes::$definitechild, generateFormattedClassTrees()
  1172.      * @return string
  1173.      */
  1174.     function getRootTree($tree,$package)
  1175.     {
  1176.         if (!$tree) return '';
  1177.         $my_tree = '';
  1178.         $cur = '#root';
  1179.         $lastcur = array(false);
  1180.         $kids = array();
  1181.         $dopar = false;
  1182.         if ($tree[$cur]['parent'])
  1183.         {
  1184.             $dopar = true;
  1185.             if (!is_object($tree[$cur]['parent']))
  1186.             {
  1187. //                debug("parent ".$tree[$cur]['parent']." not found");
  1188.                 $my_tree .= '<li>' . $tree[$cur]['parent'] .'<ul>';
  1189.             }
  1190.             else
  1191.             {
  1192. //                        debug("parent ".$this->returnSee($tree[$cur]['parent'])." in other package");
  1193.                 $my_tree .= '<li>' . $this->returnSee($tree[$cur]['parent']);
  1194.                 if ($tree[$cur]['parent']->package != $package) $my_tree .= ' <b>(Different package)</b><ul>';
  1195.             }
  1196.         }
  1197.         do
  1198.         {
  1199. //            fancy_debug($cur,$lastcur,$kids);
  1200.             if (count($tree[$cur]['children']))
  1201.             {
  1202. //                debug("$cur has children");
  1203.                 if (!isset($kids[$cur]))
  1204.                 {
  1205. //                    debug("set $cur kids");
  1206.                     $kids[$cur] = 1;
  1207.                     $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link']);
  1208.                     $my_tree .= '<ul>'."\n";
  1209.                 }
  1210.                 array_push($lastcur,$cur);
  1211.                 list(,$cur) = each($tree[$cur]['children']);
  1212. //                var_dump('listed',$cur);
  1213.                 if ($cur)
  1214.                 {
  1215.                     $cur = $cur['package'] . '#' . $cur['class'];
  1216. //                    debug("set cur to child $cur");
  1217. //                    $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link']);
  1218.                     continue;
  1219.                 } else
  1220.                 {
  1221. //                    debug("end of children for $cur");
  1222.                     $cur = array_pop($lastcur);
  1223.                     $cur = array_pop($lastcur);
  1224.                     $my_tree .= '</ul></li>'."\n";
  1225.                     if ($dopar && ($cur == '#root' || !$cur)) $my_tree .= '</ul></li>';
  1226.                 }
  1227.             } else 
  1228.             {
  1229. //                debug("$cur has no children");
  1230.                 $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link'])."</li>";
  1231.                 if ($dopar && $cur == '#root') $my_tree .= '</ul></li>';
  1232.                 $cur = array_pop($lastcur);
  1233.             }
  1234.         } while ($cur);
  1235.         return $my_tree;
  1236.     }
  1237.     /**
  1238.      * Generate alphabetical index of all elements
  1239.      *
  1240.      * @see $elements, walk()
  1241.      */
  1242.     function generateElementIndex()
  1243.     {
  1244.         $elementindex = array();
  1245.         $letters = array();
  1246.         $i = 0;
  1247.         foreach($this->elements as $letter => $nutoh)
  1248.         {
  1249.             $letters[]['letter'] = $letter;
  1250.             $elindex['letter'] = $letter;
  1251.             foreach($this->elements[$letter] as $i => $yuh)
  1252.             {
  1253.                 switch($this->elements[$letter][$i]->type)
  1254.                 {
  1255.                     case 'class':
  1256.                         $aa = '';
  1257.                         $aa = $this->elements[$letter][$i]->docblock->getSDesc($this);
  1258.                         if (!empty($aa)) $aa = "<br>    $aa";
  1259.                         $oo['name'] = $this->elements[$letter][$i]->getName();
  1260.                         $oo['listing'] =
  1261.                             'in file '.$this->elements[$letter][$i]->file.', class '.$this->getClassLink($this->elements[$letter][$i]->getName(),
  1262.                                                 $this->elements[$letter][$i]->docblock->package,
  1263.                                                 $this->elements[$letter][$i]->getPath(),
  1264.                                                 $this->elements[$letter][$i]->getName())."$aa";
  1265.                         $elindex['index'][] = $oo; 
  1266.                     break;
  1267.                     case 'define':
  1268.                         $aa = '';
  1269.                         $aa = $this->elements[$letter][$i]->docblock->getSDesc($this);
  1270.                         if (!empty($aa)) $aa = "<br>    $aa";
  1271.                         $oo['name'] = $this->elements[$letter][$i]->getName();
  1272.                         $oo['listing'] =
  1273.                             'in file '.$this->elements[$letter][$i]->file.', constant '.$this->getDefineLink($this->elements[$letter][$i]->getName(),
  1274.                                                  $this->elements[$letter][$i]->docblock->package,
  1275.                                                  $this->elements[$letter][$i]->getPath(),
  1276.                                                  $this->elements[$letter][$i]->getName())."$aa";
  1277.                         $elindex['index'][] = $oo; 
  1278.                     break;
  1279.                     case 'global':
  1280.                         $aa = '';
  1281.                         $aa = $this->elements[$letter][$i]->docblock->getSDesc($this);
  1282.                         if (!empty($aa)) $aa = "<br>    $aa";
  1283.                         $oo['name'] = $this->elements[$letter][$i]->getName();
  1284.                         $oo['listing'] =
  1285.                             'in file '.$this->elements[$letter][$i]->file.', global variable '.$this->getGlobalLink($this->elements[$letter][$i]->getName(),
  1286.                                                  $this->elements[$letter][$i]->docblock->package,
  1287.                                                  $this->elements[$letter][$i]->getPath(),
  1288.                                                  $this->elements[$letter][$i]->getName())."$aa";
  1289.                         $elindex['index'][] = $oo; 
  1290.                     break;
  1291.                     case 'function':
  1292.                         $aa = '';
  1293.                         $aa = $this->elements[$letter][$i]->docblock->getSDesc($this);
  1294.                         if (!empty($aa)) $aa = "<br>    $aa";
  1295.                         $oo['name'] = $this->elements[$letter][$i]->getName();
  1296.                         $oo['listing'] =
  1297.                             'in file '.$this->elements[$letter][$i]->file.', function '.$this->getFunctionLink($this->elements[$letter][$i]->getName(),
  1298.                                                    $this->elements[$letter][$i]->docblock->package,
  1299.                                                    $this->elements[$letter][$i]->getPath(),
  1300.                                                    $this->elements[$letter][$i]->getName().'()')."$aa";
  1301.                         $elindex['index'][] = $oo; 
  1302.                     break;
  1303.                     case 'method':
  1304.                         $aa = '';
  1305.                         $aa = $this->elements[$letter][$i]->docblock->getSDesc($this);
  1306.                         if (!empty($aa)) $aa = "<br>    $aa";
  1307.                         $oo['name'] = $this->elements[$letter][$i]->getName();
  1308.                         $oo['listing'] =
  1309.                             'in file '.$this->elements[$letter][$i]->file.', method '.$this->getMethodLink($this->elements[$letter][$i]->getName(),
  1310.                                                  $this->elements[$letter][$i]->class,
  1311.                                                  $this->elements[$letter][$i]->docblock->package,
  1312.                                                  $this->elements[$letter][$i]->getPath(),
  1313.                                                  $this->elements[$letter][$i]->class.'::'.$this->elements[$letter][$i]->getName().'()'
  1314.                                                  )."$aa";
  1315.                         $elindex['index'][] = $oo; 
  1316.                     break;
  1317.                     case 'var':
  1318.                         $aa = '';
  1319.                         $aa = $this->elements[$letter][$i]->docblock->getSDesc($this);
  1320.                         if (!empty($aa)) $aa = "<br>    $aa";
  1321.                         $oo['name'] = $this->elements[$letter][$i]->getName();
  1322.                         $oo['listing'] =
  1323.                             'in file '.$this->elements[$letter][$i]->file.', variable '.$this->getVarLink($this->elements[$letter][$i]->getName(),
  1324.                                               $this->elements[$letter][$i]->class,
  1325.                                               $this->elements[$letter][$i]->docblock->package,
  1326.                                               $this->elements[$letter][$i]->getPath(),
  1327.                                               $this->elements[$letter][$i]->class.'::'.$this->elements[$letter][$i]->getName()
  1328.                                               )."$aa";
  1329.                         $elindex['index'][] = $oo; 
  1330.                     break;
  1331.                     case 'page':
  1332.                         $oo['name'] = $this->elements[$letter][$i]->getFile();
  1333.                         $oo['listing'] =
  1334.                             'procedural page '.$this->getPageLink($this->elements[$letter][$i]->getFile(),
  1335.                                                $this->elements[$letter][$i]->package,
  1336.                                                $this->elements[$letter][$i]->getPath(),
  1337.                                                $this->elements[$letter][$i]->getFile());
  1338.                         $elindex['index'][] = $oo; 
  1339.                     break;
  1340.                 }
  1341.             }
  1342.             if (isset($elindex['index']))
  1343.             {
  1344.                 $elementindex[] = $elindex;
  1345.             } else
  1346.             {
  1347.                 unset($letters[count($letters) - 1]);
  1348.             }
  1349.             $elindex = array();
  1350.         }
  1351.         return array($elementindex,$letters);
  1352.     }
  1353.     
  1354.     function copyMediaRecursively($media,$targetdir,$subdir = '')
  1355.     {
  1356.         foreach($media as $dir => $files)
  1357.         {
  1358.             if ($dir === '/')
  1359.             {
  1360.                 $this->copyMediaRecursively($files,$targetdir);
  1361.             } else
  1362.             {
  1363.                 if (!is_numeric($dir))
  1364.                 {
  1365.                     // create the subdir
  1366.                     phpDocumentor_out("creating $targetdir/$dir\n");
  1367.                     Converter::setTargetDir($targetdir . PATH_DELIMITER . $dir);
  1368.                     if (!empty($subdir)) $subdir .= PATH_DELIMITER;
  1369.                     $this->copyMediaRecursively($files,"$targetdir/$dir",$subdir . $dir);
  1370.                 } else
  1371.                 {
  1372.                     // copy the file
  1373.                     phpDocumentor_out("copying $targetdir/".$files['file']."\n");
  1374.                     $this->copyFile($files['file'],$subdir);
  1375.                 }
  1376.             }
  1377.         }
  1378.     }
  1379.     
  1380.     /**
  1381.      * calls the converter setTargetDir, and then copies any template images and the stylesheet if they haven't been copied
  1382.      * @see Converter::setTargetDir()
  1383.      */
  1384.     function setTargetDir($dir)
  1385.     {
  1386.         Converter::setTargetDir($dir);
  1387.         if ($this->_wrote_tdir) return;
  1388.         $this->_wrote_tdir = true;
  1389.         $template_images = array();
  1390.         $stylesheets = array();
  1391.         $tdir = $dir;
  1392.         $dir = $this->templateDir;
  1393.         $this->templateDir = $this->templateDir.'templates/';
  1394.         $info = new Io;
  1395.         $this->copyMediaRecursively($info->getDirTree($this->templateDir.'media',$this->templateDir),$tdir);
  1396.     }
  1397.     
  1398.     /**
  1399.      * Generate alphabetical index of all elements by package and subpackage
  1400.      *
  1401.      * @param string $package name of a package
  1402.      * @see $pkg_elements, walk(), generatePkgElementIndexes()
  1403.      */
  1404.     function generatePkgElementIndex($package)
  1405.     {
  1406.         $elementindex = array();
  1407.         $letters = array();
  1408.         $letterind = array();
  1409.         $used = array();
  1410.         $subp = '';
  1411.         foreach($this->pkg_elements[$package] as $subpackage => $els)
  1412.         {
  1413.             if (empty($els)) continue;
  1414.             if (!empty($subpackage)) $subp = " (<b>subpackage:</b> $subpackage)"; else $subp = '';
  1415.             foreach($els as $letter => $yuh)
  1416.             {
  1417.                 if (!isset($used[$letter]))
  1418.                 {
  1419.                     $letters[]['letter'] = $letter;
  1420.                     $letterind[$letter] = count($letters) - 1;
  1421.                     $used[$letter] = 1;
  1422.                 }
  1423.                 $elindex[$letter]['letter'] = $letter;
  1424.                 foreach($els[$letter] as $i => $yuh)
  1425.                 {
  1426.                     switch($els[$letter][$i]->type)
  1427.                     {
  1428.                         case 'class':
  1429.                             $aa = '';
  1430.                             $aa = $els[$letter][$i]->docblock->getSDesc($this);
  1431.                             if (!empty($aa)) $aa = "<br>    $aa";
  1432.                             $oo['name'] = $els[$letter][$i]->getName();
  1433.                             $oo['listing'] =
  1434.                                 'in file '.$els[$letter][$i]->file.', class '.$this->getClassLink($els[$letter][$i]->getName(),
  1435.                                                     $els[$letter][$i]->docblock->package,
  1436.                                                     $els[$letter][$i]->getPath(),
  1437.                                                     $els[$letter][$i]->getName())."$subp$aa";
  1438.                             $elindex[$letter]['index'][] = $oo; 
  1439.                         break;
  1440.                         case 'define':
  1441.                             $aa = '';
  1442.                             $aa = $els[$letter][$i]->docblock->getSDesc($this);
  1443.                             if (!empty($aa)) $aa = "<br>    $aa";
  1444.                             $oo['name'] = $els[$letter][$i]->getName();
  1445.                             $oo['listing'] =
  1446.                                 'in file '.$els[$letter][$i]->file.', constant '.$this->getDefineLink($els[$letter][$i]->getName(),
  1447.                                                      $els[$letter][$i]->docblock->package,
  1448.                                                      $els[$letter][$i]->getPath(),
  1449.                                                      $els[$letter][$i]->getName())."$subp$aa";
  1450.                             $elindex[$letter]['index'][] = $oo; 
  1451.                         break;
  1452.                         case 'global':
  1453.                             $aa = '';
  1454.                             $aa = $els[$letter][$i]->docblock->getSDesc($this);
  1455.                             if (!empty($aa)) $aa = "<br>    $aa";
  1456.                             $oo['name'] = $els[$letter][$i]->getName();
  1457.                             $oo['listing'] =
  1458.                                 'in file '.$els[$letter][$i]->file.', global variable '.$this->getGlobalLink($els[$letter][$i]->getName(),
  1459.                                                      $els[$letter][$i]->docblock->package, 
  1460.                                                      $els[$letter][$i]->getPath(),
  1461.                                                      $els[$letter][$i]->getName())."$subp$aa";
  1462.                             $elindex[$letter]['index'][] = $oo; 
  1463.                         break;
  1464.                         case 'function':
  1465.                             $aa = '';
  1466.                             $aa = $els[$letter][$i]->docblock->getSDesc($this);
  1467.                             if (!empty($aa)) $aa = "<br>    $aa";
  1468.                             $oo['name'] = $els[$letter][$i]->getName();
  1469.                             $oo['listing'] =
  1470.                                 'in file '.$els[$letter][$i]->file.', function '.$this->getFunctionLink($els[$letter][$i]->getName(),
  1471.                                                        $els[$letter][$i]->docblock->package,
  1472.                                                        $els[$letter][$i]->getPath(),
  1473.                                                        $els[$letter][$i]->getName().'()')."$subp$aa";
  1474.                             $elindex[$letter]['index'][] = $oo; 
  1475.                         break;
  1476.                         case 'method':
  1477.                             $aa = '';
  1478.                             $aa = $els[$letter][$i]->docblock->getSDesc($this);
  1479.                             if (!empty($aa)) $aa = "<br>    $aa";
  1480.                             $oo['name'] = $els[$letter][$i]->getName();
  1481.                             $oo['listing'] =
  1482.                                 'in file '.$els[$letter][$i]->file.', method '.$this->getMethodLink($els[$letter][$i]->getName(),
  1483.                                                      $els[$letter][$i]->class,
  1484.                                                      $els[$letter][$i]->docblock->package, 
  1485.                                                      $els[$letter][$i]->getPath(),
  1486.                                                      $els[$letter][$i]->class.'::'.$els[$letter][$i]->getName().'()')."$subp$aa";
  1487.                             $elindex[$letter]['index'][] = $oo; 
  1488.                         break;
  1489.                         case 'var':
  1490.                             $aa = '';
  1491.                             $aa = $els[$letter][$i]->docblock->getSDesc($this);
  1492.                             if (!empty($aa)) $aa = "<br>    $aa";
  1493.                             $oo['name'] = $els[$letter][$i]->getName();
  1494.                             $oo['listing'] =
  1495.                                 'in file '.$els[$letter][$i]->file.', variable '.$this->getVarLink($els[$letter][$i]->getName(),
  1496.                                                   $els[$letter][$i]->class,
  1497.                                                   $els[$letter][$i]->docblock->package,
  1498.                                                   $els[$letter][$i]->getPath(),
  1499.                                                   $els[$letter][$i]->class.'::'.$els[$letter][$i]->getName())."$subp$aa";
  1500.                             $elindex[$letter]['index'][] = $oo; 
  1501.                         break;
  1502.                         case 'page':
  1503.                             $oo['name'] = $els[$letter][$i]->getFile();
  1504.                             $oo['listing'] =
  1505.                                 'procedural page '.$this->getPageLink($els[$letter][$i]->getFile(),
  1506.                                                    $els[$letter][$i]->package,
  1507.                                                    $els[$letter][$i]->getPath(),
  1508.                                                    $els[$letter][$i]->getFile())."$subp";
  1509.                             $elindex[$letter]['index'][] = $oo; 
  1510.                         break;
  1511.                     }
  1512.                 }
  1513.             }
  1514.         }
  1515.         ksort($elindex);
  1516.         usort($letters,'HTMLSmarty_lettersort');
  1517.         if (isset($elindex))
  1518.         {
  1519.             while(list($letter,$tempel) = each($elindex))
  1520.             {
  1521.                 if (!isset($tempel))
  1522.                 {
  1523.                     unset($letters[$letterind[$tempel['letter']]]);
  1524.                 } else
  1525.                 $elementindex[] = $tempel;
  1526.             }
  1527.         } else $letters = array();
  1528.         return array($elementindex,$letters);
  1529.     }
  1530.     
  1531.     /**
  1532.      *
  1533.      * @see generatePkgElementIndex()
  1534.      */
  1535.     function generatePkgElementIndexes()
  1536.     {
  1537.         $packages = array();
  1538.         $package_names = array();
  1539.         $pkg = array();
  1540.         $letters = array();
  1541.         foreach($this->pkg_elements as $package => $trash)
  1542.         {
  1543.             $pkgs['package'] = $package;
  1544.             $pkg['package'] = $package;
  1545.             list($pkg['pindex'],$letters[$package]) = $this->generatePkgElementIndex($package);
  1546.             if (count($pkg['pindex']))
  1547.             {
  1548.                 $packages[] = $pkg;
  1549.                 $package_names[] = $pkgs;
  1550.             }
  1551.             unset($pkgs);
  1552.             unset($pkg);
  1553.         }
  1554.         foreach($packages as $i => $package)
  1555.         {
  1556.             $pnames = array();
  1557.             for($j=0;$j<count($package_names);$j++)
  1558.             {
  1559.                 if ($package_names[$j]['package'] != $package['package']) $pnames[] = $package_names[$j];
  1560.             }
  1561.             $packages[$i]['packageindexes'] = $pnames;
  1562.         }
  1563.         return array($packages,$package_names,$letters);
  1564.     }
  1565.     
  1566.     /**
  1567.      * @param string name of class
  1568.      * @param string package name
  1569.      * @param string full path to look in (used in index generation)
  1570.      * @param boolean deprecated
  1571.      * @param boolean return just the URL, or enclose it in an html a tag
  1572.      * @return mixed false if not found, or an html a link to the class's documentation
  1573.      * @see parent::getClassLink()
  1574.      */
  1575.     function getClassLink($expr,$package, $file = false,$text = false, $with_a = true)
  1576.     {
  1577.         $a = Converter::getClassLink($expr,$package,$file);
  1578.         if (!$a) return false;
  1579.         return $this->returnSee($a, $text, $with_a);
  1580.     }
  1581.  
  1582.     /**
  1583.      * @param string name of function
  1584.      * @param string package name
  1585.      * @param string full path to look in (used in index generation)
  1586.      * @param boolean deprecated
  1587.      * @param boolean return just the URL, or enclose it in an html a tag
  1588.      * @return mixed false if not found, or an html a link to the function's documentation
  1589.      * @see parent::getFunctionLink()
  1590.      */
  1591.     function getFunctionLink($expr,$package, $file = false,$text = false)
  1592.     {
  1593.         $a = Converter::getFunctionLink($expr,$package,$file);
  1594.         if (!$a) return false;
  1595.         return $this->returnSee($a, $text);
  1596.     }
  1597.  
  1598.     /**
  1599.      * @param string name of define
  1600.      * @param string package name
  1601.      * @param string full path to look in (used in index generation)
  1602.      * @param boolean deprecated
  1603.      * @param boolean return just the URL, or enclose it in an html a tag
  1604.      * @return mixed false if not found, or an html a link to the define's documentation
  1605.      * @see parent::getDefineLink()
  1606.      */
  1607.     function getDefineLink($expr,$package, $file = false,$text = false)
  1608.     {
  1609.         $a = Converter::getDefineLink($expr,$package,$file);
  1610.         if (!$a) return false;
  1611.         return $this->returnSee($a, $text);
  1612.     }
  1613.  
  1614.     /**
  1615.      * @param string name of global variable
  1616.      * @param string package name
  1617.      * @param string full path to look in (used in index generation)
  1618.      * @param boolean deprecated
  1619.      * @param boolean return just the URL, or enclose it in an html a tag
  1620.      * @return mixed false if not found, or an html a link to the global variable's documentation
  1621.      * @see parent::getGlobalLink()
  1622.      */
  1623.     function getGlobalLink($expr,$package, $file = false,$text = false)
  1624.     {
  1625.         $a = Converter::getGlobalLink($expr,$package,$file);
  1626.         if (!$a) return false;
  1627.         return $this->returnSee($a, $text);
  1628.     }
  1629.  
  1630.     /**
  1631.      * @param string name of procedural page
  1632.      * @param string package name
  1633.      * @param string full path to look in (used in index generation)
  1634.      * @param boolean deprecated
  1635.      * @param boolean return just the URL, or enclose it in an html a tag
  1636.      * @return mixed false if not found, or an html a link to the procedural page's documentation
  1637.      * @see parent::getPageLink()
  1638.      */
  1639.     function getPageLink($expr,$package, $path = false,$text = false)
  1640.     {
  1641.         $a = Converter::getPageLink($expr,$package,$path);
  1642.         if (!$a) return false;
  1643.         return $this->returnSee($a, $text);
  1644.     }
  1645.  
  1646.     /**
  1647.      * @param string name of method
  1648.      * @param string class containing method
  1649.      * @param string package name
  1650.      * @param string full path to look in (used in index generation)
  1651.      * @param boolean deprecated
  1652.      * @param boolean return just the URL, or enclose it in an html a tag
  1653.      * @return mixed false if not found, or an html a link to the method's documentation
  1654.      * @see parent::getMethodLink()
  1655.      */
  1656.     function getMethodLink($expr,$class,$package, $file = false,$text = false)
  1657.     {
  1658.         $a = Converter::getMethodLink($expr,$class,$package,$file);
  1659.         if (!$a) return false;
  1660.         return $this->returnSee($a, $text);
  1661.     }
  1662.  
  1663.     /**
  1664.      * @param string name of var
  1665.      * @param string class containing var
  1666.      * @param string package name
  1667.      * @param string full path to look in (used in index generation)
  1668.      * @param boolean deprecated
  1669.      * @param boolean return just the URL, or enclose it in an html a tag
  1670.      * @return mixed false if not found, or an html a link to the var's documentation
  1671.      * @see parent::getVarLink()
  1672.      */
  1673.     function getVarLink($expr,$class,$package, $file = false,$text = false)
  1674.     {
  1675.         $a = Converter::getVarLink($expr,$class,$package,$file);
  1676.         if (!$a) return false;
  1677.         return $this->returnSee($a, $text);
  1678.     }
  1679.     
  1680.     /**
  1681.      * does a nat case sort on the specified second level value of the array
  1682.      *
  1683.      * @param    mixed    $a
  1684.      * @param    mixed    $b
  1685.      * @return    int
  1686.      */
  1687.     function rcNatCmp ($a, $b)
  1688.     {
  1689.         $aa = strtoupper($a[$this->rcnatcmpkey]);
  1690.         $bb = strtoupper($b[$this->rcnatcmpkey]);
  1691.         
  1692.         return strnatcasecmp($aa, $bb);
  1693.     }
  1694.     
  1695.     /**
  1696.      * does a nat case sort on the specified second level value of the array.
  1697.      * this one puts constructors first
  1698.      *
  1699.      * @param    mixed    $a
  1700.      * @param    mixed    $b
  1701.      * @return    int
  1702.      */
  1703.     function rcNatCmp1 ($a, $b)
  1704.     {
  1705.         $aa = strtoupper($a[$this->rcnatcmpkey]);
  1706.         $bb = strtoupper($b[$this->rcnatcmpkey]);
  1707.         
  1708.         if (strpos($aa,'CONSTRUCTOR') === 0)
  1709.         {
  1710.             return -1;
  1711.         }
  1712.         if (strpos($bb,'CONSTRUCTOR') === 0)
  1713.         {
  1714.             return 1;
  1715.         }
  1716.         if (strpos($aa,strtoupper($this->class)) === 0)
  1717.         {
  1718.             return -1;
  1719.         }
  1720.         if (strpos($bb,strtoupper($this->class)) === 0)
  1721.         {
  1722.             return -1;
  1723.         }
  1724.         return strnatcasecmp($aa, $bb);
  1725.     }
  1726.     
  1727.     /**
  1728.      * This function is not used by HTMLdefaultConverter, but is required by Converter
  1729.      */
  1730.     function Output()
  1731.     {
  1732.     }
  1733. }
  1734.  
  1735. /**
  1736.  * @access private
  1737.  * @global string name of the package to set as the first package
  1738.  */
  1739. function HTMLSmarty_pindexcmp($a, $b)
  1740. {
  1741.     global $phpDocumentor_DefaultPackageName;
  1742.     if ($a['title'] == $phpDocumentor_DefaultPackageName) return -1;
  1743.     if ($b['title'] == $phpDocumentor_DefaultPackageName) return 1;
  1744.     return strnatcasecmp($a['title'],$b['title']);
  1745. }
  1746.  
  1747. /** @access private */
  1748. function HTMLSmarty_lettersort($a, $b)
  1749. {
  1750.     return strnatcasecmp($a['letter'],$b['letter']);
  1751. }
  1752.  
  1753. /** @access private */
  1754. function HTMLSmarty_outputfilter($src, &$smarty)
  1755. {
  1756.     return str_replace('{$subdir}',$smarty->_tpl_vars['subdir'],$src);
  1757. }
  1758. ?>
  1759.