From cfb2d5b16472ea7a6576833265f1844c0c9b24a6 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 23 Aug 2010 17:28:08 -0600 Subject: [PATCH] Simplify getOption() --- framework/Tree/lib/Horde/Tree.php | 27 +++++---------------------- framework/Tree/lib/Horde/Tree/Html.php | 12 ++++++++++++ 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/framework/Tree/lib/Horde/Tree.php b/framework/Tree/lib/Horde/Tree.php index 6ec307374..16d8203e6 100644 --- a/framework/Tree/lib/Horde/Tree.php +++ b/framework/Tree/lib/Horde/Tree.php @@ -217,32 +217,15 @@ class Horde_Tree implements Countable /** * Gets an option's value. * - * @param string $option The name of the option to fetch. - * @param boolean $html Whether to format the return value in HTML. - * @param string $default A default value to use in case none is set for - * the requested option. + * @param string $option The name of the option to fetch. * * @return mixed The option's value. */ - public function getOption($option, $html = false, $default = null) + public function getOption($option) { - $value = null; - - if (!isset($this->_options[$option]) && !is_null($default)) { - /* Requested option has not been but there is a - * default. */ - $value = $default; - } elseif (isset($this->_options[$option])) { - /* Requested option has been set, get its value. */ - $value = $this->_options[$option]; - } - - if ($html && !is_null($value)) { - /* Format value for html output. */ - $value = sprintf(' %s="%s"', $option, $value); - } - - return $value; + return isset($this->_options[$option]) + ? $this->_options[$option] + : null; } /** diff --git a/framework/Tree/lib/Horde/Tree/Html.php b/framework/Tree/lib/Horde/Tree/Html.php index 432a8b5fe..29653abbe 100644 --- a/framework/Tree/lib/Horde/Tree/Html.php +++ b/framework/Tree/lib/Horde/Tree/Html.php @@ -89,15 +89,27 @@ class Horde_Tree_Html extends Horde_Tree * @param array $params Additional parameters: *
      * alternate - (boolean) Alternate shading in the table?
+     *             DEFAULT: false
      * class - (string) The class to use for the table.
+     *         DEFAULT: ''
      * hideHeaders - (boolean) Don't render any HTML for the header row, just
      *               use the widths.
+     *               DEFAULT: false
      * lines - (boolean) Show tree lines?
+     *         DEFAULT: true
+     * lines_base - (boolean) Show tree lines for the base level? Requires
+     *              'lines' to be true also.
+     *              DEFAULT: false
      * multiline - (boolean) Do the node labels contain linebreaks?
+     *             DEFAULT: false
      * 
*/ public function __construct($name, array $params = array()) { + $params = array_merge(array( + 'lines' => true + ), $params); + parent::__construct($name, $params); } -- 2.11.0