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

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | phpDocumentor                                                          |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2000-2003 Joshua Eichorn, Gregory Beaver                 |
  7. // | Email         jeichorn@phpdoc.org, cellog@phpdoc.org                   |
  8. // | Web           http://www.phpdoc.org                                    |
  9. // | Mirror        http://phpdocu.sourceforge.net/                          |
  10. // | PEAR          http://pear.php.net/package-info.php?pacid=137           |
  11. // +------------------------------------------------------------------------+
  12. // | This source file is subject to version 3.00 of the PHP License,        |
  13. // | that is available at http://www.php.net/license/3_0.txt.               |
  14. // | If you did not receive a copy of the PHP license and are unable to     |
  15. // | obtain it through the world-wide-web, please send a note to            |
  16. // | license@php.net so we can mail you a copy immediately.                 |
  17. // +------------------------------------------------------------------------+
  18. //
  19.  
  20. /**
  21.  * Parser Elements, all classes representing documentable elements
  22.  * @package phpDocumentor
  23.  * @subpackage ParserElements
  24.  * @since 1.1
  25.  * @version $Id: ParserElements.inc,v 1.45.2.4 2003/08/13 20:01:56 CelloG Exp $
  26.  */
  27.  
  28. /**
  29.  * all elements except {@link parserPackagePage} descend from this abstract class
  30.  * @abstract
  31.  * @package phpDocumentor
  32.  * @subpackage ParserElements
  33.  * @author Greg Beaver <cellog@users.sourceforge.net>
  34.  * @since 1.0rc1
  35.  * @version $Id: ParserElements.inc,v 1.45.2.4 2003/08/13 20:01:56 CelloG Exp $
  36.  */
  37. class parserElement extends parserBase
  38. {
  39.     /**
  40.      * @var mixed either false or a {@link parserDocBlock}
  41.      */
  42.     var $docblock = false;
  43.     /**
  44.      * name of this element, or include type if element is a {@link parserInclude}
  45.      */
  46.     var $name;
  47.     
  48.     /**
  49.      * @var mixed either false or an array of paths to files with conflicts
  50.      */
  51.     var $conflicts = false;
  52.     
  53.     /**
  54.      * location of this element (filename)
  55.      * @var string
  56.      */
  57.     var $file = '';
  58.     
  59.     /**
  60.      * full path location of this element (filename)
  61.      * @var string
  62.      */
  63.     var $path = '';
  64.     
  65.     /**
  66.      * line number on file where this element stops
  67.      * @since 1.2
  68.      * @var false|integer
  69.      */
  70.     var $endlinenumber = 0;
  71.     
  72.     /**
  73.      * Line number in the source on which this element appears
  74.      * @since 1.2
  75.      * @var false|integer
  76.      */
  77.     var $linenumber = false;
  78.     
  79.     /**
  80.      * @param parserDocBlock
  81.      */
  82.     function setDocBlock($docblock)
  83.     {
  84.         $this->docblock = $docblock;
  85.     }
  86.     
  87.     /**
  88.      * @param string
  89.      */
  90.     function setName($name)
  91.     {
  92.         $this->name = trim($name);
  93.     }
  94.     
  95.     /**
  96.      * Set starting line number
  97.      * @param integer
  98.      */
  99.     function setLineNumber($number)
  100.     {
  101.         $this->linenumber = $number;
  102.     }
  103.     
  104.     /**
  105.      * Sets the ending line number of elements
  106.      * @param integer
  107.      */
  108.     function setEndLineNumber($l)
  109.     {
  110.         $this->endlinenumber = $l;
  111.     }
  112.     
  113.     /**
  114.      * @return integer
  115.      */
  116.     function getLineNumber()
  117.     {
  118.         return $this->linenumber;
  119.     }
  120.     
  121.     /**
  122.      * @return integer
  123.      */
  124.     function getEndLineNumber()
  125.     {
  126.         return $this->endlinenumber;
  127.     }
  128.     
  129.     /** @return string package containing this element */
  130.     function getPackage()
  131.     {
  132.         if ($this->docblock)
  133.         {
  134.             return $this->docblock->package;
  135.         } else return $GLOBALS['phpDocumentor_DefaultPackageName'];
  136.     }
  137.     
  138.     /** @param string */
  139.     function setFile($file)
  140.     {
  141.         $this->file = $file;
  142.     }
  143.     
  144.     /** @param string */
  145.     function setPath($file)
  146.     {
  147.         // look for special windows case
  148.         if(SMART_PATH_DELIMITER === '\\')
  149.             $this->path = strtr($file,'/','\\');
  150.         else
  151.             $this->path = $file;
  152.         $this->path = $file;
  153.     }
  154.     
  155.     /**
  156.      * @return string
  157.      */
  158.     function getName()
  159.     {
  160.         if (!isset($this->name)) return false;
  161.         return $this->name;
  162.     }
  163.     
  164.     /**
  165.      * @return string
  166.      */
  167.     function getFile()
  168.     {
  169.         if (!isset($this->file)) return false;
  170.         return $this->file;
  171.     }
  172.     
  173.     /**
  174.      * @return string
  175.      */
  176.     function getPath()
  177.     {
  178.         if (!isset($this->path)) return false;
  179.         return $this->path;
  180.     }
  181. }
  182.  
  183. /**
  184.  * @package phpDocumentor
  185.  * @subpackage ParserElements
  186.  * @author Greg Beaver <cellog@users.sourceforge.net>
  187.  * @since 1.0rc1
  188.  * @version $Id: ParserElements.inc,v 1.45.2.4 2003/08/13 20:01:56 CelloG Exp $
  189.  */
  190. class parserInclude extends parserElement
  191. {
  192.     /**
  193.      * Type is used by many functions to skip the hassle of if get_class($blah) == 'parserBlah'
  194.      * @var string always 'include'
  195.      */
  196.     var $type = 'include';
  197. }
  198.  
  199. /**
  200.  * @package phpDocumentor
  201.  * @subpackage ParserElements
  202.  * @author Greg Beaver <cellog@users.sourceforge.net>
  203.  * @since 1.1
  204.  * @version $Id: ParserElements.inc,v 1.45.2.4 2003/08/13 20:01:56 CelloG Exp $
  205.  */
  206. class parserGlobal extends parserElement
  207. {
  208.     /**
  209.      * Type is used by many functions to skip the hassle of if get_class($blah) == 'parserBlah'
  210.      * @var string always 'global'
  211.      */
  212.     var $type = 'global';
  213.     
  214.     /**
  215.      * Name of the global's data type
  216.      * @var string
  217.      */
  218.     var $datatype = 'mixed';
  219.  
  220.     /**
  221.      * quick way to link to this element
  222.      * {@internal
  223.      * There comes a time in every programmer's life when he or she must show
  224.      * off.  Now is such a time.  Check out the amazing use of assigning to
  225.      * $this!  No please, you're too kind, hold your applause until after the
  226.      * demonstration.
  227.      *
  228.      * {@source}}}
  229.      * @return mixed converter-specific link to this global variable
  230.      * @param Converter
  231.      * @param string text to display for the link or false for default text
  232.      */
  233.     function getLink(&$c, $text = false, $returnobj = false)
  234.     {
  235.         if ($returnobj)
  236.         { /// !!!! crazy stuff, this PHP business
  237.             $save = $this;
  238.             $this = &$c;
  239.             $a = Converter::getGlobalLink($save->name, $save->docblock->package, $save->path, $text);
  240.             $this = &$save;
  241.             return $a;
  242.         }
  243.         return $c->getGlobalLink($this->name, $this->docblock->package, $this->path, $text);
  244.     }
  245.  
  246.     /**
  247.      * Returns all global variables in other packages that have the same name as this global variable
  248.      * @return mixed false or an array Format: (package => {@link parserGlobal} of conflicting global variable)
  249.      * @param Converter
  250.      */
  251.     function getConflicts(&$c)
  252.     {
  253.         $a = $c->proceduralpages->getGlobalConflicts($this->name);
  254.         unset($a[$this->docblock->package]);
  255.         return $a;
  256.     }
  257.     
  258.     /**
  259.      * Sets the name of the global variable's type
  260.      * @param string
  261.      */
  262.     function setDataType($type)
  263.     {
  264.         $this->datatype = $type;
  265.     }
  266.     
  267.     /**
  268.      * Retrieve converter-specific representation of the data type
  269.      *
  270.      * If the data type is a documented class name, then this function will
  271.      * return a Converter-specific link to that class's documentation, so users
  272.      * can click/browse to the documentation directly from the global variable
  273.      * declaration
  274.      * @return string
  275.      * @param Converter
  276.      */
  277.     function getDataType(&$converter)
  278.     {
  279.         $converted_datatype = $this->datatype;
  280.         if (strpos($this->datatype,'|'))
  281.         {
  282.             $types = explode('|',$this->datatype);
  283.             foreach($types as $returntype)
  284.             {
  285.                 $a = $converter->getLink($returntype);
  286.                 if (is_object($a) && get_class($a) == 'classlink')
  287.                 {
  288.                     if (!empty($my_types)) $my_types .= '|';
  289.                     $my_types .= $converter->returnSee($a,$converter->type_adjust($returntype));
  290.                 } else
  291.                 {
  292.                     if (!empty($my_types)) $my_types .= '|';
  293.                     $my_types .= $converter->type_adjust($returntype);
  294.                 }
  295.             }
  296.             $converted_datatype = $my_types;
  297.         } else
  298.         {
  299.             $a = $converter->getLink($this->datatype);
  300.             if (is_object($a) && get_class($a) == 'classlink')
  301.             {
  302.                 $converted_datatype = $converter->returnSee($a,$converter->type_adjust($this->datatype));
  303.             } else
  304.             {
  305.                 $converted_dataype = $converter->type_adjust($this->datatype);
  306.             }
  307.         }
  308.         return $converted_datatype;
  309.     }
  310.  
  311. }
  312.  
  313. /**
  314.  * @package phpDocumentor
  315.  * @subpackage ParserElements
  316.  * @author Greg Beaver <cellog@users.sourceforge.net>
  317.  * @since 1.0rc1
  318.  * @version $Id: ParserElements.inc,v 1.45.2.4 2003/08/13 20:01:56 CelloG Exp $
  319.  */
  320. class parserFunction extends parserElement
  321. {
  322.     /**
  323.      * Type is used by many functions to skip the hassle of if get_class($blah) == 'parserBlah'
  324.      * @var string always 'function'
  325.      */
  326.     var $type = 'function';
  327.     /**
  328.      * parameters parsed from function definition.
  329.      *
  330.      * param name may be null, in which case, updateParams() must be called from the Converter
  331.      * @var array Format: array(param name => default value parsed from function definition)
  332.      * @see updateParams()
  333.      */
  334.     var $params = false;
  335.     /**
  336.      * Function returns a reference to an element, instead of a value
  337.      *
  338.      * set to true if function is declared as:
  339.      * <code>
  340.      * function &func(...
  341.      * </code>
  342.      * @var boolean
  343.      */
  344.     var $returnsreference = false;
  345.     /**
  346.      * global declarations parsed from function definition
  347.      *
  348.      * @var array Format: array(globalname1, globalname2,....)
  349.      */
  350.     var $globals = false;
  351.     /**
  352.      * static variable declarations parsed from function definition
  353.      * @var array Format: array(array('name' => staticvar1,'val' => '' or default val of staticvar1),...)
  354.      */
  355.     var $statics = false;
  356.     
  357.     var $source = '';
  358.     /**
  359.      * @param string
  360.      * @param string default value parsed from function definition
  361.      * @param boolean indicates whether this parameter has a default value
  362.      */
  363.     function addParam($name, $value, $has_default = true)
  364.     {
  365.         $this->params[$name] = array($value, $has_default);
  366.     }
  367.     
  368.     /**
  369.      * Set the source code.  Always array in PHP 4.3.0+
  370.      * @param string|array
  371.      */
  372.     function addSource($source)
  373.     {
  374.         $this->source = $source;
  375.     }
  376.     
  377.     /**
  378.      * Determine whether the source code has been requested via {@}source}
  379.      * @return boolean
  380.      */
  381.     function hasSource()
  382.     {
  383.         if (is_array($this->source)) return true;
  384.         return strlen($this->source);
  385.     }
  386.     
  387.     /**
  388.      * @return string|array source code ready for highlighting
  389.      */
  390.     function getSource()
  391.     {
  392.         return $this->source;
  393.     }
  394.     
  395.     /**
  396.      * quick way to link to this element
  397.      * @return mixed converter-specific link to this function
  398.      * @param Converter
  399.      * @param string text to display for the link or false for default text
  400.      */
  401.     function getLink($c, $text = false, $returnobj = false)
  402.     {
  403.         if ($returnobj)
  404.         { /// !!!! crazy stuff, this PHP business
  405.             $save = $this;
  406.             $this = &$c;
  407.             $a = Converter::getFunctionLink($save->name, $save->docblock->package, $save->path, $text);
  408.             $this = &$save;
  409.             return $a;
  410.         }
  411.         return $c->getFunctionLink($this->name, $this->docblock->package, $this->path, $text);
  412.     }
  413.  
  414.     /**
  415.      * Returns all functions in other packages that have the same name as this function
  416.      * @return mixed false or an array Format: (package => {@link parserFunction} of conflicting functions)
  417.      * @param Converter
  418.      */
  419.     function getConflicts(&$c)
  420.     {
  421.         $a = $c->proceduralpages->getFuncConflicts($this->name);
  422.         unset($a[$this->docblock->package]);
  423.         return $a;
  424.     }
  425.     
  426.     /**
  427.      * Add all "global $var, $var2" declarations to this function
  428.      * @param array $globals Format: array(globalname1, globalname2,....)
  429.      */
  430.     function addGlobals($globals)
  431.     {
  432.         $this->globals = $globals;
  433.     }
  434.  
  435.     /**
  436.      * Add all "static $var, $var2 = 6" declarations to this function
  437.      * @param array Format: array(varname1, varname2,...)
  438.      * @param array Format: array(default val of var 1, default val of var 2,...) if var 1 has no default, array(default val of var 2,...)
  439.      */
  440.     function addStatics($static,$vals)
  441.     {
  442.         if (count($static))
  443.         {
  444.             $this->statics = array();
  445.             for($i=0;$i<count($static);$i++)
  446.             {
  447.                 if (isset($static[$i]))
  448.                 {
  449.                     $a = '';
  450.                     if (isset($vals[$i])) $a = $vals[$i];
  451.                     $this->statics[] = array('name' => $static[$i],'val' => $a);
  452.                 }
  453.             }
  454.         }
  455.     }
  456.  
  457.     /**
  458.      * @return string default value of param $name
  459.      * @param string
  460.      */
  461.     function getParam ($name)
  462.     {
  463.         if (!isset($this->params[$name])) return false;
  464.         $test = $this->params[$name];
  465.         if ($test[1])
  466.         {
  467.             return $this->params[$name];
  468.         } else
  469.         {
  470.             return false;
  471.         }
  472.     }
  473.  
  474.     /**
  475.      * @return array format: array(array(paramname, default value),...)
  476.      */
  477.     function listParams ()
  478.     {
  479.         if (isset($this->params))
  480.         {
  481.             $ret = array();
  482.             if ($this->params)
  483.             foreach($this->params as $key => $val)
  484.             {
  485.                 if ($val[1])
  486.                 {
  487.                     $ret[] = array($key,$val[0]);
  488.                 } else
  489.                 {
  490.                     $ret[] = array($key,false);
  491.                 }
  492.             }
  493.             return $ret;
  494.         } else {
  495.             return array();
  496.         }
  497.     }
  498.     
  499.     /**
  500.      * @return array format: array(array(index, globalname),...)
  501.      */
  502.     function listGlobals ()
  503.     {
  504.         if (isset($this->globals))
  505.         {
  506.             $ret = array();
  507.             if ($this->globals)
  508.             foreach($this->globals as $key => $val)
  509.             {
  510.                 $ret[] = array($key,$val);
  511.             }
  512.             return $ret;
  513.         } else {
  514.             return array();
  515.         }
  516.     }
  517.     
  518.     /**
  519.      * @return array format: array(array(static var name, static var default value),...)
  520.      */
  521.     function listStatics ()
  522.     {
  523.         if (isset($this->statics))
  524.         {
  525.             $ret = array();
  526.             if ($this->statics)
  527.             foreach($this->statics as $key => $val)
  528.             {
  529.                 $ret[] = array($val['name'],$val['val']);
  530.             }
  531.             return $ret;
  532.         } else {
  533.             return array();
  534.         }
  535.     }
  536.     
  537.     /**
  538.      * sets {@link $returnsreference} to true
  539.      */
  540.     function setReturnsReference()
  541.     {
  542.         $this->returnsreference = true;
  543.     }
  544.     
  545.     /**
  546.      * @return boolean returns value of {@link $returnsreference}
  547.      */
  548.     function getReturnsReference()
  549.     {
  550.         return $this->returnsreference;
  551.     }
  552.     
  553.     /**
  554.      * Get a human-friendly description of the function call
  555.      *
  556.      * takes declaration like:
  557.      * <code>
  558.      * /** @returns string ... {rest of docblock}
  559.      * function &func($param1, $param2 = 6,
  560.      *                $param3 = array('20',9 => "heroo"))
  561.      * {...}
  562.      * </code>
  563.      * and returns:
  564.      * string &func( $param1, [$param2 = 6], [$param3 = array('20',9 => "heroo")] )
  565.      * @return string stylized function declaration
  566.      */
  567.     function getFunctionCall()
  568.     {
  569.         $a = '';
  570.         if ($this->getReturnsReference()) $a = '&';
  571.         $function_call = $a.$this->getName() . " ( ";
  572.         $tmp = 0;
  573.         foreach($this->listParams() as $param)
  574.         {
  575.             if ($tmp == 0)
  576.             {
  577.                 $tmp = 1;
  578.             } else {
  579.                 $function_call .= ", ";
  580.             }
  581.             if ($param[1] !== false)
  582.             {
  583.                 $function_call .= "[$param[0] = $param[1]]";
  584.             } else {
  585.                 $function_call .= $param[0];
  586.             }
  587.             $update_params[] = $param[0];
  588.         }
  589.         $function_call .= " )";
  590.         return $function_call;
  591.     }
  592.     
  593.     /**
  594.      * Like getFunctionCall(), but has no English or pre-determined formatting.
  595.      *
  596.      * Much more flexible.
  597.      * @return array Format:
  598.      * <code>
  599.      * array('name' => function name,
  600.      *       'returnsref' => boolean if declared as "function &name()"
  601.      *       'params' => array('type' => data type of parameter,
  602.      *                         'description' => from @param tag,
  603.      *                         'name' => variable name,
  604.      *                         'default' => default value if any))
  605.      * </code>
  606.      * @see getFunctionCall()
  607.      */
  608.     function getIntricateFunctionCall($converter,$paramtags)
  609.     {
  610.         $a = array();
  611.         if ($this->getReturnsReference()) $a['returnsref'] = true;
  612.         $a['name'] = $converter->type_adjust($this->getName());
  613.         $c = $this->listParams();
  614.         foreach($c as $param)
  615.         {
  616.             $b = array();
  617.             $b['type'] = 'mixed';
  618.             if (isset($paramtags[$param[0]]))
  619.             {
  620.                 $b['type'] = $paramtags[$param[0]]['datatype'];
  621.                 $b['description'] = $paramtags[$param[0]]['data'];
  622.                 unset($paramtags[$param[0]]);
  623.             } elseif(isset($paramtags[substr($param[0],1)]))
  624.             {
  625.                 $b['type'] = $paramtags[substr($param[0],1)]['datatype'];
  626.                 $b['description'] = $paramtags[substr($param[0],1)]['data'];
  627.                 unset($paramtags[substr($param[0],1)]);
  628.             }
  629.             $b['name'] = $param[0];
  630.             $b['default'] = $param[1];
  631.             $b['hasdefault'] = ($param[1] !== false);
  632.             $a['params'][] = $b;
  633.         }
  634.         // @param tags that don't correspond to actual parameters (like extra function values)
  635.         if (count($paramtags))
  636.         {
  637.             foreach($paramtags as $param)
  638.             {
  639.                 $b = array();
  640.                 $b['type'] = $param['datatype'];
  641.                 $b['description'] = $param['data'];
  642.                 $b['name'] = $param['var'];
  643.                 $b['default'] = '';
  644.                 $b['hasdefault'] = false;
  645.                 $a['params'][] = $b;
  646.             }
  647.         }
  648.         return $a;
  649.     }
  650. }
  651.  
  652. /**
  653.  * @package phpDocumentor
  654.  * @subpackage ParserElements
  655.  * @author Greg Beaver <cellog@users.sourceforge.net>
  656.  * @since 1.0rc1
  657.  * @version $Id: ParserElements.inc,v 1.45.2.4 2003/08/13 20:01:56 CelloG Exp $
  658.  */
  659. class parserClass extends parserElement
  660. {
  661.     /**
  662.      * Type is used by many functions to skip the hassle of if get_class($blah) == 'parserBlah'
  663.      * @var string always 'class'
  664.      */
  665.     var $type = 'class';
  666.     /** @var string
  667.      * @see parserPage::$sourceLocation */
  668.     var $sourceLocation = '';
  669.     /**
  670.      * @var mixed false or contents of extends clause in class declaration
  671.      */
  672.     var $extends = false;
  673.     /**
  674.      * Format: array(file, parent) where parent class is found or false if no parent
  675.      * @var mixed
  676.      */
  677.     var $parent = false;
  678.     /**
  679.      * Used to determine whether a class should be ignored or not.  Helps maintain integrity of parsing
  680.      * @var boolean
  681.      * @see Classes::getParentClass()
  682.      */
  683.     var $ignore = false;
  684.  
  685.     /**
  686.      * @var string same as {@link parserElement::$path}
  687.      */
  688.     var $curfile = false;
  689.     /**
  690.      * @var tutorialLink|false either a link to the tutorial associated with this class, or false
  691.      */
  692.     var $tutorial = false;
  693.     
  694.     /**
  695.      * @param parserTutorial
  696.      * @param Converter
  697.      */
  698.     function addTutorial($t,&$c)
  699.     {
  700.         $this->tutorial = new tutorialLink;
  701.         $this->tutorial->addLink('',$t->path,$t->name,$t->package,$t->subpackage,$t->getTitle($c));
  702.     }
  703.     
  704.     /**
  705.      * Get the associated tutorial for this class, if any
  706.      * @tutorial tutorials.pkg
  707.      * @return parserTutorial
  708.      */
  709.     function getTutorial()
  710.     {
  711.         return $this->tutorial;
  712.     }
  713.     
  714.     /**
  715.      * Returns all classes in other packages that have the same name as this class
  716.      * @return mixed false or an array Format: (package => {@link parserClass} of conflicting classes)
  717.      * @param Converter
  718.      */
  719.     function getConflicts(&$c)
  720.     {
  721.         $a = $c->classes->getConflicts($this->name);
  722.         unset($a[$this->docblock->package]);
  723.         return $a;
  724.     }
  725.     
  726.     /**
  727.      * quick way to link to this element
  728.      * @return mixed converter-specific link to this class
  729.      * @param Converter
  730.      * @param string text to display for the link or false for default text
  731.      */
  732.     function getLink($c, $text = false, $returnobj = false)
  733.     {
  734.         if ($returnobj)
  735.         { /// !!!! crazy stuff, this PHP business
  736.             $save = $this;
  737.             $this = &$c;
  738.             $a = Converter::getClassLink($save->name, $save->docblock->package, $save->curfile, $text);
  739.             $this = &$save;
  740.             return $a;
  741.         }
  742.         return $c->getClassLink($this->name, $this->docblock->package, $this->curfile, $text);
  743.     }
  744.  
  745.     /**
  746.      * @param string parent class name
  747.      * @param string parent class file
  748.      * @param Classes {@link Classes} object currently calling setParent
  749.      * @see Classes::setClassParent()
  750.      */
  751.     
  752.     function setParent($p,$f, &$c)
  753.     {
  754.         $this->parent = array($f, $p);
  755.         $p = $c->getClass($p, $f);
  756.         // inherit package if no @package tag is in the docblock, fixes 591396
  757.         if (!$this->docblock->getExplicitPackage())
  758.         {
  759.             $this->docblock->package = $p->docblock->package;
  760.         }
  761.         if ($this->docblock->package == $p->docblock->package)
  762.         {
  763.             if ($this->docblock->subpackage == '')
  764.             $this->docblock->subpackage = $p->docblock->subpackage;
  765.         }
  766.         $author = $p->docblock->getKeyword('author');
  767.         $version = $p->docblock->getKeyword('version');
  768.         $copyright = $p->docblock->getKeyword('copyright');
  769.         // inherit tags
  770.         if (!$this->docblock->getKeyword('author'))
  771.         {
  772.             if ($author && !is_array($author)) $author = array($author);
  773.             if ($author) $this->docblock->tags['author'] = $author;
  774.         }
  775.         if (!$this->docblock->getKeyword('version'))
  776.         {
  777.             if ($version && !is_array($version)) $version = array($version);
  778.             if ($version) $this->docblock->tags['version'] = $version;
  779.         }
  780.         if (!$this->docblock->getKeyword('copyright'))
  781.         {
  782.             if ($copyright && !is_array($copyright)) $copyright = array($copyright);
  783.             if ($copyright) $this->docblock->tags['copyright'] = $copyright;
  784.         }
  785.         if (!$this->docblock->sdesc)
  786.         {
  787.             $this->docblock->setShortDesc($p->docblock);
  788.             $this->docblock->setDesc($p->docblock);
  789.         } else
  790.         {
  791.             if ($this->docblock->hasInheritDoc())
  792.             {
  793.                 $this->docblock->replaceInheritDoc($p->docblock);
  794.             }
  795.         }
  796.     }
  797.     
  798.     /**
  799.      * @param string $par parent class name (used by {@link Classes::setClassParent()} if parent class not found
  800.      */
  801.     function setParentNoClass($par)
  802.     {
  803.         $this->parent = $par;
  804.     }
  805.     
  806.     /**
  807.      * retrieve object that represents the parent class
  808.      * @param Converter this function will not work before the Conversion stage of parsing
  809.      * @return mixed returns the {@link parserClass} representation of the parent class, or false if no parent class
  810.      */
  811.     function &getParent(&$c)
  812.     {
  813.         if (!$this->parent) return false;
  814.         if (is_array($this->parent))
  815.         {
  816.             return $c->classes->getClass($this->parent[1],$this->parent[0]);
  817.         } else return $this->parent;
  818.     }
  819.     
  820.     /**
  821.      * @param Converter this function will not work before the Conversion stage of parsing
  822.      * @return array returns a simple array of method objects
  823.      */
  824.     function getMethods(&$c)
  825.     {
  826.         return $c->classes->getMethods($this->name,$this->curfile);
  827.     }
  828.     
  829.     /**
  830.      * @return mixed {@link parserMethod} or false if not found
  831.      * @param Converter this function will not work before the Conversion stage of parsing
  832.      * @param string method name in this class
  833.      */
  834.     function getMethod(&$c, $name)
  835.     {
  836.         return $c->classes->getMethod($this->name,$this->curfile,$name);
  837.     }
  838.     
  839.     /**
  840.      * @return mixed {@link parserVar} or false if not found
  841.      * @param Converter this function will not work before the Conversion stage of parsing
  842.      * @param string var name in this class
  843.      */
  844.     function getVar(&$c, $name)
  845.     {
  846.         return $c->classes->getVar($this->name,$this->curfile,$name);
  847.     }
  848.     
  849.     /**
  850.      * @param Converter this function will not work before the Conversion stage of parsing
  851.      * @return array returns a simple array of method name strings
  852.      */
  853.     function getMethodNames(&$c)
  854.     {
  855.         if (!$c->classes->hasMethods($this->curfile, $this->name)) return array();
  856.         $arr = array();
  857.         $arr1 = $this->getMethods($c);
  858.         for($i=0; $i < count($arr1); $i++)
  859.         {
  860.             $arr[] = $arr1[$i]->name;
  861.         }
  862.         return $arr;
  863.     }
  864.     
  865.     /**
  866.      * @param Converter this function will not work before the Conversion stage of parsing
  867.      * @param string method name
  868.      * @return boolean whether this class has a method of name $name
  869.      */
  870.     function hasMethod(&$c,$name)
  871.     {
  872.         return $c->classes->hasMethod($this->name, $this->curfile, $name);
  873.     }
  874.     
  875.     /**
  876.      * @param Converter this function will not work before the Conversion stage of parsing
  877.      * @param string var name
  878.      * @return boolean whether this class has a var of name $name
  879.      */
  880.     function hasVar(&$c,$name)
  881.     {
  882.         return $c->classes->hasVar($this->name, $this->curfile, $name);
  883.     }
  884.     
  885.     /**
  886.      * @param Converter this function will not work before the Conversion stage of parsing
  887.      * @return array returns a simple array of var objects
  888.      */
  889.     function getVars(&$c)
  890.     {
  891.         return $c->classes->getVars($this->name,$this->curfile);
  892.     }
  893.     
  894.     /**
  895.      * @param Converter this function will not work before the Conversion stage of parsing
  896.      * @return array returns a simple array of var name strings
  897.      */
  898.     function getVarNames(&$c)
  899.     {
  900.         if (!$c->classes->hasVars($this->curfile, $this->name)) return array();
  901.         $arr = array();
  902.         $arr1 = $this->getVars($c);
  903.         for($i=0; $i < count($arr1); $i++)
  904.         {
  905.             $arr[] = $arr1[$i]->name;
  906.         }
  907.         return $arr;
  908.     }
  909.     
  910.     /**
  911.      * @param Converter this function will not work before the Conversion stage of parsing
  912.      * @param boolean determines whether overriden methods should be included in the list of inherited methods
  913.      * @return array returns an array of methods by parent classname array(name => array(method1,method2..),name2 => array(method1....))
  914.      */
  915.     function getInheritedMethods(&$c,$override = false)
  916.     {
  917.         $x = $this;
  918.         $methods = array();
  919.         $arr = array();
  920.         while ($x->parent && is_array($x->parent))
  921.         {
  922.             $methods = array_merge($methods,$x->getMethodNames($c));
  923.             $par = $x->getParent($c);
  924.             $parmethodnames = $par->getMethodNames($c);
  925.             $parmethods = $par->getMethods($c);
  926.             for($i=0; $i<count($parmethodnames); $i++)
  927.             {
  928.                 if ($override)
  929.                 {
  930.                     if (!in_array($parmethodnames[$i],$methods))
  931.                     {
  932.                         // fix for bug 587733
  933.                         if ($parmethods[$i]->docblock && $parmethods[$i]->docblock->hasaccess && !$c->parseprivate && $parmethods[$i]->docblock->tags['access'][0]->value == 'private')
  934.                         {
  935.                             continue;
  936.                         }
  937.                         $methods[] = $parmethodnames[$i];
  938.                         $arr[$par->getName()]['methods'][] = $parmethods[$i];
  939.                         $arr[$par->getName()]['file'] = $par->curfile;
  940.                     }
  941.                 } else
  942.                 {
  943.                     // fix for bug 587733
  944.                     if ($parmethods[$i]->docblock && $parmethods[$i]->docblock->hasaccess && !$c->parseprivate && $parmethods[$i]->docblock->tags['access'][0]->value == 'private')
  945.                     {
  946.                         continue;
  947.                     }
  948.                     $arr[$par->getName()]['methods'][] = $parmethods[$i];
  949.                     $arr[$par->getName()]['file'] = $par->curfile;
  950.                 }
  951.             }
  952.             $x = &$par;
  953.         }
  954.         return $arr;
  955.     }
  956.     
  957.     /**
  958.      * @param Converter this function will not work before the Conversion stage of parsing
  959.      * @param boolean determines whether overriden vars should be included in the list of inherited vars
  960.      * @return array returns an array of vars by parent classname array(name => array(var1,var1..),name2 => array(var1....))
  961.      */
  962.     function getInheritedVars(&$c,$override = true, $vars = false)
  963.     {
  964.         $x = $this;
  965.         $vars = array();
  966.         $arr = array();
  967.         while ($x->parent && is_array($x->parent))
  968.         {
  969.             $vars = array_merge($vars,$x->getVarNames($c));
  970.             $par = $x->getParent($c);
  971.             $parvarnames = $par->getVarNames($c);
  972.             $parvars = $par->getVars($c);
  973.             for($i=0; $i<count($parvarnames); $i++)
  974.             {
  975.                 if ($override)
  976.                 {
  977.                     if (!in_array($parvarnames[$i],$vars))
  978.                     {
  979.                         // fix for bug 587733
  980.                         if ($parvars[$i]->docblock && $parvars[$i]->docblock->hasaccess && !$c->parseprivate && $parvars[$i]->docblock->tags['access'][0]->value == 'private')
  981.                         {
  982.                             continue;
  983.                         }
  984.                         $vars[] = $parvarnames[$i];
  985.                         $arr[$par->getName()]['vars'][] = $parvars[$i];
  986.                         $arr[$par->getName()]['file'] = $par->curfile;
  987.                     }
  988.                 } else
  989.                 {
  990.                     // fix for bug 587733
  991.                     if ($parvars[$i]->docblock && $parvars[$i]->docblock->hasaccess && !$c->parseprivate && $parvars[$i]->docblock->tags['access'][0]->value == 'private')
  992.                     {
  993.                         continue;
  994.                     }
  995.                     $arr[$par->getName()]['vars'][] = $parvars[$i];
  996.                     $arr[$par->getName()]['file'] = $par->curfile;
  997.                 }
  998.             }
  999.             $x = &$par;
  1000.         }
  1001.         return $arr;
  1002.     }
  1003.     
  1004.     /**
  1005.      * @param Converter this function will not work before the Conversion stage of parsing
  1006.      * @return array Format: array(parentclassname => parserClass/false if no parent, parentclassname2 => ...)
  1007.      */
  1008.     function getParentClassTree(&$c)
  1009.     {
  1010.         $result = array();
  1011.         $result[$this->name] = $arr = $this->getParent($c);
  1012.         if (is_string($arr)) $result[$arr] = false;
  1013.         while ($arr && is_object($arr))
  1014.         {
  1015.             $result[$arr->name] = $arr->getParent($c);
  1016.             $arr = $arr->getParent($c);
  1017.             if (is_string($arr)) $result[$arr] = false;
  1018.         }
  1019.         return $result;
  1020.     }
  1021.     
  1022.     /**
  1023.      * returns a list of all child classes of this class
  1024.      * @param Converter this function will not work before the Conversion stage of parsing
  1025.      * @return array Format: array(parserClass child1,parserClass child2,...)
  1026.      */
  1027.     function getChildClassList(&$c)
  1028.     {
  1029.         $list = array();
  1030.         $kids = $c->classes->getDefiniteChildren($this->name,$this->curfile);
  1031.         if ($kids)
  1032.         {
  1033.             foreach($kids as $chile => $file)
  1034.             {
  1035.                 $list[] = $c->classes->getClass($chile,$file);
  1036.             }
  1037.         }
  1038.         return $list;
  1039.     }
  1040.     
  1041.     /**
  1042.      * @param string
  1043.      * @see $sourceLocation
  1044.      */
  1045.     function setSourceLocation($sl)
  1046.     {
  1047.         $this->sourceLocation = $sl;
  1048.     }
  1049.     
  1050.     /**
  1051.      * @param Converter
  1052.      * @param boolean
  1053.      * @return string
  1054.      * @see $sourceLocation
  1055.      */
  1056.     function getSourceLocation($c,$pearize = false)
  1057.     {
  1058.         global $_phpDocumentor_options;
  1059.         if (!isset($this->sourceLocation)) return false;
  1060.         if ($pearize)
  1061.         {
  1062.             $sl = $this->sourceLocation;
  1063.             if (strpos($sl,'pear/'))
  1064.             {
  1065.                 $sl = substr($sl,strpos($sl,'pear/') + 5);
  1066.                 return $sl;
  1067.             } else
  1068.             {
  1069.                 return str_replace($_phpDocumentor_options['Program_Root'] . PATH_DELIMITER,'',$sl);
  1070.             }
  1071.             return $sl;
  1072.         }
  1073.         return $this->sourceLocation;
  1074.     }
  1075.     
  1076.     /**
  1077.      * @param string
  1078.      * @see $extends
  1079.      */
  1080.     function setExtends($extends)
  1081.     {
  1082.         $this->extends = $extends;
  1083.     }
  1084.     
  1085.     /**
  1086.      * @return boolean
  1087.      * @see $extends
  1088.      */
  1089.     function getExtends()
  1090.     {
  1091.         if (!isset($this->extends)) return false;
  1092.         return $this->extends;
  1093.     }
  1094. }
  1095.  
  1096. /**
  1097.  * @package phpDocumentor
  1098.  * @subpackage ParserElements
  1099.  * @author Greg Beaver <cellog@users.sourceforge.net>
  1100.  * @since 1.0rc1
  1101.  * @version $Id: ParserElements.inc,v 1.45.2.4 2003/08/13 20:01:56 CelloG Exp $
  1102.  */
  1103. class parserVar extends parserElement
  1104. {
  1105.     /**
  1106.      * Type is used by many functions to skip the hassle of if get_class($blah) == 'parserBlah'
  1107.      * @var string always 'var'
  1108.      */
  1109.     var $type = 'var';
  1110.     /** @var string class that contains this var */
  1111.     var $class = '';
  1112.     
  1113.     /**
  1114.      * @param string
  1115.      */
  1116.     function parserVar($class)
  1117.     {
  1118.         $this->class = $class;
  1119.     }
  1120.     
  1121.     /**
  1122.      * Retrieve the class name
  1123.      * @return string Class name that this var belongs to
  1124.      */
  1125.     function getClass()
  1126.     {
  1127.         return $this->class;
  1128.     }
  1129.  
  1130.     /**
  1131.      * quick way to link to this element
  1132.      * @return mixed converter-specific link to this var
  1133.      * @param Converter $c
  1134.      * @param string $text text to display for the link or false for default text
  1135.      */
  1136.     function getLink($c, $text = false, $returnobj = false)
  1137.     {
  1138.         if ($returnobj)
  1139.         { /// !!!! crazy stuff, this PHP business
  1140.             $save = $this;
  1141.             $this = &$c;
  1142.             $a = Converter::getVarLink($save->name, $save->class, $save->docblock->package, false, $text);
  1143.             $this = &$save;
  1144.             return $a;
  1145.         }
  1146.         return $c->getVarLink($this->name, $this->class, $this->docblock->package, false, $text);
  1147.     }
  1148.  
  1149.     /**
  1150.      * @param Converter
  1151.      * @return mixed {@link parserVar} representing var this var overrides from the parent class, or false if none
  1152.      */
  1153.     function getOverrides(&$c)
  1154.     {
  1155.         $class = $c->classes->getClass($this->class,$this->path);
  1156.         $par = $class->getParent($c);
  1157.         
  1158.         while (is_object($par))
  1159.         {
  1160.           if ($par->hasVar($c,$this->name))
  1161.                     {
  1162.                         $var = $par->getVar($c,$this->name);
  1163.                         if (!($var->docblock && $var->docblock->hasaccess && !$c->parseprivate && $var->docblock->tags['access'][0]->value == 'private'))
  1164.                             return $var;
  1165.                     }
  1166.           $par = $par->getParent($c);
  1167.         }
  1168.         
  1169.         return false;
  1170.     }
  1171.  
  1172.     /**
  1173.      * @param Converter
  1174.      * @return array an array of parserVars from ALL child classes that override this var
  1175.      */
  1176.     function getOverridingVars(&$c)
  1177.     {
  1178.         $class = $c->classes->getClass($this->class,$this->path);
  1179.  
  1180.                 return $this->getOverridingVarsForClass($c, $class);
  1181.     }
  1182.  
  1183.     /**
  1184.      * @param Converter
  1185.          * @param parserClass
  1186.      * @return array an array of parserVars from ALL child classes that override this var in the given class
  1187.      */
  1188.         function getOverridingVarsForClass(&$c, &$class)
  1189.         {
  1190.             $vars = array();
  1191.             if (!$class) return $meths;
  1192.             $kids = $class->getChildClassList($c);
  1193.             for($i=0; $i<count($kids); $i++)
  1194.             {
  1195.                     if ($kids[$i]->hasVar($c, $this->name))
  1196.                     {
  1197.                         $var = $kids[$i]->getVar($c,$this->name);
  1198.                         if (!($var->docblock && $var->docblock->hasaccess && !$c->parseprivate && $var->docblock->tags['access'][0]->value == 'private'))
  1199.                             $vars[] = $var;
  1200.                     }
  1201.  
  1202.                     $vars = array_merge($vars, $this->getOverridingVarsForClass($c, $kids[$i]));
  1203.             }
  1204.             return $vars;
  1205.         }
  1206. }
  1207.  
  1208. /**
  1209.  * @package phpDocumentor
  1210.  * @subpackage ParserElements
  1211.  * @author Greg Beaver <cellog@users.sourceforge.net>
  1212.  * @since 1.0rc1
  1213.  * @version $Id: ParserElements.inc,v 1.45.2.4 2003/08/13 20:01:56 CelloG Exp $
  1214.  */
  1215. class parserMethod extends parserFunction
  1216. {
  1217.     /**
  1218.      * Type is used by many functions to skip the hassle of if get_class($blah) == 'parserBlah'
  1219.      * @var string always 'method'
  1220.      */
  1221.     var $type = 'method';
  1222.     /** @var boolean whether this method is a constructor */
  1223.     var $isConstructor = false;
  1224.     /** @var boolean whether this method is a destructor by PEAR standards */
  1225.     var $isDestructor = false;
  1226.     /** @var string class that contains this method */
  1227.     var $class = '';
  1228.     
  1229.     /**
  1230.      * @param string
  1231.      */
  1232.     function parserMethod($class)
  1233.     {
  1234.         $this->class = $class;
  1235.     }
  1236.     
  1237.     /**
  1238.      * adds "constructor " to start of function call if {@link $isConstructor} is true
  1239.      * @return string
  1240.      * @see parent::getFunctionCall()
  1241.      */
  1242.     function getFunctionCall()
  1243.     {
  1244.         $a = parserFunction::getFunctionCall();
  1245.         if ($this->isConstructor) $a = "constructor $a";
  1246.         return $a;
  1247.     }
  1248.     
  1249.     function getIntricateFunctionCall($converter,$paramtags)
  1250.     {
  1251.         $a = parserFunction::getIntricateFunctionCall($converter,$paramtags);
  1252.         if ($this->isConstructor) $a['constructor'] = true;
  1253.         if ($this->isDestructor) $a['destructor'] = true;
  1254.         return $a;
  1255.     }
  1256.     
  1257.     /**
  1258.      * Return name of the class that contains this method
  1259.      * @return string
  1260.      */
  1261.     function getClass()
  1262.     {
  1263.         return $this->class;
  1264.     }
  1265.     
  1266.     /**
  1267.      * @param Converter
  1268.      * @return mixed {@link parserMethod} representing method this method overrides from the parent class, or false if none
  1269.      */
  1270.     function getOverrides(&$c)
  1271.     {
  1272.         $class = $c->classes->getClass($this->class,$this->path);
  1273.         
  1274.         $par = $class->getParent($c);
  1275.         
  1276.         while (is_object($par))
  1277.         {
  1278.           if ($par->hasMethod($c,$this->name))
  1279.                     {
  1280.                         $meth = $par->getMethod($c,$this->name);
  1281.                         if (!($meth->docblock && $meth->docblock->hasaccess && !$c->parseprivate && $meth->docblock->tags['access'][0]->value == 'private'))
  1282.                             return $meth;
  1283.                     }
  1284.  
  1285.           $par = $par->getParent($c);
  1286.         }
  1287.         
  1288.         return false;
  1289.     }
  1290.     
  1291.     /**
  1292.      * quick way to link to this element
  1293.      * @return mixed converter-specific link to this method
  1294.      * @param Converter $c
  1295.      * @param string $text text to display for the link or false for default text
  1296.      */
  1297.     function getLink($c, $text = false, $returnobj = false)
  1298.     {
  1299.         if ($returnobj)
  1300.         { /// !!!! crazy stuff, this PHP business
  1301.             $save = $this;
  1302.             $this = &$c;
  1303.             $a = Converter::getMethodLink($save->name, $save->class, $save->docblock->package, false, $text);
  1304.             $this = &$save;
  1305.             return $a;
  1306.         }
  1307.         return $c->getMethodLink($this->name, $this->class, $this->docblock->package, false, $text);
  1308.     }
  1309.  
  1310.     /**
  1311.      * Use this method to tell the parser that this method is the class constructor
  1312.      */
  1313.     function setConstructor()
  1314.     {
  1315.         $this->isConstructor = true;
  1316.     }
  1317.     
  1318.     /**
  1319.      * Use this method to tell the parser that this method is the class constructor
  1320.      */
  1321.     function setDestructor()
  1322.     {
  1323.         $this->isDestructor = true;
  1324.     }
  1325.     
  1326.     /**
  1327.      * @param Converter
  1328.      * @return array an array of parserMethods from child classes that override this method
  1329.      */
  1330.     function getOverridingMethods(&$c)
  1331.     {
  1332.         $class = $c->classes->getClass($this->class,$this->path);
  1333.  
  1334.                 return $this->getOverridingMethodsForClass($c, $class);
  1335.     }
  1336.  
  1337.     /**
  1338.      * @param Converter
  1339.          * @param parserClass
  1340.      * @return array an array of parserMethods from ALL child classes that override this method in the given class
  1341.      */
  1342.         function getOverridingMethodsForClass(&$c, &$class)
  1343.         {
  1344.             $meths = array();
  1345.             if (!$class) return $meths;
  1346.             $kids = $class->getChildClassList($c);
  1347.             for($i=0; $i<count($kids); $i++)
  1348.             {
  1349.                     if ($kids[$i]->hasMethod($c, $this->name))
  1350.                     {
  1351.                         $meth = $kids[$i]->getMethod($c,$this->name);
  1352.                         if (!($meth->docblock && $meth->docblock->hasaccess && !$c->parseprivate && $meth->docblock->tags['access'][0]->value == 'private'))
  1353.                             $meths[] = $meth;
  1354.                     }
  1355.  
  1356.                     $meths = array_merge($meths, $this->getOverridingMethodsForClass($c, $kids[$i]));
  1357.             }
  1358.             return $meths;
  1359.         }
  1360. }
  1361.  
  1362. /**
  1363.  * @package phpDocumentor
  1364.  * @subpackage ParserElements
  1365.  * @author Greg Beaver <cellog@users.sourceforge.net>
  1366.  * @since 1.0rc1
  1367.  * @version $Id: ParserElements.inc,v 1.45.2.4 2003/08/13 20:01:56 CelloG Exp $
  1368.  */
  1369. class parserDefine extends parserElement
  1370. {
  1371.     /**
  1372.      * Type is used by many functions to skip the hassle of if get_class($blah) == 'parserBlah'
  1373.      * @var string always 'define'
  1374.      */
  1375.     var $type = 'define';
  1376.  
  1377.     /**
  1378.      * quick way to link to this element
  1379.      * @return mixed converter-specific link to this define
  1380.      * @param Converter $c
  1381.      * @param string $text text to display for the link or false for default text
  1382.      */
  1383.     function getLink($c, $text = false, $returnobj = false)
  1384.     {
  1385.         if ($returnobj)
  1386.         { /// !!!! crazy stuff, this PHP business
  1387.             $save = $this;
  1388.             $this = &$c;
  1389.             $a = Converter::getDefineLink($save->name, $save->docblock->package, false, $text);
  1390.             $this = &$save;
  1391.             return $a;
  1392.         }
  1393.         return $c->getDefineLink($this->name, $this->docblock->package, false, $text);
  1394.     }
  1395.  
  1396.     /**
  1397.      * Returns all defines in other packages that have the same name as this define
  1398.      * @return mixed false or an array Format: (package => {@link parserDefine} of conflicting defines)
  1399.      * @param Converter
  1400.      */
  1401.     function getConflicts(&$c)
  1402.     {
  1403.         $a = $c->proceduralpages->getDefineConflicts($this->name);
  1404.         unset($a[$this->docblock->package]);
  1405.         return $a;
  1406.     }
  1407.     
  1408. }
  1409.  
  1410. /**
  1411.  * @package phpDocumentor
  1412.  * @subpackage ParserElements
  1413.  * @author Greg Beaver <cellog@users.sourceforge.net>
  1414.  * @since 1.0rc1
  1415.  * @version $Id: ParserElements.inc,v 1.45.2.4 2003/08/13 20:01:56 CelloG Exp $
  1416.  */
  1417. class parserPackagePage extends parserStringWithInlineTags
  1418. {
  1419.     /**
  1420.      * Type is used by many functions to skip the hassle of if get_class($blah) == 'parserBlah'
  1421.      * @var string always 'packagepage'
  1422.      */
  1423.     var $type = 'packagepage';
  1424.     /** @var string */
  1425.     var $package = 'default';
  1426.     
  1427.     /**
  1428.      * @param string
  1429.      */
  1430.     function parserPackagePage($package)
  1431.     {
  1432.         $this->package = $package;
  1433.     }
  1434.     
  1435.     /**
  1436.      * @param Converter
  1437.      */
  1438.     function Convert(&$c)
  1439.     {
  1440.         return parent::Convert($c,false);
  1441.     }
  1442. }
  1443.  
  1444. /**
  1445.  * @package phpDocumentor
  1446.  * @subpackage ParserElements
  1447.  * @since 1.2
  1448.  */
  1449. class parserTutorial extends parserPackagePage
  1450. {
  1451.     /**
  1452.      * Type is used by many functions to skip the hassle of if get_class($blah) == 'parserBlah'
  1453.      * @var string always 'tutorial'
  1454.      */
  1455.     var $type = 'tutorial';
  1456.     /** @var string */
  1457.     var $package = 'default';
  1458.     /**
  1459.      * Either cls, pkg, or proc
  1460.      * @var string
  1461.      */
  1462.     var $tutorial_type;
  1463.     /**
  1464.      * The documentable element this tutorial is linked to
  1465.      *
  1466.      * Can be a parserData, parserClass, or nothing for package/subpackage docs
  1467.      */
  1468.     var $linked_element;
  1469.     /**
  1470.      * path to the tutorial page
  1471.      * @var string
  1472.      */
  1473.     var $path;
  1474.     /**
  1475.      * filename minus extension of this tutorial (used for @tutorial tag)
  1476.      * @var string
  1477.      */
  1478.     var $name;
  1479.     /** @var boolean */
  1480.     var $_xml = true;
  1481.     /**
  1482.      * output from tutorialname.ext.ini
  1483.      *
  1484.      * an array generated by {@link phpDocumentor_parse_ini_file()} containing
  1485.      * an index 'Linked Tutorials' with an array of tutorial names in the order
  1486.      * they should appear.  This is used to generate a linked list of tutorials like
  1487.      * {@tutorial phpDocumentor/tags.pkg}
  1488.      * @var array
  1489.      */
  1490.     var $ini = false;
  1491.     /**
  1492.      * link to the next tutorial in a document series, or false if none
  1493.      * @var tutorialLink
  1494.      */
  1495.     var $next = false;
  1496.     /**
  1497.      * link to the previous tutorial in a document series, or false if none
  1498.      * @var tutorialLink
  1499.      */
  1500.     var $prev = false;
  1501.     /**
  1502.      * link to the parent tutorial in a document series, or false if none
  1503.      *
  1504.      * This is used to generate an "Up" or "Home" link like the php manual.
  1505.      * The parent is defined as a tutorial that has a parenttutorialname.ext.ini
  1506.      * file and is not contained by any other tutorial's tutorialname.ext.ini
  1507.      * @var tutorialLink
  1508.      */
  1509.     var $parent = false;
  1510.     /**
  1511.      * links to the child tutorials, or false if none
  1512.      * @var array
  1513.      */
  1514.     var $children = false;
  1515.     
  1516.     /**
  1517.      * @param parserXMLDocBookTag top-level tag (<refentry> for 1.2.0)
  1518.      * @param information about the tutorial file.  Format:
  1519.      *
  1520.      * <pre>
  1521.      * array('tutename' => tutorial name,
  1522.      *       'path' => relative path of tutorial to tutorials/ directory
  1523.      *       'ini' => contents of the tutorial .ini file, if any)
  1524.      * </pre>
  1525.      */
  1526.     function parserTutorial($data, $info)
  1527.     {
  1528.         $this->value = $data;
  1529.         $this->package = $info['package'];
  1530.         $this->subpackage = $info['subpackage'];
  1531.         $this->tutorial_type = $info['tutetype'];
  1532.         $this->name = $info['tutename'];
  1533.         $this->path = $info['path'];
  1534.         $this->ini = $info['ini'];
  1535.     }
  1536.     
  1537.     /**
  1538.      * Retrieve the title of the tutorial, or of any subsection
  1539.      * @param Converter
  1540.      * @param string which subsection to retrieve the title from, if any
  1541.      * @uses parserXMLDocBookTag::getSubSection() retrieve the subsection to
  1542.      *       to get a title from
  1543.      */
  1544.     function getTitle(&$c,$subsection = '')
  1545.     {
  1546.         if (!empty($subsection))
  1547.         {
  1548.             $z = $this->value->getSubSection($c,$subsection);
  1549.             if (!$z)
  1550.             {
  1551.                 addWarning(PDERROR_TUTORIAL_SUBSECTION_NOT_FOUND,$this->name,$subsection);
  1552.                 return $subsection;
  1553.             }
  1554.             return $z->getTitle($c);
  1555.         }
  1556.         return $this->value->getTitle($c);
  1557.     }
  1558.     
  1559.     /**
  1560.      * @param Converter
  1561.      * @param boolean determines whether character data is postprocessed to be
  1562.      *                Converter-friendly or not.
  1563.      */
  1564.     function Convert(&$c, $postprocess = true)
  1565.     {
  1566.         return $this->value->Convert($c, $postprocess);
  1567.     }
  1568.     
  1569.     /**
  1570.      * @uses $parent creates a link to the documentation for the parent tutorial
  1571.      * @param parserTutorial
  1572.      * @param Converter
  1573.      */
  1574.     function setParent($parent,&$c)
  1575.     {
  1576.         $this->parent = new tutorialLink;
  1577.         $this->parent->addLink('', $parent->path, $parent->name, $parent->package, $parent->subpackage, $parent->getTitle($c));
  1578.     }
  1579.     
  1580.     /**
  1581.      * @param array array of parserTutorials that have child tutorials
  1582.      */
  1583.     function isChildOf($parents)
  1584.     {
  1585.         foreach($parents as $i => $parent)
  1586.         {
  1587.             if ($parent->path == $this->path) continue;
  1588.             if ($parent->ini && ($parent->package == $this->package) && ($parent->subpackage == $this->subpackage) && ($parent->tutorial_type == $this->tutorial_type))
  1589.             {
  1590.                 foreach($parent->ini['Linked Tutorials'] as $child)
  1591.                 {
  1592.                     if ($child . '.' . $this->tutorial_type == $this->name) return true;
  1593.                 }
  1594.             }
  1595.         }
  1596.     }
  1597.     
  1598.     /**
  1599.      * Retrieve converter-specific link to the parent tutorial's documentation
  1600.      * @param Converter
  1601.      */
  1602.     function getParent(&$c)
  1603.     {
  1604.         if (!$this->parent) return false;
  1605.         return $c->returnSee($this->parent);
  1606.     }
  1607.     
  1608.     /**
  1609.      * @uses $next creates a link to the documentation for the next tutorial
  1610.      * @param parserTutorial
  1611.      * @param Converter
  1612.      */
  1613.     function setNext($next,&$c)
  1614.     {
  1615.         if (get_class($next) == 'tutoriallink') return $this->next = $next;
  1616.         $this->next = new tutorialLink;
  1617.         $this->next->addLink('', $next->path, $next->name, $next->package, $next->subpackage, $next->getTitle($c));
  1618.     }
  1619.     
  1620.     /**
  1621.      * Retrieve converter-specific link to the next tutorial's documentation
  1622.      * @param Converter
  1623.      */
  1624.     function getNext(&$c)
  1625.     {
  1626.         if (!$this->next) return false;
  1627.         return $c->returnSee($this->next);
  1628.     }
  1629.     
  1630.     /**
  1631.      * @uses $prev creates a link to the documentation for the previous tutorial
  1632.      * @param parserTutorial
  1633.      * @param Converter
  1634.      */
  1635.     function setPrev($prev,&$c)
  1636.     {
  1637.         if (get_class($prev) == 'tutoriallink') return $this->prev = $prev;
  1638.         $this->prev = new tutorialLink;
  1639.         $this->prev->addLink('', $prev->path, $prev->name, $prev->package, $prev->subpackage, $prev->getTitle($c));
  1640.     }
  1641.     
  1642.     /**
  1643.      * Retrieve converter-specific link to the previous tutorial's documentation
  1644.      * @param Converter
  1645.      */
  1646.     function getPrev(&$c)
  1647.     {
  1648.         if (!$this->prev) return false;
  1649.         return $c->returnSee($this->prev);
  1650.     }
  1651.     
  1652.     /**
  1653.      * Get a link to this tutorial, or to any subsection of this tutorial
  1654.      * @param Converter
  1655.      * @param boolean if true, returns a {@link tutorialLink} instead of a string
  1656.      * @param string section name to link to
  1657.      * @return string|tutorialLink
  1658.      */
  1659.     function getLink(&$c,$pure = false,$section = '')
  1660.     {
  1661.         $link = new tutorialLink;
  1662.         $link->addLink($section, $this->path, $this->name, $this->package, $this->subpackage, $this->getTitle($c), $this->category);
  1663.         if ($pure) return $link;
  1664.         return $c->returnSee($link);
  1665.     }
  1666. }
  1667.  
  1668. ?>