[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Text/reST/Formatter/ -> html.php (source)

   1  <?php
   2  
   3  require_once dirname(__FILE__) . '/../Formatter.php';
   4  
   5  /**
   6   * The Text_reST_Formatter_html:: class is the HTML formatter.
   7   *
   8   * $Horde: framework/Text_reST/reST/Formatter/html.php,v 1.6.12.5 2006/01/01 21:28:39 jan Exp $
   9   *
  10   * Copyright 2003-2006 Jason M. Felice <jfelice@cronosys.com>
  11   *
  12   * See the enclosed file COPYING for license information (LGPL). If you did not
  13   * receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  14   *
  15   * @author  Jason M. Felice <jfelice@cronosys.com>
  16   * @package Text_reST
  17   */
  18  class Text_reST_Formatter_html extends Text_reST_Formatter {
  19  
  20      /**
  21       * The current output charset.
  22       *
  23       * @var string
  24       */
  25      var $_charset = null;
  26  
  27      function format(&$node, $charset = null)
  28      {
  29          if (!isset($charset)) {
  30              $charset = $this->_charset;
  31          }
  32  
  33          if (is_string($node)) {
  34              if (isset($charset)) {
  35                  return @htmlspecialchars($node, ENT_QUOTES, $charset);
  36              } else {
  37                  return htmlspecialchars($node, ENT_QUOTES);
  38              }
  39          }
  40  
  41          switch ($node->_type) {
  42          case 'Document':
  43              return $this->_children($node);
  44  
  45          case 'Heading':
  46              $level = $node->getProperty('level');
  47              return '<h' . $level . '>' . $this->_children($node) . '</h' .
  48                  $level . '>';
  49  
  50          case 'Link':
  51              return '<a href="' .
  52                  (isset($charset) ?
  53                   @htmlspecialchars($node->getProperty('href'), ENT_QUOTES, $charset) :
  54                   htmlspecialchars($node->getProperty('href'), ENT_QUOTES)) .
  55                  '">' .
  56                  $this->_children($node) . '</a>';
  57  
  58          case 'Literal-Block':
  59              list($text) = $node->_children;
  60              return '<pre>' . (isset($charset) ?
  61                                @htmlspecialchars($text, ENT_QUOTES, $charset) :
  62                                htmlspecialchars($text, ENT_QUOTES)) . '</pre>';
  63  
  64          case 'Paragraph':
  65              return "<p>" . $this->_children($node) . "</p>";
  66  
  67          case 'Interpreted-Text':
  68              switch ($node->getProperty('role')) {
  69              case 'emphasis':
  70                  return '<em>' . $this->_children($node) . '</em>';
  71  
  72              case 'literal':
  73                  return '<tt>' . $this->_children($node) . '</tt>';
  74  
  75              case 'strong':
  76                  return '<strong>' . $this->_children($node) . '</strong>';
  77  
  78              case 'superscript':
  79                  return '<sup>' . $this->_children($node) . '</sup>';
  80  
  81              case 'subscript':
  82                  return '<sub>' . $this->_children($node) . '</sub>';
  83  
  84              case 'title-reference':
  85                  return '<cite>' . $this->_children($node) . '</cite>';
  86  
  87              default:
  88                  // XXX: Issue a warning.
  89                  return $this->_children($node);
  90              }
  91  
  92          case 'Section':
  93              return $this->_children($node);
  94          }
  95      }
  96  
  97      function _children(&$node)
  98      {
  99          $result = '';
 100          foreach ($node->_children as $child) {
 101              $result .= $this->format($child);
 102          }
 103          return $result;
 104      }
 105  
 106  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7