1: <?php
2: /**
3: * The Horde_Core_Tree_Html:: class extends the Horde_Tree_Html class to
4: * provide for creation of Horde-specific URLs.
5: *
6: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (LGPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
10: *
11: * @author Michael Slusarz <slusarz@horde.org>
12: * @category Horde
13: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
14: * @package Core
15: */
16: class Horde_Core_Tree_Html extends Horde_Tree_Html
17: {
18: /**
19: * Images array.
20: * Values correspond to 'treeImg#' CSS classes in horde/themes/screen.css.
21: *
22: * @var array
23: */
24: protected $_images = array(
25: 'line' => 1,
26: 'blank' => '',
27: 'join' => 2,
28: 'join_bottom' => 4,
29: 'join_top' => 3,
30: 'plus' => 10,
31: 'plus_bottom' => 11,
32: 'plus_only' => 12,
33: 'minus' => 6,
34: 'minus_bottom' => 7,
35: 'minus_only' => 8,
36: 'null_only' => 13,
37: 'folder' => 14,
38: 'folderopen' => 15,
39: 'leaf' => 16
40: );
41:
42: /**
43: * Generate a link URL tag.
44: *
45: * @param string $node_id The node ID.
46: *
47: * @return string The link tag.
48: */
49: protected function _generateUrlTag($node_id)
50: {
51: return Horde::link(Horde::selfUrl()->add(Horde_Tree::TOGGLE . $this->_instance, $node_id));
52: }
53:
54: /**
55: * Generate the icon image.
56: *
57: * @param string $src The source image.
58: * @param string $class Additional class to add to image.
59: * @param string $alt Alt text to add to the image.
60: *
61: * @return string A HTML tag to display the image.
62: */
63: protected function _generateImage($src, $class = '', $alt = null)
64: {
65: switch ($class) {
66: case 'treeIcon':
67: return parent::_generateImage($src, $class, $alt);
68:
69: case 'treeToggle':
70: $class .= ' treeImg';
71: break;
72:
73: default:
74: $class = 'treeImg';
75: break;
76: }
77:
78: $img = '<span class="' . $class . ' treeImg' . $src . '"';
79:
80: if (!is_null($alt)) {
81: $img.= ' alt="' . $alt . '"';
82: }
83:
84: return $img . '></span>';
85: }
86:
87: }
88: