case 'javascript':
$renderer = 'Horde_Core_Tree_Javascript';
break;
+
+ case 'simplehtml':
+ $renderer = 'Horde_Core_Tree_Simplehtml';
+ break;
}
$params['session'] = 'horde_tree';
--- /dev/null
+<?php
+/**
+ * The Horde_Core_Tree_Simplehtml:: class extends the Horde_Tree_Simplehtml
+ * class to provide for creation of Horde-specific URLs.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@curecanti.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Core
+ */
+class Horde_Core_Tree_Simplehtml extends Horde_Tree_Simplehtml
+{
+ /**
+ * Generate a link URL tag.
+ *
+ * @param string $node_id The node ID.
+ *
+ * @return string The link tag.
+ */
+ protected function _generateUrlTag($node_id)
+ {
+ return Horde::link(Horde::selfUrl()->add(self::TOGGLE . $this->_instance, $node_id));
+ }
+
+}
<dir name="Tree">
<file name="Html.php" role="php" />
<file name="Javascript.php" role="php" />
+ <file name="Simplehtml.php" role="php" />
</dir> <!-- /lib/Horde/Core/Tree -->
<dir name="Ui">
<dir name="VarRenderer">
<install as="Horde/Core/Text/Filter/Highlightquotes.php" name="lib/Horde/Core/Text/Filter/Highlightquotes.php" />
<install as="Horde/Core/Tree/Html.php" name="lib/Horde/Core/Tree/Html.php" />
<install as="Horde/Core/Tree/Javascript.php" name="lib/Horde/Core/Tree/Javascript.php" />
+ <install as="Horde/Core/Tree/Simplehtml.php" name="lib/Horde/Core/Tree/Simplehtml.php" />
<install as="Horde/Core/Ui/VarRenderer/Html.php" name="lib/Horde/Core/Ui/VarRenderer/Html.php" />
<install as="Horde/Core/Ui/VarRenderer/TablesetHtml.php" name="lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php" />
<install as="Horde/Core/Ui/FlagImage.php" name="lib/Horde/Core/Ui/FlagImage.php" />
--- /dev/null
+<?php
+/**
+ * The Horde_Tree_Simplehtml:: class extends the Horde_Tree class to provide
+ * a simple HTML rendering of a tree (no graphics).
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Tree
+ */
+class Horde_Tree_Simplehtml extends Horde_Tree
+{
+ /**
+ * Allowed parameters for nodes.
+ *
+ * @var array
+ */
+ protected $_allowed = array(
+ 'class',
+ 'url'
+ );
+
+ /**
+ * Should the tree be rendered statically?
+ *
+ * @var boolean
+ */
+ protected $_static = true;
+
+ /**
+ * Returns the tree.
+ *
+ * @return string The HTML code of the rendered tree.
+ */
+ public function getTree()
+ {
+ $this->_buildIndents($this->_root_nodes);
+
+ $tree = '';
+ foreach ($this->_root_nodes as $node_id) {
+ $tree .= $this->_buildTree($node_id);
+ }
+
+ return $tree;
+ }
+
+ /**
+ * Adds additional parameters to a node.
+ *
+ * @param string $id The unique node id.
+ * @param array $params Parameters to set (key/value pairs).
+ * <pre>
+ * class - CSS class to use with this node
+ * url - URL to link the node to
+ * </pre>
+ */
+ public function addNodeParams($id, $params = array())
+ {
+ parent::addNodeParams($id, $params);
+ }
+
+ /**
+ * Recursive function to walk through the tree array and build the output.
+ *
+ * @param string $node_id The Node ID.
+ *
+ * @return string The tree rendering.
+ */
+ protected function _buildTree($node_id)
+ {
+ $node = $this->_nodes[$node_id];
+
+ $output = '<div' .
+ (empty($node['class']) ? '' : ' class="' . $node['class'] . '"') .
+ '>';
+ if (isset($node['extra'][self::EXTRA_LEFT])) {
+ $output .= implode(' ', $node['extra'][self::EXTRA_LEFT]);
+ }
+ $output .= str_repeat(' ', $node['indent'] * 2);
+
+ if (isset($node['children'])) {
+ $output .= '[' .
+ $this->_generateUrlTag($node_id) .
+ ($node['expanded'] ? '-' : '+') .
+ '</a>] ';
+ }
+
+ $output .= empty($node['url'])
+ ? $node['label']
+ : '<a href="' . strval($node['url']) . '">' . $node['label'] . '</a>';
+ if (isset($node['extra'][self::EXTRA_RIGHT])) {
+ $output .= implode(' ', $node['extra'][self::EXTRA_RIGHT]);
+ }
+ $output .= '</div>';
+
+ if (isset($node['children']) && $node['expanded']) {
+ foreach ($node['children'] as $val) {
+ $output .= $this->_buildTree($val);
+ }
+ }
+
+ return $output;
+ }
+
+ /**
+ * Generate a link URL.
+ *
+ * @param string $node_id The node ID.
+ *
+ * @return string The link tag.
+ */
+ protected function _generateUrlTag($node_id)
+ {
+ $url = new Horde_Url($_SERVER['PHP_SELF']);
+ return $url->add(self::TOGGLE . $this->_instance, $node_id)->link();
+ }
+
+}
<name>Tree</name>
<channel>pear.horde.org</channel>
<summary>Horde Tree API</summary>
- <description>The Horde_Tree:: package provides a tree view of hierarchical information. It allows for expanding/collapsing of branches and maintains their state.
+ <description>This package provides a tree view of hierarchical information. It allows for expanding/collapsing of branches and maintains their state.
</description>
<lead>
<name>Chuck Hagenbuch</name>
<email>jan@horde.org</email>
<active>yes</active>
</lead>
+ <lead>
+ <name>Michael Slusarz</name>
+ <user>slusarz</user>
+ <email>slusarz@horde.org</email>
+ <active>yes</active>
+ </lead>
<date>2009-12-15</date>
<version>
<release>0.1.0</release>
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/gpl.html">GPL</license>
- <notes>* Remove dependency on horde/Core.
+ <notes>* Add simple HTML renderer.
+ * Remove dependency on horde/Core.
* Move javascript renderer to horde/Core.
* Add Horde_Tree_Exception::.
* Initial Horde 4 package.
<file name="Exception.php" role="php" />
<file name="Html.php" role="php" />
<file name="Select.php" role="php" />
+ <file name="Simplehtml.php" role="php" />
</dir> <!-- /lib/Horde/Tree -->
<file name="Tree.php" role="php" />
</dir> <!-- /lib/Horde -->
<install name="lib/Horde/Tree/Exception.php" as="Horde/Tree/Exception.php" />
<install name="lib/Horde/Tree/Html.php" as="Horde/Tree/Html.php" />
<install name="lib/Horde/Tree/Select.php" as="Horde/Tree/Select.php" />
+ <install name="lib/Horde/Tree/Simplehtml.php" as="Horde/Tree/Simplehtml.php" />
<install name="lib/Horde/Tree.php" as="Horde/Tree.php" />
</filelist>
</phprelease>