Allow to specify class name and additional link attributes. Don't hardcode the url.
authorJan Schneider <jan@horde.org>
Tue, 16 Nov 2010 18:00:38 +0000 (19:00 +0100)
committerJan Schneider <jan@horde.org>
Tue, 16 Nov 2010 23:35:49 +0000 (00:35 +0100)
framework/Tree/lib/Horde/Tree/Jquerymobile.php
imp/lib/Imap/Tree.php

index 6c138e5..b3b52a5 100644 (file)
@@ -22,9 +22,11 @@ class Horde_Tree_Jquerymobile extends Horde_Tree_Base
      * @var array
      */
     protected $_allowed = array(
+        'class',
         'icon',
         'special',
         'url',
+        'urlattributes',
     );
 
     /**
@@ -57,12 +59,22 @@ class Horde_Tree_Jquerymobile extends Horde_Tree_Base
         $output = '';
 
         if ($node['special'] == $special) {
-            $output = '<li>';
+            $output = '<li';
+            if (isset($node['class'])) {
+                $output .= ' class="' . $node['class'] . '"';
+            }
+            $output .= '>';
             if (isset($node['extra'][Horde_Tree::EXTRA_LEFT])) {
                 $output .= implode(' ', $node['extra'][Horde_Tree::EXTRA_LEFT]);
             }
             if (!empty($node['url'])) {
-                $output .= '<a href="#mailbox" foo="' . strval($node['url']) . '">';
+                $output .= '<a href="' . (string)$node['url'] . '"';
+                if (isset($node['urlattributes'])) {
+                    foreach ($node['urlattributes'] as $attribute => $value) {
+                        $output .= ' ' . $attribute . '="' . htmlspecialchars($value) . '"';
+                    }
+                }
+                $output .= '>';
             }
             $output .= $this->_getIcon($node_id) . $node['label'];
             if (!empty($node['url'])) {
index e7d0b3b..2be5e56 100644 (file)
@@ -1526,6 +1526,8 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
                 $icon = $val->icon;
                 $params['icon'] = $icon->icon;
                 $params['special'] = $val->special;
+                $params['class'] = 'imp-folder';
+                $params['urlattributes'] = array('mailbox' => $val->value);
                 break;
             }
 
@@ -1551,10 +1553,13 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
             }
 
             if (!$val->container) {
-                $params['url'] = $mailbox_url->add('mailbox', $val->value);
-
-                if ($this->_showunsub && !$val->sub) {
-                    $params['class'] = 'folderunsub';
+                if ($opts['render_type'] == 'Jquerymobile') {
+                    $params['url'] = '#';
+                } else {
+                    $params['url'] = $mailbox_url->add('mailbox', $val->value);
+                    if ($this->_showunsub && !$val->sub) {
+                        $params['class'] = 'folderunsub';
+                    }
                 }
             }