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: require_once 'Text/Wiki/Parse/Default/Toc.php';
 4: 
 5: /**
 6:  * Replaces the default Toc parser to search for Heading2 tokens instead.
 7:  *
 8:  * @package Wicked
 9:  */
10: class Text_Wiki_Parse_Toc2 extends Text_Wiki_Parse_Toc
11: {
12:     /**
13:     *
14:     * Generates a replacement for the matched text.
15:     *
16:     * Token options are:
17:     *
18:     * 'type' => ['list_start'|'list_end'|'item_start'|'item_end'|'target']
19:     *
20:     * 'level' => The heading level (1-6).
21:     *
22:     * 'count' => Which entry number this is in the list.
23:     *
24:     * @access public
25:     *
26:     * @param array &$matches The array of matches from parse().
27:     *
28:     * @return string A token indicating the TOC collection point.
29:     *
30:     */
31: 
32:     public function process(&$matches)
33:     {
34:         $count = 0;
35: 
36:         if (isset($matches[1])) {
37:             $attr = $this->getAttrs(trim($matches[1]));
38:         } else {
39:             $attr = array();
40:         }
41: 
42:         $output = $this->wiki->addToken(
43:             $this->rule,
44:             array(
45:                 'type' => 'list_start',
46:                 'level' => 0,
47:                 'attr' => $attr
48:             )
49:         );
50: 
51:         foreach ($this->wiki->getTokens('Heading2') as $key => $val) {
52: 
53:             if ($val[1]['type'] != 'start') {
54:                 continue;
55:             }
56: 
57:             $options = array(
58:                 'type'  => 'item_start',
59:                 'id'    => $val[1]['id'],
60:                 'level' => $val[1]['level'],
61:                 'count' => $count ++
62:             );
63: 
64:             $output .= $this->wiki->addToken($this->rule, $options);
65: 
66:             $output .= $val[1]['text'];
67: 
68:             $output .= $this->wiki->addToken(
69:                 $this->rule,
70:                 array(
71:                     'type' => 'item_end',
72:                     'level' => $val[1]['level']
73:                 )
74:             );
75:         }
76: 
77:         $output .= $this->wiki->addToken(
78:             $this->rule, array(
79:                 'type' => 'list_end',
80:                 'level' => 0
81:             )
82:         );
83: 
84:         return "\n$output\n";
85:     }
86: }
87: 
API documentation generated by ApiGen