1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17: class Horde_Tree_Jquerymobile extends Horde_Tree_Base
18: {
19: 20: 21: 22: 23:
24: protected $_allowed = array(
25: 'class',
26: 'icon',
27: 'special',
28: 'url',
29: 'urlattributes',
30: );
31:
32: 33: 34: 35: 36:
37: public function getTree($static = false)
38: {
39: $tree = '';
40: foreach (array(true, false) as $special) {
41: foreach ($this->_root_nodes as $node_id) {
42: $tree .= $this->_buildTree($node_id, $special);
43: }
44: }
45:
46: return $tree;
47: }
48:
49: 50: 51: 52: 53: 54: 55:
56: protected function _buildTree($node_id, $special)
57: {
58: $node = $this->_nodes[$node_id];
59: $output = '';
60:
61: if ($node['special'] == $special) {
62: $output = '<li';
63: if (isset($node['class'])) {
64: $output .= ' class="' . $node['class'] . '"';
65: }
66: $output .= '>';
67: if (isset($node['extra'][Horde_Tree::EXTRA_LEFT])) {
68: $output .= implode(' ', $node['extra'][Horde_Tree::EXTRA_LEFT]);
69: }
70: if (!empty($node['url'])) {
71: $output .= '<a href="' . (string)$node['url'] . '"';
72: if (isset($node['urlattributes'])) {
73: foreach ($node['urlattributes'] as $attribute => $value) {
74: $output .= ' ' . $attribute . '="' . htmlspecialchars($value) . '"';
75: }
76: }
77: $output .= '>';
78: }
79: $output .= $this->_getIcon($node_id) . $node['label'];
80: if (!empty($node['url'])) {
81: $output .= '</a>';
82: }
83: if (isset($node['extra'][Horde_Tree::EXTRA_RIGHT])) {
84: $output .= '<span class="ui-li-count">' . implode(' ', $node['extra'][Horde_Tree::EXTRA_RIGHT]) . '</span>';
85: }
86: $output .= '</li>';
87: }
88:
89: if (isset($node['children'])) {
90: foreach ($node['children'] as $val) {
91: $output .= $this->_buildTree($val, $special);
92: }
93: }
94:
95: return $output;
96: }
97:
98: 99: 100: 101: 102: 103: 104:
105: protected function _getIcon($node_id)
106: {
107: $node = $this->_nodes[$node_id];
108: if (empty($node['icon'])) {
109: return '';
110: }
111: return '<img src="' . $node['icon'] . '" class="ui-li-icon">';
112: }
113:
114: }
115: