From: Michael M Slusarz Date: Mon, 23 Aug 2010 22:00:25 +0000 (-0600) Subject: Make addNodeParams() driver-specific X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=c0d54569d51a9dfb1abb51b2cd1d5629998e1a90;p=horde.git Make addNodeParams() driver-specific --- diff --git a/framework/Tree/lib/Horde/Tree.php b/framework/Tree/lib/Horde/Tree.php index 2abef21c7..eecbead5a 100644 --- a/framework/Tree/lib/Horde/Tree.php +++ b/framework/Tree/lib/Horde/Tree.php @@ -26,6 +26,13 @@ class Horde_Tree implements Countable const TOGGLE = 'ht_toggle_'; /** + * Allowed parameters for nodes. + * + * @var array + */ + protected $_allowed = array(); + + /** * The name of this instance. * * @var string @@ -318,18 +325,7 @@ class Horde_Tree implements Countable * Adds additional parameters to a node. * * @param string $id The unique node id. - * @param array $params Any other parameters to set. - *
-     * class - CSS class to use with this node
-     * icon - Icon to display next node
-     * iconalt - Alt text to use for the icon
-     * iconopen - Icon to indicate this node as expanded
-     * onclick - Onclick event attached to this node
-     * url - URL to link the node to
-     * urlclass - CSS class for the node's URL
-     * title - Link tooltip title
-     * target - Target for the 'url' link
-     * 
+ * @param array $params Parameters to set (key/value pairs). */ public function addNodeParams($id, $params = array()) { @@ -339,17 +335,12 @@ class Horde_Tree implements Countable $params = array($params); } - $allowed = array( - 'class', 'icon', 'iconalt', 'iconopen', - 'onclick', 'url', 'urlclass', 'title', 'target', - ); - - foreach ($params as $param_id => $param_val) { + foreach ($params as $p_id => $p_val) { // Set only allowed and non-null params. - if (in_array($param_id, $allowed) && !is_null($param_val)) { - $this->_nodes[$id][$param_id] = is_object($param_val) - ? strval($param_val) - : $param_val; + if (!is_null($p_val) && in_array($p_id, $this->_allowed)) { + $this->_nodes[$id][$p_id] = is_object($p_val) + ? strval($p_val) + : $p_val; } } } diff --git a/framework/Tree/lib/Horde/Tree/Html.php b/framework/Tree/lib/Horde/Tree/Html.php index 65f9023aa..587bfe972 100644 --- a/framework/Tree/lib/Horde/Tree/Html.php +++ b/framework/Tree/lib/Horde/Tree/Html.php @@ -44,6 +44,23 @@ class Horde_Tree_Html extends Horde_Tree protected $_alt_count = 0; /** + * Allowed parameters for nodes. + * + * @var array + */ + protected $_allowed = array( + 'class', + 'icon', + 'iconalt', + 'iconopen', + 'onclick', + 'url', + 'urlclass', + 'title', + 'target' + ); + + /** * Images array. * * @var array diff --git a/framework/Tree/lib/Horde/Tree/Select.php b/framework/Tree/lib/Horde/Tree/Select.php index dfa5257aa..086ffa2ad 100644 --- a/framework/Tree/lib/Horde/Tree/Select.php +++ b/framework/Tree/lib/Horde/Tree/Select.php @@ -16,11 +16,13 @@ class Horde_Tree_Select extends Horde_Tree { /** - * Node list. + * Allowed parameters for nodes. * * @var array */ - protected $_nodes = array(); + protected $_allowed = array( + 'selected' + ); /** * Should the tree be rendered statically? @@ -50,27 +52,14 @@ class Horde_Tree_Select extends Horde_Tree * Adds additional parameters to a node. * * @param string $id The unique node id. - * @param array $params Any other parameters to set. + * @param array $params Parameters to set (key/value pairs). *
      * selected - (boolean) Whether this node is selected.
      * 
*/ public function addNodeParams($id, $params = array()) { - $id = $this->_nodeId($id); - - if (!is_array($params)) { - $params = array($params); - } - - $allowed = array('selected'); - - foreach ($params as $param_id => $param_val) { - /* Set only allowed and non-null params. */ - if (in_array($param_id, $allowed) && !is_null($param_val)) { - $this->_nodes[$id][$param_id] = $param_val; - } - } + parent::addNodeParams($id, $params); } /**