phpDocumentor phpDocumentor
InlineTags
[ class tree: phpDocumentor ] [ index: phpDocumentor ] [ all elements ]

Source for file InlineTags.inc

Documentation is available at InlineTags.inc

  1. <?php
  2. /**
  3.  * All abstract representations of inline tags are in this file
  4.  *
  5.  * phpDocumentor :: automatic documentation generator
  6.  * 
  7.  * PHP versions 4 and 5
  8.  *
  9.  * Copyright (c) 2002-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    phpDocumentor
  29.  * @subpackage InlineTags
  30.  * @author     Gregory Beaver <[email protected]>
  31.  * @copyright  2002-2006 Gregory Beaver
  32.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  33.  * @version    CVS: $Id: InlineTags.inc,v 1.6 2006/05/22 01:07:28 cellog Exp $
  34.  * @filesource
  35.  * @link       http://www.phpdoc.org
  36.  * @link       http://pear.php.net/PhpDocumentor
  37.  * @since      separate file since 1.2
  38.  */
  39. /**
  40.  * Use this element to represent an {@}inline tag} like {@}link}
  41.  * @see parserStringWithInlineTags
  42.  * @package phpDocumentor
  43.  * @subpackage InlineTags
  44.  * @author Greg Beaver <[email protected]>
  45.  * @since 1.0rc1
  46.  * @version $Revision: 1.6 $
  47.  * @tutorial inlinetags.pkg
  48.  */
  49. class parserInlineTag extends parserBase
  50. {
  51.     /**
  52.      * Element type
  53.      *
  54.      * Type is used by many functions to skip the hassle of
  55.      *
  56.      * <code>
  57.      * if phpDocumentor_get_class($blah) == 'parserBlah'
  58.      * </code>
  59.      * always "inlinetag"
  60.      * @var string 
  61.      */
  62.     var $type = 'inlinetag';
  63.     /**
  64.      * the name of the inline tag (like link)
  65.      * @var string 
  66.      */
  67.     var $inlinetype = '';
  68.     
  69.     /**
  70.      * @param string $type tag type (example: link)
  71.      * @param string $value tag value (example: what to link to)
  72.      */
  73.     function parserInlineTag($type,$value)
  74.     {
  75.         $this->inlinetype = $type;
  76.         $this->value = trim($value);
  77.     }
  78.     
  79.     /**
  80.      * @return integer length of the tag
  81.      */
  82.     function Strlen()
  83.     {
  84.         // fix 1203451
  85.         if (is_array($this->value))
  86.         {
  87.             return array_reduce(create_function('$a,$b''return $a + strlen($b);')) +
  88.                 count($this->value);
  89.         }
  90.         return strlen($this->value);
  91.     }
  92.     
  93.     /**
  94.      * @return string always '', used by {@link Parser::handleDocBlock()} to
  95.      *                 calculate the short description of a DocBlock
  96.      * @see parserStringWithInlineTags::getString()
  97.      * @see parserStringWithInlineTags::trimmedStrlen()
  98.      */
  99.     function getString()
  100.     {
  101.         return '';
  102.     }
  103. }
  104.  
  105. /**
  106.  * represents inline links
  107.  * @tutorial tags.inlinelink.pkg
  108.  * @package phpDocumentor
  109.  * @subpackage InlineTags
  110.  * @author Greg Beaver <[email protected]>
  111.  * @since 1.0rc1
  112.  */
  113. {
  114.     /**
  115.      * text to display in the link, can be different from the link for standard
  116.      * links like websites
  117.      * @var string 
  118.      */
  119.     var $linktext = '';
  120.     
  121.     /**
  122.      * @param string $link stored in $value, see {@link parserBase::$value}
  123.      * @param string $text see {@link $linktext}
  124.      */
  125.     function parserLinkInlineTag($link,$text)
  126.     {
  127.         if (strpos($link','))
  128.         {
  129.             $link explode(',',$link);
  130.             parserInlineTag::parserInlineTag('link','');
  131.             $this->value = $link;
  132.         else
  133.         {
  134.             parserInlineTag::parserInlineTag('link',$link);
  135.         }
  136.         $this->linktext = trim($text);
  137.     }
  138.     
  139.     /**
  140.      * @param Converter converter used to change the abstract link into text for
  141.      *                   display
  142.      * @return false|stringreturns the converted link or false if not converted
  143.      *                       successfully
  144.      */
  145.     function Convert(&$c)
  146.     {
  147.         if (is_array($this->value))
  148.         {
  149.             $ret '';
  150.             foreach($this->value as $text)
  151.             {
  152.                 if (!empty($ret))
  153.                 {
  154.                     $ret .= ', ';
  155.                 }
  156.                 $ret .= $this->ConvertPart($ctrim($text));
  157.             }
  158.             return $ret;
  159.         else
  160.         {
  161.             return $this->ConvertPart($c$this->value);
  162.         }
  163.     }
  164.     
  165.     function ConvertPart(&$c$value)
  166.     {
  167.         if (strpos($value,'://'|| (strpos($value,'mailto:'=== 0))
  168.         {
  169.             if (strpos($value' '))
  170.             {
  171.                 $value explode(' '$value);
  172.                 $link array_shift($value);
  173.                 $text join(' '$value);
  174.             else
  175.             {
  176.                 $link $value;
  177.                 $text $this->linktext;
  178.             }
  179.             return $c->returnLink($link,htmlspecialchars($text));
  180.         else
  181.         {
  182.             $savevalue $value;
  183.             $descrip false;
  184.             if (strpos(trim($value),' '))
  185.             {
  186.                 $v preg_split('/\s/',trim($value));
  187.                 if (in_array(strtolower($v[0])array('object''function')))
  188.                 {
  189.                     if (!isset($v[1]||
  190.                         (isset($v[1]&& strlen($v[1])
  191.                             && !in_array($v[1]{0}array('$','&'))
  192.                             && $v[1!= '###commanana####'))
  193.                     {
  194.                         $vsave $v[0];
  195.                         array_shift($v);
  196.                         $v[0$vsave ' ' $v[0];
  197.                     }
  198.                 }
  199.                 $value $c->getLink($v[0]);
  200.                 array_shift($v);
  201.                 $descrip join($v,' ');
  202.                 $descrip str_replace('###commanana####'','$descrip);
  203.             else
  204.             {
  205.                 $value $c->getLink($value);
  206.             }
  207.             if (is_string($value))
  208.             {
  209.                 // feature 564991
  210.                 if (strpos($value,'://'))
  211.                 {
  212.                     // php function
  213.                     return $c->returnLink($value,
  214.                         $descrip $descrip str_replace('PHP_MANUAL#','',$value));
  215.                 }
  216.                 return $value;
  217.             }
  218.             if (!$descrip$descrip $c->type_adjust($savevalue);
  219.             if (is_object($value)) return $c->returnSee($value$descrip);
  220. /*            // getLink parsed a comma-delimited list of linked thingies, add the commas back in
  221.             if (is_array($value))
  222.             {
  223.                 $a = '';
  224.                 foreach($value as $i => $bub)
  225.                 {
  226.                     if (!empty($a)) $a .= ', ';
  227.                     if (is_string($value[$i]))
  228.                     {
  229.                         // feature 564991
  230.                         if (strpos($value[$i],'://'))
  231.                         {
  232.                             // php function
  233.                             $a .= $c->returnLink($value[$i],str_replace('PHP_MANUAL#','',$vals[$i]));
  234.                         } else
  235.                         $a .= $value[$i];
  236.                     }
  237.                     if (is_object($value[$i])) $a .= $c->returnSee($value[$i],$descrip[$i]);
  238.                 }
  239.                 return $a;
  240.             } */
  241.             return $savevalue;
  242.         }
  243.     }
  244. }
  245.  
  246. /**
  247.  * Represents inline links to external tutorial documentation
  248.  * @tutorial tags.inlinetutorial.pkg
  249.  * @package phpDocumentor
  250.  * @subpackage InlineTags
  251.  */
  252. {
  253.     /**
  254.      * @param string $link stored in $value, see {@link parserBase::$value}
  255.      * @param string $text see {@link $linktext}
  256.      */
  257.     function parserTutorialInlineTag($link,$text)
  258.     {
  259.         parserInlineTag::parserInlineTag('tutorial',$link);
  260.         $this->linktext = trim($text);
  261.     }
  262.  
  263.     /**
  264.      * @param Converter converter used to change the abstract link into text for display
  265.      * @return mixed returns the converted link or false if not converted successfully
  266.      */
  267.     function Convert(&$c)
  268.     {
  269.         $descrip false;
  270.         if (strpos($this->value,','=== false)
  271.         {
  272.             if (strpos(trim($this->value),' '))
  273.             {
  274.                 $v split(' ',trim($this->value));
  275.                 $value $c->getTutorialLink($v[0]);
  276.                 array_shift($v);
  277.                 $descrip join($v,' ');
  278.             else $value $c->getTutorialLink($this->value);
  279.         else
  280.         {
  281.             $vals split(',',$this->value);
  282.             $descrip array();
  283.             foreach($vals as $val)
  284.             {
  285.                 $val trim($val);
  286.                 if (strpos($val,' '))
  287.                 {
  288.                     $v split(' ',$val);
  289.                     $value[$c->getTutorialLink($v[0]);
  290.                     array_shift($v);
  291.                     $descrip[join($v,' ');
  292.                 else
  293.                 {
  294.                     $value[$c->getTutorialLink($val);
  295.                     $descrip[false;
  296.                 }
  297.             }
  298.         }
  299.         if (is_string($value))
  300.         {
  301.             return $value;
  302.         }
  303.         if (is_object($value)) return $c->returnSee($value,$descrip);
  304.         // getLink parsed a comma-delimited list of linked thingies, add the commas back in
  305.         if (is_array($value))
  306.         {
  307.             $a '';
  308.             foreach($value as $i => $bub)
  309.             {
  310.                 if (!empty($a)) $a .= ', ';
  311.                 if (is_string($value[$i]))
  312.                 {
  313.                     $a .= $value[$i];
  314.                 }
  315.                 if (is_object($value[$i])) $a .= $c->returnSee($value[$i],$descrip[$i]);
  316.             }
  317.             return $a;
  318.         }
  319.         return false;
  320.     }
  321. }
  322.  
  323. /**
  324.  * represents inline source tag, used for function/method source
  325.  * @tutorial tags.inlinesource.pkg
  326.  * @package phpDocumentor
  327.  * @subpackage InlineTags
  328.  */
  329. {
  330.     /**
  331.      * always 'source'
  332.      * @var string 
  333.      */
  334.     var $inlinetype = 'source';
  335.     /**
  336.      * First line of source code to display
  337.      * @var integer 
  338.      * @see $end
  339.      */
  340.     var $start = 1;
  341.     /**
  342.      * Last line to display
  343.      * @var '*'|integerIf '*' then the whole source will be used, otherwise
  344.      *                   the {@link $start} to $end line numbers will be displayed
  345.      */
  346.     var $end = '*';
  347.     /**
  348.      * tokenized source organized by line numbers for php 4.3.0+, the old
  349.      * {@}source} tag used a string
  350.      * @var string|array
  351.      */
  352.     var $source = false;
  353.     /**#@+ @access private */
  354.     /** @var string|false*/
  355.     var $_class;
  356.     /**#@-*/
  357.     /**
  358.      * @param string format "start [end]" where start and end are line numbers
  359.      *                with the end line number optional
  360.      */
  361.     function parserSourceInlineTag($value)
  362.     {
  363.         parserInlineTag::parserInlineTag('source','');
  364.         preg_match('/^([0-9]+)\W([0-9]*)$/',trim($value)$match);
  365.         if (!count($match))
  366.         {
  367.             preg_match('/^([0-9]+)$/',trim($value),$match);
  368.             if (count($match))
  369.             {
  370.                 $this->start = (int) $match[1];
  371.             }
  372.         else
  373.         {
  374.             $this->start = (int) $match[1];
  375.             $this->end = (int) $match[2];
  376.         }
  377.     }
  378.     
  379.     /**
  380.      * only used to determine blank lines.  {@}source} will not be blank,
  381.      * probably
  382.      */
  383.     function Strlen()
  384.     {
  385.         return 1;
  386.     }
  387.     
  388.     function getString()
  389.     {
  390.         return '{@source}';
  391.     }
  392.     
  393.     /**
  394.      * @param string|arraysource code
  395.      * @param boolean in php 4.3.0, if this is a method this will be true
  396.      * @param string class name if this is a method
  397.      */
  398.     function setSource($source$class false)
  399.     {
  400.         if (is_array($source))
  401.         {
  402.             $this->_class $class;
  403.             $this->source = $source;
  404.         else
  405.         {
  406.             $source strstr($source,'function');
  407.             $pos strrpos($source,'}');
  408.             $this->source = substr($source,0,$pos 1);
  409.         }
  410.     }
  411.     
  412.     /**
  413.      * @uses stringConvert() in PHP 4.2.3-, this method is used to convert
  414.      * @uses arrayConvert() in PHP 4.3.0+, this method is used to convert
  415.      * @param Converter 
  416.      */
  417.     function Convert(&$c)
  418.     {
  419.         if (is_string($this->source)) return $this->stringConvert($c);
  420.         return $this->arrayConvert($c);
  421.     }
  422.     
  423.     /**
  424.      * @param Converter 
  425.      * @uses phpDocumentor_HighlightParser Parses the tokenized source
  426.      */
  427.     function arrayConvert(&$c)
  428.     {
  429.         $source $this->source;
  430.         if ($this->end != '*')
  431.         {
  432.             $source array_slice($this->source,0,$this->end + $this->start - 1);
  433.         }
  434.         $start $this->start - 1;
  435.         if ($start 0$start 0;
  436.         return $c->ProgramExample($sourcetruetrue$this->_class$start);
  437.     }
  438.     
  439.     /**
  440.      * @param Converter 
  441.      * @uses Converter::unmangle() remove the extraneous stuff from
  442.      *                              {@link highlight_string()}
  443.      * @deprecated in favor of PHP 4.3.0+ {@link arrayConvert()}
  444.      */
  445.     function stringConvert(&$c)
  446.     {
  447.         $source highlight_string('<?php '.$this->source.' ?>'true);
  448.         $source '<code>'.substr($source,strlen('<code><font color="#000000">
  449. <font color="#0000CC">&lt;?php&nbsp;</font>'1);
  450.         $source str_replace('}&nbsp;</font><font color="#0000CC">?&gt;</font>','}</font></code>',$source);
  451.         if ($this->start || ($this->end != '*'))
  452.         {
  453.             $source explode('<br />',$source);
  454.             $start $this->start;
  455.             if ($this->end != '*')
  456.             {
  457.                 $source array_slice($source,$start 1,$this->end - $start 1);
  458.             else
  459.             {
  460.                 $source array_slice($source,$start 1);
  461.             }
  462.             $source implode($source,'<br />');
  463.             if ($start 0$source "<code>$source";
  464.             if ($this->end != '*'$source "$source</code>";
  465.         }
  466.         $source $c->unmangle($source,$this->source);
  467.         return $source;
  468.     }
  469. }
  470.  
  471. /**
  472.  * Represents the example inline tag, used to display an example file
  473.  * inside a docblock or tutorial
  474.  * @tutorial tags.inlineexample.pkg
  475.  * @package phpDocumentor
  476.  * @subpackage InlineTags
  477.  */
  478. {
  479.     /**
  480.      * @param string format "filepath[ start [end]]" where start and end are line numbers
  481.      *                with the end line number optional
  482.      * @param string full path to the current file, used to check relative
  483.      *                directory locations
  484.      * @param boolean if true, then this is in a tutorial
  485.      */
  486.     function parserExampleInlineTag($value$current_path$isTutorial false)
  487.     {
  488.         global $_phpDocumentor_setting;
  489.         parserInlineTag::parserInlineTag('example','');
  490.         $path false;
  491.         $tagValue trim($value);
  492.         $path $isAbsPath $pathOnly $fileName $fileExt $original_path  $title FALSE;
  493.         do
  494.         {
  495.             // make sure the format is stuff.ext startline[ endline]
  496.             if (!preg_match('`(.*)\.(\w*)\s(.*)`'$tagValue$match))
  497.             {
  498.                 // or format is stuff.ext
  499.                 if (!preg_match('`(.*)\.(\w*)\s*$`'$tagValue$match))
  500.                 {
  501.                     // Murphy: Some funny path was given
  502.                     $original_path $tagValue// used for error output
  503.                     break// try-block
  504.                 }
  505.             }
  506.             if (strlen($match[1]=== 0)
  507.             {
  508.                 // Murphy: Some funny path was given
  509.                 $original_path $tagValue// used for error output
  510.                 break// try-block
  511.             }
  512.             $fileExt $match[2];
  513.             if (isset($match[3]))
  514.             {
  515.                 $lines explode(' 'trim($match[3]));
  516.                 $this->start = (int) $lines[0];
  517.                 if (isset($lines[1])) {
  518.                     $this->end = (int) $lines[1];
  519.                 }
  520.             }
  521.             $pathTmp str_replace('\\''/'$match[1])// Replace windows '\' the path.
  522.  
  523.             // Is there a path and a file or is it just a file?
  524.             if (strpos($pathTmp,'/'=== false)
  525.             {
  526.                 // No path part
  527.                 $pathOnly '';
  528.                 $fileName $pathTmp .'.'$fileExt;
  529.             else
  530.             {
  531.                 $splitPos strrpos($pathTmp,'/')// split the path on the last directory, find the filename
  532.                 $pathOnly substr($match[1]0$splitPos+1);
  533.                 $fileName substr($match[1]$splitPos+1.'.'$fileExt;
  534.                 // Is the path absolute? (i.e. does it start like an absolute path?)
  535.                 if (('/' === $pathTmp[0]|| preg_match('`^\w*:`i'$pathTmp))
  536.                 // works for both windows 'C:' and URLs like 'http://'
  537.                     $isAbsPath true// Yes
  538.                 }
  539.             }
  540.  
  541.             $original_path $pathOnly $fileName;
  542.  
  543.             // Now look for the file starting with abs. path.
  544.             if ($isAbsPath)
  545.             {
  546.                 $tmp realpath($original_path)// remove any weirdities like /../file.ext
  547.                 if ($tmp && is_file($tmp))
  548.                 {
  549.                     $path $tmp;
  550.                 }
  551.                 // Alway break if abs. path was detected; even if file was not found.
  552.                 break// try-block
  553.             }
  554.  
  555.             // Search for the example file some standard places 
  556.             // 1) Look if the ini-var examplesdir is set and look there ...
  557.             if (isset($_phpDocumentor_setting['examplesdir']))
  558.             {
  559.                 $tmp realpath($_phpDocumentor_setting['examplesdir'PATH_DELIMITER  $original_path);
  560.                 if ($tmp && is_file($tmp))
  561.                 {
  562.                     $path $tmp// Yo! found it :)
  563.                     break// try-block
  564.                 }
  565.             }
  566.  
  567.             // 2) Then try to look for an 'example/'-dir below the *currently* parsed file ...
  568.             if (!empty($current_path))
  569.             {
  570.                 $tmp realpath(dirname($current_pathPATH_DELIMITER 'examples' PATH_DELIMITER $fileName);
  571.                 if ($tmp && is_file($tmp))
  572.                 {
  573.                     $path $tmp// Yo! found it :)
  574.                     break// try-block
  575.                 }
  576.             }
  577.  
  578.             // 3) Then try to look for the example file below the subdir PHPDOCUMENTOR_BASE/examples/ ...
  579.             if (is_dir(PHPDOCUMENTOR_BASE PATH_DELIMITER 'examples'))
  580.             {
  581.                 $tmp realpath(PHPDOCUMENTOR_BASE PATH_DELIMITER 'examples' PATH_DELIMITER $original_path);
  582.                 if ($tmp && is_file($tmp))
  583.                 {
  584.                     $path $tmp// Yo! found it :)
  585.                     break// try-block
  586.                 }
  587.             }
  588.  
  589.             $tmp realpath(PHPDOCUMENTOR_BASE PATH_DELIMITER $original_path);
  590.             if ($tmp && is_file($tmp))
  591.             {
  592.                 $path $tmp// Yo! found it :)
  593.                 break// try-block
  594.             }
  595.             // If we reach this point, nothing was found and $path is false.
  596.         while (false);
  597.  
  598.         if (!$path)
  599.         {
  600.             addWarning(PDERROR_EXAMPLE_NOT_FOUND$original_path);
  601.             $this->path false;
  602.         else
  603.         {
  604.             $f @fopen($path,'r');
  605.             if ($f)
  606.             {
  607.                 $example fread($f,filesize($path));
  608.                 if (tokenizer_ext && !$isTutorial)
  609.                 {
  610.                     $obj new phpDocumentorTWordParser;
  611.                     $obj->setup($example);
  612.                     $this->setSource($obj->getFileSource());
  613.                     unset($obj);
  614.                 else
  615.                 {
  616.                     $this->setSource($example);
  617.                 }
  618.             }
  619.         }
  620.     }
  621.     
  622.     /**
  623.      * @param string|arraysource code
  624.      * @param boolean in php 4.3.0, if this is a method this will be true
  625.      * @param string class name if this is a method
  626.      */
  627.     function setSource($source$class false)
  628.     {
  629.         $this->_class $class;
  630.         $this->source = $source;
  631.     }
  632.     
  633.     /**
  634.      * @param Converter 
  635.      * @uses phpDocumentor_HighlightParser Parses the tokenized source
  636.      */
  637.     function arrayConvert(&$c)
  638.     {
  639.         $source $this->source;
  640.         if ($this->end != '*')
  641.         {
  642.             $source array_slice($this->source,0,$this->end + $this->start - 1);
  643.         }
  644.         $start $this->start - 1;
  645.         if ($start 0$start 0;
  646.         return $c->exampleProgramExample($sourcetruetrue$this->_class$start);
  647.     }
  648.  
  649.     /**
  650.      * Return the source for the example file, enclosed in
  651.      * a <programlisting> tag to use in a tutorial
  652.      * @return string 
  653.      */
  654.     function getProgramListing()
  655.     {
  656.         $source explode("\n"$this->source);
  657.         $start $this->start;
  658.         if ($this->end != '*')
  659.         {
  660.             $source array_slice($source,$start 1,$this->end - $start 1);
  661.         else
  662.         {
  663.             $source array_slice($source,$start 1);
  664.         }
  665.         $source join("\n"$source);
  666.         return
  667.         "<programlisting role=\"php\">
  668.          <![CDATA[\n" .
  669.           $source .
  670.         "\n]]>\n</programlisting>";
  671.     }
  672. }
  673.  
  674. /**
  675.  * Represents the inheritdoc inline tag, used by classes/methods/vars to inherit
  676.  * documentation from the parent class if possible
  677.  * @tutorial tags.inlineinheritdoc.pkg
  678.  * @package phpDocumentor
  679.  * @subpackage InlineTags
  680.  */
  681. {
  682.     /**
  683.      * always 'inheritdoc'
  684.      * @var string 
  685.      */
  686.     var $inlinetype = 'inheritdoc';
  687.     
  688.     /**
  689.      * Does nothing, overrides parent constructor
  690.      */
  691.     function parserInheritdocInlineTag()
  692.     {
  693.     }
  694.     
  695.     function Convert()
  696.     {
  697.         return '';
  698.     }
  699. }
  700.  
  701. /**
  702.  * Represents the inline {@}id} tag for tutorials
  703.  * @tutorial tags.inlineid.pkg
  704.  * @package phpDocumentor
  705.  * @subpackage InlineTags
  706.  */
  707. {
  708.     /**
  709.      * always 'id'
  710.      * @var string 
  711.      */
  712.     var $inlinetype = 'id';
  713.     /**
  714.      * package of the {@}id}
  715.      * @var string 
  716.      */
  717.     var $package = 'default';
  718.     /**
  719.      * category of the {@}id}
  720.      * @var string 
  721.      */
  722.     var $category = 'default';
  723.     /**
  724.      * subpackage of the {@}id}
  725.      * @var string 
  726.      */
  727.     var $subpackage = '';
  728.     /**
  729.      * full name of the tutorial
  730.      * @var string 
  731.      */
  732.     var $tutorial;
  733.     /**
  734.      * section/subsection name
  735.      * @var string 
  736.      */
  737.     var $id;
  738.     
  739.     /**
  740.      * @param string package name
  741.      * @param string subpackage name
  742.      * @param string tutorial name
  743.      * @param string section/subsection name
  744.      * @param string category name
  745.      */
  746.     function parserIdInlineTag($category,$package,$subpackage,$tutorial,$id false)
  747.     {
  748.         $this->package = $package;
  749.         $this->subpackage = $subpackage;
  750.         $this->tutorial = $tutorial;
  751.         $this->id = $id;
  752.         $this->category = $category;
  753.     }
  754.     
  755.     /**
  756.      * @param Converter 
  757.      * @uses Converter::getTutorialId() retrieve converter-specific ID
  758.      */
  759.     function Convert(&$c)
  760.     {
  761.         if (!$this->idreturn '';
  762.         return $c->getTutorialId($this->package,$this->subpackage,$this->tutorial,$this->id,$this->category);
  763.     }
  764. }
  765.  
  766. /**
  767.  * Represents {@}toc} for table of contents generation in tutorials
  768.  * @tutorial tags.inlinetoc.pkg
  769.  * @package phpDocumentor
  770.  * @subpackage InlineTags
  771.  */
  772. {
  773.     /**
  774.      * always 'toc'
  775.      * @var string 
  776.      */
  777.     var $inlinetype = 'toc';
  778.     /**
  779.      * @var array format:
  780.      *  <pre>
  781.      *  array(array('tagname' => section,
  782.      *              'link' => returnsee link,
  783.      *              'id' => anchor name,
  784.      *              'title' => from title tag),...)
  785.      *  </pre>
  786.      * @access private
  787.      */
  788.     var $_toc false;
  789.     /**
  790.      * full path to tutorial, used in conversion
  791.      * @var string 
  792.      * @access private
  793.      */
  794.     var $_path false;
  795.  
  796.     function parserTocInlineTag()
  797.     {
  798.         parent::parserInlineTag('toc','');
  799.     }
  800.     
  801.     /**
  802.      * @param array format:
  803.      *  <pre>
  804.      *  array(array('tag' => {@link parserXMLDocBookTag},
  805.      *              'id' => {@link parserIdInlineTag},
  806.      *              'title' => {@link parserXMLDocBookTag title}),...)
  807.      *  </pre>
  808.      */
  809.     function setTOC($toc)
  810.     {
  811.         $this->toc $toc;
  812.     }
  813.     
  814.     /**
  815.      * @param string 
  816.      */
  817.     function setPath($path)
  818.     {
  819.         $this->_path $path;
  820.     }
  821.     
  822.     /**
  823.      * @uses Converter::formatTutorialTOC() passes an array of format:
  824.      *
  825.      *  <pre>
  826.      *  array(
  827.      *     'tagname' => string name of tag,
  828.      *     'link' => {@link tutorialLink} to the tutorial,
  829.      *     'id' => converter specific tutorial ID from {@link Converter::getTutorialId()}
  830.      *     'title' => title of the tutorial)
  831.      *  </pre>
  832.      *
  833.      *  and returns the results as the table of contents
  834.      * @uses Converter::getTutorialId() retrieve the tutorial ID for
  835.      * @param Converter 
  836.      */
  837.     function Convert(&$c)
  838.     {
  839.         $newtoc array();
  840.         if (isset($this->toc&& is_array($this->toc)) {
  841.             foreach($this->toc as $i => $toc)
  842.             {
  843.                 if (isset($toc['title']))
  844.                 $toc['tag']->setTitle($toc['title']);
  845.                 else
  846.                 $toc['tag']->setTitle(new parserStringWithInlineTags);
  847.                 $newtoc[$i]['tagname'$toc['tag']->name;
  848.                 $l new tutorialLink;
  849.                 if (!isset($toc['title'])) $title 'section '.$toc['id']->id;
  850.                 else
  851.                 $title $toc['title']->Convert($c);
  852.                 $l->addLink($toc['id']->id,$this->_path,basename($this->_path),$toc['id']->package$toc['id']->subpackagestrip_tags($title));
  853.                 $newtoc[$i]['link'$c->returnSee($l);
  854.                 $newtoc[$i]['id'$c->getTutorialId($toc['id']->package$toc['id']->subpackagebasename($this->_path)$toc['id']->id$toc['id']->category);
  855.                 $newtoc[$i]['title'$title;
  856.             }
  857.         }
  858.         return $c->formatTutorialTOC($newtoc);
  859.     }
  860. }
  861. ?>

Documentation generated on Tue, 24 Oct 2006 09:23:37 -0500 by phpDocumentor 1.3.1