1: <?php
2:
3: require_once 'Text/Wiki/Parse/Default/Toc.php';
4:
5: 6: 7: 8: 9:
10: class Text_Wiki_Parse_Toc2 extends Text_Wiki_Parse_Toc
11: {
12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 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: