Converters
[ class tree: Converters ] [ index: Converters ] [ all elements ]

Source for file Converter.inc

Documentation is available at Converter.inc

  1. <?php
  2. /**
  3.  * Base class for all Converters
  4.  *
  5.  * phpDocumentor :: automatic documentation generator
  6.  * 
  7.  * PHP versions 4 and 5
  8.  *
  9.  * Copyright (c) 2001-2006 Gregory Beaver
  10.  * 
  11.  * LICENSE:
  12.  * 
  13.  * This library is free software; you can redistribute it
  14.  * and/or modify it under the terms of the GNU Lesser General
  15.  * Public License as published by the Free Software Foundation;
  16.  * either version 2.1 of the License, or (at your option) any
  17.  * later version.
  18.  * 
  19.  * This library is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  22.  * Lesser General Public License for more details.
  23.  * 
  24.  * You should have received a copy of the GNU Lesser General Public
  25.  * License along with this library; if not, write to the Free Software
  26.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27.  *
  28.  * @package    Converters
  29.  * @author     Greg Beaver <cellog@php.net>
  30.  * @copyright  2001-2006 Gregory Beaver
  31.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  32.  * @version    CVS: $Id: Converter.inc,v 1.38 2007/04/25 19:02:42 ashnazg Exp $
  33.  * @filesource
  34.  * @link       http://www.phpdoc.org
  35.  * @link       http://pear.php.net/PhpDocumentor
  36.  * @see        parserDocBlock, parserInclude, parserPage, parserClass
  37.  * @see        parserDefine, parserFunction, parserMethod, parserVar
  38.  * @since      1.0rc1
  39.  */
  40. /**
  41.  * Smarty template files
  42.  */
  43. include_once("phpDocumentor/Smarty-2.6.0/libs/Smarty.class.php");
  44. /**
  45.  * Base class for all output converters.
  46.  *
  47.  * The Converter marks the final stage in phpDocumentor.  phpDocumentor works
  48.  * in this order:
  49.  *
  50.  * <pre>Parsing => Intermediate Parsing organization => Conversion to output</pre>
  51.  *
  52.  * A Converter takes output from the {@link phpDocumentor_IntermediateParser} and
  53.  * converts it to output.  With version 1.2, phpDocumentor includes a variety
  54.  * of output converters:
  55.  * <ul>
  56.  *  <li>{@link HTMLframesConverter}</li>
  57.  *  <li>{@link HTMLSmartyConverter}</li>
  58.  *  <li>{@link PDFdefaultConverter}</li>
  59.  *  <li>{@link CHMdefaultConverter}</li>
  60.  *  <li>{@link CSVdia2codeConverter}</li>
  61.  *  <li>{@link XMLDocBookConverter}</li>
  62.  * </ul>
  63.  * {@internal 
  64.  * The converter takes output directly from {@link phpDocumentor_IntermediateParser}
  65.  * and using {@link walk()} or {@link walk_everything} (depending on the value of
  66.  * {@link $sort_absolutely_everything}) it "walks" over an array of phpDocumentor elements.}}}
  67.  *
  68.  * @package Converters
  69.  * @abstract
  70.  * @author Greg Beaver <cellog@php.net>
  71.  * @since 1.0rc1
  72.  * @version $Id: Converter.inc,v 1.38 2007/04/25 19:02:42 ashnazg Exp $
  73.  */
  74. class Converter
  75. {
  76.     /**
  77.      * This converter knows about the new root tree processing
  78.      * In order to fix PEAR Bug #6389
  79.      * @var boolean 
  80.      */
  81.     var $processSpecialRoots = false;
  82.     /**
  83.      * output format of this converter
  84.      *
  85.      * in Child converters, this will match the first part of the -o command-line
  86.      * as in -o HTML:frames:default "HTML"
  87.      * @tutorial phpDocumentor.howto.pkg#using.command-line.output
  88.      * @var string 
  89.      */
  90.     var $outputformat = 'Generic';
  91.     /**
  92.      * package name currently being converted
  93.      * @var string 
  94.      */
  95.     var $package = 'default';
  96.     /**
  97.      * subpackage name currently being converted
  98.      * @var string 
  99.      */
  100.     var $subpackage = '';
  101.     /**
  102.      * set to a classname if currently parsing a class, false if not
  103.      * @var string|false
  104.      */
  105.     var $class = false;
  106.     /**#@+
  107.      * @access private
  108.      */
  109.     /**
  110.      * the workhorse of linking.
  111.      *
  112.      * This array is an array of link objects of format:
  113.      * [package][subpackage][eltype][elname] = descendant of {@link abstractLink}
  114.      * eltype can be page|function|define|class|method|var
  115.      * if eltype is method or var, the array format is:
  116.      * [package][subpackage][eltype][class][elname]
  117.      * @var array 
  118.      * @see functionLink, pageLink, classLink, defineLink, methodLink, varLink, globalLink
  119.      */
  120.     var $links = array();
  121.  
  122.     /**
  123.      * the workhorse of linking, with allowance for support of multiple
  124.      * elements in different files.
  125.      *
  126.      * This array is an array of link objects of format:
  127.      * [package][subpackage][eltype][file][elname] = descendant of {@link abstractLink}
  128.      * eltype can be function|define|class|method|var
  129.      * if eltype is method or var, the array format is:
  130.      * [package][subpackage][eltype][file][class][elname]
  131.      * @var array 
  132.      * @see functionLink, pageLink, classLink, defineLink, methodLink, varLink, globalLink
  133.     */
  134.     var $linkswithfile = array();
  135.     /**#@-*/
  136.     /**
  137.      * set to value of -po commandline
  138.      * @tutorial phpDocumentor.howto.pkg#using.command-line.packageoutput
  139.      * @var mixed 
  140.      */
  141.     var $package_output;
  142.  
  143.     /**
  144.      * name of current page being converted
  145.      * @var string 
  146.      */
  147.     var $page;
  148.  
  149.     /**
  150.      * path of current page being converted
  151.      * @var string 
  152.      */
  153.     var $path;
  154.  
  155.     /**
  156.      * template for the procedural page currently being processed
  157.      * @var Smarty 
  158.      */
  159.     var $page_data;
  160.  
  161.     /**
  162.      * template for the class currently being processed
  163.      * @var Smarty 
  164.      */
  165.     var $class_data;
  166.  
  167.     /**
  168.      * current procedural page being processed
  169.      * @var parserPage 
  170.      */
  171.     var $curpage;
  172.     /**
  173.      * alphabetical index of all elements sorted by package, subpackage, page,
  174.      * and class.
  175.      * @var array Format: array(package => array(subpackage => array('page'|'class' => array(path|classname => array(element, element,...)))))
  176.      * @uses $sort_absolutely_everything if true, then $package_elements is used,
  177.      *        otherwise, the {@link ParserData::$classelements} and
  178.      *        {@link ParserData::$pageelements} variables are used
  179.      */
  180.     var $package_elements = array();
  181.     /**
  182.      * alphabetical index of all elements
  183.      *
  184.      * @var array Format: array(first letter of element name => array({@link parserElement} or {@link parserPage},...))
  185.      * @see formatIndex(), HTMLframesConverter::formatIndex()
  186.      */
  187.     var $elements = array();
  188.     /**
  189.      * alphabetized index of procedural pages by package
  190.      *
  191.      * @see $leftindex
  192.      * @var array Format: array(package => array(subpackage => array({@link pageLink} 1,{@link pageLink} 2,...)
  193.      */
  194.     var $page_elements = array();
  195.     /**
  196.      * alphabetized index of defines by package
  197.      *
  198.      * @see $leftindex
  199.      * @var array Format: array(package => array(subpackage => array({@link defineLink} 1,{@link defineLink} 2,...)
  200.      */
  201.     var $define_elements = array();
  202.     /**
  203.      * alphabetized index of classes by package
  204.      *
  205.      * @see $leftindex
  206.      * @var array Format: array(package => array(subpackage => array({@link classLink} 1,{@link classLink} 2,...)
  207.      */
  208.     var $class_elements = array();
  209.     /**
  210.      * alphabetized index of global variables by package
  211.      *
  212.      * @see $leftindex
  213.      * @var array Format: array(package => array(subpackage => array({@link globalLink} 1,{@link globalLink} 2,...)
  214.      */
  215.     var $global_elements = array();
  216.     /**
  217.      * alphabetized index of functions by package
  218.      *
  219.      * @see $leftindex
  220.      * @var array Format: array(package => array(subpackage => array({@link functionLink} 1,{@link functionLink} 2,...)
  221.      */
  222.     var $function_elements = array();
  223.     /**
  224.      * alphabetical index of all elements, indexed by package/subpackage
  225.      *
  226.      * @var array Format: array(first letter of element name => array({@link parserElement} or {@link parserPage},...))
  227.      * @see formatPkgIndex(), HTMLframesConverter::formatPkgIndex()
  228.      */
  229.     var $pkg_elements = array();
  230.  
  231.     /**
  232.      * alphabetical index of all elements on a page by package/subpackage
  233.      *
  234.      * The page itself has a link under ###main
  235.      * @var array Format: array(package => array(subpackage => array(path => array({@link abstractLink} descendant 1, ...)))
  236.      * @see formatLeftIndex()
  237.      */
  238.     var $page_contents = array();
  239.  
  240.     /**
  241.      * This determines whether the {@link $page_contents} array should be sorted by element type as well as alphabetically by name
  242.      * @see sortPageContentsByElementType()
  243.      * @var boolean 
  244.      */
  245.     var $sort_page_contents_by_type = false;
  246.     /**
  247.      * This is used if the content must be passed in the order it should be read, i.e. by package, procedural then classes
  248.      *
  249.      * This fixes bug 637921, and is used by {@link PDFdefaultConverter}
  250.      */
  251.     var $sort_absolutely_everything = false;
  252.     /**
  253.      * alphabetical index of all methods and vars in a class by package/subpackage
  254.      *
  255.      * The class itself has a link under ###main
  256.      * @var array 
  257.      *  Format:<pre>
  258.      *  array(package =>
  259.      *        array(subpackage =>
  260.      *              array(path =>
  261.      *                    array(class =>
  262.      *                          array({@link abstractLink} descendant 1, ...
  263.      *                         )
  264.      *                   )
  265.      *             )
  266.      *       )</pre>
  267.      * @see formatLeftIndex()
  268.      */
  269.     var $class_contents = array();
  270.     /**
  271.      * controls processing of elements marked private with @access private
  272.      *
  273.      * defaults to false.  Set with command-line --parseprivate or -pp
  274.      * @var bool 
  275.      */
  276.     var $parseprivate;
  277.     /**
  278.      * controls display of progress information while parsing.
  279.      *
  280.      * defaults to false.  Set to true for cron jobs or other situations where no visual output is necessary
  281.      * @var bool 
  282.      */
  283.     var $quietmode;
  284.  
  285.     /**
  286.      * directory that output is sent to. -t command-line sets this.
  287.      * @tutorial phpDocumentor.howto.pkg#using.command-line.target
  288.      */
  289.     var $targetDir = '';
  290.  
  291.     /**
  292.      * Directory that the template is in, relative to phpDocumentor root directory
  293.      * @var string 
  294.      */
  295.     var $templateDir = '';
  296.  
  297.     /**
  298.      * Directory that the smarty templates are in
  299.      * @var string 
  300.      */
  301.     var $smarty_dir = '';
  302.  
  303.     /**
  304.      * Name of the template, from last part of -o
  305.      * @tutorial phpDocumentor.howto.pkg#using.command-line.output
  306.      * @var string 
  307.      */
  308.     var $templateName = '';
  309.  
  310.     /**
  311.      * full path of the current file being converted
  312.      */
  313.     var $curfile;
  314.  
  315.     /**
  316.      * All class information, organized by path, and by package
  317.      * @var Classes 
  318.      */
  319.     var $classes;
  320.  
  321.     /**
  322.      * Flag used to help converters determine whether to do special source highlighting
  323.      * @var boolean 
  324.      */
  325.     var $highlightingSource = false;
  326.  
  327.     /**
  328.      * Hierarchy of packages
  329.      *
  330.      * Every package that contains classes may have parent or child classes
  331.      * in other packages.  In other words, this code is legal:
  332.      *
  333.      * <code>
  334.      * /**
  335.      *  * @package one
  336.      *  * /
  337.      * class one {}
  338.      *
  339.      * /**
  340.      *  * @package two
  341.      *  * /
  342.      * class two extends one {}
  343.      * </code>
  344.      *
  345.      * In this case, package one is a parent of package two
  346.      * @var array 
  347.      * @see phpDocumentor_IntermediateParser::$package_parents
  348.      */
  349.     var $package_parents;
  350.  
  351.     /**
  352.      * Packages associated with categories
  353.      *
  354.      * Used by the XML:DocBook/peardoc2 converter, and available to others, to
  355.      * group many packages into categories
  356.      * @see phpDocumentor_IntermediateParser::$packagecategories
  357.      * @var array 
  358.      */
  359.     var $packagecategories;
  360.  
  361.     /**
  362.      * All packages encountered in parsing
  363.      * @var array 
  364.      * @see phpDocumentor_IntermediateParser::$all_packages
  365.      */
  366.     var $all_packages;
  367.  
  368.     /**
  369.      * A list of files that have had source code generated
  370.      * @var array 
  371.      */
  372.     var $sourcePaths = array();
  373.  
  374.     /**
  375.      * Controls which of the one-element-only indexes are generated.
  376.      *
  377.      * Generation of these indexes for large packages is time-consuming.  This is an optimization feature.  An
  378.      * example of how to use this is in {@link HTMLframesConverter::$leftindex}, and in {@link HTMLframesConverter::formatLeftIndex()}.
  379.      * These indexes are intended for use as navigational aids through documentation, but can be used for anything by converters.
  380.      * @see $class_elements, $page_elements, $function_elements, $define_elements, $global_elements
  381.      * @see formatLeftIndex()
  382.      * @var array 
  383.      */
  384.     var $leftindex = array('classes' => true'pages' => true'functions' => true'defines' => true'globals' => true);
  385.  
  386.     /** @access private */
  387.     var $killclass = false;
  388.     /**
  389.      * @var string 
  390.      * @see phpDocumentor_IntermediateParser::$title
  391.      */
  392.     var $title = 'Generated Documentation';
  393.  
  394.     /**
  395.      * Options for each template, parsed from the options.ini file in the template base directory
  396.      * @tutorial phpDocumentor/tutorials.pkg#conversion.ppage
  397.      * @var array 
  398.      */
  399.     var $template_options;
  400.  
  401.     /**
  402.      * Tutorials and Extended Documentation parsed from a tutorials/package[/subpackage] directory
  403.      * @tutorial tutorials.pkg
  404.      * @access private
  405.      */
  406.     var $tutorials = array();
  407.  
  408.     /**
  409.      * tree-format structure of tutorials and their child tutorials, if any
  410.      * @var array 
  411.      * @access private
  412.      */
  413.     var $tutorial_tree = false;
  414.  
  415.     /**
  416.      * list of tutorials that have already been processed. Used by @link _setupTutorialTree()
  417.      * @var array 
  418.      * @access private
  419.      */
  420.     var $processed_tutorials;
  421.  
  422.     /**
  423.      * List of all @todo tags and a link to the element with the @todo
  424.      *
  425.      * Format: array(package => array(link to element, array(todo {@link parserTag},...)),...)
  426.      * @tutorial tags.todo.pkg
  427.      * @var array 
  428.      */
  429.     var $todoList = array();
  430.  
  431.     /**
  432.      * Directory where compiled templates go - will be deleted on exit
  433.      *
  434.      * @var string 
  435.      * @access private
  436.      */
  437.      var $_compiledDir = array();
  438.  
  439.     /**
  440.      * Initialize Converter data structures
  441.      * @param array {@link $all_packages} value
  442.      * @param array {@link $package_parents} value
  443.      * @param Classes {@link $classes} value
  444.      * @param ProceduralPages {@link $proceduralpages} value
  445.      * @param array {@link $package_output} value
  446.      * @param boolean {@link $parseprivate} value
  447.      * @param boolean {@link $quietmode} value
  448.      * @param string {@link $targetDir} value
  449.      * @param string {@link $templateDir} value
  450.      * @param string (@link $title} value
  451.      */
  452.     function Converter(&$allp&$packp&$classes&$procpages$po$pp$qm$targetDir$template$title)
  453.     {
  454.         $this->all_packages = $allp;
  455.         $this->package_parents = $packp;
  456.         $this->package = $GLOBALS['phpDocumentor_DefaultPackageName'];
  457.         $this->proceduralpages &$procpages;
  458.         $this->package_output = $po;
  459.         if (is_array($po))
  460.         {
  461.             $a $po[0];
  462.             $this->all_packages = array_flip($po);
  463.             $this->all_packages[$a= 1;
  464.         }
  465.         $this->parseprivate = $pp;
  466.         $this->quietmode = $qm;
  467.         $this->classes = &$classes;
  468.         $this->roots $classes->getRoots($this->processSpecialRoots);
  469.         $this->title = $title;
  470.         $this->setTemplateDir($template);
  471.         $this->setTargetdir($targetDir);
  472.     }
  473.  
  474.     /**
  475.      * Called by IntermediateParser after creation
  476.      * @access private
  477.      */
  478.     function setTutorials($tutorials)
  479.     {
  480.         $this->tutorials $tutorials;
  481.     }
  482.  
  483.     /**
  484.      * @param pkg|cls|procthe tutorial type to search for
  485.      * @param tutorial name
  486.      * @param string package name
  487.      * @param string subpackage name, if any
  488.      * @return false|parserTutorialif the tutorial exists, return it
  489.      */
  490.     function hasTutorial($type$name$package$subpackage '')
  491.     {
  492.         if (isset($this->tutorials[$package][$subpackage][$type][$name '.' $type]))
  493.             return $this->tutorials[$package][$subpackage][$type][$name '.' $type];
  494.         return false;
  495.     }
  496.  
  497.     /**
  498.      * Called by {@link walk()} while converting, when the last class element
  499.      * has been parsed.
  500.      *
  501.      * A Converter can use this method in any way it pleases. HTMLframesConverter
  502.      * uses it to complete the template for the class and to output its
  503.      * documentation
  504.      * @see HTMLframesConverter::endClass()
  505.      * @abstract
  506.      */
  507.     function endClass()
  508.     {
  509.     }
  510.  
  511.     /**
  512.     * Called by {@link walk()} while converting, when the last procedural page
  513.     * element has been parsed.
  514.     *
  515.     * A Converter can use this method in any way it pleases. HTMLframesConverter
  516.     * uses it to complete the template for the procedural page and to output its
  517.     * documentation
  518.     * @see HTMLframesConverter::endClass()
  519.     * @abstract
  520.     */
  521.     function endPage()
  522.     {
  523.     }
  524.  
  525.     /**
  526.     * Called by {@link walk()} while converting.
  527.     *
  528.     * This method is intended to be the place that {@link $pkg_elements} is
  529.     * formatted for output.
  530.     * @see HTMLframesConverter::formatPkgIndex()
  531.     * @abstract
  532.     */
  533.     function formatPkgIndex()
  534.     {
  535.     }
  536.  
  537.     /**
  538.     * Called by {@link walk()} while converting.
  539.     *
  540.     * This method is intended to be the place that {@link $elements} is
  541.     * formatted for output.
  542.     * @see HTMLframesConverter::formatIndex()
  543.     * @abstract
  544.     */
  545.     function formatIndex()
  546.     {
  547.     }
  548.  
  549.     /**
  550.     * Called by {@link walk()} while converting.
  551.     *
  552.     * This method is intended to be the place that any of
  553.     * {@link $class_elements, $function_elements, $page_elements},
  554.     * {@link $define_elements}, and {@link $global_elements} is formatted for
  555.     * output, depending on the value of {@link $leftindex}
  556.     * @see HTMLframesConverter::formatLeftIndex()
  557.     * @abstract
  558.     */
  559.     function formatLeftIndex()
  560.     {
  561.     }
  562.  
  563.     /**
  564.      * Called by {@link parserSourceInlineTag::stringConvert()} to allow
  565.      * converters to format the source code the way they'd like.
  566.      *
  567.      * default returns it unchanged (html with xhtml tags)
  568.      * @param string output from highlight_string() - use this function to
  569.      *  reformat the returned data for Converter-specific output
  570.      * @return string 
  571.      * @deprecated in favor of tokenizer-based highlighting.  This will be
  572.      *              removed for 2.0
  573.      */
  574.     function unmangle($sourcecode)
  575.     {
  576.         return $sourcecode;
  577.     }
  578.  
  579.     /**
  580.      * Initialize highlight caching
  581.      */
  582.     function startHighlight()
  583.     {
  584.         $this->_highlightCache = array(falsefalse);
  585.         $this->_appendHighlight '';
  586.     }
  587.  
  588.     function getHighlightState()
  589.     {
  590.         return $this->_highlightCache;
  591.     }
  592.  
  593.     function _setHighlightCache($type$token)
  594.     {
  595.         $test ($this->_highlightCache[0=== $type && $this->_highlightCache[1== $token);
  596.         if (!$test{
  597.             $this->_appendHighlight $this->flushHighlightCache();
  598.         else {
  599.             $this->_appendHighlight '';
  600.         }
  601.         $this->_highlightCache = array($type$token);
  602.         return $test;
  603.     }
  604.  
  605.     /**
  606.      * Return the close text for the current token
  607.      * @return string 
  608.      */
  609.     function flushHighlightCache()
  610.     {
  611.         $hc $this->_highlightCache;
  612.         $this->_highlightCache = array(falsefalse);
  613.         if ($hc[0]{
  614.             if (!isset($this->template_options[$hc[0]]['/'.$hc[1]])) {
  615.                 return '';
  616.             }
  617.             return $this->template_options[$hc[0]]['/'.$hc[1]];
  618.         }
  619.         return '';
  620.     }
  621.  
  622.     /**
  623.      * Used to allow converters to format the source code the way they'd like.
  624.      *
  625.      * default returns it unchanged.  Mainly used by the {@link HighlightParser}
  626.      * {@internal 
  627.      * The method takes information from options.ini, the template options
  628.      * file, specifically the [highlightSourceTokens] and [highlightSource]
  629.      * sections, and uses them to enclose tokens.
  630.      *
  631.      * {@source } }
  632.      * @param integer token value from {@link PHP_MANUAL#tokenizer tokenizer constants}
  633.      * @param string contents of token
  634.      * @param boolean whether the contents are preformatted or need modification
  635.      * @return string 
  636.      */
  637.     function highlightSource($token$word$preformatted = false)
  638.     {
  639.         if ($token !== false)
  640.         {
  641.             if (!$preformatted$word $this->postProcess($word);
  642.             if (isset($this->template_options['highlightSourceTokens'][token_name($token)]))
  643.             {
  644.                 if ($this->_setHighlightCache('highlightSourceTokens'token_name($token))) {
  645.                     return $word;
  646.                 }
  647.                 $e $this->_appendHighlight;
  648.                 return $e $this->template_options['highlightSourceTokens'][token_name($token)$word;
  649.             else
  650.             {
  651.                 $this->_setHighlightCache(falsefalse);
  652.                 $e $this->_appendHighlight;
  653.                 return $e $word;
  654.             }
  655.         else
  656.         {
  657.             if (isset($this->template_options['highlightSource'][$word]))
  658.             {
  659.                 $newword ($preformatted $word $this->postProcess($word));
  660.                 if ($this->_setHighlightCache('highlightSource'$word)) {
  661.                     return $newword;
  662.                 }
  663.                 $e $this->_appendHighlight;
  664.                 return $e $this->template_options['highlightSource'][$word$newword;
  665.             else
  666.             {
  667.                 $this->_setHighlightCache(falsefalse);
  668.                 $e $this->_appendHighlight;
  669.                 return $e ($preformatted $word $this->postProcess($word));
  670.             }
  671.         }
  672.     }
  673.  
  674.     /**
  675.      * Used to allow converters to format the source code of DocBlocks the way
  676.      * they'd like.
  677.      *
  678.      * default returns it unchanged.  Mainly used by the {@link HighlightParser}
  679.      * {@internal 
  680.      * The method takes information from options.ini, the template options
  681.      * file, specifically the [highlightDocBlockSourceTokens] section, and uses
  682.      * it to enclose tokens.
  683.      *
  684.      * {@source } }
  685.      * @param string name of docblock token type
  686.      * @param string contents of token
  687.      * @param boolean whether the contents are preformatted or need modification
  688.      * @return string 
  689.      */
  690.     function highlightDocBlockSource($token$word$preformatted = false)
  691.     {
  692.         if (empty($word)) {
  693.             $this->_setHighlightCache(falsefalse);
  694.             $e $this->_appendHighlight;
  695.             return $e $word;
  696.         }
  697.         if (isset($this->template_options['highlightDocBlockSourceTokens'][$token]))
  698.         {
  699.             if (!$preformatted$word $this->postProcess($word);
  700.             if ($this->_setHighlightCache('highlightDocBlockSourceTokens'$token)) {
  701.                 return $word;
  702.             }
  703.             $e $this->_appendHighlight;
  704.             return $e $this->template_options['highlightDocBlockSourceTokens'][$token$word;
  705.         else {
  706.             $this->_setHighlightCache(falsefalse);
  707.             $e $this->_appendHighlight;
  708.             return $e ($preformatted $word $this->postProcess($word));
  709.         }
  710.     }
  711.  
  712.     /**
  713.      * Used to allow converters to format the source code of Tutorial XML the way
  714.      * they'd like.
  715.      *
  716.      * default returns it unchanged.  Mainly used by the {@link HighlightParser}
  717.      * {@internal 
  718.      * The method takes information from options.ini, the template options
  719.      * file, specifically the [highlightDocBlockSourceTokens] section, and uses
  720.      * it to enclose tokens.
  721.      *
  722.      * {@source } }
  723.      * @param string name of docblock token type
  724.      * @param string contents of token
  725.      * @param boolean whether the contents are preformatted or need modification
  726.      * @return string 
  727.      */
  728.     function highlightTutorialSource($token$word$preformatted = false)
  729.     {
  730.         if (empty($word)) {
  731.             $this->_setHighlightCache(falsefalse);
  732.             $e $this->_appendHighlight;
  733.             return $e $word;
  734.         }
  735.         if (isset($this->template_options['highlightTutorialSourceTokens'][$token]))
  736.         {
  737.             if (!$preformatted$word $this->postProcess($word);
  738.             if ($this->_setHighlightCache('highlightTutorialSourceTokens'$token)) {
  739.                 return $word;
  740.             }
  741.             $e $this->_appendHighlight;
  742.             return $e $this->template_options['highlightTutorialSourceTokens'][$token$word;
  743.         else {
  744.             $this->_setHighlightCache(falsefalse);
  745.             $e $this->_appendHighlight;
  746.             return $e ($preformatted $word $this->postProcess($word));
  747.         }
  748.     }
  749.  
  750.     /**
  751.      * Called by {@link parserReturnTag::Convert()} to allow converters to
  752.      * change type names to desired formatting
  753.      *
  754.      * Used by {@link XMLDocBookConverter::type_adjust()} to change true and
  755.      * false to the peardoc2 values
  756.      * @param string 
  757.      * @return string 
  758.      */
  759.     function type_adjust($typename)
  760.     {
  761.         return $typename;
  762.     }
  763.  
  764.     /**
  765.      * Used to convert the {@}example} inline tag in a docblock.
  766.      *
  767.      * By default, this just wraps ProgramExample
  768.      * @see XMLDocBookpeardoc2Converter::exampleProgramExample
  769.      * @param string 
  770.      * @param boolean true if this is to highlight a tutorial <programlisting>
  771.      * @return string 
  772.      */
  773.     function exampleProgramExample($example$tutorial = false$inlinesourceparse = null/*false*/,
  774.                             $class = null/*false*/$linenum = null/*false*/$filesourcepath = null/*false*/)
  775.     {
  776.         return $this->ProgramExample($example$tutorial$inlinesourceparse$class$linenum$filesourcepath);
  777.     }
  778.  
  779.     /**
  780.      * Used to convert the <<code>> tag in a docblock
  781.      * @param string 
  782.      * @param boolean true if this is to highlight a tutorial <programlisting>
  783.      * @return string 
  784.      */
  785.     function ProgramExample($example$tutorial = false$inlinesourceparse = null/*false*/,
  786.                             $class = null/*false*/$linenum = null/*false*/$filesourcepath = null/*false*/)
  787.     {
  788.         $this->highlightingSource = true;
  789.         if (tokenizer_ext)
  790.         {
  791.             $e $example;
  792.             if (!is_array($example))
  793.             {
  794.                 $obj = new phpDocumentorTWordParser;
  795.                 $obj->setup($example);
  796.                 $e $obj->getFileSource();
  797.                 $bOpenTagFound = false;
  798.                 foreach ($e as $ke => $ee)
  799.                 {
  800.                     foreach ($ee as $kee => $eee)
  801.                     {
  802.                         if ((int) $e[$ke][$kee][0== T_OPEN_TAG)
  803.                         {
  804.                             $bOpenTagFound = true;
  805.                         }
  806.                     }
  807.                 }
  808.                 if (!$bOpenTagFound{
  809.                     $example "<?php\n".$example;
  810.                     $obj->setup($example);
  811.                     $e $obj->getFileSource();
  812.                     unset($e[0]);
  813.                     $e array_values($e);
  814.                 }
  815.                 unset($obj);
  816.             }
  817.             $saveclass $this->class;
  818.             $parser = new phpDocumentor_HighlightParser;
  819.             if (!isset($inlinesourceparse))
  820.             {
  821.                 $example $parser->parse($e$thistrue)// force php mode
  822.             else
  823.             {
  824.                 if (isset($filesourcepath))
  825.                 {
  826.                     $example $parser->parse($e$this$inlinesourceparse$class$linenum$filesourcepath);
  827.                 elseif (isset($linenum))
  828.                 {
  829.                     $example $parser->parse($e$this$inlinesourceparse$class$linenum);
  830.                 elseif (isset($class))
  831.                 {
  832.                     $example $parser->parse($e$this$inlinesourceparse$class);
  833.                 else
  834.                 {
  835.                     $example $parser->parse($e$this$inlinesourceparse);
  836.                 }
  837.             }
  838.             $this->class = $saveclass;
  839.         else
  840.         {
  841.             $example $this->postProcess($example);
  842.         }
  843.         $this->highlightingSource = false;
  844.  
  845.         if ($tutorial)
  846.         {
  847.             return $example;
  848.         }
  849.  
  850.         if (!isset($this->template_options['desctranslate'])) return $example;
  851.         if (!isset($this->template_options['desctranslate']['code'])) return $example;
  852.         $example $this->template_options['desctranslate']['code'$example;
  853.         if (!isset($this->template_options['desctranslate']['/code'])) return $example;
  854.         return $example $this->template_options['desctranslate']['/code'];
  855.     }
  856.  
  857.     /**
  858.      * @param string 
  859.      */
  860.     function TutorialExample($example)
  861.     {
  862.         $this->highlightingSource = true;
  863.         $parse = new phpDocumentor_TutorialHighlightParser;
  864.         $x $parse->parse($example$this);
  865.         $this->highlightingSource = false;
  866.         return $x;
  867.     }
  868.  
  869.     /**
  870.      * Used to convert the contents of <<li>> in a docblock
  871.      * @param string 
  872.      * @return string 
  873.      */
  874.     function ListItem($item)
  875.     {
  876.         if (!isset($this->template_options['desctranslate'])) return $item;
  877.         if (!isset($this->template_options['desctranslate']['li'])) return $item;
  878.         $item $this->template_options['desctranslate']['li'$item;
  879.         if (!isset($this->template_options['desctranslate']['/li'])) return $item;
  880.         return $item $this->template_options['desctranslate']['/li'];
  881.     }
  882.  
  883.     /**
  884.      * Used to convert the contents of <<ol>> or <<ul>> in a docblock
  885.      * @param string 
  886.      * @return string 
  887.      */
  888.     function EncloseList($list,$ordered)
  889.     {
  890.         $listname ($ordered 'ol' 'ul');
  891.         if (!isset($this->template_options['desctranslate'])) return $list;
  892.         if (!isset($this->template_options['desctranslate'][$listname])) return $list;
  893.         $list $this->template_options['desctranslate'][$listname$list;
  894.         if (!isset($this->template_options['desctranslate']['/'.$listname])) return $list;
  895.         return $list $this->template_options['desctranslate']['/'.$listname];
  896.     }
  897.  
  898.     /**
  899.      * Used to convert the contents of <<pre>> in a docblock
  900.      * @param string 
  901.      * @return string 
  902.      */
  903.     function PreserveWhiteSpace($string)
  904.     {
  905.         if (!isset($this->template_options['desctranslate'])) return $string;
  906.         if (!isset($this->template_options['desctranslate']['pre'])) return $string;
  907.         $string $this->template_options['desctranslate']['pre'$string;
  908.         if (!isset($this->template_options['desctranslate']['/pre'])) return $string;
  909.         return $string $this->template_options['desctranslate']['/pre'];
  910.     }
  911.  
  912.     /**
  913.      * Used to enclose a paragraph in a docblock
  914.      * @param string 
  915.      * @return string 
  916.      */
  917.     function EncloseParagraph($para)
  918.     {
  919.         if (!isset($this->template_options['desctranslate'])) return $para;
  920.         if (!isset($this->template_options['desctranslate']['p'])) return $para;
  921.         $para $this->template_options['desctranslate']['p'$para;
  922.         if (!isset($this->template_options['desctranslate']['/p'])) return $para;
  923.         return $para $this->template_options['desctranslate']['/p'];
  924.     }
  925.  
  926.     /**
  927.      * Used to convert the contents of <<b>> in a docblock
  928.      * @param string 
  929.      * @return string 
  930.      */
  931.     function Bolden($para)
  932.     {
  933.         if (!isset($this->template_options['desctranslate'])) return $para;
  934.         if (!isset($this->template_options['desctranslate']['b'])) return $para;
  935.         $para $this->template_options['desctranslate']['b'$para;
  936.         if (!isset($this->template_options['desctranslate']['/b'])) return $para;
  937.         return $para $this->template_options['desctranslate']['/b'];
  938.     }
  939.  
  940.     /**
  941.      * Used to convert the contents of <<i>> in a docblock
  942.      * @param string 
  943.      * @return string 
  944.      */
  945.     function Italicize($para)
  946.     {
  947.         if (!isset($this->template_options['desctranslate'])) return $para;
  948.         if (!isset($this->template_options['desctranslate']['i'])) return $para;
  949.         $para $this->template_options['desctranslate']['i'$para;
  950.         if (!isset($this->template_options['desctranslate']['/i'])) return $para;
  951.         return $para $this->template_options['desctranslate']['/i'];
  952.     }
  953.  
  954.     /**
  955.      * Used to convert the contents of <<var>> in a docblock
  956.      * @param string 
  957.      * @return string 
  958.      */
  959.     function Varize($para)
  960.     {
  961.         if (!isset($this->template_options['desctranslate'])) return $para;
  962.         if (!isset($this->template_options['desctranslate']['var'])) return $para;
  963.         $para $this->template_options['desctranslate']['var'$para;
  964.         if (!isset($this->template_options['desctranslate']['/var'])) return $para;
  965.         return $para $this->template_options['desctranslate']['/var'];
  966.     }
  967.  
  968.     /**
  969.      * Used to convert the contents of <<kbd>> in a docblock
  970.      * @param string 
  971.      * @return string 
  972.      */
  973.     function Kbdize($para)
  974.     {
  975.         if (!isset($this->template_options['desctranslate'])) return $para;
  976.         if (!isset($this->template_options['desctranslate']['kbd'])) return $para;
  977.         $para $this->template_options['desctranslate']['kbd'$para;
  978.         if (!isset($this->template_options['desctranslate']['/kbd'])) return $para;
  979.         return $para $this->template_options['desctranslate']['/kbd'];
  980.     }
  981.  
  982.     /**
  983.      * Used to convert the contents of <<samp>> in a docblock
  984.      * @param string 
  985.      * @return string 
  986.      */
  987.     function Sampize($para)
  988.     {
  989.         if (!isset($this->template_options['desctranslate'])) return $para;
  990.         if (!isset($this->template_options['desctranslate']['samp'])) return $para;
  991.         $para $this->template_options['desctranslate']['samp'$para;
  992.         if (!isset($this->template_options['desctranslate']['/samp'])) return $para;
  993.         return $para $this->template_options['desctranslate']['/samp'];
  994.     }
  995.  
  996.     /**
  997.      * Used to convert <<br>> in a docblock
  998.      * @param string 
  999.      * @return string 
  1000.      */
  1001.     function Br($para)
  1002.     {
  1003.         if (!isset($this->template_options['desctranslate'])) return $para;
  1004.         if (!isset($this->template_options['desctranslate']['br'])) return $para;
  1005.         $para $this->template_options['desctranslate']['br'$para;
  1006.         return $para;
  1007.     }
  1008.  
  1009.     /**
  1010.      * This version does nothing
  1011.      *
  1012.      * Perform necessary post-processing of string data.  For example, the HTML
  1013.      * Converters should escape < and > to become &lt; and &gt;
  1014.      * @return string 
  1015.      */
  1016.     function postProcess($text)
  1017.     {
  1018.         return $text;
  1019.     }
  1020.  
  1021.     /**
  1022.      * Creates a table of contents for a {@}toc} inline tag in a tutorial
  1023.      *
  1024.      * This function should return a formatted table of contents.  By default, it
  1025.      * does nothing, it is up to the converter to format the TOC
  1026.      * @abstract
  1027.      * @return string table of contents formatted for use in the current output format
  1028.      * @param array format: array(array('tagname' => section, 'link' => returnsee link, 'id' => anchor name, 'title' => from title tag),...)
  1029.      */
  1030.     function formatTutorialTOC($toc)
  1031.     {
  1032.         return '';
  1033.     }
  1034.  
  1035.     /**
  1036.      * Write out the formatted source code for a php file
  1037.      *
  1038.      * This function provides the primary functionality for the
  1039.      * {@tutorial tags.filesource.pkg} tag.
  1040.      * @param string full path to the file
  1041.      * @param string fully highlighted/linked source code of the file
  1042.      * @abstract
  1043.      */
  1044.     function writeSource($filepath$source)
  1045.     {
  1046.         debug($source);
  1047.         return;
  1048.     }
  1049.  
  1050.     /**
  1051.      * Write out the formatted source code for an example php file
  1052.      *
  1053.      * This function provides the primary functionality for the
  1054.      * {@tutorial tags.example.pkg} tag.
  1055.      * @param string example title
  1056.      * @param string example filename (no path)
  1057.      * @param string fully highlighted/linked source code of the file
  1058.      * @abstract
  1059.      */
  1060.     function writeExample($title$path$source)
  1061.     {
  1062.         return;
  1063.     }
  1064.  
  1065.     /** Translate the path info into a unique file name for the highlighted
  1066.      * source code.
  1067.      * @param string $pathinfo 
  1068.      * @return string 
  1069.      */
  1070.     function getFileSourceName($path)
  1071.     {
  1072.         global $_phpDocumentor_options;
  1073.         $pathinfo $this->proceduralpages->getPathInfo($path$this);
  1074.         $pathinfo['source_loc'str_replace($_phpDocumentor_options['Program_Root'].'/','',$pathinfo['source_loc']);
  1075.         $pathinfo['source_loc'str_replace('/','_',$pathinfo['source_loc']);
  1076.         return "fsource_{$pathinfo['package']}_{$pathinfo['subpackage']}_{$pathinfo['source_loc']}";
  1077.     }
  1078.  
  1079.     /** Return the fixed path to the source-code file folder.
  1080.      * @param string $base Path is relative to this folder
  1081.      * @return string 
  1082.      */
  1083.     function getFileSourcePath($base)
  1084.     {
  1085.         if (substr($basestrlen($base- 1!= PATH_DELIMITER{
  1086.             $base .= PATH_DELIMITER;
  1087.         }
  1088.         return $base '__filesource';
  1089.     }
  1090.  
  1091.     /** Return the path to the current
  1092.      * @param string $pathinfo 
  1093.      * @return string 
  1094.      */
  1095.     function getCurrentPageURL()
  1096.     {
  1097.         return '{$srcdir}' PATH_DELIMITER . $this->page_dir;
  1098.     }
  1099.  
  1100.     /**
  1101.      * @return string an output-format dependent link to phpxref-style highlighted
  1102.      *  source code
  1103.      * @abstract
  1104.      */
  1105.     function getSourceLink($path)
  1106.     {
  1107.         return '';
  1108.     }
  1109.  
  1110.     /**
  1111.      * @return string Link to the current page being parsed.
  1112.      *  Should return {@link $curname} and a converter-specific extension.
  1113.      * @abstract
  1114.      */
  1115.     function getCurrentPageLink()
  1116.     {
  1117.     }
  1118.  
  1119.     /**
  1120.      * Return a line of highlighted source code with formatted line number
  1121.      *
  1122.      * If the $path is a full path, then an anchor to the line number will be
  1123.      * added as well
  1124.      * @param integer line number
  1125.      * @param string highlighted source code line
  1126.      * @param false|stringfull path to @filesource file this line is a part of,
  1127.      *         if this is a single line from a complete file.
  1128.      * @return string formatted source code line with line number
  1129.      */
  1130.     function sourceLine($linenumber$line$path = false)
  1131.     {
  1132.         if ($path)
  1133.         {
  1134.             return $this->getSourceAnchor($path$linenumber.
  1135.                    $this->Br(sprintf('%-6u',$linenumber).str_replace("\n",'',$line));
  1136.         else
  1137.         {
  1138.             return $this->Br(sprintf('%-6u',$linenumber).str_replace("\n",'',$line));
  1139.         }
  1140.     }
  1141.  
  1142.     /**
  1143.      * Determine whether an element's file has generated source code, used for
  1144.      * linking to line numbers of source.
  1145.      *
  1146.      * Wrapper for {@link $sourcePaths} in this version
  1147.      * @param string full path to the source code file
  1148.      * @return boolean 
  1149.      */
  1150.     function hasSourceCode($path)
  1151.     {
  1152.         return isset($this->sourcePaths[$path]);
  1153.     }
  1154.  
  1155.     /**
  1156.      * Mark a file as having had source code highlighted
  1157.      * @param string full path of source file
  1158.      */
  1159.     function setSourcePaths($path)
  1160.     {
  1161.         $this->sourcePaths[$path= true;
  1162.     }
  1163.  
  1164.     /**
  1165.      * Used to translate an XML DocBook entity like &rdquo; from a tutorial by
  1166.      * reading the options.ini file for the template.
  1167.      * @param string entity name
  1168.      */
  1169.     function TranslateEntity($name)
  1170.     {
  1171.         if (!isset($this->template_options['ppage']))
  1172.         {
  1173.             if (!$this->template_options['preservedocbooktags'])
  1174.             return '';
  1175.             else
  1176.             return '&'.$name.';';
  1177.         }
  1178.         if (isset($this->template_options['ppage']['&'.$name.';']))
  1179.         {
  1180.             return $this->template_options['ppage']['&'.$name.';'];
  1181.         else
  1182.         {
  1183.             if (!$this->template_options['preservedocbooktags'])
  1184.             return '';
  1185.             else
  1186.             return '&'.$name.';';
  1187.         }
  1188.     }
  1189.  
  1190.     /**
  1191.      * Used to translate an XML DocBook tag from a tutorial by reading the
  1192.      * options.ini file for the template.
  1193.      * @param string tag name
  1194.      * @param string any attributes Format: array(name => value)
  1195.      * @param string the tag contents, if any
  1196.      * @param string the tag contents, if any, unpost-processed
  1197.      * @return string 
  1198.      */
  1199.     function TranslateTag($name,$attr,$cdata,$unconvertedcdata)
  1200.     {
  1201.         if (!isset($this->template_options['ppage']))
  1202.         {
  1203.             if (!$this->template_options['preservedocbooktags'])
  1204.             return $cdata;
  1205.             else
  1206.             return '<'.$name.$this->AttrToString($name,$attr,true).'>'.$cdata.'</'.$name.'>'."\n";
  1207.         }
  1208.         // make sure this template transforms the tag into something
  1209.         if (isset($this->template_options['ppage'][$name]))
  1210.         {
  1211.             // test for global attribute transforms like $attr$role = class, changing
  1212.             // all role="*" attributes to class="*" in html, for example
  1213.             foreach($attr as $att => $val)
  1214.             {
  1215.                 if (isset($this->template_options['$attr$'.$att]))
  1216.                 {
  1217.                     $new '';
  1218.                     if (!isset($this->template_options['$attr$'.$att]['close']))
  1219.                     {
  1220.                         $new .= '<'.$this->template_options['$attr$'.$att]['open'];
  1221.                         if (isset($this->template_options['$attr$'.$att]['cdata!']))
  1222.                         {
  1223.                             if (isset($this->template_options['$attr$'.$att]['separateall']))
  1224.                             $new .= $this->template_options['$attr$'.$att]['separator'];
  1225.                             else
  1226.                             $new .= ' ';
  1227.                             $new .= $this->template_options['$attr$'.$att]['$'.$att];
  1228.                             $new .= $this->template_options['$attr$'.$att]['separator'];
  1229.                             if ($this->template_options['$attr$'.$att]['quotevalues']$val '"'.$val.'"';
  1230.                             $new .= $val.'>';
  1231.                         else
  1232.                         {
  1233.                             $new .= '>'.$val;
  1234.                         }
  1235.                         $new .= '</'.$this->template_options['$attr$'.$att]['open'].'>';
  1236.                     else
  1237.                     {
  1238.                         $new .= $this->template_options['$attr$'.$att]['open'$val $this->template_options['$attr$'.$att]['close'];
  1239.                     }
  1240.                     unset($attr[$att]);
  1241.                     $cdata $new $cdata;
  1242.                 }
  1243.             }
  1244.  
  1245.             if (!isset($this->template_options['ppage']['/'.$name]))
  1246.             {// if the close tag isn't specified, we put opening and closing tags around it, with translated attributes
  1247.                 if (isset($this->template_options['ppage'][$name.'/']))
  1248.                 $cdata '<'.$this->template_options['ppage'][$name].$this->AttrToString($name,$attr).'/>' $cdata;
  1249.                 else
  1250.                 $cdata '<'.$this->template_options['ppage'][$name].$this->AttrToString($name,$attr).'>' $cdata .
  1251.                          '</'.$this->template_options['ppage'][$name].'>';
  1252.             else
  1253.             // if close tag is specified, use the open and close as literal
  1254.                 if ($name == 'programlisting' && isset($attr['role']&&
  1255.                       ($attr['role'== 'php' || $attr['role'== 'tutorial' || $attr['role'== 'html'))
  1256.                 // highlight PHP source
  1257. //                    var_dump($unconvertedcdata, $cdata);exit;
  1258.                     if ($attr['role'== 'php'{
  1259.                         $cdata $this->ProgramExample($unconvertedcdatatrue);
  1260.                     elseif ($attr['role'== 'tutorial'{
  1261.                         $cdata $this->TutorialExample($unconvertedcdata);
  1262.                     elseif ($attr['role'== 'html'{
  1263.                         $cdata $unconvertedcdata;
  1264.                     }
  1265.                 else
  1266.                 {// normal case below
  1267.                     $cdata $this->template_options['ppage'][$name].$this->AttrToString($name,$attr)$cdata .$this->template_options['ppage']['/'.$name];
  1268.                 }
  1269.             }
  1270.             return $cdata;
  1271.         else
  1272.         {
  1273.             if ($this->template_options['preservedocbooktags'])
  1274.             {
  1275.                 return '<'.$name.$this->AttrToString($name,$attr,true).'>' $cdata .
  1276.                          '</'.$name.'>'."\n";
  1277.             else
  1278.             {
  1279.                 return $cdata;
  1280.             }
  1281.         }
  1282.     }
  1283.  
  1284.     /**
  1285.      * Convert the attribute of a Tutorial docbook tag's attribute list
  1286.      * to a string based on the template options.ini
  1287.      * @param string tag name
  1288.      * @param attribute array
  1289.      * @param boolean if true, returns attrname="value"...
  1290.      * @return string 
  1291.      */
  1292.     function AttrToString($tag,$attr,$unmodified = false)
  1293.     {
  1294.         $ret '';
  1295.         if ($unmodified)
  1296.         {
  1297.             $ret ' ';
  1298.             foreach($attr as $n => $v)
  1299.             {
  1300.                 $ret .= $n.' = "'.$v.'"';
  1301.             }
  1302.             return $ret;
  1303.         }
  1304.         // no_attr tells us to ignore all attributes
  1305.         if (isset($this->template_options['no_attr'])) return $ret;
  1306.         // tagname! tells us to ignore all attributes for this tag
  1307.         if (isset($this->template_options['ppage'][$tag.'!'])) return $ret;
  1308.         if (count($attr)) $ret ' ';
  1309.         // pass 1, check to see if any attributes add together
  1310.         $same = array();
  1311.         foreach($attr as $n => $v)
  1312.         {
  1313.             if (isset($this->template_options['ppage'][$tag.'->'.$n]))
  1314.             {
  1315.                 $same[$this->template_options['ppage'][$tag.'->'.$n]][$n;
  1316.             }
  1317.         }
  1318.         foreach($attr as $n => $v)
  1319.         {
  1320.             if (isset($this->template_options['ppage'][$tag.'->'.$n]))
  1321.             {
  1322.                 if (count($same[$this->template_options['ppage'][$tag.'->'.$n]]== 1)
  1323.                 // only 1 attribute translated for this one
  1324.                     // this is useful for equivalent value names
  1325.                     if (isset($this->template_options['ppage'][$tag.'->'.$n.'+'.$v])) $v $this->template_options['ppage'][$tag.'->'.$n.'+'.$v];
  1326.                 else
  1327.                 // more than 1 attribute combines to make the new attribute
  1328.                     $teststrtemp = array();
  1329.                     foreach($same[$this->template_options['ppage'][$tag.'->'.$n]] as $oldattr)
  1330.                     {
  1331.                         $teststrtemp[$oldattr.'+'.$attr[$oldattr];
  1332.                     }
  1333.                     $teststrs = array();
  1334.                     $num count($same[$this->template_options['ppage'][$tag.'->'.$n]]);
  1335.                     for($i=0;$i<$num;$i++)
  1336.                     {
  1337.                         $started = false;
  1338.                         $a '';
  1339.                         for($j=$i;!$started || $j != $i;$j ($j $i$num)
  1340.                         {
  1341.                             if (!empty($a)) $a .= '|';
  1342.                             $a .= $teststrtemp[$j];
  1343.                         }
  1344.                         $teststrs[$i$a;
  1345.                     }
  1346.                     $done = false;
  1347.                     foreach($teststrs as $test)
  1348.                     {
  1349.                         if ($donebreak;
  1350.                         if (isset($this->template_options['ppage'][$tag.'->'.$test]))
  1351.                         {
  1352.                             $done = true;
  1353.                             $v $this->template_options['ppage'][$tag.'->'.$test];
  1354.                         }
  1355.                     }
  1356.                 }
  1357.                 $ret .= $this->template_options['ppage'][$tag.'->'.$n].' = "'.$v.'"';
  1358.             else
  1359.             {
  1360.                 if (!isset($this->template_options['ppage'][$tag.'!'.$n]))
  1361.                 {
  1362.                     if (isset($this->template_options['ppage']['$attr$'.$n]))
  1363.                     $ret .= $this->template_options['ppage']['$attr$'.$n].' = "'.$v.'"';
  1364.                     else
  1365.                     $ret .= $n.' = "'.$v.'"';
  1366.                 }
  1367.             }
  1368.         }
  1369.         return $ret;
  1370.     }
  1371.  
  1372.     /**
  1373.      * Convert the title of a Tutorial docbook tag section
  1374.      * to a string based on the template options.ini
  1375.      * @param string tag name
  1376.      * @param array 
  1377.      * @param string title text
  1378.      * @param string 
  1379.      * @return string 
  1380.      */
  1381.     function ConvertTitle($tag,$attr,$title,$cdata)
  1382.     {
  1383.         if (!isset($this->template_options[$tag.'_title'])) return array($attr,$cdata);
  1384.         if (isset($this->template_options[$tag.'_title']['tag_attr']))
  1385.         {
  1386.             $attr[$this->template_options[$tag.'_title']['tag_attr']] urlencode($cdata);
  1387.             $cdata '';
  1388.         elseif(isset($this->template_options[$tag.'_title']['cdata_start']))
  1389.         {
  1390.             $cdata $this->template_options[$tag.'_title']['open'$title .
  1391.                      $this->template_options[$tag.'_title']['close'$cdata;
  1392.         else $cdata $title.$cdata;
  1393.         return array($attr,$cdata);
  1394.     }
  1395.  
  1396.     /**
  1397.      * Return a converter-specific id to distinguish tutorials and their
  1398.      * sections
  1399.      *
  1400.      * Used by {@}id}
  1401.      * @return string 
  1402.      */
  1403.     function getTutorialId($package,$subpackage,$tutorial,$id)
  1404.     {
  1405.         return $package.$subpackage.$tutorial.$id;
  1406.     }
  1407.  
  1408.     /**
  1409.      * Create the {@link $elements, $pkg_elements} and {@link $links} arrays
  1410.      * @access private
  1411.      * @todo version 2.0 - faulty package_output logic should be removed
  1412.      *
  1413.      *        in this version, if the parent file isn't in the package, all
  1414.      *        the procedural elements are simply shunted to another package!
  1415.      */
  1416.     function _createPkgElements(&$pages)
  1417.     {
  1418.         if (empty($this->elements))
  1419.         {
  1420.             $this->elements = array();
  1421.             $this->pkg_elements = array();
  1422.             $this->links = array();
  1423.             phpDocumentor_out('Building indexes...');
  1424.             flush();
  1425.             foreach($pages as $j => $flub)
  1426.             {
  1427.                 $this->package = $pages[$j]->parent->package;
  1428.                 $this->subpackage = $pages[$j]->parent->subpackage;
  1429.                 $this->class = false;
  1430.                 $this->curfile = $pages[$j]->parent->getFile();
  1431.                 $this->curname $this->getPageName($pages[$j]->parent);
  1432.                 $this->curpath $pages[$j]->parent->getPath();
  1433.                 $use = true;
  1434.                 if ($this->package_output)
  1435.                 {
  1436.                     if (in_array($this->package,$this->package_output))
  1437.                     {
  1438.                         $this->addElement($pages[$j]->parent,$pages[$j]);
  1439.                     else
  1440.                     {
  1441.                         if (count($pages[$j]->classelements))
  1442.                         {
  1443.                             list(,$pages[$j]->parent->packageeach($this->package_output);
  1444.                             reset($this->package_output);
  1445.                             $pages[$j]->parent->subpackage = '';
  1446.                             $this->addElement($pages[$j]->parent,$pages[$j]);
  1447.                         else
  1448.                         {
  1449.                             unset($pages[$j]);
  1450.                             continue;
  1451.                         }
  1452.                     }
  1453.                 else
  1454.                 {
  1455.                     $this->addElement($pages[$j]->parent,$pages[$j]);
  1456.                 }
  1457.                 if ($use)
  1458.                 for($i=0; $i<count($pages[$j]->elements)$i++)
  1459.                 {
  1460.                     $pages[$j]->elements[$i]->docblock->package = $this->package;
  1461.                     $pages[$j]->elements[$i]->docblock->subpackage = $this->subpackage;
  1462.                     $this->proceduralpages->replaceElement($pages[$j]->elements[$i]);
  1463.                     $this->addElement($pages[$j]->elements[$i]);
  1464.                 }
  1465.                 for($i=0; $i<count($pages[$j]->classelements)$i++)
  1466.                 {
  1467.                     if ($this->class)
  1468.                     {
  1469.                         if ($pages[$j]->classelements[$i]->type == 'class')
  1470.                         {
  1471.                             if ($this->checkKillClass($pages[$j]->classelements[$i]->getName(),$pages[$j]->classelements[$i]->getPath())) continue;
  1472.                             $this->package = $pages[$j]->classelements[$i]->docblock->package;
  1473.                             if ($this->package_outputif (!in_array($this->package,$this->package_output)) continue;
  1474.                             $this->subpackage = $pages[$j]->classelements[$i]->docblock->subpackage;
  1475.                             $this->class = $pages[$j]->classelements[$i]->name;
  1476.                         else
  1477.                         {
  1478.                             if ($this->killclasscontinue;
  1479.                             // force all contained elements to have parent package/subpackage
  1480.                             $pages[$j]->classelements[$i]->docblock->package = $this->package;
  1481.                             $pages[$j]->classelements[$i]->docblock->subpackage = $this->subpackage;
  1482.                         }
  1483.                     }
  1484.                     if ($pages[$j]->classelements[$i]->type == 'class')
  1485.                     {
  1486.                         if ($this->checkKillClass($pages[$j]->classelements[$i]->getName(),$pages[$j]->classelements[$i]->getPath())) continue;
  1487.                         $this->package = $pages[$j]->classelements[$i]->docblock->package;
  1488.                         if ($this->package_outputif (!in_array($this->package,$this->package_output)) continue;
  1489.                         $this->subpackage = $pages[$j]->classelements[$i]->docblock->subpackage;
  1490.                         $this->class = $pages[$j]->classelements[$i]->name;
  1491.                     }
  1492.                     if (!$this->killclass$this->addElement($pages[$j]->classelements[$i]);
  1493.                 }
  1494.             }
  1495.             phpDocumentor_out("done\n");
  1496.             flush();
  1497.         }
  1498.         $this->sortIndexes();
  1499.         $this->sortTodos();
  1500.         if ($this->sort_page_contents_by_type$this->sortPageContentsByElementType($pages);
  1501.     }
  1502.  
  1503.     /**
  1504.      * Process the {@link $tutorials} array
  1505.      *
  1506.      * Using the tutorialname.ext.ini files, this method sets up tutorial
  1507.      * hierarchy.  There is some minimal error checking to make sure that no
  1508.      * tutorial links to itself, even two levels deep as in tute->next->tute.
  1509.      *
  1510.      * If all tests pass, it creates the hierarchy
  1511.      * @uses generateTutorialOrder()
  1512.      * @uses _setupTutorialTree()
  1513.      * @access private
  1514.      */
  1515.     function _processTutorials()
  1516.     {
  1517.         $parents $all = array();
  1518.         foreach($this->tutorials as $package => $els)
  1519.         {
  1520.             if ($this->package_output)
  1521.             {
  1522.                 if (!in_array($package,$this->package_output))
  1523.                 {
  1524.                     unset($this->tutorials[$package]);
  1525.                     continue;
  1526.                 }
  1527.             }
  1528.             if (!isset($this->pkg_elements[$package]))
  1529.             {
  1530.                 unset($this->tutorials[$package]);
  1531.                 continue;
  1532.             }
  1533.             foreach($els as $subpackage => $els2)
  1534.             {
  1535.                 foreach($els2 as $type => $tutorials)
  1536.                 {
  1537.                     foreach($tutorials as $tutorial)
  1538.                     {
  1539.                         if ($tutorial->ini)
  1540.                         {
  1541.                             if (isset($tutorial->ini['Linked Tutorials']))
  1542.                             {
  1543.                                 foreach($tutorial->ini['Linked Tutorials'as $child)
  1544.                                 {
  1545.                                     $sub (empty($tutorial->subpackage'' $tutorial->subpackage . '/');
  1546.                                     $kid $tutorial->package . '/' $sub $child '.' $tutorial->tutorial_type;
  1547.                                     // parent includes self as a linked tutorial?
  1548.                                     $kidlink $this->getTutorialLink($kid,false,false,array($tutorial->package));
  1549.                                     if (is_object($kidlink&& $this->returnSee($kidlink== $tutorial->getLink($this))
  1550.                                     // bad!
  1551.                                         addErrorDie(PDERROR_TUTORIAL_IS_OWN_CHILD,$tutorial->name,$tutorial->name.'.ini');
  1552.                                     }
  1553.                                 }
  1554.                                 $parents[$tutorial;
  1555.                             }
  1556.                         }
  1557.                         $all[$package][$subpackage][$type][$tutorial;
  1558.                     }
  1559.                 }
  1560.             }
  1561.         }
  1562.         // loop error-checking, use this to eliminate possibility of accidentally linking to a parent as a child
  1563.         $testlinks = array();
  1564.         foreach($parents as $parent)
  1565.         {
  1566.             $testlinks[$parent->name]['links'][$parent->getLink($this);
  1567.             $testlinks[$parent->name]['name'][$parent->getLink($this)$parent->name;
  1568.         }
  1569.         // generate the order of tutorials, and link them together
  1570.         foreach($parents as $parent)
  1571.         {
  1572.             foreach($parent->ini['Linked Tutorials'as $child)
  1573.             {
  1574.                 $sub (empty($parent->subpackage'' $parent->subpackage . '/');
  1575.                 $kid $parent->package . '/' $sub $child '.' $parent->tutorial_type;
  1576.                 // child tutorials must be in the same package AND subpackage
  1577.                 // AND have the same extension as the parent, makes things clearer for both ends
  1578.                 if (in_array($this->returnSee($this->getTutorialLink($kid,false,false,array($parent->package))),$testlinks[$parent->name]['links']))
  1579.                     addErrorDie(PDERROR_TUTORIAL_IS_OWN_GRANDPA,$testlinks[$parent->name][$this->returnSee($this->getTutorialLink($kid,false,false,array($parent->package)))],$kid->name,$testlinks[$parent->name][$this->returnSee($this->getTutorialLink($kid,false,false,array($parent->package)))],$kid->name.'.ini');
  1580.                 if ($this->returnSee($this->getTutorialLink($kid,false,false,array($parent->package))) == $kid)
  1581.                 {
  1582.                     addWarning(PDERROR_CHILD_TUTORIAL_NOT_FOUND$child '.' $parent->tutorial_type$parent->name .'.ini',$parent->package$parent->subpackage);
  1583.                 }
  1584.             }
  1585.         }
  1586.         $new $tree $roots = array();
  1587.         // build a list of all 'root' tutorials (tutorials without parents).
  1588.         foreach($parents as $i => $parent)
  1589.         {
  1590.             if ($parent->isChildOf($parents)) {
  1591.                 $roots[$parent;
  1592.             }
  1593.         }
  1594.         $parents $roots;
  1595.         // add the parents and all child tutorials in order to the list of tutorials to process
  1596.         foreach($parents as $parent)
  1597.         {
  1598.             $this->generateTutorialOrder($parent,$all,$new);
  1599.         }
  1600.         if (count($all))
  1601.         {
  1602.             // add the leftover tutorials
  1603.             foreach($all as $package => $els)
  1604.             {
  1605.                 foreach($els as $subpackage => $els2)
  1606.                 {
  1607.                     foreach($els2 as $type => $tutorials)
  1608.                     {
  1609.                         foreach($tutorials as $tutorial)
  1610.                         {
  1611.                             $new[$package][$subpackage][$type][$tutorial;
  1612.                         }
  1613.                     }
  1614.                 }
  1615.             }
  1616.         }
  1617.         // remove the old, unprocessed tutorials, and set it up with the next code
  1618.         $this->tutorials = array();
  1619.         // reset integrity of the tutorial list
  1620.         $prev = false;
  1621.         uksort($new'tutorialcmp');
  1622. //        debug($this->vardump_tree($new));exit;
  1623.         foreach($new as $package => $els)
  1624.         {
  1625.             foreach($els as $subpackage => $els2)
  1626.             {
  1627.                 foreach($els2 as $type => $tutorials)
  1628.                 {
  1629.                     foreach($tutorials as $tutorial)
  1630.                     {
  1631.                         if ($prev)
  1632.                         {
  1633.                             $this->tutorials[$prevpackage][$prevsubpackage][$prevtype][$prevname]->setNext($tutorial,$this);
  1634.                             $tutorial->setPrev($prev,$this);
  1635.                         }
  1636.                         $this->tutorials[$package][$subpackage][$type][$tutorial->name$tutorial;
  1637.                         $prev $tutorial->getLink($this,true);
  1638.                         $prevpackage $package;
  1639.                         $prevsubpackage $subpackage;
  1640.                         $prevtype $type;
  1641.                         $prevname $tutorial->name;
  1642.                     }
  1643.                 }
  1644.             }
  1645.         }
  1646.         $this->tutorial_tree $this->_setupTutorialTree();
  1647.         return $new;
  1648.     }
  1649.  
  1650.     /**
  1651.     * called by {@link phpDocumentor_IntermediateParser::Convert()} to traverse
  1652.     * the array of pages and their elements, converting them to the output format
  1653.     *
  1654.     * The walk() method should be flexible enough such that it never needs
  1655.     * modification.  walk() sets up all of the indexes, and sorts everything in
  1656.     * logical alphabetical order.  It then passes each element individually to
  1657.     * {@link Convert()}, which then passes to the Convert*() methods.  A child
  1658.     * Converter need not override any of these unless special functionality must
  1659.     * be added. see {@tutorial Converters/template.vars.cls} for details.
  1660.     * {@internal 
  1661.     * walk() first creates all of the indexes {@link $elements, $pkg_elements}
  1662.     * and the left indexes specified by {@link $leftindexes},
  1663.     * and then sorts them by calling {@link sortIndexes()}.
  1664.     *
  1665.     * Next, it converts all README/CHANGELOG/INSTALL-style files, using
  1666.     * {@link Convert_RIC}.
  1667.     *
  1668.     * After this, it
  1669.     * passes all package-level docs to Convert().  Then, it calls the index
  1670.     * sorting functions {@link formatPkgIndex(), formatIndex()} and
  1671.     * {@link formatLeftIndex()}.
  1672.     *
  1673.     * Finally, it converts each procedural page in alphabetical order.  This
  1674.     * stage passes elements from the physical file to Convert() in alphabetical
  1675.     * order.  First, procedural page elements {@link parserDefine, parserInclude}
  1676.     * {@link parserGlobal}, and {@link parserFunction} are passed to Convert().
  1677.     *
  1678.     * Then, class elements are passed in this order: {@link parserClass}, then
  1679.     * all of the {@link parserVar}s in the class and all of the
  1680.     * {@link parserMethod}s in the class.  Classes are in alphabetical order,
  1681.     * and both vars and methods are in alphabetical order.
  1682.     *
  1683.     * Finally, {@link ConvertErrorLog()} is called and the data walk is complete.}}}
  1684.     * @param array Format: array(fullpath => {@link parserData} structure with full {@link parserData::$elements}
  1685.     *                                          and {@link parserData::$class_elements}.
  1686.     * @param array Format: array({@link parserPackagePage} 1, {@link parserPackagePage} 2,...)
  1687.     * @uses Converter::_createPkgElements() sets up {@link $elements} and
  1688.     *        {@link $pkg_elements} array, as well as {@link $links}
  1689.     */
  1690.     function walk(&$pages,&$package_pages)
  1691.     {
  1692.         if (empty($pages))
  1693.         {
  1694.             die("<b>ERROR</b>: nothing parsed");
  1695.         }
  1696.         $this->_createPkgElements($pages);
  1697.         if (count($this->ric))
  1698.         {
  1699.             phpDocumentor_out("Converting README/INSTALL/CHANGELOG contents...\n");
  1700.             flush();
  1701.             foreach($this->ric as $name => $contents)
  1702.             {
  1703.                 phpDocumentor_out("$name...");
  1704.                 flush();
  1705.                 $this->Convert_RIC($name,$contents);
  1706.             }
  1707.             phpDocumentor_out("\ndone\n");
  1708.             flush();
  1709.         }
  1710.         foreach($package_pages as $i => $perp)
  1711.         {
  1712.             if ($this->package_output)
  1713.             {
  1714.                 if (!in_array($package_pages[$i]->package,$this->package_output)) continue;
  1715.             }
  1716.             phpDocumentor_out('Converting package page for package '.$package_pages[$i]->package.'... ');
  1717.             flush();
  1718.             $this->package = $package_pages[$i]->package;
  1719.             $this->subpackage = '';
  1720.             $this->class = false;
  1721.             $this->Convert($package_pages[$i]);
  1722.             phpDocumentor_out("done\n");
  1723.             flush();
  1724.         }
  1725.         phpDocumentor_out("Converting tutorials/extended docs\n");
  1726.         flush();
  1727.         // get tutorials into the order they will display, and set next/prev links
  1728.         $new $this->_processTutorials();
  1729.         foreach($this->tutorials as $package => $els)
  1730.         {
  1731.             foreach($els as $subpackage => $els2)
  1732.             {
  1733.                 foreach($els2 as $type => $tutorials)
  1734.                 {
  1735.                     foreach($tutorials as $tutorial)
  1736.                     {
  1737.                         switch ($type)
  1738.                         {
  1739.                             case 'pkg' :
  1740.                                 $a '';
  1741.                                 if ($tutorial->ini)
  1742.                                 $a .= 'Top-level ';
  1743.                                 if (!empty($tutorial->subpackage))
  1744.                                 $a .= 'Sub-';
  1745.                                 $ptext = "Converting ${a}Package-level tutorial ".$tutorial->name.'...';
  1746.                             break;
  1747.                             case 'cls' :
  1748.                                 $a '';
  1749.                                 if ($tutorial->ini)
  1750.                                 $a .= 'Top-level ';
  1751.                                 $ptext = "Converting ${a}Class-level tutorial " . $tutorial->name ." and associating...";
  1752.                                 $link Converter::getClassLink(str_replace('.cls','',$tutorial->name)$tutorial->package);
  1753.                                 if (is_object($link))
  1754.                                 {
  1755.                                     if ($this->sort_absolutely_everything)
  1756.                                     {
  1757.                                         $addend 'unsuccessful ';
  1758.                                         if (isset($this->package_elements[$tutorial->package][$tutorial->subpackage]['class'][$link->name]))
  1759.                                         {
  1760.                                             $this->package_elements[$tutorial->package][$tutorial->subpackage]['class'][$link->name][0]->addTutorial($tutorial,$this);
  1761.                                             $addend 'success ';
  1762.                                         }
  1763.                                     else
  1764.                                     {
  1765.                                         $addend 'unsuccessful ';
  1766.                                         if (!isset($this->classes->killclass[str_replace('.cls','',$tutorial->name)]&& !isset($this->classes->killclass[str_replace('.cls','',$tutorial->name)][$tutorial->path]))
  1767.                                         {
  1768.                                             foreach($pages as $j => $inf)
  1769.                                             {
  1770.                                                 foreach($inf->classelements as $i => $class)
  1771.                                                 {
  1772.                                                     if ($class->type == 'class' && $class->name == str_replace('.cls','',$tutorial->name&& $class->path == $link->path)
  1773.                                                     {
  1774.                                                         $pages[$j]->classelements[$i]->addTutorial($tutorial,$this);
  1775.                                                         $addend 'success ';
  1776.                                                     }
  1777.                                                 }
  1778.                                             }
  1779.                                         }
  1780.                                     }
  1781.                                     $ptext .= $addend;
  1782.                                 else $ptext .= "unsuccessful ";
  1783.                             break;
  1784.                             case 'proc' :
  1785.                                 $a '';
  1786.                                 if ($tutorial->ini)
  1787.                                 $a .= 'Top-level ';
  1788.                                 $ptext = "Converting ${a}Procedural-level tutorial ".$tutorial->name." and associating...";
  1789.                                 $link Converter::getPageLink(str_replace('.proc','',$tutorial->name)$tutorial->package);
  1790.                                 if (is_object($link))
  1791.                                 {
  1792.                                     $addend 'unsuccessful ';
  1793.                                     if ($this->sort_absolutely_everything)
  1794.                                     {
  1795.                                         if (isset($this->package_elements[$tutorial->package][$tutorial->subpackage]['page'][$link->path]))
  1796.                                         {
  1797.                                             $this->package_elements[$tutorial->package][$tutorial->subpackage]['page'][$link->path][0]->addTutorial($tutorial,$this);
  1798.                                             $addend "success ";
  1799.                                         }
  1800.                                     else
  1801.                                     {
  1802.                                         foreach($pages as $j => $info)
  1803.                                         {
  1804.                                             if ($j == $link->path)
  1805.                                             {
  1806.                                                 $pages[$j]->addTutorial($tutorial,$this);
  1807.                                                 $addend "success ";
  1808.                                             }
  1809.                                         }
  1810.                                     }
  1811.                                     $ptext .= $addend;
  1812.                                 else $ptext .= "unsuccessful ";
  1813.                             break;
  1814.                         }
  1815.                         phpDocumentor_out($ptext);
  1816.                         flush();
  1817.                         $this->package = $tutorial->package;
  1818.                         $this->subpackage = $tutorial->subpackage;
  1819.                         $this->Convert($tutorial);
  1820.                         phpDocumentor_out("done\n");
  1821.                         flush();
  1822.                     }
  1823.                 }
  1824.             }
  1825.         }
  1826.         phpDocumentor_out("Formatting Package Indexes...");
  1827.         flush();
  1828.         $this->formatPkgIndex();
  1829.         phpDocumentor_out("done\n");
  1830.         flush();
  1831.         phpDocumentor_out("Formatting Index...");
  1832.         flush();
  1833.         $this->formatIndex();
  1834.         phpDocumentor_out("done\n\n");
  1835.         flush();
  1836.         phpDocumentor_out("Formatting Left Quick Index...");
  1837.         flush();
  1838.         $this->formatLeftIndex();
  1839.         phpDocumentor_out("done\n\n");
  1840.         flush();
  1841.         if ($this->sort_absolutely_everythingreturn $this->walk_everything();
  1842.         foreach($pages as $j => $flub)
  1843.         {
  1844.             phpDocumentor_out('Converting '.$pages[$j]->parent->getPath());
  1845.             flush();
  1846.             $this->package = $pages[$j]->parent->package;
  1847.             $this->subpackage = $pages[$j]->parent->subpackage;
  1848.             $this->class = false;
  1849.             $this->curfile = $pages[$j]->parent->getFile();
  1850.             $this->curname $this->getPageName($pages[$j]->parent);
  1851.             $this->curpath $pages[$j]->parent->getPath();
  1852.             $use = true;
  1853.             if ($this->package_output)
  1854.             {
  1855.                 if (in_array($this->package,$this->package_output))
  1856.                 {
  1857.                     $this->Convert($pages[$j]);
  1858.                 else
  1859.                 {
  1860.                     $use = false;
  1861.                 }
  1862.             else
  1863.             {
  1864.                 $this->Convert($pages[$j]);
  1865.             }
  1866.             phpDocumentor_out(" Procedural Page Elements...");
  1867.             flush();
  1868.             if ($use)
  1869.             for($i=0; $i<count($pages[$j]->elements)$i++)
  1870.             {
  1871.                 $a $pages[$j]->elements[$i]->docblock->getKeyword('access');
  1872.                 if (is_object($a)) $a $a->getString();
  1873.                 if (!$this->parseprivate && ($a == 'private'))
  1874.                     continue;
  1875. //                phpDocumentor_out("    ".$pages[$j]->elements[$i]->name."\n");
  1876.                 $pages[$j]->elements[$i]->docblock->package = $this->package;
  1877.                 $pages[$j]->elements[$i]->docblock->subpackage = $this->subpackage;
  1878.                 $this->Convert($pages[$j]->elements[$i]);
  1879.             }
  1880.             phpDocumentor_out(" Classes...");
  1881.             $this->class = false;
  1882.             flush();
  1883.             for($i=0; $i<count($pages[$j]->classelements)$i++)
  1884.             {
  1885.                 if ($this->class)
  1886.                 {
  1887.                     if ($pages[$j]->classelements[$i]->type == 'class')
  1888.                     {
  1889.                         if (!$this->killclass$this->endClass();
  1890.                         $this->killclass = false;
  1891.                         if ($this->checkKillClass($pages[$j]->classelements[$i]->getName(),$pages[$j]->classelements[$i]->getPath())) continue;
  1892.                         $this->package = $pages[$j]->classelements[$i]->docblock->package;
  1893.                         if ($this->package_outputif (!in_array($this->package,$this->package_output)) continue;
  1894.                         $this->subpackage = $pages[$j]->classelements[$i]->docblock->subpackage;
  1895.                         $this->class = $pages[$j]->classelements[$i]->name;
  1896.                     else
  1897.                     {
  1898.                         $a $pages[$j]->classelements[$i]->docblock->getKeyword('access');
  1899.                         if (is_object($a)) $a $a->getString();
  1900.                         if (!$this->parseprivate && ($a == 'private'))
  1901.                             continue;
  1902.                         if ($this->killclasscontinue;
  1903.                         // force all contained elements to have parent package/subpackage
  1904.                         $pages[$j]->classelements[$i]->docblock->package = $this->package;
  1905.                         $pages[$j]->classelements[$i]->docblock->subpackage = $this->subpackage;
  1906.                     }
  1907.                 }
  1908.                 if ($pages[$j]->classelements[$i]->type == 'class')
  1909.                 {
  1910.                     $this->killclass = false;
  1911.                     if ($this->checkKillClass($pages[$j]->classelements[$i]->getName(),$pages[$j]->classelements[$i]->getPath())) continue;
  1912.                     $this->package = $pages[$j]->classelements[$i]->docblock->package;
  1913.                     if ($this->package_outputif (!in_array($this->package,$this->package_output)) continue;
  1914.                     $this->subpackage = $pages[$j]->classelements[$i]->docblock->subpackage;
  1915.                     $this->class = $pages[$j]->classelements[$i]->name;
  1916.                 }
  1917.                 if ($this->killclasscontinue;
  1918. //                phpDocumentor_out("    ".$pages[$j]->classelements[$i]->name."\n");
  1919.                 $this->Convert($pages[$j]->classelements[$i]);
  1920.             }
  1921.             if (count($pages[$j]->classelements&& !$this->killclass$this->endClass();
  1922.             phpDocumentor_out(" done\n");
  1923.             flush();
  1924.             $this->endPage();
  1925.         }
  1926.         phpDocumentor_out("\nConverting @todo List...");
  1927.         flush();
  1928.         if (count($this->todoList))
  1929.         {
  1930.             $this->ConvertTodoList();
  1931.         }
  1932.         phpDocumentor_out("done\n");
  1933.         flush();
  1934.         phpDocumentor_out("\nConverting Error Log...");
  1935.         flush();
  1936.         $this->ConvertErrorLog();
  1937.         phpDocumentor_out("done\n");
  1938.         flush();
  1939.     }
  1940.  
  1941.  
  1942.     /**
  1943.      * Get a tree structure representing the hierarchy of tutorials
  1944.      *
  1945.      * Returns an array in format:
  1946.      * <pre>
  1947.      * array('tutorial' => {@link parserTutorial},
  1948.      *       'kids' => array( // child tutorials
  1949.      *                   array('tutorial' => child {@link parserTutorial},
  1950.      *                         'kids' => array(...)
  1951.      *                        )
  1952.      *                      )
  1953.      *      )
  1954.      * </pre>
  1955.      * @param parserTutorial|array
  1956.      * @tutorial tutorials.pkg
  1957.      * @return array 
  1958.      */
  1959.     function getTutorialTree($tutorial)
  1960.     {
  1961.         if (is_object($tutorial))
  1962.         {
  1963.             $path $this->_tutorial_path($tutorial,$tutorial,$tutorial);
  1964.             if (isset($this->tutorial_tree[$path])) {
  1965.                 $tutorial $this->tutorial_tree[$path];
  1966.             else {
  1967.                 return false;
  1968.             }
  1969.         }
  1970.         $tree = array();
  1971.         if (isset($tutorial['tutorial']))
  1972.         {
  1973.             $tree['tutorial'$tutorial['tutorial'];
  1974.             if (isset($tutorial['child']))
  1975.             {
  1976.                 foreach($tutorial['child'as $a => $b)
  1977.                 {
  1978.                     $btut $b['tutorial'];
  1979.                     $res['tutorial'$this->tutorials[$btut->package][$btut->subpackage][$btut->tutorial_type][$btut->name];
  1980.                     if (isset($b['child']))
  1981.                     {
  1982.                          $tempres Converter::getTutorialTree($b);
  1983.                          $res['kids'$tempres['kids'];
  1984.                     }
  1985.                     $tree['kids'][$res;
  1986.                 }
  1987.             }
  1988.         }
  1989.         return $tree;
  1990.     }
  1991.  
  1992.     /**
  1993.      * Remove tutorials one by one from $all, and transfer them into $new in the
  1994.      * order they should be parsed
  1995.      * @param parserTutorial 
  1996.      * @param array 
  1997.      * @param array 
  1998.      * @access private
  1999.      */
  2000.     function generateTutorialOrder($parent,&$all,&$new)
  2001.     {
  2002.         // remove from the list of tutorials to process
  2003.         foreach($all[$parent->package][$parent->subpackage][$parent->tutorial_typeas $ind => $t)
  2004.         {
  2005.             if ($t->name == $parent->name{
  2006.                 unset($all[$parent->package][$parent->subpackage][$parent->tutorial_type][$ind]);
  2007.             }
  2008.         }
  2009.         // add to the new ordered list of tutorials
  2010.         $x &$new[$parent->package][$parent->subpackage][$parent->tutorial_type];
  2011.         if (!is_object($x[count($x- 1]|| $x[count($x- 1]->name != $parent->name)
  2012.         // only add if the parent isn't also a child
  2013.             $new[$parent->package][$parent->subpackage][$parent->tutorial_type][$parent;
  2014.             // add a new branch to the tree
  2015.         }
  2016.         // process all child tutorials, and insert them in order
  2017. //        debug("processing parent ".$parent->name);
  2018.         if ($parent->ini)
  2019.         {
  2020.             foreach($parent->ini['Linked Tutorials'as $child)
  2021.             {
  2022.                 $sub (empty($parent->subpackage'' $parent->subpackage . '/');
  2023.                 $kid $parent->package . '/' $sub $child '.' $parent->tutorial_type;
  2024.                 $_klink $this->getTutorialLink($kid,false,false,array($parent->package));
  2025.                 if (is_object($_klink)) {
  2026.                     $klink $this->returnSee($_klink);
  2027.                 else {
  2028.                     $klink = false;
  2029.                 }
  2030.                 // remove the child from the list of remaining tutorials
  2031.                 foreach($all[$parent->package][$parent->subpackage][$parent->tutorial_typeas $ind => $tute)
  2032.                 {
  2033.                     if ($klink && $tute->getLink($this== $klink)
  2034.                     {
  2035.                         // set up parent, next and prev links
  2036.                         $tute->setParent($parent$this);
  2037.                         // remove the child from the list of tutorials to process
  2038.                         foreach($all[$parent->package][$parent->subpackage][$parent->tutorial_typeas $ind => $t)
  2039.                         {
  2040.                             if ($t->name == $tute->name)
  2041.                             unset($all[$parent->package][$parent->subpackage][$parent->tutorial_type][$ind]);
  2042.                         }
  2043.                         // add to the new ordered list of tutorials
  2044.                         $new[$parent->package][$parent->subpackage][$parent->tutorial_type][$tute;
  2045.                         if ($tute->ini)
  2046.                         {
  2047.                             // add all the child's child tutorials to the list
  2048.                             $this->generateTutorialOrder($tute,$all,$new);
  2049.                         }
  2050.                     }
  2051.                 }
  2052.             }
  2053.         }
  2054.         return;
  2055.     }
  2056.  
  2057.         /** Returns the path to this tutorial as a string
  2058.          * @param parserTutorial $pkg 
  2059.          * @param parserTutorial $subpkg 
  2060.          * @param parserTutorial $namepkg 
  2061.          * @return string */
  2062.         function _tutorial_path($pkg$subpkg = 0$namepkg = 0)
  2063.         {
  2064.             if (!$subpkg{
  2065.                 $subpkg $pkg;
  2066.             }
  2067.             if (!$namepkg{
  2068.                 $namepkg $pkg;
  2069.             }
  2070.             $subpackagename ($subpkg->subpackage ? '/' $subpkg->subpackage : '');
  2071.             return $pkg->package . $subpackagename '/' $namepkg->name;
  2072.         }
  2073.  
  2074.  
  2075.     /**
  2076.      * Creates a tree structure of tutorials
  2077.      *
  2078.      * Format:
  2079.      * <pre>
  2080.      * array('package/subpackage/tutorial1.ext' =>
  2081.      *          array('tutorial' => {@link parserTutorial},
  2082.      *                'child'    =>
  2083.      *                    array('package/subpackage/child1tutorial.ext' => ...,
  2084.      *                          'package/subpackage/child2tutorial.ext' => ...,
  2085.      *                          ...
  2086.      *                         )
  2087.      *       'package/subpackage/tutorial2.ext' => ...,
  2088.      *       ...
  2089.      *       )
  2090.      * </pre>
  2091.      * @return array the tutorial tree
  2092.      * @access private
  2093.      */
  2094.     function _setupTutorialTree($parent = false)
  2095.     {
  2096.         if (isset($this->processed_tutorials)) {
  2097.             $this->processed_tutorials = array();
  2098.         }
  2099.         $tree = array();
  2100.         if (!$parent)
  2101.         {
  2102.             foreach($this->tutorials as $package => $s)
  2103.             {
  2104.                 foreach($s as $subpackage => $t)
  2105.                 {
  2106.                     foreach($t as $type => $n)
  2107.                     {
  2108.                         foreach($n as $name => $tutorial)
  2109.                         {
  2110.                             if ($tutorial->parent{
  2111.                                 continue;
  2112.                             }
  2113.                             
  2114.                             $child_path $this->_tutorial_path($tutorial,$tutorial,$tutorial);
  2115.                             if (isset($this->processed_tutorials[$child_path])) {
  2116.                                 continue;
  2117.                             }
  2118.                             $this->processed_tutorials[$child_path$tutorial;
  2119.                             //debug("parent ".$tutorial->name);
  2120.                             $ret $this->_setupTutorialTree($tutorial);
  2121.                             if (!count($tree)) {
  2122.                                 $tree $ret;
  2123.                             else {
  2124.                                 $tree array_merge($tree,$ret);
  2125.                             }
  2126.                         }
  2127.                     }
  2128.                 }
  2129.             }
  2130.             return $tree;
  2131.         }
  2132.         $parent_path $this->_tutorial_path($parent);
  2133.         $tree[$parent_path]['tutorial'$parent;
  2134.         // process all child tutorials, and insert them in order
  2135.         if ($parent->ini)
  2136.         {
  2137.             foreach($parent->ini['Linked Tutorials'as $child)
  2138.             {
  2139.                 if (isset($this->tutorials[$parent->package][$parent->subpackage]
  2140.                                           [$parent->tutorial_type][$child '.' .
  2141.                                            $parent->tutorial_type])) {
  2142.                     // remove the child from the list of remaining tutorials
  2143.                     $tute $this->tutorials[$parent->package][$parent->subpackage]
  2144.                                             [$parent->tutorial_type][$child '.' .
  2145.                                              $parent->tutorial_type];
  2146.                 else {
  2147.                     $tute = false;
  2148.                 }
  2149.  
  2150.                 if (!$tute{
  2151.                     continue;
  2152.                 }
  2153.                 $child_path $this->_tutorial_path($parent,$parent,$tute);
  2154.                 if (isset($this->processed_tutorials[$child_path])) {
  2155.                     continue;
  2156.                 }
  2157.                 $this->processed_tutorials[$child_path$tute;
  2158.                 if ($tute->name != $child '.' $parent->tutorial_type{
  2159.                     continue;
  2160.                 }
  2161.                 //echo "Adding [$child_path] to [$parent_path]<br>";
  2162.                 $tree[$parent_path]['child'][$this->_tutorial_path($parent,$parent,$tute)]['tutorial']
  2163.                     = $tute;
  2164.                 if (!$tute->ini{
  2165.                     continue;
  2166.                 }
  2167.                 // add all the child's child tutorials to the list
  2168.                 if (!isset($tree[$parent_path]['child'])) {
  2169.                     $tree[$parent_path]['child'$this->_setupTutorialTree($tute);
  2170.                 else {
  2171.                     $tree[$parent_path]['child'array_merge($tree[$parent_path]['child'],
  2172.                         $this->_setupTutorialTree($tute));
  2173.                 }
  2174.             }
  2175.         }
  2176.         return $tree;
  2177.     }
  2178.  
  2179.     /**
  2180.      * Debugging function for dumping {@link $tutorial_tree}
  2181.      * @return string 
  2182.      */
  2183.     function vardump_tree($tree,$indent='')
  2184.     {
  2185.         if (phpDocumentor_get_class($tree== 'parsertutorial'return $tree->name.' extends '.($tree->parent? $tree->parent->name : 'nothing');
  2186.         $a '';
  2187.         foreach($tree as $ind => $stuff)
  2188.         {
  2189.             $x $this->vardump_tree($stuff,"$indent   ");
  2190.             $a .= $indent.'['.$ind." => \n   ".$indent.$x."]\n";
  2191.         }
  2192.         return substr($a,0,strlen($a- 1);
  2193.     }
  2194.  
  2195.     /**
  2196.      * @access private
  2197.      */
  2198.     function sort_package_elements($a,$b)
  2199.     {
  2200.         if (($a->type == $b->type&& (isset($a->isConstructor&& $a->isConstructor)) return -1;
  2201.         if (($a->type == $b->type&& (isset($b->isConstructor&& $b->isConstructor)) return 1;
  2202.         if ($a->type == $b->typereturn strnatcasecmp($a->name,$b->name);
  2203.         if ($a->type == 'class'return -1;
  2204.         if ($b->type == 'class'return 1;
  2205.         if ($a->type == 'const'return -1;
  2206.         if ($b->type == 'const'return 1;
  2207.         if ($a->type == 'var'return -1;
  2208.         if ($b->type == 'var'return 1;
  2209.         if ($a->type == 'page'return -1;
  2210.         if ($b->type == 'page'return 1;
  2211.         if ($a->type == 'include'return -1;
  2212.         if ($b->type == 'include'return 1;
  2213.         if ($a->type == 'define'return -1;
  2214.         if ($b->type == 'define'return 1;
  2215.         if ($a->type == 'global'return -1;
  2216.         if ($b->type == 'global'return 1;
  2217.         if ($a->type == 'function'return -1;
  2218.         if ($b->type == 'function'return 1;
  2219.     }
  2220.  
  2221.     /**
  2222.      * @access private
  2223.      */
  2224.     function defpackagesort($a,$b)
  2225.     {
  2226.         if ($a == $GLOBALS['phpDocumentor_DefaultPackageName']return -1;
  2227.         if ($b == $GLOBALS['phpDocumentor_DefaultPackageName']return 0;
  2228.         return strnatcasecmp($a,$b);
  2229.     }
  2230.  
  2231.     /**
  2232.      * @access private
  2233.      */
  2234.     function Pc_sort($a,$b)
  2235.     {
  2236.         return strnatcasecmp(key($a),key($b));
  2237.     }
  2238.  
  2239.     /**
  2240.      * walk over elements by package rather than page
  2241.      *
  2242.      * This method is designed for converters like the PDF converter that need
  2243.      * everything passed in alphabetical order by package/subpackage and by
  2244.      * procedural and then class information
  2245.      * @see PDFdefaultConverter
  2246.      * @see walk()
  2247.      */
  2248.     function walk_everything()
  2249.     {
  2250.         global $hooser;
  2251.         $hooser = false;
  2252.         uksort($this->package_elements,array($this,'defpackagesort'));
  2253.         foreach($this->package_elements as $package => $r)
  2254.         {
  2255.             if ($this->package_output)
  2256.             {
  2257.                 if (!in_array($this->package,$this->package_output))
  2258.                 {
  2259.                     unset($this->package_elements[$package]);
  2260.                     continue;
  2261.                 }
  2262.             }
  2263.             uksort($this->package_elements[$package],'strnatcasecmp');
  2264.         }
  2265.         foreach($this->package_elements as $package => $r)
  2266.         {
  2267.             foreach($this->package_elements[$packageas $subpackage => $r)
  2268.             {
  2269.                 if (isset($r['page']))
  2270.                 {
  2271.                     uksort($r['page'],'strnatcasecmp');
  2272.                     foreach($r['page'as $page => $oo)
  2273.                     {
  2274.                         usort($this->package_elements[$package][$subpackage]['page'][$page],array($this,'sort_package_elements'));
  2275.                     }
  2276.                 }
  2277.                 if (isset($r['class']))
  2278.                 {
  2279.                     uksort($r['class'],'strnatcasecmp');
  2280.                     foreach($r['class'as $page => $oo)
  2281.                     {
  2282.                         usort($r['class'][$page],array($this,'sort_package_elements'));
  2283.                     }
  2284.                 }
  2285.                 $this->package_elements[$package][$subpackage$r;
  2286.             }
  2287.         }
  2288.         foreach($this->package_elements as $package => $s)
  2289.         {
  2290.             $notyet = false;
  2291.             foreach($s as $subpackage => $r)
  2292.             {
  2293.                 $this->package = $package;
  2294.                 $this->subpackage = $subpackage;
  2295.                 if (isset($r['page']))
  2296.                 {
  2297.                     $this->class = false;
  2298.                     foreach($r['page'as $page => $elements)
  2299.                     {
  2300.                         if (is_array($elements))
  2301.                         {
  2302.                             foreach($elements as $element)
  2303.                             {
  2304.                                 if ($element->type == 'page')
  2305.                                 {
  2306.                                     phpDocumentor_out('Converting '.$element->parent->getPath());
  2307.                                     flush();
  2308.                                     $this->curfile = $element->parent->getFile();
  2309.                                     $this->curname $this->getPageName($element->parent);
  2310.                                     $this->curpath $element->parent->getPath();
  2311.                                     $notyet = true;
  2312.                                 else
  2313.                                 {
  2314.                                     // force all contained elements to have parent package/subpackage
  2315.                                     $element->docblock->package = $this->package;
  2316.                                     $element->docblock->subpackage = $this->subpackage;
  2317.                                     $a $element->docblock->getKeyword('access');
  2318.                                     if (is_object($a)) $a $a->getString();
  2319.                                     if (!$this->parseprivate && ($a == 'private'))
  2320.                                         continue;
  2321.                                 }
  2322.                                 if ($notyet)
  2323.                                 {
  2324.                                     phpDocumentor_out(" Procedural Page Elements...");
  2325.                                     flush();
  2326.                                     $notyet = false;
  2327.                                 }
  2328.                                 $this->Convert($element);
  2329.                             }
  2330.                         }
  2331.                         $this->endPage();
  2332.                         phpDocumentor_out("done\n");
  2333.                         flush();
  2334.                     }
  2335.                 }
  2336.                 $start_classes = true;
  2337.                 if (isset($r['class']))
  2338.                 {
  2339.                     foreach($r['class'as $class => $elements)
  2340.                     {
  2341.                         foreach($elements as $element)
  2342.                         {
  2343.                             if ($element->type == 'class')
  2344.                             {
  2345.                                 if (!$start_classes)
  2346.                                 {
  2347.                                     if (count($elements&& !$this->killclass$this->endClass();
  2348.                                     phpDocumentor_out("done\n");
  2349.                                     flush();
  2350.                                 }
  2351.                                 $start_classes = false;
  2352.                                 $this->class = $element->getName();
  2353.                                 $this->killclass = false;
  2354.                                 if ($this->checkKillClass($element->getName(),$element->getPath())) continue;
  2355.                                 if (!$this->killclass)
  2356.                                 {
  2357.                                     phpDocumentor_out('Converting '.$this->class."...");
  2358.                                     flush();
  2359.                                     $notyet = true;
  2360.                                 }
  2361.                             else
  2362.                             {
  2363.                                 if ($notyet)
  2364.                                 {
  2365.                                     phpDocumentor_out("Variables/methods/Class constants...\n");
  2366.                                     flush();
  2367.                                     $notyet = false;
  2368.                                 }
  2369.                                 $a $element->docblock->getKeyword('access');
  2370.                                 if (is_object($a)) $a $a->getString();
  2371.                                 if (!$this->parseprivate && ($a == 'private'))
  2372.                                     continue;
  2373.                                 if ($this->killclasscontinue;
  2374.                                 // force all contained elements to have parent package/subpackage
  2375.                                 $element->docblock->package = $this->package;
  2376.                                 $element->docblock->subpackage = $this->subpackage;
  2377.                             }
  2378.                             if ($this->killclasscontinue;
  2379.                             $this->Convert($element);
  2380.                         }
  2381.                     }
  2382.                     if (count($elements&& !$this->killclass$this->endClass();
  2383.                     phpDocumentor_out("done\n");
  2384.                     flush();
  2385.                 // if isset($r['class'])
  2386.             // foreach($s
  2387.         // foreach($this->package_elements)
  2388.         phpDocumentor_out("\nConverting @todo List...");
  2389.         flush();
  2390.         if (count($this->todoList))
  2391.         {
  2392.             $this->ConvertTodoList();
  2393.         }
  2394.         phpDocumentor_out("done\n");
  2395.         flush();
  2396.         phpDocumentor_out("\nConverting Error Log...");
  2397.         flush();
  2398.         $this->ConvertErrorLog();
  2399.         phpDocumentor_out("done\n");
  2400.         flush();
  2401.     }
  2402.  
  2403.     /**
  2404.      * Convert the phpDocumentor parsing/conversion error log
  2405.      * @abstract
  2406.      */
  2407.     function ConvertErrorLog()
  2408.     {
  2409.     }
  2410.  
  2411.     /**
  2412.      * Convert the list of all @todo tags
  2413.      * @abstract
  2414.      */
  2415.     function ConvertTodoList()
  2416.     {
  2417.     }
  2418.  
  2419.     /**
  2420.      * Sorts the @todo list - do not override or modify this function
  2421.      * @access private
  2422.      * @uses _sortTodos passed to {@link usort()} to sort the todo list
  2423.      */
  2424.     function sortTodos()
  2425.     {
  2426.         phpDocumentor_out("\nSorting @todo list...");
  2427.         flush();
  2428.         foreach($this->todoList as $package => $r{
  2429.             usort($this->todoList[$package]array('Converter''_sortTodoPackage'));
  2430.             foreach ($r as $a => $sub{
  2431.                 if (is_array($this->todoList[$package][$a][1])) {
  2432.                     usort($this->todoList[$package][$a][1],array('Converter''_sortTodos'));
  2433.                 }
  2434.             }
  2435.         }
  2436.         phpDocumentor_out("done\n");
  2437.     }
  2438.  
  2439.     /** @access private */
  2440.     function _sortTodoPackage($a$b)
  2441.     {
  2442.         return strnatcasecmp($a[0]->name$b[0]->name);
  2443.     }
  2444.  
  2445.     /** @access private */
  2446.     function _sortTodos($a$b)
  2447.     {
  2448.         if (!is_object($a)) {
  2449.             var_dump($a);
  2450.         }
  2451.         return strnatcasecmp($a->getString()$b->getString());
  2452.     }
  2453.  
  2454.     /**
  2455.      * Sorts all indexes - do not override or modify this function
  2456.      * @uses $leftindex based on the value of leftindex, sorts link arrays
  2457.      * @uses $class_elements sorts with {@link compareLink}
  2458.      * @uses $page_elements sorts with {@link compareLink}
  2459.      * @uses $define_elements sorts with {@link compareLink}
  2460.      * @uses $global_elements sorts with {@link compareLink}
  2461.      * @uses $function_elements sorts with {@link compareLink}
  2462.      * @uses $elements sorts with {@link elementCmp}
  2463.      * @uses $pkg_elements sorts with {@link elementCmp} after sorting by
  2464.      *                      package/subpackage alphabetically
  2465.      * @access private
  2466.      */
  2467.     function sortIndexes()
  2468.     {
  2469.         phpDocumentor_out("\nSorting Indexes...");
  2470.         flush();
  2471.         uksort($this->elements,'strnatcasecmp');
  2472.         if ($this->leftindex['classes'])
  2473.         {
  2474.             foreach($this->class_elements as $package => $o1)
  2475.             {
  2476.                 foreach($o1 as $subpackage => $links)
  2477.                 {
  2478.                     usort($this->class_elements[$package][$subpackage],array($this,'compareLink'));
  2479.                 }
  2480.             }
  2481.         }
  2482.         if ($this->leftindex['pages'])
  2483.         {
  2484.             foreach($this->page_elements as $package => $o1)
  2485.             {
  2486.                 uksort($this->page_elements[$package],'strnatcasecmp');
  2487.                 foreach($o1 as $subpackage => $links)
  2488.                 {
  2489.                     usort($this->page_elements[$package][$subpackage],array($this,'compareLink'));
  2490.                 }
  2491.             }
  2492.         }
  2493.         if ($this->leftindex['defines'])
  2494.         {
  2495.             foreach($this->define_elements as $package => $o1)
  2496.             {
  2497.                 uksort($this->define_elements[$package],'strnatcasecmp');
  2498.                 foreach($o1 as $subpackage => $links)
  2499.                 {
  2500.                     usort($this->define_elements[$package][$subpackage],array($this,'compareLink'));
  2501.                 }
  2502.             }
  2503.         }
  2504.         if ($this->leftindex['globals'])
  2505.         {
  2506.             foreach($this->global_elements as $package => $o1)
  2507.             {
  2508.                 uksort($this->global_elements[$package],'strnatcasecmp');
  2509.                 foreach($o1 as $subpackage => $links)
  2510.                 {
  2511.                     usort($this->global_elements[$package][$subpackage],array($this,'compareLink'));
  2512.                 }
  2513.             }
  2514.         }
  2515.         if ($this->leftindex['functions'])
  2516.         {
  2517.             foreach($this->function_elements as $package => $o1)
  2518.             {
  2519.                 uksort($this->function_elements[$package],'strnatcasecmp');
  2520.                 foreach($o1 as $subpackage => $links)
  2521.                 {
  2522.                     usort($this->function_elements[$package][$subpackage],array($this,'compareLink'));
  2523.                 }
  2524.             }
  2525.         }
  2526.         foreach($this->elements as $letter => $nothuing)
  2527.         {
  2528.             uasort($this->elements[$letter],array($this,"elementCmp"));
  2529.         }
  2530.         foreach($this->pkg_elements as $package => $els)
  2531.         {
  2532.             uksort($this->pkg_elements[$package],'strnatcasecmp');
  2533.             foreach($this->pkg_elements[$packageas $subpackage => $els)
  2534.             {
  2535.                 if (empty($els)) continue;
  2536.                 uksort($this->pkg_elements[$package][$subpackage],'strnatcasecmp');
  2537.                 foreach($els as $letter => $yuh)
  2538.                 {
  2539.                     usort($this->pkg_elements[$package][$subpackage][$letter],array($this,"elementCmp"));
  2540.                 }
  2541.             }
  2542.         }
  2543.         phpDocumentor_out("done\n");
  2544.         flush();
  2545.     }
  2546.  
  2547.     /**
  2548.      * sorts {@link $page_contents} by element type as well as alphabetically
  2549.      * @see $sort_page_contents_by_element_type
  2550.      */
  2551.     function sortPageContentsByElementType(&$pages)
  2552.     {
  2553.         foreach($this->page_contents as $package => $els)
  2554.         {
  2555.             foreach($this->page_contents[$packageas $subpackage => $els)
  2556.             {
  2557.                 if (empty($els)) continue;
  2558.                 foreach($this->page_contents[$package][$subpackageas $path => $stuff)
  2559.                 {
  2560.                     if (!count($pages[$path]->elements)) continue;
  2561.                     usort($pages[$path]->elements,array($this,'eltypecmp'));
  2562.                     usort($this->page_contents[$package][$subpackage][$path],array($this,'eltypecmp'));
  2563.                     if (isset($this->page_contents[$package][$subpackage][$path][0]))
  2564.                     $this->page_contents[$package][$subpackage][$path]['###main'$this->page_contents[$package][$subpackage][$path][0];
  2565.                     unset($this->page_contents[$package][$subpackage][$path][0]);
  2566.                 }
  2567.             }
  2568.         }
  2569.     }
  2570.  
  2571.     /**
  2572.      * @access private
  2573.      * @see Converter::sortIndexes()
  2574.      */
  2575.     function compareLink($a$b)
  2576.     {
  2577.          return strnatcasecmp($a->name,$b->name);
  2578.     }
  2579.  
  2580.     /**
  2581.      * @access private
  2582.      * @see Converter::sortPageContentsByElementType()
  2583.      */
  2584.     function eltypecmp($a$b)
  2585.     {
  2586.         if ($a->type == 'page'return -1;
  2587.         if ($b->type == 'page'return 1;
  2588.          return strnatcasecmp($a->type.$a->name,$b->type.$b->name);
  2589.     }
  2590.  
  2591.     /**
  2592.      * does a nat case sort on the specified second level value of the array
  2593.      *
  2594.      * @param    mixed    $a 
  2595.      * @param    mixed    $b 
  2596.      * @return    int 
  2597.      * @access private
  2598.      */
  2599.     function elementCmp ($a$b)
  2600.     {
  2601.         return strnatcasecmp($a->getName()$b->getName());
  2602.     }
  2603.  
  2604.     /**
  2605.      * Used to stop conversion of @ignored or private @access classes
  2606.      * @uses $killclass sets killclass based on the value of {@link Classes::$killclass}
  2607.      *        and {@link $package_output}
  2608.      * @access private
  2609.      */
  2610.     function checkKillClass($class$path)
  2611.     {
  2612.         $this->killclass = false;
  2613.         if (isset($this->classes->killclass[$class]&& isset($this->classes->killclass[$class][$path])) $this->killclass = true;
  2614.         if ($this->package_output)
  2615.         {
  2616.             $a $this->classes->getClass($class$path);
  2617.             if (!in_array($a->docblock->package,$this->package_output)) $this->killclass = true;
  2618.         }
  2619.         if (PHPDOCUMENTOR_DEBUG && $this->killclassdebug("$class $path killed");
  2620.         return $this->killclass;
  2621.     }
  2622.  
  2623.     /**
  2624.      * @param abstractLink descendant of abstractLink
  2625.      * @param array|parserTaglist of @todos|@todo tag
  2626.      * @access private
  2627.      */
  2628.     function addTodoLink($link$todos)
  2629.     {
  2630.         $this->todoList[$link->package][= array($link$todos);
  2631.     }
  2632.  
  2633.     /**
  2634.      * Adds all elements to the {@link $elements, $pkg_elements, $links},
  2635.      * {@link $linkswithfile} and left indexes - Do not modify or override
  2636.      * @access private
  2637.      * @param parserBase any documentable element descendant of parserBase
  2638.      *                    except parserTutorial
  2639.      * @param false|parserPageonly used to add a {@link parserPage} if the
  2640.      *                          $element passed is a parserPage
  2641.      * @staticvar string path of current page, used for {@link $page_contents} setup
  2642.      */
  2643.     function addElement(&$element,$pageel=false)
  2644.     {
  2645.         static $curpath '';
  2646.         if ($this->package_output)
  2647.         {
  2648.             if (!in_array($this->package$this->package_output)) return;
  2649.         }
  2650.         if ($pageel && phpDocumentor_get_class($pageel== 'parserdata')
  2651.         {
  2652.             if (isset($pageel->docblock&& phpDocumentor_get_class($pageel->docblock== 'parserdocblock')
  2653.             {
  2654.                 $a $pageel->docblock->getKeyword('todo');
  2655.                 if ($a)
  2656.                 {
  2657.                     $this->addTodoLink($this->addLink($element),$a);
  2658.                 }
  2659.             }
  2660.         }
  2661.         if (isset($element->docblock))
  2662.         {
  2663.             $a $element->docblock->getKeyword('access');
  2664.             if (is_object($a)) $a $a->getString();
  2665.             if (!$this->parseprivate && ($a == 'private'))
  2666.                 return;
  2667.             $a $element->docblock->getKeyword('todo');
  2668.             if ($a)
  2669.             {
  2670.                 if ($element->type != 'include'{
  2671.                     $this->addTodoLink($this->addLink($element),$a);
  2672.                 else {
  2673.                     addWarning(PDERROR_NOTODO_INCLUDE$element->getLineNumber(),
  2674.                         $element->getPath());
  2675.                 }
  2676.             }
  2677.         }
  2678.         $startPositionOfElementName = 0;    // which character of the element name actually starts its textual name
  2679.         switch($element->type)
  2680.         {
  2681.             case 'page' :
  2682.                 if ($this->sort_absolutely_everything)
  2683.                 {
  2684.                     $this->package_elements[$element->package][$element->subpackage]['page'][$element->getPath()][$pageel;
  2685.                 }
  2686.                 $link $this->addLink($element);
  2687.                 $curpath $element->getPath();
  2688.                 if ($this->leftindex['pages'])
  2689.                 $this->page_elements[$element->package][$element->subpackage][$link;
  2690.                 $this->page_contents[$element->package][$element->subpackage][$curpath]['###main'$link;
  2691.             break;
  2692.             case 'class' :
  2693.                 if ($this->sort_absolutely_everything)
  2694.                 {
  2695.                     $this->package_elements[$element->docblock->package][$element->docblock->subpackage]['class'][$this->class][$element;
  2696.                 }
  2697.                 $link $this->addLink($element);
  2698.                 if ($this->leftindex['classes'])
  2699.                 $this->class_elements[$element->docblock->package][$element->docblock->subpackage][$link;
  2700.                 $this->class_contents[$element->docblock->package][$element->docblock->subpackage][$this->class]['###main'$link;
  2701.             break;
  2702.             case 'include' :
  2703.                 if ($this->sort_absolutely_everything)
  2704.                 {
  2705.                     $this->package_elements[$element->docblock->package][$element->docblock->subpackage]['page'][$curpath][$element;
  2706.                 }
  2707.                 $link $this->addLink($element);
  2708.             break;
  2709.             case 'define' :
  2710.                 if ($this->sort_absolutely_everything)
  2711.                 {
  2712.                     $this->package_elements[$element->docblock->package][$element->docblock->subpackage]['page'][$curpath][$element;
  2713.                 }
  2714.                 $link $this->addLink($element);
  2715.                 if ($this->leftindex['defines'])
  2716.                 $this->define_elements[$element->docblock->package][$element->docblock->subpackage][$link;
  2717.                 $this->page_contents[$element->docblock->package][$element->docblock->subpackage][$curpath][$link;
  2718.             break;
  2719.             case 'global' :
  2720.                 if ($this->sort_absolutely_everything)
  2721.                 {
  2722.                     $this->package_elements[$element->docblock->package][$element->docblock->subpackage]['page'][$curpath][$element;
  2723.                 }
  2724.                 $link $this->addLink($element);
  2725.                 $startPositionOfElementName = 1;    // lose the leading "$" character
  2726.                 if ($this->leftindex['globals'])
  2727.                 $this->global_elements[$element->docblock->package][$element->docblock->subpackage][$link;
  2728.                 $this->page_contents[$element->docblock->package][$element->docblock->subpackage][$curpath][$link;
  2729.             break;
  2730.             case 'var' :
  2731.                 if ($this->sort_absolutely_everything)
  2732.                 {
  2733.                     $this->package_elements[$element->docblock->package][$element->docblock->subpackage]['class'][$this->class][$element;
  2734.                 }
  2735.                 $link $this->addLink($element);
  2736.                 $startPositionOfElementName = 1;    // lose the leading "$" character
  2737.                 $this->class_contents[$element->docblock->package][$element->docblock->subpackage][$this->class][$link;
  2738.             break;
  2739.             case 'const' :
  2740.                 if ($this->sort_absolutely_everything)
  2741.                 {
  2742.                     $this->package_elements[$element->docblock->package][$element->docblock->subpackage]['class'][$this->class][$element;
  2743.                 }
  2744.                 $link $this->addLink($element);
  2745.                 $this->class_contents[$element->docblock->package][$element->docblock->subpackage][$this->class][$link;
  2746.             break;
  2747.             case 'method' :
  2748.                 if ($this->sort_absolutely_everything)
  2749.                 {
  2750.                     $this->package_elements[$element->docblock->package][$element->docblock->subpackage]['class'][$this->class][$element;
  2751.                 }
  2752.                 $link $this->addLink($element);
  2753.                 $this->class_contents[$element->docblock->package][$element->docblock->subpackage][$this->class][$link;
  2754.             break;
  2755.             case 'function' :
  2756.                 if ($this->sort_absolutely_everything)
  2757.                 {
  2758.                     $this->package_elements[$element->docblock->package][$element->docblock->subpackage]['page'][$curpath][$element;
  2759.                 }
  2760.                 $link $this->addLink($element);
  2761.                 if ($this->leftindex['functions'])
  2762.                 $this->function_elements[$element->docblock->package][$element->docblock->subpackage][$link;
  2763.                 $this->page_contents[$element->docblock->package][$element->docblock->subpackage][$curpath][$link;
  2764.             break;
  2765.             default :
  2766.             break;
  2767.         }
  2768.         if ($element->getType(!= 'include')
  2769.         {
  2770.             if ($element->getType(== 'var' || $element->getType(== 'method'|| $element->getType(== 'const')
  2771.             {
  2772.                 $this->links[$this->package][$this->subpackage][$element->getType()][$element->class][$element->getName()$link;
  2773.                 $this->linkswithfile[$this->package][$this->subpackage][$element->getType()][$element->getPath()][$element->class][$element->getName()$link;
  2774.             else
  2775.             {
  2776.                 if ($element->type == 'page')
  2777.                 {
  2778.                     $this->links[$this->package][$this->subpackage][$element->getType()][$element->getFile()$link;
  2779.                     $this->linkswithfile[$this->package][$this->subpackage][$element->getType()][$element->getPath()][$element->getFile()$link;
  2780.                 else
  2781.                 {
  2782.                     $this->links[$this->package][$this->subpackage][$element->getType()][$element->getName()$link;
  2783.                     $this->linkswithfile[$this->package][$this->subpackage][$element->getType()][$element->getPath()][$element->getName()$link;
  2784.                 }
  2785.             }
  2786.         }
  2787.         if ($element->type == 'page')
  2788.         {
  2789.             $this->elements[substr(strtolower($element->getFile()),$startPositionOfElementName,1)][$element;
  2790.             $this->pkg_elements[$this->package][$this->subpackage][substr(strtolower($element->getFile()),$startPositionOfElementName,1)][$element;
  2791.         else
  2792.         {
  2793.             $this->elements[substr(strtolower($element->getName()),$startPositionOfElementName,1)][$element;
  2794.             $this->pkg_elements[$this->package][$this->subpackage][substr(strtolower($element->getName()),$startPositionOfElementName,1)][$element;
  2795.         }
  2796.     }
  2797.  
  2798.     /**
  2799.      * returns an abstract link to element.  Do not modify or override
  2800.      *
  2801.      * This method should only be called in process of Conversion, unless
  2802.      * $element is a parserPage, or $page is set to true, and $element is
  2803.      * not a parserPage
  2804.      * @return abstractLink abstractLink descendant
  2805.      * @access private
  2806.      * @param parserElement element to add a new link (descended from
  2807.      *                       {@link abstractLink})to the {@link $links} array
  2808.      * @param string classname for elements that are class-based (this may be
  2809.      *                deprecated in the future, as the classname
  2810.      *                should be contained within the element.  if $element is a
  2811.      *                page, this parameter is a package name
  2812.      * @param string subpackage name for page elements
  2813.      */
  2814.     function addLink(&$element,$page = false)
  2815.     {
  2816.         if ($page)
  2817.         {
  2818.             // create a fake parserPage to extract the fileAlias for this link
  2819.             $fakepage = new parserPage;
  2820.             $fakepage->setPath($element->getPath());
  2821.             $fakepage->setFile(basename($element->getPath()));
  2822.             $this->curname = $this->getPageName($fakepage);
  2823.         }
  2824.         switch($element->type)
  2825.         {
  2826.             case 'function':
  2827.                 $x = new functionLink;
  2828.                 $x->addLink($element->getPath()$this->curname$element->name$element->docblock->package$element->docblock->subpackage$element->docblock->category);
  2829.                 return $x;
  2830.             break;
  2831.             case 'define':
  2832.                 $x = new defineLink;
  2833.                 $x->addLink($element->getPath()$this->curname$element->name$element->docblock->package$element->docblock->subpackage$element->docblock->category);
  2834.                 return $x;
  2835.             break;
  2836.             case 'global':
  2837.                 $x = new globalLink;
  2838.                 $x->addLink($element->getPath()$this->curname$element->name$element->docblock->package$element->docblock->subpackage$element->docblock->category);
  2839.                 return $x;
  2840.             break;
  2841.             case 'class':
  2842.                 $x = new classLink;
  2843.                 $x->addLink($element->getPath()$this->curname$element->name$element->docblock->package$element->docblock->subpackage$element->docblock->category);
  2844.                 return $x;
  2845.             break;
  2846.             case 'method':
  2847.                 $x = new methodLink;
  2848.                 $x->addLink($this->class$element->getPath()$this->curname$element->name$element->docblock->package$element->docblock->subpackage$element->docblock->category);
  2849.                 return $x;
  2850.             break;
  2851.             case 'var':
  2852.                 $x = new varLink;
  2853.                 $x->addLink($this->class$element->getPath()$this->curname$element->name$element->docblock->package$element->docblock->subpackage$element->docblock->category);
  2854.                 return $x;
  2855.             break;
  2856.             case 'const':
  2857.                 $x = new constLink;
  2858.                 $x->addLink($this->class$element->getPath()$this->curname$element->name$element->docblock->package$element->docblock->subpackage$element->docblock->category);
  2859.                 return $x;
  2860.             break;
  2861.             case 'page':
  2862.                 $x = new pageLink;
  2863.                 $x->addLink($element->getPath(),$this->getPageName($element),$element->file,$element->package$element->subpackage$element->category);
  2864.                 return $x;
  2865.             break;
  2866.         }
  2867.     }
  2868.  
  2869.     /**
  2870.      * Return a tree of all classes that extend this class
  2871.      *
  2872.      * The data structure returned is designed for a non-recursive algorithm,
  2873.      * and is somewhat complex.
  2874.      * In most cases, the array returned is:
  2875.      *
  2876.      * <pre>
  2877.      * array('#root' =>
  2878.      *         array('link' => {@link classLink} to $class,
  2879.      *               'parent' => false,
  2880.      *               'children' => array(array('class' => 'childclass1',
  2881.      *                                         'package' => 'child1package'),
  2882.      *                                    array('class' => 'childclass2',
  2883.      *                                         'package' => 'child2package'),...
  2884.      *                                  )
  2885.      *               ),
  2886.      *       'child1package#childclass1' =>
  2887.      *         array('link' => {@link classLink} to childclass1,
  2888.      *               'parent' => '#root',
  2889.      *               'children' => array(array('class' => 'kidclass',
  2890.      *                                         'package' => 'kidpackage'),...
  2891.      *                                  )
  2892.      *              ),
  2893.      *       'kidpackage#kidclass' =>
  2894.      *         array('link' => {@link classLink} to kidclass,
  2895.      *               'parent' => 'child1package#childclass1',
  2896.      *               'children' => array() // no children
  2897.      *              ),
  2898.      *      ....
  2899.      *      )
  2900.      *</pre>
  2901.      *
  2902.      * To describe this format using language, every class in the tree has an
  2903.      * entry in the first level of the array.  The index for all child
  2904.      * classes that extend the root class is childpackage#childclassname.
  2905.      * Each entry in the array has 3 elements: link, parent, and children.
  2906.      * <ul>
  2907.      *  <li>link - a {@link classLink} to the current class</li>
  2908.      *  <li>parent - a {@link classLink} to the class's parent, or false (except for one special case described below)</li>
  2909.      *  <li>children - an array of arrays, each entry has a 'class' and 'package' index to the child class,
  2910.      * used to find the entry in the big array</li>
  2911.      * </ul>
  2912.      *
  2913.      * special cases are when the #root class has a parent in another package,
  2914.      * or when the #root class extends a class not found
  2915.      * by phpDocumentor.  In the first case, parent will be a
  2916.      * classLink to the parent class.  In the second, parent will be the
  2917.      * extends clause, as in:
  2918.      * <code>
  2919.      * class X extends Y
  2920.      * {
  2921.      * ...
  2922.      * }
  2923.      * </code>
  2924.      * in this case, the #root entry will be array('link' => classLink to X, 'parent' => 'Y', children => array(...))
  2925.      *
  2926.      * The fastest way to design a method to process the array returned
  2927.      * is to copy HTMLframesConverter::getRootTree() into
  2928.      * your converter and to modify the html to whatever output format you are going to use
  2929.      * @see HTMLframesConverter::getRootTree()
  2930.      * @param string class name
  2931.      * @param string 
  2932.      * @param string 
  2933.      * @return array Format: see docs
  2934.      */
  2935.     function getSortedClassTreeFromClass($class,$package,$subpackage)
  2936.     {
  2937.         $my_tree = array();
  2938.         $root $this->classes->getClassByPackage($class,$package);
  2939.         if (!$rootreturn false;
  2940.         $class_children $this->classes->getDefiniteChildren($class,$root->curfile);
  2941.         if (!$class_children)
  2942.         {
  2943.             // special case: parent class is found, but is not part of this package, class has no children
  2944.             if (is_array($root->parent))
  2945.             {
  2946.                 $x $root->getParent($this);
  2947.                 if ($x->docblock->package != $package)
  2948.                 {
  2949.                     $v Converter::getClassLink($root->getName(),$package,$root->getPath());
  2950.                     return array('#root' => array('link' => $v,'parent' => Converter::getClassLink($x->getName(),$x->docblock->package,$x->getPath())'children' => array()));
  2951.                 }
  2952.             else
  2953.             // class has normal situation, no children
  2954.                 if (is_string($root->getParent($this)))
  2955.                 return array('#root' => array('link' => Converter::getClassLink($root->getName(),$package,$root->getPath())'parent' => $root->getExtends(),'children' => array()));
  2956.                 else
  2957.                 return array('#root' => array('link' => Converter::getClassLink($root->getName(),$package,$root->getPath())'parent' => false'children' => array()));
  2958.             }
  2959.         }
  2960.         // special case: parent class is found, but is not part of this package, class has children
  2961.         if (is_array($root->parent))
  2962.         {
  2963.             $x $root->getParent($this);
  2964.             if ($x->docblock->package != $package)
  2965.             {
  2966.                 $v Converter::getClassLink($root->getName(),$package,$root->getPath());
  2967.                 $my_tree = array('#root' => array('link' => $v'parent' => Converter::getClassLink($x->getName(),$x->docblock->package,$x->getPath())'children' => array()));
  2968.             else
  2969.             {
  2970.             }
  2971.         else
  2972.         $my_tree = array('#root' => array('link' => Converter::getClassLink($root->getName(),$package,$root->getPath())'parent' => false'children' => array()));
  2973.         // location of tree walker
  2974.         $cur '#root';
  2975.         $lastcur = array(array(false,0));
  2976.         $childpos = 0;
  2977.         if (isset($class_children))
  2978.         {
  2979.             do
  2980.             {
  2981.                 if (!$class_children)
  2982.                 {
  2983.                     list($cur$childposarray_pop($lastcur);
  2984.                     if (isset($my_tree[$cur]['children'][$childpos + 1]))
  2985.                     {
  2986.                         array_push($lastcurarray($cur$childpos + 1));
  2987.                         $par $cur;
  2988.                         $cur $my_tree[$cur]['children'][$childpos + 1];
  2989.                         $x $this->classes->getClassByPackage($cur['class'],$cur['package']);
  2990.                         $childpos = 0;
  2991.                         $cur $cur['package''#' $cur['class'];
  2992.                         $my_tree[$cur]['link'Converter::getClassLink($x->getName(),$x->docblock->package,$x->getPath());
  2993.                         $my_tree[$cur]['parent'$par;
  2994.                         $my_tree[$cur]['children'= array();
  2995.                         $class_children $this->classes->getDefiniteChildren($x->getName()$x->curfile);
  2996.                         continue;
  2997.                     else
  2998.                     {
  2999.                         $class_children = false;
  3000.                         continue;
  3001.                     }
  3002.                 }
  3003.                 foreach($class_children as $chileclass => $chilefile)
  3004.                 {
  3005.                     $ch $this->classes->getClass($chileclass,$chilefile);
  3006.                     $my_tree[$cur]['children'][= array('class' => $ch->getName()'package' => $ch->docblock->package);
  3007.                 }
  3008.                 usort($my_tree[$cur]['children'],'rootcmp');
  3009.                 if (isset($my_tree[$cur]['children'][$childpos]))
  3010.                 {
  3011.                     array_push($lastcurarray($cur$childpos));
  3012.                     $par $cur;
  3013.                     $cur $my_tree[$cur]['children'][$childpos];
  3014.                     $x $this->classes->getClassByPackage($cur['class'],$cur['package']);
  3015.                     $cur $cur['package''#' $cur['class'];
  3016.                     $my_tree[$cur]['link'Converter::getClassLink($x->getName(),$x->docblock->package,$x->getPath());
  3017.                     $my_tree[$cur]['parent'$par;
  3018.                     $my_tree[$cur]['children'= array();
  3019.                     $childpos = 0;
  3020.                     $class_children $this->classes->getDefiniteChildren($x->getName()$x->curfile);
  3021.                 else
  3022.                 {
  3023.                     list($cur$childposarray_pop($lastcur);
  3024.                 }
  3025.             while ($cur);
  3026.         }
  3027.         return $my_tree;
  3028.     }
  3029.  
  3030.     /**
  3031.      * do not override
  3032.      * @return bool true if a link to this class exists in package $package and subpackage $subpackage
  3033.      * @param string $expr class name
  3034.      * @param string $package package to search in
  3035.      * @param string $subpackage subpackage to search in
  3036.      * @access private
  3037.      */
  3038.     function isLinkedClass($expr,$package,$subpackage,$file=false)
  3039.     {
  3040.         if ($file)
  3041.         return isset($this->linkswithfile[$package][$subpackage]['class'][$file][$expr]);
  3042.         return isset($this->links[$package][$subpackage]['class'][$expr]);
  3043.     }
  3044.  
  3045.     /**
  3046.      * do not override
  3047.      * @return bool true if a link to this function exists in package $package and subpackage $subpackage
  3048.      * @param string $expr function name
  3049.      * @param string $package package to search in
  3050.      * @param string $subpackage subpackage to search in
  3051.      * @access private
  3052.      */
  3053.     function isLinkedFunction($expr,$package,$subpackage,$file=false)
  3054.     {
  3055.         if ($file)
  3056.         return isset($this->linkswithfile[$package][$subpackage]['function'][$file][$expr]);
  3057.         return isset($this->links[$package][$subpackage]['function'][$expr]);
  3058.     }
  3059.  
  3060.     /**
  3061.      * do not override
  3062.      * @return bool true if a link to this define exists in package $package and subpackage $subpackage
  3063.      * @param string $expr define name
  3064.      * @param string $package package to search in
  3065.      * @param string $subpackage subpackage to search in
  3066.      * @access private
  3067.      */
  3068.     function isLinkedDefine($expr,$package,$subpackage,$file=false)
  3069.     {
  3070.         if ($file)
  3071.         return isset($this->linkswithfile[$package][$subpackage]['define'][$file][$expr]);
  3072.         return isset($this->links[$package][$subpackage]['define'][$expr]);
  3073.     }
  3074.  
  3075.     /**
  3076.      * do not override
  3077.      * @return bool true if a link to this define exists in package $package and subpackage $subpackage
  3078.      * @param string $expr define name
  3079.      * @param string $package package to search in
  3080.      * @param string $subpackage subpackage to search in
  3081.      * @access private
  3082.      */
  3083.     function isLinkedGlobal($expr,$package,$subpackage,$file=false)
  3084.     {
  3085.         if ($file)
  3086.         return isset($this->linkswithfile[$package][$subpackage]['global'][$file][$expr]);
  3087.         return isset($this->links[$package][$subpackage]['global'][$expr]);
  3088.     }
  3089.  
  3090.     /**
  3091.      * do not override
  3092.      * @return bool true if a link to this procedural page exists in package $package and subpackage $subpackage
  3093.      * @param string $expr procedural page name
  3094.      * @param string $package package to search in
  3095.      * @param string $subpackage subpackage to search in
  3096.      * @access private
  3097.      */
  3098.     function isLinkedPage($expr,$package,$subpackage,$path=false)
  3099.     {
  3100.         if ($path)
  3101.         return isset($this->linkswithfile[$package][$subpackage]['page'][$path][$expr]);
  3102.         return isset($this->links[$package][$subpackage]['page'][$expr]);
  3103.     }
  3104.  
  3105.     /**
  3106.      * do not override
  3107.      * @return bool true if a link to this method exists in package $package, subpackage $subpackage and class $class
  3108.      * @param string $expr method name
  3109.      * @param string $class class name
  3110.      * @param string $package package to search in
  3111.      * @param string $subpackage subpackage to search in
  3112.      * @access private
  3113.      */
  3114.     function isLinkedMethod($expr,$package,$subpackage,$class,$file=false)
  3115.     {
  3116.         if ($file)
  3117.         return isset($this->linkswithfile[$package][$subpackage]['method'][$file][$class][$expr]);
  3118.         return isset($this->links[$package][$subpackage]['method'][$class][$expr]);
  3119.     }
  3120.  
  3121.     /**
  3122.      * do not override
  3123.      * @return bool true if a link to this method exists in package $package, subpackage $subpackage and class $class
  3124.      * @param string $expr var name
  3125.      * @param string $class class name
  3126.      * @param string $package package to search in
  3127.      * @param string $subpackage subpackage to search in
  3128.      * @access private
  3129.      */
  3130.     function isLinkedVar($expr,$package,$subpackage,$class,$file=false)
  3131.     {
  3132.         if ($file)
  3133.         return isset($this->linkswithfile[$package][$subpackage]['var'][$file][$class][$expr]);
  3134.         return isset($this->links[$package][$subpackage]['var'][$class][$expr]);
  3135.     }
  3136.  
  3137.     /**
  3138.      * do not override
  3139.      * @return bool true if a link to this method exists in package $package, subpackage $subpackage and class $class
  3140.      * @param string $expr constant name
  3141.      * @param string $class class name
  3142.      * @param string $package package to search in
  3143.      * @param string $subpackage subpackage to search in
  3144.      * @access private
  3145.      */
  3146.     function isLinkedConst($expr,$package,$subpackage,$class,$file=false)
  3147.     {
  3148.         if ($file)
  3149.         return isset($this->linkswithfile[$package][$subpackage]['const'][$file][$class][$expr]);
  3150.         return isset($this->links[$package][$subpackage]['const'][$class][$expr]);
  3151.     }
  3152.  
  3153.     /**
  3154.      * return false or a {@link classLink} to $expr
  3155.      * @param string $expr class name
  3156.      * @param string $package package name
  3157.      * @return mixed returns a {@link classLink} or false if the element is not found in package $package
  3158.      * @see classLink
  3159.      */
  3160.     function getClassLink($expr,$package,$file=false$text = false)
  3161.     {
  3162.         if (!isset($this->links[$package])) return false;
  3163.         foreach($this->links[$packageas $subpackage => $notused)
  3164.         {
  3165.             if ($this->isLinkedClass($expr,$package,$subpackage,$file))
  3166.             {
  3167.                 if ($file)
  3168.                 {
  3169.                     return $this->linkswithfile[$package][$subpackage]['class'][$file][$expr];
  3170.                 }
  3171.                 return $this->links[$package][$subpackage]['class'][$expr];
  3172.             }
  3173.         }
  3174.         return false;
  3175.     }
  3176.  
  3177.     /**
  3178.      * return false or a {@link functionLink} to $expr
  3179.      * @param string $expr function name
  3180.      * @param string $package package name
  3181.      * @return mixed returns a {@link functionLink} or false if the element is not found in package $package
  3182.      * @see functionLink
  3183.      */
  3184.     function getFunctionLink($expr,$package,$file=false$text = false)
  3185.     {
  3186.         if (!isset($this->links[$package])) return false;
  3187.         foreach($this->links[$packageas $subpackage => $notused)
  3188.         {
  3189.             if ($this->isLinkedFunction($expr,$package,$subpackage,$file))
  3190.             {
  3191.                 if ($file)
  3192.                 {
  3193.                     return $this->linkswithfile[$package][$subpackage]['function'][$file][$expr];
  3194.                 }
  3195.                 return $this->links[$package][$subpackage]['function'][$expr];
  3196.             }
  3197.         }
  3198.         return false;
  3199.     }
  3200.  
  3201.     /**
  3202.      * return false or a {@link defineLink} to $expr
  3203.      * @param string $expr constant name
  3204.      * @param string $package package name
  3205.      * @return mixed returns a {@link defineLink} or false if the element is not found in package $package
  3206.      * @see defineLink
  3207.      */
  3208.     function getDefineLink($expr,$package,$file=false$text = false)
  3209.     {
  3210.         if (!isset($this->links[$package])) return false;
  3211.         foreach($this->links[$packageas $subpackage => $notused)
  3212.         {
  3213.             if ($this->isLinkedDefine($expr,$package,$subpackage,$file))
  3214.             {
  3215.                 if ($file)
  3216.                 {
  3217.                     return $this->linkswithfile[$package][$subpackage]['define'][$file][$expr];
  3218.                 }
  3219.                 return $this->links[$package][$subpackage]['define'][$expr];
  3220.             }
  3221.         }
  3222.         return false;
  3223.     }
  3224.  
  3225.     /**
  3226.      * return false or a {@link globalLink} to $expr
  3227.      * @param string $expr global variable name (with leading $)
  3228.      * @param string $package package name
  3229.      * @return mixed returns a {@link defineLink} or false if the element is not found in package $package
  3230.      * @see defineLink
  3231.      */
  3232.     function getGlobalLink($expr,$package,$file=false$text = false)
  3233.     {
  3234.         if (!isset($this->links[$package])) return false;
  3235.         foreach($this->links[$packageas $subpackage => $notused)
  3236.         {
  3237.             if ($this->isLinkedGlobal($expr,$package,$subpackage,$file))
  3238.             {
  3239.                 if ($file)
  3240.                 {
  3241.                     return $this->linkswithfile[$package][$subpackage]['global'][$file][$expr];
  3242.                 }
  3243.                 return $this->links[$package][$subpackage]['global'][$expr];
  3244.             }
  3245.         }
  3246.         return false;
  3247.     }
  3248.  
  3249.     /**
  3250.      * return false or a {@link pageLink} to $expr
  3251.      * @param string $expr procedural page name
  3252.      * @param string $package package name
  3253.      * @return mixed returns a {@link pageLink} or false if the element is not found in package $package
  3254.      * @see pageLink
  3255.      */
  3256.     function getPageLink($expr,$package,$path = false$text = false$packages = false)
  3257.     {
  3258.         if (!isset($this->links[$package])) return false;
  3259.         foreach($this->links[$packageas $subpackage => $notused)
  3260.         {
  3261.             if ($this->isLinkedPage($expr,$package,$subpackage,$path))
  3262.             {
  3263.                 if ($path)
  3264.                 {
  3265.                     return $this->linkswithfile[$package][$subpackage]['page'][$path][$expr];
  3266.                 }
  3267.                 return $this->links[$package][$subpackage]['page'][$expr];
  3268.             }
  3269.         }
  3270.         return false;
  3271.     }
  3272.  
  3273.     /**
  3274.      * return false or a {@link methodLink} to $expr in $class
  3275.      * @param string $expr method name
  3276.      * @param string $class class name
  3277.      * @param string $package package name
  3278.      * @return mixed returns a {@link methodLink} or false if the element is not found in package $package, class $class
  3279.      * @see methodLink
  3280.      */
  3281.     function getMethodLink($expr,$class,$package,$file=false$text = false)
  3282.     {
  3283.         $expr trim($expr);
  3284.         $class trim($class);
  3285.         if (!isset($this->links[$package])) return false;
  3286.         foreach($this->links[$packageas $subpackage => $notused)
  3287.         {
  3288.             if ($this->isLinkedMethod($expr,$package,$subpackage,$class,$file))
  3289.             {
  3290.                 if ($file)
  3291.                 {
  3292.                     return $this->linkswithfile[$package][$subpackage]['method'][$file][$class][$expr];
  3293.                 }
  3294.                 return $this->links[$package][$subpackage]['method'][$class][$expr];
  3295.             }
  3296.         }
  3297.         return false;
  3298.     }
  3299.  
  3300.     /**
  3301.      * return false or a {@link varLink} to $expr in $class
  3302.      * @param string $expr var name
  3303.      * @param string $class class name
  3304.      * @param string $package package name
  3305.      * @return mixed returns a {@link varLink} or false if the element is not found in package $package, class $class
  3306.      * @see varLink
  3307.      */
  3308.     function getVarLink($expr,$class,$package,$file=false$text = false)
  3309.     {
  3310.         $expr trim($expr);
  3311.         $class trim($class);
  3312.         if (!isset($this->links[$package])) return false;
  3313.         foreach($this->links[$packageas $subpackage => $notused)
  3314.         {
  3315.             if ($this->isLinkedVar($expr,$package,$subpackage,$class,$file))
  3316.             {
  3317.                 if ($file)
  3318.                 {
  3319.                     return $this->linkswithfile[$package][$subpackage]['var'][$file][$class][$expr];
  3320.                 }
  3321.                 return $this->links[$package][$subpackage]['var'][$class][$expr];
  3322.             }
  3323.         }
  3324.         return false;
  3325.     }
  3326.  
  3327.     /**
  3328.      * return false or a {@link constLink} to $expr in $class
  3329.      * @param string $expr constant name
  3330.      * @param string $class class name
  3331.      * @param string $package package name
  3332.      * @return mixed returns a {@link varLink} or false if the element is not found in package $package, class $class
  3333.      * @see constLink
  3334.      */
  3335.     function getConstLink($expr,$class,$package,$file=false$text = false)
  3336.     {
  3337.         $expr trim($expr);
  3338.         $class trim($class);
  3339.         if (!isset($this->links[$package])) return false;
  3340.         foreach($this->links[$packageas $subpackage => $notused)
  3341.         {
  3342.             if ($this->isLinkedConst($expr,$package,$subpackage,$class,$file))
  3343.             {
  3344.                 if ($file)
  3345.                 {
  3346.                     return $this->linkswithfile[$package][$subpackage]['const'][$file][$class][$expr];
  3347.                 }
  3348.                 return $this->links[$package][$subpackage]['const'][$class][$expr];
  3349.             }
  3350.         }
  3351.         return false;
  3352.     }
  3353.  
  3354.     /**
  3355.      * The meat of the @tutorial tag and inline {@}tutorial} tag
  3356.      *
  3357.      * Take a string and return an abstract link to the tutorial it represents.
  3358.      * Since tutorial naming literally works like the underlying filesystem, the
  3359.      * way to reference the tutorial is similar.  Tutorials are located in a
  3360.      * subdirectory of any directory parsed, which is named 'tutorials/' (we
  3361.      * try to make things simple when we can :).  They are further organized by
  3362.      * package and subpackage as:
  3363.      *
  3364.      * tutorials/package/subpackage
  3365.      *
  3366.      * and the files are named *.cls, *.pkg, or *.proc, and so a link to a tutorial
  3367.      * named file.cls can be referenced (depending on context) as any of:
  3368.      *
  3369.      * <code>
  3370.      * * @tutorial package/subpackage/file.cls
  3371.      * * @tutorial package/file.cls
  3372.      * * @tutorial file.cls
  3373.      * </code>
  3374.      *
  3375.      * The first case will only be needed if file.cls exists in both the current
  3376.      * package, in anotherpackage/file.cls and in anotherpackage/subpackage/file.cls
  3377.      * and you wish to reference the one in anotherpackage/subpackage.
  3378.      * The second case is only needed if you wish to reference file.cls in another
  3379.      * package and it is unique in that package. the third will link to the first
  3380.      * file.cls it finds using this search method:
  3381.      *
  3382.      * <ol>
  3383.      *    <li>current package/subpackage</li>
  3384.      *    <li>all other subpackages of current package</li>
  3385.      *    <li>parent package, if this package has classes that extend classes in
  3386.      *    another package</li>
  3387.      *    <li>all other packages</li>
  3388.      * </ol>
  3389.      * @return tutorialLink|stringreturns either a link, or the original text, if not found
  3390.      * @param string the original expression
  3391.      * @param string package to look in first
  3392.      * @param string subpackage to look in first
  3393.      * @param array array of package names to search in if not found in parent packages.
  3394.      *               This is used to limit the search, phpDocumentor automatically searches
  3395.      *               all packages
  3396.      * @since 1.2
  3397.      */
  3398.     function getTutorialLink($expr$package = false$subpackage = false$packages = false)
  3399.     {
  3400.         // is $expr a comma-delimited list?
  3401.         if (strpos($expr,','))
  3402.         {
  3403.             $a explode(',',$expr);
  3404.             $b = array();
  3405.             for($i=0;$i<count($a);$i++)
  3406.             {
  3407.                 // if so return each component with a link
  3408.                 $b[Converter::getTutorialLink(trim($a[$i]));
  3409.             }
  3410.             return $b;
  3411.         }
  3412.         $subsection '';
  3413.         if (strpos($expr,'#'))
  3414.         {
  3415.             $a explode('#',$expr);
  3416.             $org $expr;
  3417.             $expr $a[0];
  3418.             $subsection $a[1];
  3419.         }
  3420.         if (strpos($expr,'/'))
  3421.         {
  3422.             $a explode('/',$expr);
  3423.             if (count($a== 3)
  3424.             {
  3425.                 return Converter::getTutorialLink($a[2],$a[0],$a[1],array());
  3426.             }
  3427.             if (count($a== 2)
  3428.             {
  3429.                 return Converter::getTutorialLink($a[1],$a[0],false,array());
  3430.             }
  3431.         }
  3432.         if (!$package$package $this->package;
  3433.         if (!$subpackage$subpackage $this->subpackage;
  3434.         if (!isset($this->all_packages[$package])) return $expr;
  3435.         elseif (isset($packages[$package])) unset($packages[$package]);
  3436.         $ext pathinfo($exprPATHINFO_EXTENSION);
  3437.         if (isset($this->tutorials[$package][$subpackage][$ext][$expr]))
  3438.         {
  3439.             $a $this->tutorials[$package][$subpackage][$ext][$expr];
  3440.             $link = new tutorialLink;
  3441.             $link->addLink($subsection,$a->path,$a->name,$a->package,$a->subpackage,$a->getTitle($this,$subsection));
  3442.             return $link;
  3443.         }
  3444.         do
  3445.         {
  3446.             if (!is_array($packages))
  3447.             {
  3448.                 $packages $this->all_packages;
  3449.                 if (isset($packages[$package])) unset($packages[$package]);
  3450.             }
  3451.             if (isset($this->tutorials[$package]))
  3452.             {
  3453.                 if (isset($this->tutorials[$package][$subpackage][$ext][$expr]))
  3454.                 {
  3455.                     $a $this->tutorials[$package][$subpackage][$ext][$expr];
  3456.                     $link = new tutorialLink;
  3457.                     $link->addLink($subsection,$a->path,$a->name,$a->package,$a->subpackage,$a->getTitle($this));
  3458.                     return $link;
  3459.                 else
  3460.                 {
  3461.                     foreach($this->tutorials[$packageas $subpackage => $stuff)
  3462.                     {
  3463.                         if (isset($stuff[$ext][$expr]))
  3464.                         {
  3465.                             $a $stuff[$ext][$expr];
  3466.                             $link = new tutorialLink;
  3467.                             $link->addLink($subsection,$a->path,$a->name,$a->package,$a->subpackage,$a->getTitle($this));
  3468.                             return $link;
  3469.                         }
  3470.                     }
  3471.                 }
  3472.             }
  3473.             // try other packages
  3474.             // look in parent package first, if found
  3475.             if (isset($this->package_parents[$package]))
  3476.             {
  3477.                 $p1 $package;
  3478.                 $package $this->package_parents[$package];
  3479.             else
  3480.             {
  3481.                 // no parent package, so start with the first one that's left
  3482.                 list($package,@each($packages);
  3483.             }
  3484.             if ($package)
  3485.             {
  3486.                 if (isset($packages[$package])) unset($packages[$package]);
  3487.             }
  3488.         while (count($packages|| $package);
  3489.         addWarning(PDERROR_TUTORIAL_NOT_FOUND,$expr);
  3490.         return $expr;
  3491.     }
  3492.  
  3493.     /**
  3494.      * The meat of the @see tag and inline {@}link} tag
  3495.      *
  3496.      * $expr is a string with many allowable formats:
  3497.      * <ol>
  3498.      *  <li>proceduralpagename.ext</li>
  3499.      *  <li>constant_name</li>
  3500.      *  <li>classname::function()</li>
  3501.      *  <li>classname::constantname</li> (new 1.2.4)
  3502.      *  <li>classname::$variablename</li>
  3503.      *  <li>classname</li>
  3504.      *  <li>object classname</li>
  3505.      *  <li>function functionname()</li>
  3506.      *  <li>global $globalvarname</li>
  3507.      *  <li>packagename#expr where expr is any of the above</li>
  3508.      * </ol>
  3509.      *
  3510.      * New in version 1.1, you can explicitly specify a package to link to that
  3511.      * is different from the current package.  Use the # operator
  3512.      * to specify a new package, as in tests#bug-540368.php (which should appear
  3513.      * as a link like: "{@link tests#bug-540368.php}").  This
  3514.      * example links to the procedural page bug-540368.php in package
  3515.      * tests.  Also, the "function" operator is now used to specifically
  3516.      * link to a function instead of a method in the current class.
  3517.      *
  3518.      * <code>
  3519.      * class myclass
  3520.      * {
  3521.      *  // from inside the class definition, use "function conflict()" to refer to procedural function "conflict()"
  3522.      *    function conflict()
  3523.      *    {
  3524.      *    }
  3525.      * }
  3526.      *
  3527.      * function conflict()
  3528.      * {
  3529.      * }
  3530.      * </code>
  3531.      *
  3532.      * If classname:: is not present, and the see tag is in a documentation
  3533.      * block within a class, then the function uses the classname to
  3534.      * search for $expr as a function or variable within classname, or any of its parent classes.
  3535.      * given an $expr without '$', '::' or '()' getLink first searches for
  3536.      * classes, procedural pages, constants, global variables, and then searches for
  3537.      * methods and variables within the default class, and finally for any function
  3538.      *
  3539.      * @param string $expr expression to search for a link
  3540.      * @param string $package package to start searching in
  3541.      * @param array $packages list of all packages to search in
  3542.      * @return mixed getLink returns a descendant of {@link abstractLink} if it finds a link, otherwise it returns a string
  3543.      * @see getPageLink(), getDefineLink(), getVarLink(), getFunctionLink(), getClassLink()
  3544.      * @see pageLink, functionLink, defineLink, classLink, methodLink, varLink
  3545.      */
  3546.     function &getLink($expr$package = false$packages = false)
  3547.     {
  3548.         // is $expr a comma-delimited list?
  3549.         if (strpos($expr,','))
  3550.         {
  3551.             $a explode(',',$expr);
  3552.             $b = array();
  3553.             for($i=0;$i<count($a);$i++)
  3554.             {
  3555.                 // if so return each component with a link
  3556.                 $b[Converter::getLink(trim($a[$i]));
  3557.             }
  3558.             return $b;
  3559.         }
  3560.         if (strpos($expr,'#'))
  3561.         {
  3562.             $a explode('#',$expr);
  3563.             if (count($a== 2)
  3564.             // can have exactly 1 package override, otherwise it's ignored
  3565.                 // feature 564991, link to php manual
  3566.                 if ($a[0== 'PHP_MANUAL'{
  3567.                     $s 'http://www.php.net/'.$a[1];
  3568.                     return $s;
  3569.                 }
  3570.                 $s &Converter::getLink($a[1],$a[0],array());
  3571.                 return $s;
  3572.             }
  3573.         }
  3574.         $a &$this->_getLink($expr$package$packages);
  3575.         return $a;
  3576.     }
  3577.  
  3578.     /**
  3579.      * @access private
  3580.      */
  3581.     function &_getLink($expr$package = false$packages = false)
  3582.     {
  3583.         if (!$package$package $this->package;
  3584.         //
  3585.         if (!isset($this->all_packages[$package])) return $expr;
  3586.         elseif (isset($packages[$package])) unset($packages[$package]);
  3587.         $links &$this->links;
  3588.         $class $this->class;
  3589.         if (strpos($expr,'function '=== 0)
  3590.         // asking for a function, not a method
  3591.             if ($test Converter::getFunctionLink(str_replace('function ','',str_replace('()','',$expr))$package)) return $test;
  3592.             else return $expr;
  3593.         }
  3594.         if (strpos($expr,'global '=== 0)
  3595.         // asking for a global variable
  3596.             if ($test Converter::getGlobalLink(str_replace('global ','',$expr)$package)) return $test;
  3597.             else return $expr;
  3598.         }
  3599.         if (strpos($expr,'object '=== 0)
  3600.         // asking for a class
  3601.             if ($test Converter::getClassLink(str_replace('object ','',$expr)$package)) return $test;
  3602.             else return $expr;
  3603.         }
  3604.         if (strpos($expr,'constant '=== 0)
  3605.         // asking for a class
  3606.             if ($test Converter::getDefineLink(str_replace('constant ','',$expr)$package)) return $test;
  3607.             else return $expr;
  3608.         }
  3609.         // are we in a class?
  3610.         if ($class)
  3611.         {
  3612.             // is $expr simply a word? see if it is the class
  3613.             if (trim($expr== $class)
  3614.             {
  3615.                 if ($test Converter::getClassLink(trim(str_replace('object ','',$expr)),$package)) return $test;
  3616.             }
  3617.             // if not, check to see if it is a method or variable of this class tree
  3618.             if (!strpos($expr,'::'))
  3619.             {
  3620.                 // if get is neither get() nor $get, assume get is a function, add () to make get()
  3621.                 if (strpos($expr,'$'!== 0 && !strpos($expr,'()')) //$get = $get.'()';
  3622.                 {
  3623.                     if ($a $this->getLinkMethod($expr,$class,$package)) return $a;
  3624.                     if ($a $this->getLinkConst($expr,$class,$package)) return $a;
  3625.                     if ($a $this->getLinkVar('$'.$expr,$class,$package)) return $a;
  3626.                 }
  3627.                 if (strpos($expr,'()')) if ($a $this->getLinkMethod($expr,$class,$package)) return $a;
  3628.                 if (is_numeric(strpos($expr,'$'))) if ($a $this->getLinkVar($expr,$class,$package)) return $a;
  3629.             }
  3630.         }
  3631.         if ($test Converter::getClassLink(trim(str_replace('object ','',$expr)),$package)) return $test;
  3632.         if ($test Converter::getPageLink(trim($expr),$package)) return $test;
  3633.         if ($test Converter::getDefineLink(trim($expr),$package)) return $test;
  3634.         if ($test Converter::getGlobalLink(trim($expr),$package)) return $test;
  3635. //        if (strpos($expr,'.'))
  3636.         // package specified
  3637.  
  3638.         if (!is_array($packages))
  3639.         {
  3640.             $packages $this->all_packages;
  3641.         }
  3642.         do
  3643.         {
  3644.             if (isset($packages[$package])) unset($packages[$package]);
  3645.             if ($test Converter::getClassLink(str_replace('object ','',$expr),$package)) return $test;
  3646.             if ($test Converter::getPageLink($expr,$package)) return $test;
  3647.             if ($test Converter::getDefineLink($expr,$package)) return $test;
  3648.             if ($test Converter::getGlobalLink($expr,$package)) return $test;
  3649.             // is $expr in class::method() or class::$variable format?
  3650.             if (strpos($expr,'function '=== 0)
  3651.             // asking for a function, not a method
  3652.                 if ($test Converter::getFunctionLink(str_replace('function','',str_replace('()','',$expr))$package)) return $test;
  3653.                 else return $expr;
  3654.             }
  3655.             $test $this->_getDoubleColon($expr$package$packages$class$links);
  3656.             if (!is_string($test)) return $test;
  3657.             if (strpos($test'parent::'=== 0return $test;
  3658.             // $expr does not have ::
  3659.             if (is_numeric(@strpos('$',$expr)))
  3660.             {
  3661.                 // default to current class, whose name is contained in $this->render->parent
  3662.                 if ($test Converter::getVarLink($expr$class$package)) return $test;
  3663.             }
  3664.             // $expr is a function? (non-method)
  3665.             if (@strpos($expr,'()'))
  3666.             {
  3667.                 // otherwise, see if it is a method
  3668.                 if ($class)
  3669.                 {
  3670.                     if ($test Converter::getMethodLink(str_replace('()','',$expr)$class$package)) return $test;
  3671.                 }
  3672.                 // extract the function name, use it to retrieve the file that the function is in
  3673.     //            $page = $this->func_page[str_replace('function ','',str_replace('()','',$expr))];
  3674.                 // return the link
  3675.                 if ($test Converter::getFunctionLink(str_replace('function ','',str_replace('()','',$expr))$package)) return $test;
  3676.             }
  3677.             // $expr is just a word.  First, test to see if it is a function of the current package
  3678.             if ($test Converter::getFunctionLink(str_replace('function ','',str_replace('()','',$expr))$package)) return $test;
  3679.             // try other packages
  3680.             // look in parent package first, if found
  3681.             if (isset($this->package_parents[$package]&& in_array($this->package_parents[$package]$packages))
  3682.             {
  3683.                 $p1 $package;
  3684.                 $package $this->package_parents[$package];
  3685.                 if ($package)
  3686.                 {
  3687.                     if (isset($packages[$package])) unset($packages[$package]);
  3688.                 }
  3689.                 continue;
  3690.             }
  3691.             // no parent package, so start with the first one that's left
  3692.             $package @array_shift(@array_keys($packages));
  3693.             if ($package && isset($packages[$package]))
  3694.             {
  3695.                 unset($packages[$package]);
  3696.             }
  3697.         while (count($packages|| $package);
  3698.         $funcs get_defined_functions();
  3699.         // feature 564991, link to php manual
  3700.         if (in_array(str_replace(array('(',')'),array('',''),$expr),$funcs['internal']))
  3701.         {
  3702.             $return 'http://www.php.net/'.str_replace(array('(',')'),array('',''),$expr);
  3703.             return $return;
  3704.         }
  3705.         // no links found
  3706.         return $expr;
  3707.     }
  3708.  
  3709.     /**
  3710.      * Split up getLink to make it easier to debug
  3711.      * @access private
  3712.      */
  3713.     function _getDoubleColon(&$expr&$package&$packages$class$links)
  3714.     {
  3715.         if (@strpos($expr,'::'))
  3716.         {
  3717.             $class_method explode('::',$expr);
  3718.             if ($class_method[0== 'parent')
  3719.             {
  3720.                 // can only have parent in the same package as the class!  subtle bug
  3721.                 $package $this->package;
  3722.                 $packages = array();
  3723.                 $cl $this->classes->getClassByPackage($class,$package);
  3724.                 if (!$cl)
  3725.                 // this is possible if an example file has parent::method()
  3726.                     return $expr;
  3727.                 }
  3728.                 $par $cl->getParent($this);
  3729.                 $phpparent = false;
  3730.                 if (is_object($par))
  3731.                 {
  3732.                     $package $par->docblock->package;
  3733.                     $phpparent $par->getName();
  3734.                 else
  3735.                 {
  3736.                     addWarning(PDERROR_CLASS_PARENT_NOT_FOUND,$class,$package,$class_method[1]);
  3737.                     return $expr;
  3738.                 }
  3739.                 if ($phpparent$class_method[0$phpparent;
  3740.             }
  3741.             if (strpos($class_method[1],'()'))
  3742.             {
  3743.                 // strip everything but the function name, return a link
  3744.                 if ($test Converter::getMethodLink(str_replace('()','',$class_method[1])$class_method[0]$package)) return $test;
  3745.             }
  3746.             if ($test Converter::getVarLink($class_method[1]$class_method[0]$package)) return $test;
  3747.             if ($test Converter::getConstLink($class_method[1]$class_method[0]$package)) return $test;
  3748.         }
  3749.         return $expr;
  3750.     }
  3751.  
  3752.     /**
  3753.      * cycle through parent classes to retrieve a link to a method
  3754.      * do not use or override, used by getLink
  3755.      * @access private
  3756.      */
  3757.     function &getLinkMethod($expr$class$package)
  3758.     {
  3759.         $links &$this->links;
  3760.         do
  3761.         {
  3762.             // is $expr in class::method() or class::$variable format?
  3763.             if (@strpos($expr,'::'))
  3764.             {
  3765.                 $class_method explode('::',$expr);
  3766.                 if ($class_method[0== 'parent')
  3767.                 {
  3768.                     $cl $this->classes->getClassByPackage($class,$package);
  3769.                     $par $cl->getParent($this);
  3770.                     $phpparent = false;
  3771.                     if (is_object($par))
  3772.                     {
  3773.                         $package $par->docblock->package;
  3774.                         $phpparent $par->getName();
  3775.                     else addWarning(PDERROR_CLASSPARENT_NOTFOUND,$class,$package,$class_method[1]);
  3776.                     if ($phpparent$class_method[0$phpparent;
  3777.                 else
  3778.                 {
  3779.                     $cl $this->classes->getClassByPackage($class,$package);
  3780.                 }
  3781.                 if (strpos($class_method[1],'()'))
  3782.                 {
  3783.                     // strip everything but the function name, return a link
  3784.                     if ($test Converter::getMethodLink(str_replace('function ','',str_replace('()','',$class_method[1]))$class_method[0]$package)) return $test;
  3785.                 }
  3786.             }
  3787.             if ($test Converter::getMethodLink(str_replace('()','',$expr)$class$package)) return $test;
  3788.             $cl $this->classes->getClassByPackage($class,$package);
  3789.             if ($cl)
  3790.             {
  3791.                 $par $cl->getParent($this);
  3792.                 if (is_object($par))
  3793.                 {
  3794.                     $package $par->docblock->package;
  3795.                     $class $par->getName();
  3796.                 else $class $par;
  3797.             else $class = false;
  3798.         while ($class);
  3799.         // no links found
  3800.         $flag = false;
  3801.         return $flag;
  3802.     }
  3803.  
  3804.     /**
  3805.      * cycle through parent classes to retrieve a link to a var
  3806.      * do not use or override, used by getLink
  3807.      * @access private
  3808.      */
  3809.     function &getLinkVar($expr$class$package)
  3810.     {
  3811.         $links &$this->links;
  3812.         do
  3813.         {
  3814.             // is $expr in class::method() or class::$variable format?
  3815.             if (@strpos($expr,'::'))
  3816.             {
  3817.                 $class_method explode('::',$expr);
  3818.                 if ($class_method[0== 'parent')
  3819.                 {
  3820.                     $cl $this->classes->getClassByPackage($class,$package);
  3821.                     $phpparent = false;
  3822.                     $par $cl->getParent($this);
  3823.                     if (is_object($par))
  3824.                     {
  3825.                         $package $par->docblock->package;
  3826.                         $phpparent $par->getName();
  3827.                     else addWarning(PDERROR_CLASSPARENT_NOTFOUND,$class,$package,$class_method[1]);
  3828.                     if ($phpparent$class_method[0$phpparent;
  3829.                 else
  3830.                 {
  3831.                     $cl $this->classes->getClassByPackage($class,$package);
  3832.                 }
  3833.                 if ($test Converter::getVarLink($class_method[1]$class_method[0]$package)) return $test;
  3834.                 if ($test Converter::getVarLink('$'.$class_method[1]$class_method[0]$package)) return $test;
  3835.             }
  3836.             if ($test Converter::getVarLink($expr$class$package)) return $test;
  3837.             if ($test Converter::getVarLink('$'.$expr$class$package)) return $test;
  3838.             $cl $this->classes->getClassByPackage($class,$package);
  3839.             if ($cl)
  3840.             {
  3841.                 $par $cl->getParent($this);
  3842.                 if (is_object($par))
  3843.                 {
  3844.                     $package $par->docblock->package;
  3845.                     $class $par->getName();
  3846.                 else $class $par;
  3847.             else $class = false;
  3848.         while ($class);
  3849.         // no links found
  3850.         $class = false;
  3851.         return $class;
  3852.     }
  3853.  
  3854.     /**
  3855.      * cycle through parent classes to retrieve a link to a class constant
  3856.      * do not use or override, used by getLink
  3857.      * @access private
  3858.      * @since 1.2.4
  3859.      */
  3860.     function &getLinkConst($expr$class$package)
  3861.     {
  3862.         $links &$this->links;
  3863.         do
  3864.         {
  3865.             // is $expr in class::method() or class::$variable format?
  3866.             if (@strpos($expr,'::'))
  3867.             {
  3868.                 $class_method explode('::',$expr);
  3869.                 if ($class_method[0== 'parent')
  3870.                 {
  3871.                     $cl $this->classes->getClassByPackage($class,$package);
  3872.                     $phpparent = false;
  3873.                     $par $cl->getParent($this);
  3874.                     if (is_object($par))
  3875.                     {
  3876.                         $package $par->docblock->package;
  3877.                         $phpparent $par->getName();
  3878.                     else addWarning(PDERROR_CLASSPARENT_NOTFOUND,$class,$package,$class_method[1]);
  3879.                     if ($phpparent$class_method[0$phpparent;
  3880.                 else
  3881.                 {
  3882.                     $cl $this->classes->getClassByPackage($class,$package);
  3883.                 }
  3884.                 if ($test Converter::getConstLink($class_method[1]$class_method[0]$package)) return $test;
  3885.             }
  3886.             if ($test Converter::getConstLink($expr$class$package)) return $test;
  3887.             $cl $this->classes->getClassByPackage($class,$package);
  3888.             if ($cl)
  3889.             {
  3890.                 $par $cl->getParent($this);
  3891.                 if (is_object($par))
  3892.                 {
  3893.                     $package $par->docblock->package;
  3894.                     $class $par->getName();
  3895.                 else $class $par;
  3896.             else $class = false;
  3897.         while ($class);
  3898.         // no links found
  3899.         $flag = false;
  3900.         return $flag;
  3901.     }
  3902.  
  3903.     /**
  3904.      * take URL $link and text $text and return a link in the format needed for the Converter
  3905.      * @param string URL
  3906.      * @param string text to display
  3907.      * @return string link to $link
  3908.      * @abstract
  3909.      */
  3910.     function returnLink($link,$text)
  3911.     {
  3912.     }
  3913.  
  3914.     /**
  3915.      * take {@link abstractLink} descendant and text $eltext and return a link
  3916.      * in the format needed for the Converter
  3917.      * @param abstractLink 
  3918.      * @param string 
  3919.      * @return string link to $element
  3920.      * @abstract
  3921.      */
  3922.     function returnSee(&$link$eltext = false)
  3923.     {
  3924.     }
  3925.  
  3926.     /**
  3927.      * take {@link abstractLink} descendant and text $eltext and return a
  3928.      * unique ID in the format needed for the Converter
  3929.      * @param abstractLink 
  3930.      * @return string unique identifier of $element
  3931.      * @abstract
  3932.      */
  3933.     function getId(&$link)
  3934.     {
  3935.     }
  3936.  
  3937.     /**
  3938.      * Convert README/INSTALL/CHANGELOG file contents to output format
  3939.      * @param README|INSTALL|CHANGELOG
  3940.      * @param string contents of the file
  3941.      * @abstract
  3942.      */
  3943.     function Convert_RIC($name$contents)
  3944.     {
  3945.     }
  3946.  
  3947.     /**
  3948.      * Convert all elements to output format
  3949.      *
  3950.      * This will call ConvertXxx where Xxx is {@link ucfirst}($element->type).
  3951.      * It is expected that a child converter defines a handler for every
  3952.      * element type, even if that handler does nothing.  phpDocumentor will
  3953.      * terminate with an error if a handler doesn't exist.
  3954.      * {@internal 
  3955.      * Since 1.2.0 beta 3, this function has been moved from child converters
  3956.      * to the parent, because it doesn't really make sense to put it in the
  3957.      * child converter, and we can add error handling.
  3958.      *
  3959.      * {@source } }
  3960.      * @throws {@link PDERROR_NO_CONVERT_HANDLER}
  3961.      * @param mixed {@link parserElement} descendant or {@link parserPackagePage} or {@link parserData}
  3962.      */
  3963.     function Convert(&$element)
  3964.     {
  3965.         $handler 'convert'.ucfirst($element->type);
  3966.         if (method_exists($this,$handler))
  3967.         {
  3968.             $this->$handler($element);
  3969.         else
  3970.         {
  3971.             addErrorDie(PDERROR_NO_CONVERTER_HANDLER,$element->type,$handler,phpDocumentor_get_class($this));
  3972.         }
  3973.     }
  3974.     /**#@+
  3975.      * Conversion Handlers
  3976.      *
  3977.      * All of the convert* handlers set up template variables for the Smarty
  3978.      * template.{@internal  In addition, the {@link newSmarty()} method is
  3979.      * called to retrieve the global Smarty template}}
  3980.      */
  3981.     /**
  3982.      * Default Tutorial Handler
  3983.      *
  3984.      * Sets up the tutorial template, and its prev/next/parent links
  3985.      * {@internal 
  3986.      * Retrieves the title using {@link parserTutorial::getTitle()} and uses the
  3987.      * {@link parserTutorial::prev, parserTutorial::next, parserTutorial::parent}
  3988.      * links to set up those links.}}}
  3989.      * @param parserTutorial 
  3990.      */
  3991.     function &convertTutorial(&$element)
  3992.     {
  3993.         $this->package = $element->package;
  3994.         $this->subpackage = $element->subpackage;
  3995.         $x $element->Convert($this);
  3996.         $template &$this->newSmarty();
  3997.         $template->assign('contents',$x);
  3998.         $template->assign('title',$element->getTitle($this));
  3999.         $template->assign('nav',$element->parent || $element->prev || $element->next);
  4000.         if ($element->parent)
  4001.         {
  4002.             $template->assign('up',$this->getId($element->parent));
  4003.             $template->assign('uptitle',$element->parent->title);
  4004.         }
  4005.         if ($element->prev)
  4006.         {
  4007.             $template->assign('prev',$this->getId($element->prev));
  4008.             $template->assign('prevtitle',$element->prev->title);
  4009.         }
  4010.         if ($element->next)
  4011.         {
  4012.             $template->assign('next',$this->getId($element->next));
  4013.             $template->assign('nexttitle',$element->next->title);
  4014.         }
  4015.         return $template;
  4016.     }
  4017.     /**
  4018.      * Default Class Handler
  4019.      *
  4020.      * Sets up the class template.
  4021.      * {@internal special methods
  4022.      * {@link generateChildClassList(), generateFormattedClassTree()},
  4023.      * {@link getFormattedConflicts, getFormattedInheritedMethods},
  4024.      * and {@link getFormattedInheritedVars} are called to complete vital
  4025.      * template setup.}}}
  4026.      */
  4027.     function convertClass(&$element)
  4028.     {
  4029.         $this->class = $element->getName();
  4030.         $this->class_data = &$this->newSmarty();
  4031.         $this->class_data->assign("class_name",$element->getName());
  4032.         $this->class_data->assign("vars",array());
  4033.         $this->class_data->assign("methods",array());
  4034.         $this->class_data->assign("consts",array());
  4035.         $this->class_data->assign("is_interface"$element->isInterface());
  4036.         $this->class_data->assign("implements"$this->getFormattedImplements($element));
  4037.         $this->class_data->assign("package",$element->docblock->package);
  4038.         $this->class_data->assign("line_number",$element->getLineNumber());
  4039.         $this->class_data->assign("source_location",$element->getSourceLocation($this));
  4040.                 $this->class_data->assign("page_link",$this->getCurrentPageLink());
  4041.         $docblock $this->prepareDocBlock($elementfalse);
  4042.         $this->class_data->assign("sdesc",$docblock['sdesc']);
  4043.         $this->class_data->assign("desc",$docblock['desc']);
  4044.                 $this->class_data->assign("access"$docblock['access']);
  4045.                 $this->class_data->assign("abstract"$docblock['abstract']);
  4046.         $this->class_data->assign("tags",$docblock['tags']);
  4047.         $this->class_data->assign("api_tags",$docblock['api_tags']);
  4048.         $this->class_data->assign("info_tags",$docblock['info_tags']);
  4049.         $this->class_data->assign("utags",$docblock['utags']);
  4050.         $this->class_data->assign"prop_tags"$docblock['property_tags');
  4051.         if ($this->hasSourceCode($element->getPath())) {
  4052.         $this->class_data->assign("class_slink",$this->getSourceAnchor($element->getPath(),$element->getLineNumber(),$element->getLineNumber(),true));
  4053.         }
  4054.  
  4055.         else
  4056.         $this->class_data->assign("class_slink",false);
  4057.         $this->class_data->assign("children"$this->generateChildClassList($element));
  4058.         $this->class_data->assign("class_tree"$this->generateFormattedClassTree($element));
  4059.         $this->class_data->assign("conflicts"$this->getFormattedConflicts($element,"classes"));
  4060.         $inherited_methods $this->getFormattedInheritedMethods($element);
  4061.         if (!empty($inherited_methods))
  4062.         {
  4063.             $this->class_data->assign("imethods",$inherited_methods);
  4064.         else
  4065.         {
  4066.             $this->class_data->assign("imethods",false);
  4067.         }
  4068.         $inherited_vars $this->getFormattedInheritedVars($element);
  4069.         if (!empty($inherited_vars))
  4070.         {
  4071.             $this->class_data->assign("ivars",$inherited_vars);
  4072.         else
  4073.         {
  4074.             $this->class_data->assign("ivars",false);
  4075.         }
  4076.         $inherited_consts $this->getFormattedInheritedConsts($element);
  4077.         if (!empty($inherited_consts))
  4078.         {
  4079.             $this->class_data->assign("iconsts",$inherited_consts);
  4080.         else
  4081.         {
  4082.             $this->class_data->assign("iconsts",false);
  4083.         }
  4084.     }
  4085.  
  4086.  
  4087.     /**
  4088.      * Converts method for template output
  4089.      *
  4090.      * This function must be called by a child converter with any extra
  4091.      * template variables needed in the parameter $addition
  4092.      * @param parserMethod 
  4093.      */
  4094.     function convertMethod(&$element$additions = array())
  4095.     {
  4096.         $fname $element->getName();
  4097.         $docblock $this->prepareDocBlock($element);
  4098.         $returntype 'void';
  4099.         if ($element->isConstructor$returntype $element->class;
  4100.         if ($element->docblock->return)
  4101.         {
  4102.             $a $element->docblock->return->Convert($this);
  4103.             $returntype $element->docblock->return->converted_returnType;
  4104.         }
  4105.         $params $param_i = array();
  4106.         if (count($element->docblock->params))
  4107.         foreach($element->docblock->params as $param => $val)
  4108.         {
  4109.             $a $val->Convert($this);
  4110.             $params[$param_i[$param= array("var" => $param,"datatype" => $val->converted_returnType,"data" => $a);
  4111.         }
  4112.  
  4113.         if ($element->docblock->hasaccess{
  4114.             $acc $docblock['access'];
  4115.         else {
  4116.             $acc 'public';
  4117.         }
  4118.  
  4119.         if ($this->hasSourceCode($element->getPath()))
  4120.         $additions["slink"$this->getSourceAnchor($element->getPath(),$element->getLineNumber(),$element->getLineNumber(),true);
  4121.         $this->class_data->append('methods',array_merge(
  4122.                                              array('sdesc' => $docblock['sdesc'],
  4123.                                                    'desc' => $docblock['desc'],
  4124.                                                    'static' => $docblock['static'],
  4125.                                                    'abstract' => $docblock['abstract'],
  4126.                                                    'tags' => $docblock['tags'],
  4127.                                                    'api_tags' => $docblock['api_tags'],
  4128.                                                    'see_tags' => $docblock['see_tags'],
  4129.                                                    'info_tags_sorted' => $docblock['info_tags_sorted'],
  4130.                                                    'info_tags' => $docblock['info_tags'],
  4131.                                                    'utags' => $docblock['utags'],
  4132.                                                    'constructor' => $element->isConstructor,
  4133.                                                    'access' => $acc,
  4134.                                                    'function_name'     => $fname,
  4135.                                                    'function_return'    => $returntype,
  4136.                                                    'function_call'     => $element->getFunctionCall(),
  4137.                                                    'ifunction_call'     => $element->getIntricateFunctionCall($this$param_i),
  4138.                                                    'descmethod'    => $this->getFormattedDescMethods($element),
  4139.                                                    'method_overrides'    => $this->getFormattedOverrides($element),
  4140.                                                    'method_implements'    => $this->getFormattedMethodImplements($element),
  4141.                                                    'line_number' => $element->getLineNumber(),
  4142.                                                    'id' => $this->getId($element),
  4143.                                                    'params' => $params),
  4144.                                              $additions));
  4145.     }
  4146.  
  4147.     /**
  4148.      * Converts class variables for template output.
  4149.      *
  4150.      * This function must be called by a child converter with any extra
  4151.      * template variables needed in the parameter $addition
  4152.      * @param parserVar 
  4153.      */
  4154.     function convertVar(&$element$additions = array())
  4155.     {
  4156.         $docblock $this->prepareDocBlock($element);
  4157.         $b 'mixed';
  4158.  
  4159.         if ($element->docblock->hasaccess)
  4160.             $acc $element->docblock->tags['access'][0]->value;
  4161.         else
  4162.             $acc 'public';
  4163.  
  4164.         if ($element->docblock->var)
  4165.         {
  4166.             $b $element->docblock->var->converted_returnType;
  4167.         }
  4168.         if ($this->hasSourceCode($element->getPath()))
  4169.         $additions["slink"$this->getSourceAnchor($element->getPath(),$element->getLineNumber(),$element->getLineNumber(),true);
  4170.         $this->class_data->append('vars',array_merge(
  4171.                                           array('sdesc' => $docblock['sdesc'],
  4172.                                                 'desc' => $docblock['desc'],
  4173.                                                 'static' => $docblock['static'],
  4174.                                                 'abstract' => $docblock['abstract'],
  4175.                                                 'utags' => $docblock['utags'],
  4176.                                                 'tags' => $docblock['tags'],
  4177.                                                 'api_tags' => $docblock['api_tags'],
  4178.                                                 'info_tags' => $docblock['info_tags'],
  4179.                                                 'var_name' => $element->getName(),
  4180.                                                 'has_default' => strlen($element->getValue()),
  4181.                                                 'var_default' => $this->postProcess($element->getValue()),
  4182.                                                 'var_type' => $b,
  4183.                                                 'access' => $acc,
  4184.                                                 'line_number' => $element->getLineNumber(),
  4185.                                                 'descvar'    => $this->getFormattedDescVars($element),
  4186.                                                 'var_overrides' => $this->getFormattedOverrides($element),
  4187.                                                 'id' => $this->getId($element)),
  4188.                                           $additions));
  4189.     }
  4190.  
  4191.     /**
  4192.      * Converts class constants for template output.
  4193.      *
  4194.      * This function must be called by a child converter with any extra
  4195.      * template variables needed in the parameter $addition
  4196.      * @param parserConst 
  4197.      */
  4198.     function convertConst(&$element$additions = array())
  4199.     {
  4200.         $docblock $this->prepareDocBlock($element);
  4201.  
  4202.         if ($element->docblock->hasaccess)
  4203.             $acc $element->docblock->tags['access'][0]->value;
  4204.         else
  4205.             $acc 'public';
  4206.  
  4207.         if ($this->hasSourceCode($element->getPath()))
  4208.         $additions["slink"$this->getSourceAnchor($element->getPath(),$element->getLineNumber(),$element->getLineNumber(),true);
  4209.         $this->class_data->append('consts',array_merge(
  4210.                                           array('sdesc' => $docblock['sdesc'],
  4211.                                                 'desc' => $docblock['desc'],
  4212.                                                 'access' => $docblock['access'],
  4213.                                                 'abstract' => $docblock['abstract'],
  4214.                                                 'utags' => $docblock['utags'],
  4215.                                                 'tags' => $docblock['tags'],
  4216.                                                 'api_tags' => $docblock['api_tags'],
  4217.                                                 'info_tags' => $docblock['info_tags'],
  4218.                                                 'const_name' => $element->getName(),
  4219.                                                 'const_value' => $this->postProcess($element->getValue()),
  4220.                                                 'access' => $acc,
  4221.                                                 'line_number' => $element->getLineNumber(),
  4222.                                                 'id' => $this->getId($element)),
  4223.                                           $additions));
  4224.     }
  4225.  
  4226.     /**
  4227.      * Default Page Handler
  4228.      *
  4229.      * {@internal In addition to setting up the smarty template with {@link newSmarty()},
  4230.      * this class uses {@link getSourceLocation()} and {@link getClassesOnPage()}
  4231.      * to set template variables.  Also used is {@link getPageName()}, to get
  4232.      * a Converter-specific name for the page.}}}
  4233.      * @param parserPage 
  4234.      */
  4235.     function convertPage(&$element)
  4236.     {
  4237.         $this->page_data = &$this->newSmarty(true);
  4238.         $this->page = $this->getPageName($element->parent);
  4239.         $this->path = $element->parent->getPath();
  4240.         $this->curpage = &$element->parent;
  4241.         $this->page_data->assign("source_location",$element->parent->getSourceLocation($this));
  4242.         $this->page_data->assign("functions",array());
  4243.         $this->page_data->assign("includes",array());
  4244.         $this->page_data->assign("defines",array());
  4245.         $this->page_data->assign("globals",array());
  4246.         $this->page_data->assign("classes",$this->getClassesOnPage($element));
  4247.         $this->page_data->assign("hasclasses",$element->hasClasses());
  4248.         $this->page_data->assign("hasinterfaces",$element->hasInterfaces());
  4249.         $this->page_data->assign("name"$element->parent->getFile());
  4250.         if ($t $element->getTutorial())
  4251.         {
  4252.             $this->page_data->assign("tutorial",$this->returnSee($t));
  4253.         else
  4254.         {
  4255.             $this->page_data->assign("tutorial",false);
  4256.         }
  4257.         if ($element->docblock)
  4258.         {
  4259.             $docblock $this->prepareDocBlock($elementfalse);
  4260.             $this->page_data->assign("sdesc",$docblock['sdesc']);
  4261.             $this->page_data->assign("desc",$docblock['desc']);
  4262.             $this->page_data->assign("tags",$docblock['tags']);
  4263.             $this->page_data->assign("api_tags",$docblock['api_tags']);
  4264.             $this->page_data->assign("info_tags",$docblock['info_tags']);
  4265.             $this->page_data->assign("utags",$docblock['utags']);
  4266.         }
  4267.     }
  4268.  
  4269.     /**
  4270.      * Converts global variables for template output
  4271.      *
  4272.      * This function must be called by a child converter with any extra
  4273.      * template variables needed in the parameter $addition
  4274.      * {@internal 
  4275.      * In addition to using {@link prepareDocBlock()}, this method also
  4276.      * uses utility functions {@link getGlobalValue(), getFormattedConflicts()}}}}
  4277.      * @param parserGlobal 
  4278.      * @uses postProcess() on global_value template value, makes it displayable
  4279.      * @param array any additional template variables should be in this array
  4280.      */
  4281.     function convertGlobal(&$element$addition = array())
  4282.     {
  4283.         $docblock $this->prepareDocBlock($element);
  4284.         $value $this->getGlobalValue($element->getValue());
  4285.         if ($this->hasSourceCode($element->getPath()))
  4286.         $addition["slink"$this->getSourceAnchor($element->getPath(),$element->getLineNumber(),$element->getLineNumber(),true);
  4287.         $this->page_data->append('globals',array_merge(
  4288.                                             array('sdesc' => $docblock['sdesc'],
  4289.                                                   'desc' => $docblock['desc'],
  4290.                                                   'tags' => $docblock['tags'],
  4291.                                                   'api_tags' => $docblock['api_tags'],
  4292.                                                   'info_tags' => $docblock['info_tags'],
  4293.                                                   'utags' => $docblock['utags'],
  4294.                                                   'global_name'     => $element->getName(),
  4295.                                                   'global_type' => $element->getDataType($this),
  4296.                                                   'global_value'    => $value,
  4297.                                                   'line_number' => $element->getLineNumber(),
  4298.                                                   'global_conflicts'    => $this->getFormattedConflicts($element,"global variables"),
  4299.                                                   'id' => $this->getId($element)),
  4300.                                             $addition));
  4301.     }
  4302.  
  4303.     /**
  4304.      * Converts defines for template output
  4305.      *
  4306.      * This function must be called by a child converter with any extra
  4307.      * template variables needed in the parameter $addition
  4308.      * {@internal 
  4309.      * In addition to using {@link prepareDocBlock()}, this method also
  4310.      * uses utility functions {@link getGlobalValue(), getFormattedConflicts()}}}}
  4311.      * @param parserDefine 
  4312.      * @uses postProcess() on define_value template value, makes it displayable
  4313.      * @param array any additional template variables should be in this array
  4314.      */
  4315.     function convertDefine(&$element$addition = array())
  4316.     {
  4317.         $docblock $this->prepareDocBlock($element);
  4318.         if ($this->hasSourceCode($element->getPath()))
  4319.         $addition["slink"$this->getSourceAnchor($element->getPath(),$element->getLineNumber(),$element->getLineNumber(),true);
  4320.         $this->page_data->append('defines',array_merge(
  4321.                                             array('sdesc' => $docblock['sdesc'],
  4322.                                                   'desc' => $docblock['desc'],
  4323.                                                   'tags' => $docblock['tags'],
  4324.                                                   'api_tags' => $docblock['api_tags'],
  4325.                                                   'info_tags' => $docblock['info_tags'],
  4326.                                                   'utags' => $docblock['utags'],
  4327.                                                   'define_name'     => $element->getName(),
  4328.                                                   'line_number' => $element->getLineNumber(),
  4329.                                                   'define_value'    => $this->postProcess($element->getValue()),
  4330.                                                   'define_conflicts'    => $this->getFormattedConflicts($element,"defines"),
  4331.                                                   'id' => $this->getId($element)),
  4332.                                             $addition));
  4333.     }
  4334.  
  4335.  
  4336.     /**
  4337.      * Converts includes for template output
  4338.      *
  4339.      * This function must be called by a child converter with any extra
  4340.      * template variables needed in the parameter $addition
  4341.      * @see prepareDocBlock()
  4342.      * @param parserInclude 
  4343.      */
  4344.     function convertInclude(&$element$addition = array())
  4345.     {
  4346.         $docblock $this->prepareDocBlock($element);
  4347.         $per $this->getIncludeValue($element->getValue()$element->getPath());
  4348.  
  4349.         if ($this->hasSourceCode($element->getPath()))
  4350.         $addition["slink"$this->getSourceAnchor($element->getPath(),$element->getLineNumber(),$element->getLineNumber(),true);
  4351.         $this->page_data->append('includes',array_merge(
  4352.                                              array('sdesc' => $docblock['sdesc'],
  4353.                                                    'desc' => $docblock['desc'],
  4354.                                                    'tags' => $docblock['tags'],
  4355.                                                    'api_tags' => $docblock['api_tags'],
  4356.                                                    'info_tags' => $docblock['info_tags'],
  4357.                                                    'utags' => $docblock['utags'],
  4358.                                                    'include_name'     => $element->getName(),
  4359.                                                    'line_number' => $element->getLineNumber(),
  4360.                                                    'include_value'    => $per),
  4361.                                              $addition));
  4362.     }
  4363.  
  4364.     /**
  4365.      * Converts function for template output
  4366.      *
  4367.      * This function must be called by a child converter with any extra
  4368.      * template variables needed in the parameter $addition
  4369.      * @see prepareDocBlock()
  4370.      * @param parserFunction 
  4371.      */
  4372.     function convertFunction(&$element$addition = array())
  4373.     {
  4374.         $docblock $this->prepareDocBlock($element);
  4375.         $fname $element->getName();
  4376.         $params $param_i = array();
  4377.         if (count($element->docblock->params))
  4378.         foreach($element->docblock->params as $param => $val)
  4379.         {
  4380.             $a $val->Convert($this);
  4381.             $params[$param_i[$param= array("var" => $param,"datatype" => $val->converted_returnType,"data" => $a);
  4382.         }
  4383.         $returntype 'void';
  4384.         if ($element->docblock->return)
  4385.         {
  4386.             $a $element->docblock->return->Convert($this);
  4387.             $returntype $element->docblock->return->converted_returnType;
  4388.         }
  4389.  
  4390.         if ($this->hasSourceCode($element->getPath()))
  4391.         $addition["slink"$this->getSourceAnchor($element->getPath(),$element->getLineNumber(),$element->getLineNumber(),true);
  4392.         $this->page_data->append('functions',array_merge(
  4393.                                               array('sdesc' => $docblock['sdesc'],
  4394.                                                     'desc' => $docblock['desc'],
  4395.                                                     'tags' => $docblock['tags'],
  4396.                                                     'api_tags' => $docblock['api_tags'],
  4397.                                                     'info_tags' => $docblock['info_tags'],
  4398.                                                     'utags' => $docblock['utags'],
  4399.                                                     'function_name'     => $fname,
  4400.                                                     'function_return'    => $returntype,
  4401.                                                     'function_conflicts'    => $this->getFormattedConflicts($element,"functions"),
  4402.                                                     'ifunction_call'     => $element->getIntricateFunctionCall($this$param_i),
  4403.                                                     'function_call'     => $element->getFunctionCall(),
  4404.                                                     'line_number' => $element->getLineNumber(),
  4405.                                                     'id' => $this->getId($element),
  4406.                                                     'params' => $params),
  4407.                                               $addition));
  4408.     }
  4409.     /**#@-*/
  4410.  
  4411.     /**
  4412.      * convert the element's DocBlock for output
  4413.      *
  4414.      * This function converts all tags and descriptions for output
  4415.      * @param mixed any descendant of {@link parserElement}, or {@link parserData}
  4416.      * @param array used to translate tagnames into other tags
  4417.      * @param boolean set to false for pages and classes, the only elements allowed to specify @package
  4418.      * @return array 
  4419.      *
  4420.      *  Format:
  4421.      *  <pre>
  4422.      *  array('sdesc' => DocBlock summary
  4423.      *        'desc' => DocBlock detailed description
  4424.      *        'tags' => array('keyword' => tagname, 'data' => tag description)
  4425.      *                  known tags
  4426.      *        'api_tags' => array('keyword' => tagname, 'data' => tag description)
  4427.      *                  known api documentation tags
  4428.      *        'info_tags' => array('keyword' => tagname, 'data' => tag description)
  4429.      *                  known informational tags
  4430.      *      [ 'utags' => array('keyword' => tagname, 'data' => tag description
  4431.      *                  unknown tags ]
  4432.      *      [ 'vartype' => type from @var/@return tag ]
  4433.      *      [ 'var_descrip' => description from @var/@return tag ]
  4434.      *       )
  4435.      *  </pre>
  4436.      */
  4437.     function prepareDocBlock(&$element$names = array(),$nopackage = true)
  4438.     {
  4439.         $tagses $element->docblock->listTags();
  4440.         $tags $ret $api_tags $info_tags = array();
  4441.         $api_tags_arr = array("abstract""access""deprecated""example""filesource",
  4442.                              "global""internal""name""return""see",
  4443.                              "property""property-read""property-write""method",
  4444.                              "staticvar""usedby""uses""var");
  4445.         if (!$nopackage)
  4446.         {
  4447.             $tags[= array('keyword' => 'package','data' => $element->docblock->package);
  4448.             if (!empty($element->docblock->subpackage)) $tags[= array('keyword' => 'subpackage','data' => $element->docblock->subpackage);
  4449.         }
  4450.         if ($element->docblock->var)
  4451.         {
  4452.             $a $element->docblock->var->Convert($this);
  4453.             $ret['vartype'$element->docblock->var->converted_returnType;
  4454.             if (!empty($a))
  4455.             {
  4456.                 $tags[= array('keyword' => 'var''data' => $a);
  4457.                 $ret["var_descrip"$a;
  4458.             }
  4459.         }
  4460.         if ($element->docblock->return)
  4461.         {
  4462.             $a $element->docblock->return->Convert($this);
  4463.             $ret['vartype'$element->docblock->return->converted_returnType;
  4464.             if (!empty($a))
  4465.             {
  4466.                 $tags[$api_tags[= array('keyword' => 'return''data' => $a);
  4467.                 $ret["var_descrip"$a;
  4468.             }
  4469.         }
  4470.         if ($element->docblock->funcglobals)
  4471.         foreach($element->docblock->funcglobals as $global => $val)
  4472.         {
  4473.             if ($a $this->getGlobalLink($global,$element->docblock->package))
  4474.             {
  4475.                 $global $a;
  4476.             }
  4477.             $b Converter::getLink($val[0]);
  4478.             if (is_object($b&& phpDocumentor_get_class($b== 'classlink')
  4479.             {
  4480.                 $val[0$this->returnSee($b);
  4481.             }
  4482.             $tags[$api_tags[= array('keyword' => 'global','data' => $val[0].' '.$global.': '.$val[1]->Convert($this));
  4483.         }
  4484.         if ($element->docblock->statics)
  4485.         foreach($element->docblock->statics as $static => $val)
  4486.         {
  4487.             $a $val->Convert($this);
  4488.             $tags[$api_tags[= array('keyword' => 'staticvar','data' => $val->converted_returnType.' '.$static.': '.$a);
  4489.         }
  4490.         $property_tags = array();
  4491.         foreach $element->docblock->properties as $prop_name => $val )
  4492.         {
  4493.             $a $val->Convert$this );
  4494.             if !empty$a ) )
  4495.             {
  4496.                 $tags[$api_tags[= array'keyword' => $val->keyword ,
  4497.                                                'data' => $val->converted_returnType  . ' ' $prop_name ': ' $a );
  4498.                 $prop['prop_name'$prop_name;
  4499.                 $prop['access'$val->keyword == 'property-read' 'read' :
  4500.                                     $val->keyword == 'property-write' 'write' 'read/write' );
  4501.                 $prop['prop_type'$val->converted_returnType;
  4502.                 $prop['sdesc'$a;
  4503.                 $property_tags$prop_name $prop;
  4504.             }
  4505.         }
  4506.         ksort$property_tagsSORT_STRING );
  4507.         $property_tags array_values$property_tags );
  4508.         $info_tags_sorted = array();
  4509.         $ret['static'= false;
  4510.         foreach($tagses as $tag)
  4511.         {
  4512.             if (isset($names[$tag->keyword])) $tag->keyword = $names[$tag->keyword];
  4513.             if ($tag->keyword == 'static'{
  4514.                 $ret['static'= true;
  4515.                 continue;
  4516.             }
  4517.             if ($tag->keyword)
  4518.                 $tags[= array("keyword" => $tag->keyword,"data" => $tag->Convert($this));
  4519.             if (in_array($tag->keyword$api_tags_arr)) {
  4520.                 $api_tags[= array("keyword" => $tag->keyword,"data" => $tag->Convert($this));
  4521.             else {
  4522.                 $info_tags[= array("keyword" => $tag->keyword,"data" => $tag->Convert($this));
  4523.                 @list$className$desc explode" "$tag->Convert($this));
  4524.                 $info_tags_sorted$tag->keyword ][= array'keyword' => $className'data' => $desc );
  4525.             }
  4526.         }
  4527.         $utags = array();
  4528.         foreach($element->docblock->unknown_tags as $keyword => $tag)
  4529.         {
  4530.             foreach($tag as $t)
  4531.             $utags[= array('keyword' => $keyword'data' => $t->Convert($this));
  4532.         }
  4533.         $ret['abstract'= false;
  4534.         $ret['access''public';
  4535.         $see_tags = array();
  4536.         foreach($tags as $tag)
  4537.         {
  4538.             if ($tag['keyword'== 'access'{
  4539.                 $ret['access'$tag['data'];
  4540.             }
  4541.             if ($tag['keyword'== 'abstract'{
  4542.                 $ret['abstract'= true;
  4543.             }
  4544.             if ($tag['keyword'== 'see' || $tag['keyword'== 'uses' ||
  4545.                   $tag['keyword'== 'usedby'{
  4546.                 $see_tags[$tag['data'];
  4547.             }
  4548.         }
  4549.         $ret['sdesc'$element->docblock->getSDesc($this);
  4550.         $ret['desc'$element->docblock->getDesc($this);
  4551.         $ret['tags'$tags;
  4552.         $ret['see_tags'$see_tags;
  4553.         $ret['info_tags_sorted'$info_tags_sorted;
  4554.         $ret['api_tags'$api_tags;
  4555.         $ret['info_tags'$info_tags;
  4556.         $ret['utags'$utags;
  4557.         $ret['property_tags'$property_tags;
  4558.         return $ret;
  4559.     }
  4560.  
  4561.     /**
  4562.      * gets a list of all classes declared on a procedural page represented by
  4563.      * $element, a {@link parserData} class
  4564.      * @param parserData &$element 
  4565.      * @return array links to each classes documentation
  4566.      *
  4567.      *  Format:
  4568.      *  <pre>
  4569.      *  array('name' => class name,
  4570.      *        'sdesc' => summary of the class
  4571.      *        'link' => link to the class's documentation)
  4572.      *  </pre>
  4573.      */
  4574.     function getClassesOnPage(&$element)
  4575.     {
  4576.         global $_phpDocumentor_setting;
  4577.         $a $element->getClasses($this);
  4578.         $classes = array();
  4579.         foreach($a as $package => $clas)
  4580.         {
  4581.             if (!empty($_phpDocumentor_setting['packageoutput']))
  4582.             {
  4583.                 $packages explode(',',$_phpDocumentor_setting['packageoutput']);
  4584.                 if (!in_array($package$packages)) continue;
  4585.             }
  4586.             for($i=0; $i<count($clas)$i++)
  4587.             {
  4588.                 if ($this->parseprivate || ($clas[$i]->docblock && $clas[$i]->docblock->hasaccess && $clas[$i]->docblock->tags['access'][0]->value == 'private'))
  4589.                 {
  4590.                     $sdesc '';
  4591.                     $r = array();
  4592.                     $sdesc $clas[$i]->docblock->getSDesc($this);
  4593.                     if ($clas[$i]->docblock->hasaccess)
  4594.                                             $r['access'$clas[$i]->docblock->tags['access'][0]->value;
  4595.                     else
  4596.                                             $r['access''public';
  4597.                                         if (isset ($clas[$i]->docblock->tags['abstract']))
  4598.                                             $r['abstract'= TRUE;
  4599.                                         else
  4600.                                             $r['abstract'= FALSE;
  4601.                     $r['name'$clas[$i]->getName();
  4602.                     $r['sdesc'$sdesc;
  4603.                     $r['link'$this->getClassLink($clas[$i]->getName(),$package,$clas[$i]->getPath());
  4604.                     $classes[$r;
  4605.                 }
  4606.             }
  4607.         }
  4608.         return $classes;
  4609.     }
  4610.  
  4611.     /**
  4612.      * returns an array containing the class inheritance tree from the root
  4613.      * object to the class.
  4614.      *
  4615.      * This method must be overridden, or phpDocumentor will halt with a fatal
  4616.      * error
  4617.      * @return string Converter-specific class tree for an individual class
  4618.      * @param parserClass    class variable
  4619.      * @abstract
  4620.      */
  4621.  
  4622.     function generateFormattedClassTree($class)
  4623.     {
  4624.     }
  4625.  
  4626.     /**
  4627.      * returns an array containing the class inheritance tree from the root
  4628.      * object to the class.
  4629.      *
  4630.      * This method must be overridden, or phpDocumentor will halt with a fatal
  4631.      * error
  4632.      * @return string Converter-specific class tree for an individual class
  4633.      * @param parserClass    class variable
  4634.      * @abstract
  4635.      */
  4636.  
  4637.     function getFormattedImplements($el)
  4638.     {
  4639.         $ret = array();
  4640.         foreach ($el->getImplements(as $interface)
  4641.         {
  4642.             $link $this->getLink($interface);
  4643.             if ($link && is_object($link)) {
  4644.                 $ret[$this->returnSee($link);
  4645.             else {
  4646.                 if (class_exists('ReflectionClass')) {
  4647.                     if (interface_exists($interface)) {
  4648.                         $inter = new ReflectionClass($interface);
  4649.                         if ($inter->isInternal()) {
  4650.                             $ret[$interface ' (internal interface)';
  4651.                         else {
  4652.                             $ret[$interface;
  4653.                         }
  4654.                     }
  4655.                 else {
  4656.                     $ret[$interface;
  4657.                 }
  4658.             }
  4659.         }
  4660.         return $ret;
  4661.     }
  4662.  
  4663.     /**
  4664.      * @param mixed {@link parserClass, parserFunction, parserDefine} or
  4665.      *  {@link parserGlobal}
  4666.      * @param string type to display.  either 'class','function','define'
  4667.      *                or 'global variable'
  4668.      * @return array links to conflicting elements, or empty array
  4669.      * @uses parserClass::getConflicts()
  4670.      * @uses parserFunction::getConflicts()
  4671.      * @uses parserDefine::getConflicts()
  4672.      * @uses parserGlobal::getConflicts()
  4673.      */
  4674.     function getFormattedConflicts(&$element,$type)
  4675.     {
  4676.         $conflicts $element->getConflicts($this);
  4677.         $r = array();
  4678.         if (!$conflictsreturn false;
  4679.         foreach($conflicts as $package => $class)
  4680.         {
  4681.             $r[$class->getLink($this,$class->docblock->package);
  4682.         }
  4683.         if (!empty($r)) $r = array('conflicttype' => $type'conflicts' => $r);
  4684.         return $r;
  4685.     }
  4686.  
  4687.     /**
  4688.      * Get a list of methods in child classes that override this method
  4689.      * @return array empty array or array(array('link'=>link to method,
  4690.      *  'sdesc'=>short description of the method),...)
  4691.      * @uses parserMethod::getOverridingMethods()
  4692.      * @param parserMethod 
  4693.      */
  4694.     function getFormattedDescMethods(&$element)
  4695.     {
  4696.         $meths $element->getOverridingMethods($this);
  4697.         $r = array();
  4698.         for($i=0; $i<count($meths)$i++)
  4699.         {
  4700.             $ms = array();
  4701.             $ms['link'$meths[$i]->getLink($this);
  4702.             $ms['sdesc'$meths[$i]->docblock->getSDesc($this);
  4703.             $r[$ms;
  4704.         }
  4705.         return $r;
  4706.     }
  4707.  
  4708.     /**
  4709.      * Get a list of vars in child classes that override this var
  4710.      * @return array empty array or array('link'=>link to var,
  4711.      *  'sdesc'=>short description of the method
  4712.      * @uses parserVar::getOverridingVars()
  4713.      * @param parserVar 
  4714.      */
  4715.     function getFormattedDescVars(&$element)
  4716.     {
  4717.         $vars $element->getOverridingVars($this);
  4718.         $r = array();
  4719.         for($i=0; $i<count($vars)$i++)
  4720.         {
  4721.             $vs = array();
  4722.             $vs['link'$vars[$i]->getLink($this);
  4723.             $vs['sdesc'$vars[$i]->docblock->getSDesc($this);
  4724.             $r[$vs;
  4725.         }
  4726.         return $r;
  4727.     }
  4728.  
  4729.     /**
  4730.      * Get the method this method overrides, if any
  4731.      * @return array|falsearray('link'=>link to overridden method,
  4732.      *  'sdesc'=>short description
  4733.      * @see parserMethod::getOverrides()
  4734.      * @param parserMethod 
  4735.      */
  4736.     function getFormattedOverrides(&$element)
  4737.     {
  4738.         $ovr $element->getOverrides($this);
  4739.         if (!$ovrreturn false;
  4740.         $sdesc $ovr->docblock->getSDesc($this);
  4741.         $name method_exists($ovr'getFunctionCall'$ovr->getFunctionCall($ovr->getName();
  4742.         $link ($link $ovr->getLink($this)) $link $ovr->getClass('::' $name;
  4743.         return array('link' => $link,'sdesc' => $sdesc);
  4744.     }
  4745.  
  4746.     /**
  4747.      * Get the method this method(s) implemented from an interface, if any
  4748.      * @return array|falsearray('link'=>link to implemented method,
  4749.      *  'sdesc'=>short description
  4750.      * @uses parserMethod::getImplements()
  4751.      * @param parserMethod 
  4752.      */
  4753.     function getFormattedMethodImplements(&$element)
  4754.     {
  4755.         $ovr $element->getImplements($this);
  4756.         if (!$ovrreturn false;
  4757.         $ret = array();
  4758.         foreach ($ovr as $impl{
  4759.             $sdesc $impl->docblock->getSDesc($this);
  4760.             $name $impl->getName();
  4761.             $link ($link $impl->getLink($this)) $link $impl->getClass('::' $name;
  4762.             $ret[= array('link' => $link,'sdesc' => $sdesc);
  4763.         }
  4764.         return $ret;
  4765.     }
  4766.  
  4767.     /**
  4768.      * returns a list of child classes
  4769.      *
  4770.      * @param parserClass class variable
  4771.      * @uses parserClass::getChildClassList()
  4772.      */
  4773.  
  4774.     function generateChildClassList($class)
  4775.     {
  4776.         $kids $class->getChildClassList($this);
  4777.         $list = array();
  4778.         if (count($kids))
  4779.         {
  4780.             for($i=0; $i<count($kids)$i++)
  4781.             {
  4782.                 $lt['link'$kids[$i]->getLink($this);
  4783.                 $lt['sdesc'$kids[$i]->docblock->getSDesc($this);
  4784.  
  4785.                                 if ($kids[$i]->docblock->hasaccess)
  4786.                                     $lt['access'$kids[$i]->docblock->tags['access'][0]->value;
  4787.                                 else
  4788.                                     $lt['access''public';
  4789.  
  4790.                                 $lt['abstract'= isset ($kids[$i]->docblock->tags['abstract'][0]);
  4791.  
  4792.                 $list[$lt;
  4793.             }
  4794.         else return false;
  4795.         return $list;
  4796.     }
  4797.  
  4798.     /**
  4799.      * Return template-enabled list of inherited variables
  4800.      *
  4801.      * uses parserVar helper function getInheritedVars and generates a
  4802.      * template-enabled list using getClassLink()
  4803.      * @param parserVar $child class var
  4804.      * @see getClassLink(), parserVar::getInheritedVars()
  4805.      * @return array Format:
  4806.      *  <pre>
  4807.      *  array(
  4808.      *    array('parent_class' => link to parent class's documentation,
  4809.      *          'ivars' =>
  4810.      *             array(
  4811.      *               array('name' => inherited variable name,
  4812.      *                     'link' => link to inherited variable's documentation,
  4813.      *                     'default' => default value of inherited variable,
  4814.      *                     'sdesc' => summary of inherited variable),
  4815.      *               ...),
  4816.      *    ...)
  4817.      *  </pre>
  4818.      */
  4819.  
  4820.     function getFormattedInheritedVars($child)
  4821.     {
  4822.         $package $child->docblock->package;
  4823.         $subpackage $child->docblock->subpackage;
  4824.         $ivars $child->getInheritedVars($this);
  4825.         $results = array();
  4826.         if (!count($ivars)) return $results;
  4827.         foreach($ivars as $parent => $vars)
  4828.         {
  4829.             $file $vars['file'];
  4830.             $vars $vars['vars'];
  4831.             $par $this->classes->getClass($parent,$file);
  4832.             if ($par{
  4833.                 $package $par->docblock->package;
  4834.             }
  4835.             usort($vars,array($this,"sortVar"));
  4836.             $result['parent_class'$this->getClassLink($parent$package);
  4837.             if (!$result['parent_class']{
  4838.                 $result['parent_class'$parent ' (Internal Class)';
  4839.             }
  4840.             foreach($vars as $var)
  4841.             {
  4842.                 $info = array();
  4843.  
  4844.                 if ($var->docblock->hasaccess{
  4845.                     $info['access'$var->docblock->tags['access'][0]->value;
  4846.                 else {
  4847.                     $info['access''public';
  4848.                 }
  4849.  
  4850.                 $info['abstract'= isset ($var->docblock->tags['abstract'][0]);
  4851.  
  4852.                 $info['name'$var->getName();
  4853.                 $info['link'$var->getLink($this);
  4854.                 if (!$info['link']{
  4855.                     $info['link'$info['name'];
  4856.                 }
  4857.                 $info['default'$this->postProcess($var->getValue());
  4858.                 if ($var->docblock)
  4859.                 $info['sdesc'$var->docblock->getSDesc($this);
  4860.                 $result["ivars"][$info;
  4861.             }
  4862.             $results[$result;
  4863.             $result = array();
  4864.         }
  4865.         return $results;
  4866.     }
  4867.  
  4868.     /**
  4869.      * Return template-enabled list of inherited methods
  4870.      *
  4871.      * uses parserMethod helper function getInheritedMethods and generates a
  4872.      * template-enabled list using getClassLink()
  4873.      * @param parserMethod $child class method
  4874.      * @see getClassLink(), parserMethod::getInheritedMethods()
  4875.      * @return array Format:
  4876.      *  <pre>
  4877.      *  array(
  4878.      *    array('parent_class' => link to parent class's documentation,
  4879.      *          'ivars' =>
  4880.      *             array(
  4881.      *               array('name' => inherited variable name,
  4882.      *                     'link' => link to inherited variable's documentation,
  4883.      *                     'function_call' => {@link parserMethod::getIntricateFunctionCall()}
  4884.      *                                        returned array,
  4885.      *                     'sdesc' => summary of inherited variable),
  4886.      *               ...),
  4887.      *    ...)
  4888.      *  </pre>
  4889.      */
  4890.  
  4891.     function getFormattedInheritedMethods($child)
  4892.     {
  4893.         $package $child->docblock->package;
  4894.         $subpackage $child->docblock->subpackage;
  4895.         $imethods $child->getInheritedMethods($this);
  4896.         $results = array();
  4897.         if (!count($imethods)) return $results;
  4898.         foreach($imethods as $parent => $methods)
  4899.         {
  4900.             $file $methods['file'];
  4901.             $methods $methods['methods'];
  4902.             $par $this->classes->getClass($parent,$file);
  4903.             if ($par{
  4904.                 $package $par->docblock->package;
  4905.             }
  4906.             usort($methods,array($this,"sortMethod"));
  4907.             $result['parent_class'$this->getClassLink($parent,$package);
  4908.             if (!$result['parent_class']{
  4909.                 $result['parent_class'$parent ' (Internal Class)';
  4910.             }
  4911.             foreach($methods as $method)
  4912.             {
  4913.                 $info = array();
  4914.  
  4915.                 if ($method->docblock->hasaccess{
  4916.                     $info['access'$method->docblock->tags['access'][0]->value;
  4917.                 else {
  4918.                     $info['access''public';
  4919.                 }
  4920.                 $info['abstract'= isset ($method->docblock->tags['abstract'][0]);
  4921.  
  4922.                 if ($method->isConstructor$info['constructor'= 1;
  4923.                 $returntype 'void';
  4924.                 if ($method->isConstructor{
  4925.                     $returntype $method->getClass();
  4926.                 }
  4927.                 if ($method->docblock->return{
  4928.                     $a $method->docblock->return->Convert($this);
  4929.                     $returntype $method->docblock->return->converted_returnType;
  4930.                 }
  4931.                 $info['function_return'$returntype;
  4932.                 $info['static'= isset ($method->docblock->tags['static'][0]);
  4933.                 $info['link'$method->getLink($this);
  4934.                 if (!$info['link']{
  4935.                     $info['link'$method->getFunctionCall();
  4936.                 }
  4937.                 $info['name'$method->getName();
  4938.                 if ($method->docblock)
  4939.                 $info['sdesc'$method->docblock->getSDesc($this);
  4940.                 $params = array();
  4941.                 if (count($method->docblock->params))
  4942.                 foreach($method->docblock->params as $param => $val)
  4943.                 {
  4944.                     $a $val->Convert($this);
  4945.                     $params[$param= array("var" => $param,"datatype" => $val->converted_returnType,"data" => $a);
  4946.                 }
  4947.  
  4948.                 $info['function_call'$method->getIntricateFunctionCall($this,$params);
  4949.                 $result["imethods"][$info;
  4950.             }
  4951.             $results[$result;
  4952.             $result = array();
  4953.         }
  4954.         return $results;
  4955.     }
  4956.  
  4957.     /**
  4958.      * Return template-enabled list of inherited class constants
  4959.      *
  4960.      * uses parserConst helper function getInheritedConsts and generates a
  4961.      * template-enabled list using getClassLink()
  4962.      * @param parserConst $child class constant
  4963.      * @see getClassLink(), parserMethod::getInheritedConsts()
  4964.      * @return array Format:
  4965.      *  <pre>
  4966.      *  array(
  4967.      *    array('parent_class' => link to parent class's documentation,
  4968.      *          'ivars' =>
  4969.      *             array(
  4970.      *               array('name' => inherited constant name,
  4971.      *                     'link' => link to inherited constant's documentation,
  4972.      *                     'value' => constant value,
  4973.      *                     'sdesc' => summary of inherited constant),
  4974.      *               ...),
  4975.      *    ...)
  4976.      *  </pre>
  4977.      */
  4978.  
  4979.     function getFormattedInheritedConsts($child)
  4980.     {
  4981.         $package $child->docblock->package;
  4982.         $subpackage $child->docblock->subpackage;
  4983.         $ivars $child->getInheritedConsts($this);
  4984.         $results = array();
  4985.         if (!count($ivars)) return $results;
  4986.         foreach($ivars as $parent => $vars)
  4987.         {
  4988.             $file $vars['file'];
  4989.             $vars $vars['consts'];
  4990.             $par $this->classes->getClass($parent,$file);
  4991.             if ($par{
  4992.                 $package $par->docblock->package;
  4993.             }
  4994.             usort($vars,array($this,"sortVar"));
  4995.             $result['parent_class'$this->getClassLink($parent,$package);
  4996.             if (!$result['parent_class']{
  4997.                 $result['parent_class'$parent ' (Internal Class)';
  4998.             }
  4999.             foreach($vars as $var)
  5000.             {
  5001.                 $info = array();
  5002.  
  5003.                 if ($var->docblock->hasaccess{
  5004.                     $info['access'$var->docblock->tags['access'][0]->value;
  5005.                 else {
  5006.                     $info['access''public';
  5007.                 }
  5008.                 $info['name'$var->getName();
  5009.                 $info['link'$var->getLink($this);
  5010.                 if (!$info['link']{
  5011.                     $info['link'$info['name'' = ' $var->getValue();
  5012.                 }
  5013.                 $info['value'$this->postProcess($var->getValue());
  5014.                 if ($var->docblock)
  5015.                 $info['sdesc'$var->docblock->getSDesc($this);
  5016.                 $result["iconsts"][$info;
  5017.             }
  5018.             $results[$result;
  5019.             $result = array();
  5020.         }
  5021.         return $results;
  5022.     }
  5023.  
  5024.     /**
  5025.      * Return a Smarty template object to operate with
  5026.      *
  5027.      * This returns a Smarty template with pre-initialized variables for use.
  5028.      * If the method "SmartyInit()" exists, it is called.
  5029.      * @return Smarty 
  5030.      */
  5031.     function &newSmarty()
  5032.     {
  5033.         $templ = new Smarty;
  5034.         $templ->use_sub_dirs = false;
  5035.         $templ->template_dir = realpath($this->smarty_dir . PATH_DELIMITER . 'templates');
  5036.         $templatename get_class($this$this->templateName;
  5037.         if (!file_exists($this->targetDir . DIRECTORY_SEPARATOR . md5($templatename))) {
  5038.             // we'll delete this on finishing conversion
  5039.             $this->_compiledDir[$this->targetDir . DIRECTORY_SEPARATOR . md5($templatename)= 1;
  5040.             mkdir($this->targetDir . DIRECTORY_SEPARATOR . md5($templatename),0775);
  5041.         }
  5042.         $templ->compile_dir = realpath($this->targetDir . PATH_DELIMITER . md5($templatename));
  5043.         $templ->config_dir = realpath($this->smarty_dir . PATH_DELIMITER . 'configs');
  5044.         $templ->assign("date",date("r",time()));
  5045.         $templ->assign("maintitle",$this->title);
  5046.         $templ->assign("package",$this->package);
  5047.         $templ->assign("phpdocversion",PHPDOCUMENTOR_VER);
  5048.         $templ->assign("phpdocwebsite",PHPDOCUMENTOR_WEBSITE);
  5049.         $templ->assign("subpackage",$this->subpackage);
  5050.         if (method_exists($this,'SmartyInit')) return $this->SmartyInit($templ);
  5051.         return $templ;
  5052.     }
  5053.  
  5054.     /**
  5055.      * Finish up parsing/cleanup directories
  5056.      */
  5057.     function cleanup()
  5058.     {
  5059.         foreach ($this->_compiledDir as $dir => $one{
  5060.             $this->_rmdir($dir);
  5061.         }
  5062.     }
  5063.  
  5064.     /**
  5065.      * Completely remove a directory and its contents
  5066.      *
  5067.      * @param string $directory 
  5068.      */
  5069.     function _rmdir($directory)
  5070.     {
  5071.         $handle @opendir($directory);
  5072.         if ($handle{
  5073.             while (false !== ($file readdir($handle))) {
  5074.                 if ($file == '.' || $file == '..'{
  5075.                     continue;
  5076.                 }
  5077.                 if (is_dir($directory . DIRECTORY_SEPARATOR . $file)) {
  5078.                     $this->_rmdir($directory . DIRECTORY_SEPARATOR . $file);
  5079.                 }
  5080.                 @unlink($directory . DIRECTORY_SEPARATOR . $file);
  5081.             }
  5082.             closedir($handle);
  5083.             @rmdir($directory);
  5084.         }
  5085.     }
  5086.  
  5087.     /**
  5088.      * do all necessary output
  5089.      * @see Converter
  5090.      * @abstract
  5091.      */
  5092.     function Output($title)
  5093.     {
  5094.         phpDocumentor_out("WARNING: Generic Converter::Output was used, no output will be generated");
  5095.     }
  5096.  
  5097.     /**
  5098.      * Set the template directory with a different template base directory
  5099.      * @tutorial phpDocumentor.howto.pkg#using.command-line.templatebase
  5100.      * @param string template base directory
  5101.      * @param string template name
  5102.      */
  5103.     function setTemplateBase($base$dir)
  5104.     {
  5105.         // remove trailing /'s from the base path, if any
  5106.         $base str_replace('\\','/',$base);
  5107.         while ($base{strlen($base- 1== '/'$base substr($base,0,strlen($base- 1);
  5108.         $this->templateName = substr($dir,0,strlen($dir- 1);
  5109.         $this->templateDir =  $base "/Converters/" $this->outputformat . "/" $this->name . "/templates/" $dir;
  5110.         if (!is_dir($this->templateDir))
  5111.         {
  5112.             addErrorDie(PDERROR_TEMPLATEDIR_DOESNT_EXIST$this->templateDir);
  5113.         }
  5114.  
  5115.         $this->smarty_dir = $this->templateDir;
  5116.         if (file_exists($this->templateDir . PATH_DELIMITER . 'options.ini'))
  5117.         {
  5118.             // retrieve template options, allow array creation
  5119.             $this->template_options = phpDocumentor_parse_ini_file($this->templateDir . PATH_DELIMITER . 'options.ini',true);
  5120.         }
  5121.     }
  5122.  
  5123.     /**
  5124.      * sets the template directory based on the {@link $outputformat} and {@link $name}
  5125.      * Also sets {@link $templateName} to the $dir parameter
  5126.      * @param string subdirectory
  5127.      */
  5128.     function setTemplateDir($dir)
  5129.     {
  5130.         if ('@DATA-DIR@' != '@'.'DATA-DIR@'{
  5131.             $templateBase str_replace('\\''/''@DATA-DIR@/PhpDocumentor/phpDocumentor');
  5132.         else {
  5133.             $templateBase str_replace('\\','/',$GLOBALS['_phpDocumentor_install_dir']'/phpDocumentor';
  5134.         }
  5135.         $this->setTemplateBase($templateBase$dir);
  5136.     }
  5137.  
  5138.     /**
  5139.      * Get the absolute path to the converter's base directory
  5140.      * @return string 
  5141.      */
  5142.     function getConverterDir()
  5143.     {
  5144.         if ('@DATA-DIR@' != '@' 'DATA-DIR@'{
  5145.             return str_replace('\\''/'"@DATA-DIR@/PhpDocumentor/phpDocumentor/Converters/"$this->outputformat . "/" $this->name;
  5146.         else {
  5147.             return str_replace('\\','/',$GLOBALS['_phpDocumentor_install_dir']."/phpDocumentor/Converters/" $this->outputformat . "/" $this->name;
  5148.         }
  5149.     }
  5150.  
  5151.     /**
  5152.      * Parse a global variable's default value for class initialization.
  5153.      *
  5154.      * If a global variable's default value is "new class" as in:
  5155.      * <code>
  5156.      * $globalvar = new Parser
  5157.      * </code>
  5158.      * This method will document it not as "new Parser" but instead as
  5159.      * "new {@link Parser}".    For examples, see {@link phpdoc.inc}.
  5160.      * Many global variables are classes, and phpDocumentor links to their
  5161.      * documentation
  5162.      * @return string default global variable value with link to class if
  5163.      *                 it's "new Class"
  5164.      * @param string default value of a global variable.
  5165.      */
  5166.     function getGlobalValue($value)
  5167.     {
  5168.         if (strpos($value,'new'=== 0)
  5169.         {
  5170.             preg_match('/new([^(]*)((?:.|\r|\n)*)/',$value,$newval);
  5171.             if (isset($newval[1]))
  5172.             {
  5173.                 $a Converter::getLink(trim($newval[1]));
  5174.                 if (!isset($newval[2])) $newval[2'';
  5175.                 if ($a && phpDocumentor_get_class($a== 'classlink'$value 'new '.$this->returnSee($a.
  5176.                     $this->postProcess($newval[2]);
  5177.             }
  5178.             return $value;
  5179.         }
  5180.         return $this->postProcess($value);
  5181.     }
  5182.  
  5183.     /**
  5184.      * Parse an include's file to see if it is a file documented in this project
  5185.      *
  5186.      * Although not very smart yet, this method will try to look for the
  5187.      * included file file.ext:
  5188.      *
  5189.      * <code>
  5190.      * include ("file.ext");
  5191.      * </code>
  5192.      *
  5193.      * If it finds it, it will return a link to the file's documentation.  As of
  5194.      * 1.2.0rc1, phpDocumentor is smarty enough to find these cases:
  5195.      * <ul>
  5196.      *  <li>absolute path to file</li>
  5197.      *  <li>./file.ext or ../file.ext</li>
  5198.      *  <li>relpath/to/file.ext if relpath is a subdirectory of the base parse
  5199.      *      directory</li>
  5200.      * </ul>
  5201.      * For examples, see {@link Setup.inc.php} includes.
  5202.      * Every include auto-links to the documentation for the file that is included
  5203.      * @return string included file with link to docs for file, if found
  5204.      * @param string file included by include statement.
  5205.      * @param string path of file that has the include statement
  5206.      */
  5207.     function getIncludeValue($value$ipath)
  5208.     {
  5209.         preg_match('/"([^"\']*\.[^"\']*)"/',$value,$match);
  5210.         if (!isset($match[1]))
  5211.         preg_match('/\'([^"\']*\.[^"\']*)\'/',$value,$match);
  5212.         if (isset($match[1]))
  5213.         {
  5214.             $fancy_per $this->proceduralpages->pathMatchesParsedFile($match[1],$ipath);
  5215.             if ($fancy_per)
  5216.             {
  5217.                 $link $this->addLink($fancy_per);
  5218.                 if (is_object($link&& phpDocumentor_get_class($link== 'pagelink' &&
  5219.                     isset($this->all_packages[$link->package]))
  5220.                 {
  5221.                     $value $this->returnSee($link,$value);
  5222.                 }
  5223.             else
  5224.             {
  5225.                 $per Converter::getLink($match[1]);
  5226.                 if (is_object($per&& phpDocumentor_get_class($per== 'pagelink')
  5227.                 $value $this->returnSee($per);
  5228.             }
  5229.         }
  5230.         return $value;
  5231.     }
  5232.  
  5233.     /**
  5234.      * Recursively creates all subdirectories that don't exist in the $dir path
  5235.      * @param string $dir 
  5236.      */
  5237.     function createParentDir($dir)
  5238.     {
  5239.         if (empty($dir)) return;
  5240.         $tmp explode(SMART_PATH_DELIMITER,$dir);
  5241.         array_pop($tmp);
  5242.         $parent implode(SMART_PATH_DELIMITER,$tmp);
  5243.         if ($parent != '' && !file_exists($parent))
  5244.         {
  5245.             $test @mkdir($parent,0775);
  5246.             if (!$test)
  5247.             {
  5248.                 $this->createParentDir($parent);
  5249.                 $test @mkdir($parent,0775);
  5250.                 phpDocumentor_out("Creating Parent Directory $parent\n");
  5251.             else
  5252.             {
  5253.                 phpDocumentor_out("Creating Parent Directory $parent\n");
  5254.             }
  5255.         }
  5256.     }
  5257.  
  5258.     /**
  5259.      * Sets the output directory for generated documentation
  5260.      * 
  5261.      * As of 1.3.0RC6, this also sets the compiled templates directory inside
  5262.      * the target directory
  5263.      * @param string $dir the output directory
  5264.      */
  5265.     function setTargetDir($dir)
  5266.     {
  5267.         if (strlen($dir> 0)
  5268.         {
  5269.             $this->targetDir = $dir;
  5270.             // if directory does exist create it, this should have more error checking in the future
  5271.             if (!file_exists($dir))
  5272.             {
  5273.                 $tmp str_replace(array("/","\\"),SMART_PATH_DELIMITER,$dir);
  5274.                 if (substr($tmp,-1== SMART_PATH_DELIMITER)
  5275.                 {
  5276.                     $tmp substr($tmp,0,(strlen($tmp)-1));
  5277.                 }
  5278.                 $this->createParentDir($tmp);
  5279.                 phpDocumentor_out("Creating Directory $dir\n");
  5280.                 mkdir($dir,0775);
  5281.             elseif (!is_dir($dir))
  5282.             {
  5283.                 echo "Output path: '$dir' is not a directory\n";
  5284.                 die();
  5285.             }
  5286.         else {
  5287.             echo "a target directory must be specified\n try phpdoc -h\n";
  5288.             die();
  5289.         }
  5290.     }
  5291.  
  5292.     /**
  5293.      * Writes a file to target dir
  5294.      * @param string 
  5295.      * @param string 
  5296.      * @param boolean true if the data is binary and not text
  5297.      */
  5298.     function writeFile($file,$data,$binary = false)
  5299.     {
  5300.         if (!file_exists($this->targetDir))
  5301.         {
  5302.             mkdir($this->targetDir,0775);
  5303.         }
  5304.         $string '';
  5305.         if ($binary$string 'binary file ';
  5306.         phpDocumentor_out("    Writing $string".$this->targetDir . PATH_DELIMITER . $file "\n");
  5307.         flush();
  5308.         $write 'w';
  5309.         if ($binary$write 'wb';
  5310.         $fp fopen($this->targetDir . PATH_DELIMITER . $file,$write);
  5311.         set_file_buffer$fp);
  5312.         fwrite($fp,$data,strlen($data));
  5313.         fclose($fp);
  5314.     }
  5315.  
  5316.     /**
  5317.      * Copies a file from the template directory to the target directory
  5318.      * thanks to Robert Hoffmann for this fix
  5319.      * @param string 
  5320.      */
  5321.     function copyFile($file$subdir '')
  5322.     {
  5323.         if (!file_exists($this->targetDir))
  5324.         {
  5325.             mkdir($this->targetDir,0775);
  5326.         }
  5327.         copy($this->templateDir . $subdir  PATH_DELIMITER . $file$this->targetDir . PATH_DELIMITER . $file);
  5328.     }
  5329.  
  5330.     /**
  5331.      * Return parserStringWithInlineTags::Convert() cache state
  5332.      * @see parserStringWithInlineTags::Convert()
  5333.      * @abstract
  5334.      */
  5335.     function getState()
  5336.     {
  5337.         return true;
  5338.     }
  5339.  
  5340.     /**
  5341.      * Compare parserStringWithInlineTags::Convert() cache state to $state
  5342.      * @param mixed 
  5343.      * @see parserStringWithInlineTags::Convert()
  5344.      * @abstract
  5345.      */
  5346.     function checkState($state)
  5347.     {
  5348.         return true;
  5349.     }
  5350.  
  5351. }
  5352.  
  5353. /**
  5354.  * @access private
  5355.  * @see Converter::getSortedClassTreeFromClass()
  5356.  */
  5357. function rootcmp($a$b)
  5358. {
  5359.     return strnatcasecmp($a['class'],$b['class']);
  5360. }
  5361.  
  5362. /**
  5363.  * @access private
  5364.  * @global string used to make the first tutorials converted the default package tutorials
  5365.  */
  5366. function tutorialcmp($a$b)
  5367. {
  5368.     global $phpDocumentor_DefaultPackageName;
  5369.     if ($a == $phpDocumentor_DefaultPackageNamereturn -1;
  5370.     if ($b == $phpDocumentor_DefaultPackageNamereturn 1;
  5371.     return strnatcasecmp($a$b);
  5372. }
  5373.  
  5374. /**
  5375.  * smart htmlentities, doesn't entity the allowed tags list
  5376.  * Since version 1.1, this function uses htmlspecialchars instead of
  5377.  * htmlentities, for international support
  5378.  * This function has been replaced by functionality in {@link ParserDescCleanup.inc}
  5379.  * @param string $s 
  5380.  * @return string browser-displayable page
  5381.  * @deprecated As of v1.2, No longer needed, as valid tags are parsed out of the source,
  5382.  *    and everything else is {@link Converter::postProcess()} handled
  5383.  */
  5384. function adv_htmlentities($s)
  5385. {
  5386.     return;
  5387.     global $phpDocumentor___html,$_phpDocumentor_html_allowed;
  5388.     $result htmlspecialchars($s);
  5389.     $entities array_flip(get_html_translation_table(HTML_SPECIALCHARS));
  5390.     $result strtr($result,$phpDocumentor___html);
  5391.     $matches = array();
  5392.     preg_match_all('/(&lt;img.*&gt;)/U',$result,$matches);
  5393.     for($i=0;$i<count($matches[1]);$i++)
  5394.     {
  5395.         $result str_replace($matches[1][$i],strtr($matches[1][$i],array_flip(get_html_translation_table(HTML_SPECIALCHARS))),$result);
  5396.     }
  5397.     preg_match_all('/(&lt;font.*&gt;)/U',$result,$matches);
  5398.     for($i=0;$i<count($matches[1]);$i++)
  5399.     {
  5400.         $result str_replace($matches[1][$i],strtr($matches[1][$i],array_flip(get_html_translation_table(HTML_SPECIALCHARS))),$result);
  5401.     }
  5402.     preg_match_all('/(&lt;ol.*&gt;)/U',$result,$matches);
  5403.     for($i=0;$i<count($matches[1]);$i++)
  5404.     {
  5405.         $result str_replace($matches[1][$i],strtr($matches[1][$i],array_flip(get_html_translation_table(HTML_SPECIALCHARS))),$result);
  5406.     }
  5407.     preg_match_all('/(&lt;ul.*&gt;)/U',$result,$matches);
  5408.     for($i=0;$i<count($matches[1]);$i++)
  5409.     {
  5410.         $result str_replace($matches[1][$i],strtr($matches[1][$i],array_flip(get_html_translation_table(HTML_SPECIALCHARS))),$result);
  5411.     }
  5412.     preg_match_all('/(&lt;li.*&gt;)/U',$result,$matches);
  5413.     for($i=0;$i<count($matches[1]);$i++)
  5414.     {
  5415.         $result str_replace($matches[1][$i],strtr($matches[1][$i],array_flip(get_html_translation_table(HTML_SPECIALCHARS))),$result);
  5416.     }
  5417.     preg_match_all('/(&lt;a .*&gt;)/U',$result,$matches);
  5418.     for($i=0;$i<count($matches[1]);$i++)
  5419.     {
  5420.         $result str_replace($matches[1][$i],strtr($matches[1][$i],array_flip(get_html_translation_table(HTML_SPECIALCHARS))),$result);
  5421.     }
  5422.     return $result;
  5423. }
  5424.  
  5425. /**
  5426.  * Used solely for setting up the @uses list
  5427.  * @package ignore
  5428.  * @ignore
  5429.  */
  5430. class __dummyConverter extends Converter
  5431. {
  5432.     function setTemplateDir(){}
  5433.     function setTargetDir(){}
  5434.     function getPageName(&$element)
  5435.     {
  5436.         if (phpDocumentor_get_class($element== 'parserpage'return '_'.$element->getName();
  5437.         return '_'.$element->parent->getName();
  5438.     }
  5439. }
  5440. ?>

Documentation generated on Mon, 11 Mar 2019 15:08:01 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.