From: Michael M Slusarz Date: Mon, 23 Aug 2010 22:19:01 +0000 (-0600) Subject: Horde_Tree cleanups. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=21bbb83fda471d2a576c9c10b49d16ddc88f5ad6;p=horde.git Horde_Tree cleanups. Don't hardcode float or other styles. Use spans for internal elements. --- diff --git a/agora/lib/Api.php b/agora/lib/Api.php index a5406c373..fdf2e54ce 100644 --- a/agora/lib/Api.php +++ b/agora/lib/Api.php @@ -293,12 +293,14 @@ class Agora_Api extends Horde_Registry_Api return ''; } - $col_headers = array('message_thread' => _("Subject"), - 'message_thread_class_plain' => '', - 'message_author' => _("Posted by"), - 'message_author_class_plain' => '', - 'message_timestamp' => _("Date"), - 'message_timestamp_class_plain' => ''); + $col_headers = array( + 'message_thread' => _("Subject"), + 'message_thread_class_plain' => 'msgThreadPlain', + 'message_author' => _("Posted by"), + 'message_author_class_plain' => 'msgAuthorPlain', + 'message_timestamp' => _("Date"), + 'message_timestamp_class_plain' => 'msgTimestampPlain' + ); $forums = &Agora_Messages::singleton($scope); $forum_id = $forums->getForumId($forum_name); diff --git a/agora/lib/Comments.php b/agora/lib/Comments.php index 656947847..9cd491805 100644 --- a/agora/lib/Comments.php +++ b/agora/lib/Comments.php @@ -78,12 +78,14 @@ class Agora_ViewComments { } $html .= ''; - $col_headers = array('message_thread' => _("Subject"), - 'message_thread_class_plain' => '', - 'message_author' => _("Posted by"), - 'message_author_class_plain' => '', - 'message_timestamp' => _("Date"), - 'message_timestamp_class_plain' => ''); + $col_headers = array( + 'message_thread' => _("Subject"), + 'message_thread_class_plain' => 'msgThreadPlain', + 'message_author' => _("Posted by"), + 'message_author_class_plain' => 'msgAuthorPlain', + 'message_timestamp' => _("Date"), + 'message_timestamp_class_plain' => 'msgTimestampPlain' + ); if ($view_bodies == 1) { $threads = $messages->getThreads(0, true, 'message_thread', 0, true, '', $base_url); diff --git a/agora/lib/Messages.php b/agora/lib/Messages.php index 534687fc3..3616e6ed4 100644 --- a/agora/lib/Messages.php +++ b/agora/lib/Messages.php @@ -1395,19 +1395,25 @@ class Agora_Messages { /* Render threaded lists with Horde_Tree. */ $current = key($threads); if (!$template_file && isset($threads[$current]['indent'])) { - $tree = $GLOBALS['injector']->getInstance('Horde_Tree')->getTree('threads', 'Html'); - $tree->setOption(array('multiline' => $bodies, - 'lines' => !$bodies)); + $tree = $GLOBALS['injector']->getInstance('Horde_Tree')->getTree('threads', 'Html', array( + 'multiline' => $bodies, + 'lines' => !$bodies + )); + $tree->setHeader(array( - array('html' => '' . $col_headers['message_thread'] . '', - 'width' => '50%', - 'class' => $col_headers['message_thread_class_plain']), - array('html' => '' . $col_headers['message_author'] . '', - 'width' => '25%', - 'class' => $col_headers['message_author_class_plain']), - array('html' => '' . $col_headers['message_timestamp'] . '', - 'width' => '24%', - 'class' => $col_headers['message_timestamp_class_plain']))); + array( + 'class' => $col_headers['message_thread_class_plain'], + 'html' => '' . $col_headers['message_thread'] . '' + ), + array( + 'class' => $col_headers['message_author_class_plain'], + 'html' => '' . $col_headers['message_author'] . '' + ), + array( + 'class' => $col_headers['message_timestamp_class_plain'], + 'html' => '' . $col_headers['message_timestamp'] . '' + ) + )); foreach ($threads as &$thread) { if ($bodies) { @@ -1427,15 +1433,20 @@ class Agora_Messages { } } - $tree->addNode($thread['message_id'], - $thread['parent'], - $text, - $thread['indent'], - true, - array('icon' => '', - 'class' => 'linedRow'), - array($thread['message_author'], - $thread['message_date'])); + $tree->addNode( + $thread['message_id'], + $thread['parent'], + $text, + $thread['indent'], + true, + array( + 'class' => 'linedRow', + ), + array( + $thread['message_author'], + $thread['message_date'] + ) + ); } return $tree->getTree(true); diff --git a/agora/themes/screen.css b/agora/themes/screen.css index 0817131a8..d887dec4b 100644 --- a/agora/themes/screen.css +++ b/agora/themes/screen.css @@ -15,3 +15,13 @@ .messageBody p { padding: 1em; } + +.msgThreadPlain { + width: 50%; +} +.msgAuthorPlain { + width: 25%; +} +.msgTimestampPlain { + width: 24%; +} diff --git a/framework/Core/lib/Horde/Core/Perms/Ui.php b/framework/Core/lib/Horde/Core/Perms/Ui.php index 772cf1330..e96c66c63 100644 --- a/framework/Core/lib/Horde/Core/Perms/Ui.php +++ b/framework/Core/lib/Horde/Core/Perms/Ui.php @@ -79,7 +79,11 @@ class Horde_Core_Perms_Ui 'alternate' => true, 'hideHeaders' => true )); - $tree->setHeader(array(array('width' => '50%'))); + $tree->setHeader(array( + array( + 'class' => 'treeHdrSpacer' + ) + )); foreach ($nodes as $perm_id => $node) { $node_class = ($current == $perm_id) diff --git a/framework/Tree/lib/Horde/Tree/Html.php b/framework/Tree/lib/Horde/Tree/Html.php index 3b46c64f7..432a8b5fe 100644 --- a/framework/Tree/lib/Horde/Tree/Html.php +++ b/framework/Tree/lib/Horde/Tree/Html.php @@ -90,6 +90,8 @@ class Horde_Tree_Html extends Horde_Tree *
      * alternate - (boolean) Alternate shading in the table?
      * class - (string) The class to use for the table.
+     * hideHeaders - (boolean) Don't render any HTML for the header row, just
+     *               use the widths.
      * lines - (boolean) Show tree lines?
      * multiline - (boolean) Do the node labels contain linebreaks?
      * 
@@ -147,10 +149,8 @@ class Horde_Tree_Html extends Horde_Tree * @param array $header An array containing hashes with header * information. The following keys are allowed: *
-     * align - The alignment inside the header cell
      * class - The CSS class of the header cell
      * html - The HTML content of the header cell
-     * width - The width of the header cell
      * 
*/ public function setHeader($header) @@ -165,39 +165,31 @@ class Horde_Tree_Html extends Horde_Tree */ protected function _buildHeader() { - if (!count($this->_header)) { + if (!count($this->_header) || + $this->getOption('hideHeaders')) { return ''; } - $html = 'getOption('alternate')) { - $html .= ' class="item' . $this->_alt_count . '"'; + $className .= ' item' . $this->_alt_count; $this->_alt_count = 1 - $this->_alt_count; } - $html .= '>'; + + $html = '
'; foreach ($this->_header as $header) { - $html .= '
'; } return $html . '
'; @@ -258,31 +250,13 @@ class Horde_Tree_Html extends Horde_Tree if (isset($this->_nodes[$node_id]['extra'][self::EXTRA_LEFT])) { $extra = $this->_nodes[$node_id]['extra'][self::EXTRA_LEFT]; $cMax = count($extra); - for ($c = 0; $c < $cMax; ++$c) { - $style = ''; - if (isset($this->_header[$column]['width'])) { - $style .= 'width:' . $this->_header[$column]['width'] . ';'; - } - - $line .= '
'; - + while ($column < $cMax) { + $line .= $this->_addColumn($column) . $extra[$column] . ''; $column++; } } - $style = ''; - if (isset($this->_header[$column]['width'])) { - $style .= 'width:' . $this->_header[$column]['width'] . ';'; - } - $line .= '
_addColumn($column++); if ($this->getOption('multiline')) { $line .= '
'; @@ -301,24 +275,13 @@ class Horde_Tree_Html extends Horde_Tree $line .= '
'; } - $line .= '
'; - ++$column; + $line .= ''; if (isset($this->_nodes[$node_id]['extra'][self::EXTRA_RIGHT])) { $extra = $this->_nodes[$node_id]['extra'][self::EXTRA_RIGHT]; $cMax = count($extra); - for ($c = 0; $c < $cMax; ++$c) { - $style = ''; - if (isset($this->_header[$column]['width'])) { - $style .= 'width:' . $this->_header[$column]['width'] . ';'; - } - - $line .= '
'; - + for ($c = 0, $cMax = count($extra); $c < $cMax; ++$c) { + $line .= $this->_addColumn($column) . $extra[$c] . ''; $column++; } } @@ -327,6 +290,17 @@ class Horde_Tree_Html extends Horde_Tree } /** + */ + protected function _addColumn($column) + { + $line = '_header[$column]['class'])) { + $line .= ' class="' . $this->_header[$column]['class'] . '"'; + } + return $line . '>'; + } + + /** * Sets the label on the tree line. * * @param string $node_id The Node ID. diff --git a/horde/admin/activesync.php b/horde/admin/activesync.php index 87850dba6..be6165141 100644 --- a/horde/admin/activesync.php +++ b/horde/admin/activesync.php @@ -85,36 +85,72 @@ $device_node = array('icon' => strval(Horde_Themes::img('mobile.png'))); $user_node = array('icon' => strval(Horde_Themes::img('user.png'))); $users = array(); -$tree = $injector->getInstance('Horde_Tree')->getTree('admin_devices', 'Javascript'); -$tree->setOption(array('alternate' => true)); +$tree = $injector->getInstance('Horde_Tree')->getTree('admin_devices', 'Javascript', array( + 'alternate' => true +)); + $tree->setHeader(array( - array('width' => '30%'), - array('width' => '22%', 'html' => _("Last Sync Time")), - array('html' => $spacer), - array('width' => '6%', 'html' => _("Policy Key")), - array('html' => $spacer), - array('width' => '10%', 'html' => _("Status")), - array('html' => $spacer), - array('width' => '12%' , 'html' => _("Device ID")), - array('html' => $spacer), - array('width' => '10%', 'html' => _("Actions")) - )); + array( + 'class' => 'activesyncHdr1' + ), + array( + 'class' => 'activesyncHdr2', + 'html' => _("Last Sync Time") + ), + array( + 'html' => $spacer + ), + array( + 'class' => 'activesyncHdr3', + 'html' => _("Policy Key") + ), + array( + 'html' => $spacer + ), + array( + 'class' => 'activesyncHdr4', + 'html' => _("Status") + ), + array( + 'html' => $spacer + ), + array( + 'class' => 'activesyncHdr5', + 'html' => _("Device ID") + ), + array( + 'html' => $spacer + ), + array( + 'class' => 'activesyncHdr6', + 'html' => _("Actions") + ) +)); /* Root tree node, and reprovision button */ -$tree->addNode('root', - null, - _("Registered User Devices"), - 0, - true, - $base_node_params, - array('--', $spacer, '--', $spacer, '--', $spacer, '--', $spacer, '' )); +$tree->addNode( + 'root', + null, + _("Registered User Devices"), + 0, + true, + $base_node_params, + array('--', $spacer, '--', $spacer, '--', $spacer, '--', $spacer, '' ) +); /* Build the device entry */ foreach ($devices as $key => $device) { $node_params = array(); if (array_search($device['device_user'], $users) === false) { $users[] = $device['device_user']; - $tree->addNode($device['device_user'], 'root', $device['device_user'], 0, false, $user_node); + $tree->addNode( + $device['device_user'], + 'root', + $device['device_user'], + 0, + false, + $user_node + ); } /* Load this device */ @@ -149,13 +185,15 @@ foreach ($devices as $key => $device) { $actions .= ' '; /* Add it */ - $tree->addNode($device['device_id'], - $device['device_user'], - $device['device_type']. ' | ' . $device['device_agent'], - 0, - true, - $device_node + $node_params, - array($ts->format('r'), $spacer, $device['device_policykey'], $spacer, $status, $spacer, $device['device_id'], $spacer, $actions)); + $tree->addNode( + $device['device_id'], + $device['device_user'], + $device['device_type']. ' | ' . $device['device_agent'], + 0, + true, + $device_node + $node_params, + array($ts->format('r'), $spacer, $device['device_policykey'], $spacer, $status, $spacer, $device['device_id'], $spacer, $actions) + ); } echo '

' . Horde::img('group.png') . ' ' . _("ActiveSync Devices") . '

'; diff --git a/horde/admin/groups.php b/horde/admin/groups.php index dba71247b..c8205b147 100644 --- a/horde/admin/groups.php +++ b/horde/admin/groups.php @@ -214,9 +214,15 @@ $edit_img = Horde::img('edit.png', _("Edit Group")); $delete_img = Horde::img('delete.png', _("Delete Group")); /* Set up the tree. */ -$tree = $injector->getInstance('Horde_Tree')->getTree('admin_groups', 'Javascript'); -$tree->setOption(array('alternate' => true, 'hideHeaders' => true)); -$tree->setHeader(array(array('width' => '50%'))); +$tree = $injector->getInstance('Horde_Tree')->getTree('admin_groups', 'Javascript', array( + 'alternate' => true, + 'hideHeaders' => true +)); +$tree->setHeader(array( + array( + 'class' => 'treeHdrSpacer' + ) +)); /* Explicitly check for > 0 since we can be called with current = -1 * for the root node. */ @@ -226,20 +232,35 @@ if ($cid > 0) { foreach ($nodes as $id => $node) { $node_params = ($cid == $id) ? array('class' => 'selected') : array(); + if ($id == Horde_Group::ROOT) { $add_link = Horde::link(Horde_Util::addParameter($add, 'cid', $id), _("Add a new group")) . $add_img . ''; $base_node_params = array('icon' => strval(Horde_Themes::img('administration.png'))); - $tree->addNode($id, null, _("All Groups"), 0, true, $base_node_params + $node_params, array($spacer, $add_link)); + $tree->addNode( + $id, + null, + _("All Groups"), + 0, + true, + $base_node_params + $node_params, + array($spacer, $add_link) + ); } else { $name = $groups->getGroupShortName($node); $node_params['url'] = Horde_Util::addParameter($edit, 'cid', $id); $add_link = Horde::link(Horde_Util::addParameter($add, 'cid', $id), sprintf(_("Add a child group to \"%s\""), $name)) . $add_img . ''; $delete_link = Horde::link(Horde_Util::addParameter($delete, 'cid', $id), sprintf(_("Delete \"%s\""), $name)) . $delete_img . ''; - $parent_id = $groups->getGroupParent($id); - $group_extra = array($spacer, $add_link, $delete_link); - $tree->addNode($id, $parent_id, $groups->getGroupShortName($node), $groups->getLevel($id) + 1, (isset($cid_parents[$id])), $group_node + $node_params, $group_extra); + $tree->addNode( + $id, + $groups->getGroupParent($id), + $groups->getGroupShortName($node), + $groups->getLevel($id) + 1, + (isset($cid_parents[$id])), + $group_node + $node_params, + array($spacer, $add_link, $delete_link) + ); } } diff --git a/horde/js/hordetree.js b/horde/js/hordetree.js index 320c1c9b1..bc47916cb 100644 --- a/horde/js/hordetree.js +++ b/horde/js/hordetree.js @@ -67,20 +67,12 @@ var Horde_Tree = Class.create({ var div = new Element('DIV'); this.opts.header.each(function(h) { - var tmp = new Element('DIV').insert(h.html ? h.html : ' '); + var tmp = new Element('SPAN').insert(h.html ? h.html : ' '); if (h['class']) { tmp.addClassName(h['class']); } - if (h.width) { - tmp.setStyle({ width: h.width }); - } - - if (h.align) { - tmp.setStyle({ textAlign: h.align }); - } - div.appendChild(tmp); }, this); @@ -125,15 +117,15 @@ var Horde_Tree = Class.create({ // any given cell of content. if (node.extra && node.extra[0]) { node.extra[0].each(function(n) { - div.insert(this._divWidth(new Element('DIV').update(n), column++)); + div.insert(this._divClass(new Element('SPAN').update(n), column++)); }, this); } for (; column < this.opts.extraColsLeft; ++column) { - div.insert(this._divWidth(new Element('DIV').update(' '), column)); + div.insert(this._divClass(new Element('SPAN').update(' '), column)); } - div.insert(this._divWidth(new Element('DIV'), column)); + div.insert(this._divClass(new Element('SPAN'), column)); tmp = document.createDocumentFragment(); for (i = Number(this.renderStatic); i < node.indent; ++i) { @@ -199,22 +191,24 @@ var Horde_Tree = Class.create({ if (node.extra && node.extra[1]) { node.extra[1].each(function(n) { - div.insert(this._divWidth(new Element('DIV').update(n), column++)); + div.insert(this._divClass(new Element('SPAN').update(n), column++)); }, this); } for (; column < this.opts.extraColsRight; ++column) { - div.insert(this._divWidth(new Element('DIV').update(' '), column)); + div.insert(this._divClass(new Element('SPAN').update(' '), column)); } p.appendChild(div); }, - _divWidth: function(div, c) + _divClass: function(div, c) { - if (this.opts.header[c] && this.opts.header[c]['width']) { - c.setStyle({ width: this.opts.header[c].width }); + if (this.opts.header[c] && this.opts.header[c]['class']) { + c.addClassName(this.opts.header[c]['class']); } + + return div; }, _setNodeToggle: function(nodeId) diff --git a/horde/themes/screen.css b/horde/themes/screen.css index 335f5e8dc..509051745 100644 --- a/horde/themes/screen.css +++ b/horde/themes/screen.css @@ -395,6 +395,10 @@ div.nicetitle { cursor: pointer; } +.treeHdrSpacer { + width: 50%; +} + span.treeImg { height: 20px; width: 20px; @@ -977,6 +981,27 @@ ul.sound-list { float: right; } +/* Activesync styles. */ +.activesyncHdr1 { + width: 30%; +} +.activesyncHdr2 { + width: 22%; +} +.activesyncHdr3 { + width: 6%; +} +.activesyncHdr4 { + width: 10%; +} +.activesyncHdr5 { + width: 12%; +} +.activesyncHdr6 { + width: 10%; +} + +/* Toggle quote styles. */ .toggleQuoteHide, .toggleQuoteShow { font-size: 80%; cursor: pointer;