Source for file DescHTML.inc

Documentation is available at DescHTML.inc

  1. <?php
  2. /**
  3.  * All abstract representations of html tags in DocBlocks are handled by the
  4.  * classes in this file
  5.  *
  6.  * Before version 1.2, phpDocumentor simply passed html to converters, without
  7.  * much thought, except the {@link adv_htmlentities()} function was provided
  8.  * along with a list of allowed html.  That list is no longer used, in favor
  9.  * of these classes.
  10.  *
  11.  * The PDF Converter output looked wretched in version 1.1.0 because line breaks
  12.  * in DocBlocks were honored.  This meant that output often had just a few words
  13.  * on every other line!  To fix this problem, DocBlock descriptions are now
  14.  * parsed using the {@link ParserDescParser}, and split into paragraphs.  In
  15.  * addition, html in DocBlocks are parsed into these objects to allow for easy
  16.  * conversion in destination converters.  This design also allows different
  17.  * conversion for different templates within a converter, which separates
  18.  * design from logic almost 100%
  19.  *
  20.  * phpDocumentor :: automatic documentation generator
  21.  * 
  22.  * PHP versions 4 and 5
  23.  *
  24.  * Copyright (c) 2002-2007 Gregory Beaver
  25.  * 
  26.  * LICENSE:
  27.  * 
  28.  * This library is free software; you can redistribute it
  29.  * and/or modify it under the terms of the GNU Lesser General
  30.  * Public License as published by the Free Software Foundation;
  31.  * either version 2.1 of the License, or (at your option) any
  32.  * later version.
  33.  * 
  34.  * This library is distributed in the hope that it will be useful,
  35.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  36.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  37.  * Lesser General Public License for more details.
  38.  * 
  39.  * You should have received a copy of the GNU Lesser General Public
  40.  * License along with this library; if not, write to the Free Software
  41.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  42.  * 
  43.  * @category   ToolsAndUtilities
  44.  * @package    phpDocumentor
  45.  * @subpackage DescHTML
  46.  * @author     Greg Beaver <[email protected]>
  47.  * @copyright  2002-2007 Gregory Beaver
  48.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  49.  * @version    CVS: $Id: DescHTML.inc 246329 2007-11-17 03:07:00Z ashnazg $
  50.  * @filesource
  51.  * @link       http://www.phpdoc.org
  52.  * @link       http://pear.php.net/PhpDocumentor
  53.  * @see        parserDocBlock, parserInclude, parserPage, parserClass
  54.  * @see        parserDefine, parserFunction, parserMethod, parserVar
  55.  * @since      1.2
  56.  * @todo       CS cleanup - change package to PhpDocumentor
  57.  */
  58. /**
  59.  * Used for <<code>> in a description
  60.  *
  61.  * @category   ToolsAndUtilities
  62.  * @package    phpDocumentor
  63.  * @subpackage DescHTML
  64.  * @author     Greg Beaver <[email protected]>
  65.  * @copyright  2002-2007 Gregory Beaver
  66.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  67.  * @version    Release: @VER@
  68.  * @link       http://www.phpdoc.org
  69.  * @link       http://pear.php.net/PhpDocumentor
  70.  * @since      1.2
  71.  * @todo       CS cleanup - change package to PhpDocumentor
  72.  * @todo       CS cleanup - rename class to ParserCode
  73.  */
  74. {
  75.     /**
  76.      * performs the conversion of code tags
  77.      *
  78.      * @param Converter &$c the converter object
  79.      *
  80.      * @return string the converted code block
  81.      * @uses Converter::ProgramExample()
  82.      * @todo CS cleanup - rename method to convert()
  83.      */
  84.     function Convert(&$c)
  85.     {
  86.         if (!isset($this->value[0])) {
  87.             return '';
  88.         }
  89.         if (is_string($this->value[0]&& $this->value[0]{0== "\n"{
  90.             $this->value[0substr($this->value[0]1);
  91.         }
  92.         $linktags array();
  93.         foreach ($this->value as $val{
  94.             if (phpDocumentor_get_class($val== 'parserlinkinlinetag'
  95.                 || phpDocumentor_get_class($val== 'parsertutorialinlinetag'
  96.             {
  97.                 $linktags[array(
  98.                     $c->postProcess($val->Convert($cfalsefalse))$val);
  99.             }
  100.         }
  101.         $a $c->ProgramExample(rtrim(ltrim(parent::Convert($c,
  102.             falsefalse)"\n\r")));
  103.         foreach ($linktags as $tag{
  104.             $a str_replace($tag[0]$tag[1]->Convert($cfalsefalse)$a);
  105.         }
  106.         return $a;
  107.     }
  108. }
  109.  
  110. /**
  111.  * Used for <<pre>> in a description
  112.  *
  113.  * @category   ToolsAndUtilities
  114.  * @package    phpDocumentor
  115.  * @subpackage DescHTML
  116.  * @author     Greg Beaver <[email protected]>
  117.  * @copyright  2002-2007 Gregory Beaver
  118.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  119.  * @version    Release: @VER@
  120.  * @link       http://www.phpdoc.org
  121.  * @link       http://pear.php.net/PhpDocumentor
  122.  * @since      1.2
  123.  * @todo       CS cleanup - change package to PhpDocumentor
  124.  * @todo       CS cleanup - rename class to ParserPre
  125.  */
  126. {
  127.     /**
  128.      * performs the conversion of code tags
  129.      *
  130.      * @param Converter &$c the converter object
  131.      *
  132.      * @return string the converted pre block
  133.      * @uses Converter::PreserveWhiteSpace()
  134.      * @todo CS cleanup - rename method to convert()
  135.      */
  136.     function Convert(&$c)
  137.     {
  138.         return $c->PreserveWhiteSpace(rtrim(ltrim(parent::Convert($c,
  139.             falsefalse)"\n\r")));
  140.     }
  141. }
  142.  
  143. /**
  144.  * Used for <<b>> in a description
  145.  *
  146.  * @category   ToolsAndUtilities
  147.  * @package    phpDocumentor
  148.  * @subpackage DescHTML
  149.  * @author     Greg Beaver <[email protected]>
  150.  * @copyright  2002-2007 Gregory Beaver
  151.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  152.  * @version    Release: @VER@
  153.  * @link       http://www.phpdoc.org
  154.  * @link       http://pear.php.net/PhpDocumentor
  155.  * @since      1.2
  156.  * @todo       CS cleanup - change package to PhpDocumentor
  157.  * @todo       CS cleanup - rename class to ParserB
  158.  */
  159. {
  160.     /**
  161.      * performs the conversion of bold tags
  162.      *
  163.      * @param Converter &$c the converter object
  164.      *
  165.      * @return string the converted pre block
  166.      * @uses Converter::Bolden()
  167.      * @todo CS cleanup - rename method to convert()
  168.      */
  169.     function Convert(&$c)
  170.     {
  171.         return $c->Bolden(parent::Convert($c));
  172.     }
  173. }
  174.  
  175. /**
  176.  * Used for <<i>> in a description
  177.  *
  178.  * @category   ToolsAndUtilities
  179.  * @package    phpDocumentor
  180.  * @subpackage DescHTML
  181.  * @author     Greg Beaver <[email protected]>
  182.  * @copyright  2002-2007 Gregory Beaver
  183.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  184.  * @version    Release: @VER@
  185.  * @link       http://www.phpdoc.org
  186.  * @link       http://pear.php.net/PhpDocumentor
  187.  * @since      1.2
  188.  * @todo       CS cleanup - change package to PhpDocumentor
  189.  * @todo       CS cleanup - rename class to ParserI
  190.  */
  191. {
  192.     /**
  193.      * performs the conversion of italic tags
  194.      *
  195.      * @param Converter &$c the converter object
  196.      *
  197.      * @return string the converted pre block
  198.      * @uses Converter::Italicize()
  199.      * @todo CS cleanup - rename method to convert()
  200.      */
  201.     function Convert(&$c)
  202.     {
  203.         return $c->Italicize(parent::Convert($c));
  204.     }
  205. }
  206.  
  207. /**
  208.  * Used for <<var>> in a description
  209.  *
  210.  * @category   ToolsAndUtilities
  211.  * @package    phpDocumentor
  212.  * @subpackage DescHTML
  213.  * @author     Greg Beaver <[email protected]>
  214.  * @copyright  2002-2007 Gregory Beaver
  215.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  216.  * @version    Release: @VER@
  217.  * @link       http://www.phpdoc.org
  218.  * @link       http://pear.php.net/PhpDocumentor
  219.  * @since      1.2
  220.  * @todo       CS cleanup - change package to PhpDocumentor
  221.  * @todo       CS cleanup - rename class to ParserDescVar
  222.  */
  223. {
  224.     /**
  225.      * performs the conversion of variable tags
  226.      *
  227.      * @param Converter &$c the converter object
  228.      *
  229.      * @return string the converted pre block
  230.      * @uses Converter::Varize()
  231.      * @todo CS cleanup - rename method to convert()
  232.      */
  233.     function Convert(&$c)
  234.     {
  235.         return $c->Varize(parent::Convert($c));
  236.     }
  237. }
  238.  
  239. /**
  240.  * Used for <<samp>> in a description
  241.  *
  242.  * @category   ToolsAndUtilities
  243.  * @package    phpDocumentor
  244.  * @subpackage DescHTML
  245.  * @author     Greg Beaver <[email protected]>
  246.  * @copyright  2002-2007 Gregory Beaver
  247.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  248.  * @version    Release: @VER@
  249.  * @link       http://www.phpdoc.org
  250.  * @link       http://pear.php.net/PhpDocumentor
  251.  * @since      1.2
  252.  * @todo       CS cleanup - change package to PhpDocumentor
  253.  * @todo       CS cleanup - rename class to ParserSamp
  254.  */
  255. {
  256.     /**
  257.      * performs the conversion of sample tags
  258.      *
  259.      * @param Converter &$c the converter object
  260.      *
  261.      * @return string the converted pre block
  262.      * @uses Converter::Sampize()
  263.      * @todo CS cleanup - rename method to convert()
  264.      */
  265.     function Convert(&$c)
  266.     {
  267.         return $c->Sampize(parent::Convert($c));
  268.     }
  269. }
  270.  
  271. /**
  272.  * Used for <<kbd>> in a description
  273.  *
  274.  * @category   ToolsAndUtilities
  275.  * @package    phpDocumentor
  276.  * @subpackage DescHTML
  277.  * @author     Greg Beaver <[email protected]>
  278.  * @copyright  2002-2007 Gregory Beaver
  279.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  280.  * @version    Release: @VER@
  281.  * @link       http://www.phpdoc.org
  282.  * @link       http://pear.php.net/PhpDocumentor
  283.  * @since      1.2
  284.  * @todo       CS cleanup - change package to PhpDocumentor
  285.  * @todo       CS cleanup - rename class to ParserKbd
  286.  */
  287. {
  288.     /**
  289.      * performs the conversion of keyboard tags
  290.      *
  291.      * @param Converter &$c the converter object
  292.      *
  293.      * @return string the converted pre block
  294.      * @uses Converter::Kbdize()
  295.      * @todo CS cleanup - rename method to convert()
  296.      */
  297.     function Convert(&$c)
  298.     {
  299.         return $c->Kbdize(parent::Convert($c));
  300.     }
  301. }
  302.  
  303. /**
  304.  * Used for <<br>> in a description
  305.  *
  306.  * @category   ToolsAndUtilities
  307.  * @package    phpDocumentor
  308.  * @subpackage DescHTML
  309.  * @author     Greg Beaver <[email protected]>
  310.  * @copyright  2002-2007 Gregory Beaver
  311.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  312.  * @version    Release: @VER@
  313.  * @link       http://www.phpdoc.org
  314.  * @link       http://pear.php.net/PhpDocumentor
  315.  * @since      1.2
  316.  * @todo       CS cleanup - change package to PhpDocumentor
  317.  * @todo       CS cleanup - rename class to ParserBr
  318.  */
  319. {
  320.     /**
  321.      * performs the conversion of linebreak tags
  322.      *
  323.      * @param Converter &$c the converter object
  324.      *
  325.      * @return string the converted pre block
  326.      * @uses Converter::Br()
  327.      * @todo CS cleanup - rename method to convert()
  328.      */
  329.     function Convert(&$c)
  330.     {
  331.         return $c->Br($this->getString());
  332.     }
  333. }
  334.  
  335. /**
  336.  * Used for lists <<ol>> and <<ul>>
  337.  *
  338.  * @category   ToolsAndUtilities
  339.  * @package    phpDocumentor
  340.  * @subpackage DescHTML
  341.  * @author     Greg Beaver <[email protected]>
  342.  * @copyright  2002-2007 Gregory Beaver
  343.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  344.  * @version    Release: @VER@
  345.  * @link       http://www.phpdoc.org
  346.  * @link       http://pear.php.net/PhpDocumentor
  347.  * @since      1.2
  348.  * @todo       CS cleanup - change package to PhpDocumentor
  349.  * @todo       CS cleanup - rename class to ParserList
  350.  */
  351. {
  352.     /**
  353.      * @var boolean 
  354.      */
  355.     var $numbered;
  356.     /**
  357.      * @var integer 
  358.      */
  359.     var $items = 0;
  360.     /**
  361.      * Constructor - create a new list
  362.      *
  363.      * @param integer $numbered a reference number for the new list
  364.      */
  365.     function parserList($numbered)
  366.     {
  367.         $this->numbered = $numbered;
  368.     }
  369.     
  370.     /**
  371.      * add an item to a list
  372.      *
  373.      * @param parserStringWithInlineTags $item the item to add
  374.      *
  375.      * @return void 
  376.      */
  377.     function addItem($item)
  378.     {
  379.         $this->value[$this->items++$item;
  380.     }
  381.     
  382.     /**
  383.      * add a list
  384.      *
  385.      * @param parserList $list the list to add
  386.      *
  387.      * @return void 
  388.      */
  389.     function addList($list)
  390.     {
  391.         $this->value[$this->items++$list;
  392.     }
  393.     
  394.     /**
  395.      * performs the conversion of list tags
  396.      *
  397.      * @param Converter &$c the converter object
  398.      *
  399.      * @return string the converted pre block
  400.      * @uses Converter::ListItem() enclose each item of the list
  401.      * @uses Converter::EncloseList() enclose the list
  402.      * @todo CS cleanup - rename method to convert()
  403.      */
  404.     function Convert(&$c)
  405.     {
  406.         $list '';
  407.         foreach ($this->value as $item{
  408.             $list .= $c->ListItem(trim($item->Convert($c)));
  409.         }
  410.         return $c->EncloseList($list$this->numbered);
  411.     }
  412. }
  413.  
  414. ?>

Documentation generated on Mon, 05 Dec 2011 21:09:20 -0600 by phpDocumentor 1.4.4