Text_Wiki
[ class tree: Text_Wiki ] [ index: Text_Wiki ] [ all elements ]

Source for file Toc.php

Documentation is available at Toc.php

  1. <?php
  2.  
  3. class Text_Wiki_Render_Xhtml_Toc extends Text_Wiki_Render {
  4.     
  5.     
  6.     
  7.     /**
  8.     * 
  9.     * Renders a token into text matching the requested format.
  10.     * 
  11.     * @access public
  12.     * 
  13.     * @param array $options The "options" portion of the token (second
  14.     *  element).
  15.     * 
  16.     * @return string The text rendered from the token options.
  17.     * 
  18.     */
  19.     
  20.     function token($options)
  21.     {
  22.         // type, count, level
  23.         extract($options);
  24.         
  25.         // the prefix used for anchor names
  26.         $prefix 'toc';
  27.         
  28.         if ($type == 'target'{
  29.             // ... generate an anchor.
  30.             return "<a id=\"$prefix$count\"></a>";
  31.         }
  32.         
  33.         if ($type == 'list_start'{
  34.             return "<p>\n";
  35.         }
  36.         
  37.         if ($type == 'list_end'{
  38.             return "</p>\n";
  39.         }
  40.         
  41.         if ($type == 'item_start'{
  42.             
  43.             // build some indenting spaces for the text
  44.             $indent ($level - 2* 4;
  45.             $pad str_pad(''$indent);
  46.             $pad str_replace(' ''&nbsp;'$pad);
  47.             
  48.             // add an extra linebreak in front of heading-2
  49.             // entries (makes for nice section separations)
  50.             if ($level <= 2 && $count > 0{
  51.                 $pad = "<br />\n$pad";
  52.             }
  53.             
  54.             // create the entry line as a link to the toc anchor
  55.             return "$pad<a href=\"#$prefix$count\">";
  56.         }
  57.         
  58.         if ($type == 'item_end'{
  59.             return "</a><br />\n";
  60.         }
  61.     }
  62.  
  63. }
  64. ?>

Documentation generated on Mon, 11 Mar 2019 13:51:29 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.