[ Index ]
 

Code source de Serendipity 1.2

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/bundled-libs/Text/Wiki/Render/Xhtml/ -> Toc.php (source)

   1  <?php
   2  
   3  // $Id: Toc.php,v 1.7 2004/09/25 19:05:14 pmjones Exp $
   4  
   5  class Text_Wiki_Render_Xhtml_Toc extends Text_Wiki_Render {
   6      
   7      var $conf = array(
   8          'css_list' => null,
   9          'css_item' => null,
  10          'title' => '<strong>Table of Contents</strong>',
  11          'div_id' => 'toc'
  12      );
  13      
  14      var $min = 2;
  15      
  16      /**
  17      * 
  18      * Renders a token into text matching the requested format.
  19      * 
  20      * @access public
  21      * 
  22      * @param array $options The "options" portion of the token (second
  23      * element).
  24      * 
  25      * @return string The text rendered from the token options.
  26      * 
  27      */
  28      
  29      function token($options)
  30      {
  31          // type, id, level, count, attr
  32          extract($options);
  33          
  34          switch ($type) {
  35          
  36          case 'list_start':
  37          
  38              $html = '<div';
  39              
  40              $css = $this->getConf('css_list');
  41              if ($css) {
  42                  $html .= " class=\"$css\"";
  43              }
  44              
  45              $div_id = $this->getConf('div_id');
  46              if ($div_id) {
  47                  $html .= " id=\"$div_id\"";
  48              }
  49              
  50              $html .= '>';
  51              $html .= $this->getConf('title');
  52              return $html;
  53              break;
  54          
  55          case 'list_end':
  56              return "</div>\n";
  57              break;
  58              
  59          case 'item_start':
  60              $html = '<div';
  61              
  62              $css = $this->getConf('css_item');
  63              if ($css) {
  64                  $html .= " class=\"$css\"";
  65              }
  66              
  67              $pad = ($level - $this->min);
  68              $html .= " style=\"margin-left: {$pad}em;\">";
  69              
  70              $html .= "<a href=\"#$id\">";
  71              return $html;
  72              break;
  73          
  74          case 'item_end':
  75              return "</a></div>\n";
  76              break;
  77          }
  78      }
  79  }
  80  ?>


Généré le : Sat Nov 24 09:00:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics