home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / DescHTML.inc < prev    next >
Encoding:
Text File  |  2004-03-24  |  6.1 KB  |  231 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.  * All abstract representations of html tags in DocBlocks are handled by the
  22.  * classes in this file
  23.  *
  24.  * Before version 1.2, phpDocumentor simply passed html to converters, without
  25.  * much thought, except the {@link adv_htmlentities()} function was provided
  26.  * along with a list of allowed html.  That list is no longer used, in favor
  27.  * of these classes.
  28.  *
  29.  * The PDF Converter output looked wretched in version 1.1.0 because line breaks
  30.  * in DocBlocks were honored.  This meant that output often had just a few words
  31.  * on every other line!  To fix this problem, DocBlock descriptions are now
  32.  * parsed using the {@link ParserDescParser}, and split into paragraphs.  In
  33.  * addition, html in DocBlocks are parsed into these objects to allow for easy
  34.  * conversion in destination converters.  This design also allows different
  35.  * conversion for different templates within a converter, which separates
  36.  * design from logic almost 100%
  37.  * @package phpDocumentor
  38.  * @subpackage DescHTML
  39.  * @since 1.2
  40.  */
  41. /**
  42.  * Used for <<code>> in a description
  43.  * @package phpDocumentor
  44.  * @subpackage DescHTML
  45.  */
  46. class parserCode extends parserStringWithInlineTags
  47. {
  48.     /**
  49.      * @param Converter
  50.      * @uses Converter::ProgramExample()
  51.      */
  52.     function Convert(&$c)
  53.     {
  54.         if (!isset($this->value[0])) return '';
  55.         if (is_string($this->value[0]) && $this->value[0]{0} == "\n")
  56.         {
  57.             $this->value[0] = substr($this->value[0],1);
  58.         }
  59.         return $c->ProgramExample(rtrim($this->getString(false)));
  60. //        else return $c->PreserveWhiteSpace($this->getString(false));
  61.     }
  62. }
  63.  
  64. /**
  65.  * Used for <<pre>> in a description
  66.  * @package phpDocumentor
  67.  * @subpackage DescHTML
  68.  */
  69. class parserPre extends parserStringWithInlineTags
  70. {
  71.     /**
  72.      * @param Converter
  73.      * @uses Converter::PreserveWhiteSpace()
  74.      */
  75.     function Convert(&$c)
  76.     {
  77.         return $c->PreserveWhiteSpace($this->getString(false));
  78.     }
  79. }
  80.  
  81. /**
  82.  * Used for <<b>> in a description
  83.  * @package phpDocumentor
  84.  * @subpackage DescHTML
  85.  */
  86. class parserB extends parserStringWithInlineTags
  87. {
  88.     /**
  89.      * @param Converter
  90.      * @uses Converter::Bolden()
  91.      */
  92.     function Convert(&$c)
  93.     {
  94.         return $c->Bolden($this->getString());
  95.     }
  96. }
  97.  
  98. /**
  99.  * Used for <<i>> in a description
  100.  * @package phpDocumentor
  101.  * @subpackage DescHTML
  102.  */
  103. class parserI extends parserStringWithInlineTags
  104. {
  105.     /**
  106.      * @param Converter
  107.      * @uses Converter::Italicize()
  108.      */
  109.     function Convert(&$c)
  110.     {
  111.         return $c->Italicize($this->getString());
  112.     }
  113. }
  114.  
  115. /**
  116.  * Used for <<var>> in a description
  117.  * @package phpDocumentor
  118.  * @subpackage DescHTML
  119.  */
  120. class parserDescVar extends parserStringWithInlineTags
  121. {
  122.     /**
  123.      * @param Converter
  124.      * @uses Converter::Varize()
  125.      */
  126.     function Convert(&$c)
  127.     {
  128.         return $c->Varize($this->getString());
  129.     }
  130. }
  131.  
  132. /**
  133.  * Used for <<samp>> in a description
  134.  * @package phpDocumentor
  135.  * @subpackage DescHTML
  136.  */
  137. class parserSamp extends parserStringWithInlineTags
  138. {
  139.     /**
  140.      * @param Converter
  141.      * @uses Converter::Sampize()
  142.      */
  143.     function Convert(&$c)
  144.     {
  145.         return $c->Sampize($this->getString());
  146.     }
  147. }
  148.  
  149. /**
  150.  * Used for <<kbd>> in a description
  151.  * @package phpDocumentor
  152.  * @subpackage DescHTML
  153.  */
  154. class parserKbd extends parserStringWithInlineTags
  155. {
  156.     /**
  157.      * @param Converter
  158.      * @uses Converter::Kbdize()
  159.      */
  160.     function Convert(&$c)
  161.     {
  162.         return $c->Kbdize($this->getString());
  163.     }
  164. }
  165.  
  166. /**
  167.  * Used for <<br>> in a description
  168.  * @package phpDocumentor
  169.  * @subpackage DescHTML
  170.  */
  171. class parserBr extends parserStringWithInlineTags
  172. {
  173.     /**
  174.      * @param Converter
  175.      * @uses Converter::Br()
  176.      */
  177.     function Convert(&$c)
  178.     {
  179.         return $c->Br($this->getString());
  180.     }
  181. }
  182.  
  183. /**
  184.  * Used for lists <<ol>> and <<ul>>
  185.  * @package phpDocumentor
  186.  * @subpackage DescHTML
  187.  */
  188. class parserList extends parserStringWithInlineTags
  189. {
  190.     /** @var boolean */
  191.     var $numbered;
  192.     /** @var integer */
  193.     var $items = 0;
  194.     /**
  195.      * @param integer
  196.      */
  197.     function parserList($numbered)
  198.     {
  199.         $this->numbered = $numbered;
  200.     }
  201.     
  202.     /** @param parserStringWithInlineTags */
  203.     function addItem($item)
  204.     {
  205.         $this->value[$this->items++] = $item;
  206.     }
  207.     
  208.     /** @param parserList */
  209.     function addList($list)
  210.     {
  211.         $this->value[$this->items++] = $list;
  212.     }
  213.     
  214.     /**
  215.      * @uses Converter::ListItem() enclose each item of the list
  216.      * @uses Converter::EncloseList() enclose the list
  217.      * @param Converter
  218.      */
  219.     function Convert(&$c)
  220.     {
  221.         $list = '';
  222.         foreach($this->value as $item)
  223.         {
  224.             $list .= $c->ListItem(trim($item->Convert($c)));
  225.         }
  226.         return $c->EncloseList($list,$this->numbered);
  227.     }
  228. }
  229.  
  230. ?>
  231.