1: <?php
2: /**
3: * Renders a list for a Wiki page.
4: *
5: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file COPYING for license information (GPLv2). If
8: * you did not receive this file, see
9: * http://www.horde.org/licenses/gpl
10: *
11: * PHP version 5
12: *
13: * @category Horde
14: * @package Wicked
15: * @author Gunnar Wrobel <wrobel@pardus.de>
16: * @link http://www.horde.org/apps/wicked
17: * @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
18: */
19:
20: /**
21: * Renders a list for a Wiki page.
22: *
23: * @category Horde
24: * @package Wicked
25: * @author Gunnar Wrobel <wrobel@pardus.de>
26: * @link http://www.horde.org/apps/wicked
27: * @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
28: */
29: class Text_Wiki_Render_Rst_List
30: {
31: /**
32: * Render the list.
33: *
34: * @param array $options The rendering options.
35: *
36: * @return string The output string.
37: */
38: public function token($options)
39: {
40: // make nice variables (type, level, count)
41: extract($options);
42:
43: switch ($type) {
44: case 'bullet_list_start':
45: case 'number_list_start':
46: return '';
47: case 'bullet_list_end':
48: case 'number_list_end':
49: return "\n";
50: case 'bullet_item_start':
51: return str_repeat(' ', ($level - 1) * 2) . '* ';
52: case 'number_item_start':
53: return str_repeat(' ', ($level - 1) * 2) . ($count + 1) . '. ';
54: case 'bullet_item_end':
55: case 'number_item_end':
56: return "\n";
57: default:
58: // ignore item endings and all other types.
59: // item endings are taken care of by the other types
60: // depending on their place in the list.
61: return '';
62: break;
63: }
64: }
65: }
66: