Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
248 jpm 1
<?php
2
 
3
 
4
class Text_Wiki_Render_Xhtml_List extends Text_Wiki_Render {
5
 
6
    var $conf = array(
7
        'css_ol' => null,
8
        'css_ol_li' => null,
9
        'css_ul' => null,
10
        'css_ul_li' => null
11
    );
12
 
13
    /**
14
    *
15
    * Renders a token into text matching the requested format.
16
    *
17
    * This rendering method is syntactically and semantically compliant
18
    * with XHTML 1.1 in that sub-lists are part of the previous list item.
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
        // make nice variables (type, level, count)
32
        extract($options);
33
 
34
        // set up indenting so that the results look nice; we do this
35
        // in two steps to avoid str_pad mathematics.  ;-)
36
        $pad = str_pad('', $level, "\t");
37
        $pad = str_replace("\t", '    ', $pad);
38
 
39
        switch ($type) {
40
 
41
        case 'bullet_list_start':
42
 
43
            // build the base HTML
44
            $css = $this->formatConf(' class="%s"', 'css_ul');
45
            $html = "<ul$css>";
46
 
47
            // if this is the opening block for the list,
48
            // put an extra newline in front of it so the
49
            // output looks nice.
50
            if ($level == 0) {
51
                $html = "\n$html";
52
            }
53
 
54
            // done!
55
            return $html;
56
            break;
57
 
58
        case 'bullet_list_end':
59
 
60
            // build the base HTML
61
            $html = "</li>\n$pad</ul>";
62
 
63
            // if this is the closing block for the list,
64
            // put extra newlines after it so the output
65
            // looks nice.
66
            if ($level == 0) {
67
                $html .= "\n\n";
68
            }
69
 
70
            // done!
71
            return $html;
72
            break;
73
 
74
        case 'number_list_start':
75
 
76
            // build the base HTML
77
            $css = $this->formatConf(' class="%s"', 'css_ol');
78
            $html = "<ol$css>";
79
 
80
            // if this is the opening block for the list,
81
            // put an extra newline in front of it so the
82
            // output looks nice.
83
            if ($level == 0) {
84
                $html = "\n$html";
85
            }
86
 
87
            // done!
88
            return $html;
89
            break;
90
 
91
        case 'number_list_end':
92
 
93
            // build the base HTML
94
            $html = "</li>\n$pad</ol>";
95
 
96
            // if this is the closing block for the list,
97
            // put extra newlines after it so the output
98
            // looks nice.
99
            if ($level == 0) {
100
                $html .= "\n\n";
101
            }
102
 
103
            // done!
104
            return $html;
105
            break;
106
 
107
        case 'bullet_item_start':
108
        case 'number_item_start':
109
 
110
            // pick the proper CSS class
111
            if ($type == 'bullet_item_start') {
112
                $css = $this->formatConf(' class="%s"', 'css_ul_li');
113
            } else {
114
                $css = $this->formatConf(' class="%s"', 'css_ol_li');
115
            }
116
 
117
            // build the base HTML
118
            $html = "\n$pad<li$css>";
119
 
120
            // for the very first item in the list, do nothing.
121
            // but for additional items, be sure to close the
122
            // previous item.
123
            if ($count > 0) {
124
                $html = "</li>$html";
125
            }
126
 
127
            // done!
128
            return $html;
129
            break;
130
 
131
        case 'bullet_item_end':
132
        case 'number_item_end':
133
        default:
134
            // ignore item endings and all other types.
135
            // item endings are taken care of by the other types
136
            // depending on their place in the list.
137
            return '';
138
            break;
139
        }
140
    }
141
}
142
?>