Overview

Packages

  • None
  • Wicked

Classes

  • Text_Wiki_Parse_Heading2
  • Text_Wiki_Parse_Toc2
  • Text_Wiki_Render_Latex_Heading2
  • Text_Wiki_Render_Latex_Toc2
  • Text_Wiki_Render_Plain_Heading2
  • Text_Wiki_Render_Plain_Toc2
  • Text_Wiki_Render_Rst
  • Text_Wiki_Render_Rst_Blockquote
  • Text_Wiki_Render_Rst_Bold
  • Text_Wiki_Render_Rst_Code
  • Text_Wiki_Render_Rst_Deflist
  • Text_Wiki_Render_Rst_Emphasis
  • Text_Wiki_Render_Rst_Freelink
  • Text_Wiki_Render_Rst_Heading2
  • Text_Wiki_Render_Rst_Links
  • Text_Wiki_Render_Rst_List
  • Text_Wiki_Render_Rst_Newline
  • Text_Wiki_Render_Rst_Paragraph
  • Text_Wiki_Render_Rst_Raw
  • Text_Wiki_Render_Rst_Toc2
  • Text_Wiki_Render_Rst_Tt
  • Text_Wiki_Render_Rst_Url
  • Text_Wiki_Render_Xhtml_Attribute
  • Text_Wiki_Render_Xhtml_Code2
  • Text_Wiki_Render_Xhtml_Freelink2
  • Text_Wiki_Render_Xhtml_Heading2
  • Text_Wiki_Render_Xhtml_Image2
  • Text_Wiki_Render_Xhtml_Interwiki
  • Text_Wiki_Render_Xhtml_Registrylink
  • Text_Wiki_Render_Xhtml_Toc2
  • Text_Wiki_Render_Xhtml_Url
  • Text_Wiki_Render_Xhtml_Wickedblock
  • Text_Wiki_Render_Xhtml_Wikilink2
  • Wicked
  • Wicked_Api
  • Wicked_Driver
  • Wicked_Driver_Sql
  • Wicked_Exception
  • Wicked_Factory_Driver
  • Wicked_Page
  • Wicked_Page_AddPage
  • Wicked_Page_AllPages
  • Wicked_Page_AttachedFiles
  • Wicked_Page_BackLinks
  • Wicked_Page_DeletePage
  • Wicked_Page_EditPage
  • Wicked_Page_LeastPopular
  • Wicked_Page_LikePages
  • Wicked_Page_MergeOrRename
  • Wicked_Page_MostPopular
  • Wicked_Page_NewPage
  • Wicked_Page_RecentChanges
  • Wicked_Page_RevertPage
  • Wicked_Page_Search
  • Wicked_Page_StandardHistoryPage
  • Wicked_Page_StandardPage
  • Wicked_Page_SyncDiff
  • Wicked_Page_SyncPages
  • Wicked_Sync
  • Wicked_Sync_Wicked
  • Wicked_Test
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * @package Wicked
 4:  */
 5: class Text_Wiki_Render_Xhtml_Toc2 extends Text_Wiki_Render
 6: {
 7:     public $conf = array(
 8:         'css_list' => null,
 9:         'css_item' => null,
10:         'title' => '<strong>Table of Contents</strong>',
11:         'div_id' => 'toc',
12:     );
13: 
14:     protected $_last_level = null;
15: 
16:     /**
17:      * Renders a token into text matching the requested format.
18:      *
19:      * @access public
20:      *
21:      * @param array $options The "options" portion of the token (second
22:      * element).
23:      *
24:      * @return string The text rendered from the token options.
25:      */
26:     public function token($options)
27:     {
28:         // type, id, level, count, attr.
29:         extract($options);
30: 
31:         switch ($type) {
32:         case 'list_start':
33:             Horde::addScriptFile('toc.js', 'wicked', true);
34: 
35:             // Add the div, class, and id.
36:             $html = '<div';
37:             $css = $this->getConf('css_list');
38:             if ($css) {
39:                 $html .= " class=\"$css\"";
40:             }
41: 
42:             $div_id = $this->getConf('div_id');
43:             if ($div_id) {
44:                 $html .= " id=\"$div_id\"";
45:             }
46: 
47:             // Add the title, and done.
48:             return $html . '>' . $this->getConf('title') . '<ol>';
49: 
50:         case 'list_end':
51:             $html = '';
52:             while ($this->_last_level > 1) {
53:                 $html .= '</ol>';
54:                 --$this->_last_level;
55:             }
56:             return $html . "\n</li></ol></div>\n\n";
57: 
58:         case 'item_start':
59:             $html = '';
60:             if ($this->_last_level !== null) {
61:                 if ($level > $this->_last_level) {
62:                     while ($level > $this->_last_level) {
63:                         $html .= '<ol>';
64:                         ++$this->_last_level;
65:                     }
66:                     $html .= '<li';
67:                 } elseif ($level < $this->_last_level) {
68:                     while ($level < $this->_last_level) {
69:                         $html .= '</ol>';
70:                         --$this->_last_level;
71:                     }
72:                     $html .= '</li><li';
73:                 } else {
74:                     $html = '</li><li';
75:                 }
76:             } else {
77:                 $html = '<li';
78:             }
79:             $this->_last_level = $level;
80: 
81:             $css = $this->getConf('css_item');
82:             if ($css) {
83:                 $html .= " class=\"$css\"";
84:             }
85: 
86:             return $html . "><a href=\"#$id\">";
87: 
88:         case 'item_end':
89:             return '</a>';
90:         }
91:     }
92: }
93: 
API documentation generated by ApiGen