Sidebar is now generated via Application registry calls.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 31 Aug 2010 23:40:43 +0000 (17:40 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 1 Sep 2010 07:23:02 +0000 (01:23 -0600)
THE FORMAT OF horde/config/registry.php HAS CHANGED. Namely, sidebar
entries have been changed from 'block' (which they are not) to
'sidebar', and a 'sidebar_params' entry has been added for applications
that have more than one sidebar tree node addition section.

44 files changed:
ansel/browse_edit.php
chora/lib/Application.php
chora/lib/Block/tree_menu.php [deleted file]
framework/Block/lib/Horde/Block.php
framework/Block/lib/Horde/Block/Collection.php
framework/Block/package.xml
framework/Core/lib/Horde/Config.php
framework/Core/lib/Horde/Core/Sidebar.php [new file with mode: 0644]
framework/Core/lib/Horde/Registry/Application.php
framework/Core/package.xml
gollem/lib/Application.php
gollem/lib/Block/tree_menu.php [deleted file]
hermes/lib/Application.php
hermes/lib/Block/tree_menu.php [deleted file]
hermes/lib/Block/tree_stopwatch.php [deleted file]
horde/config/registry.php.dist
horde/docs/UPGRADING
horde/lib/Ajax/Application.php
horde/lib/Api.php
horde/lib/Ui/Sidebar.php [deleted file]
horde/services/portal/edit.php
horde/services/sidebar.php
horde/templates/admin/menu.inc
imp/lib/Application.php
imp/lib/Block/tree_folders.php [deleted file]
imp/lib/Imap/Tree.php
jonah/lib/Application.php
jonah/lib/Block/tree_menu.php [deleted file]
kronolith/lib/Application.php
kronolith/lib/Block/tree_alarms.php [deleted file]
kronolith/lib/Block/tree_menu.php [deleted file]
mnemo/lib/Application.php
mnemo/lib/Block/tree_menu.php [deleted file]
nag/lib/Application.php
nag/lib/Block/tree_alarms.php [deleted file]
nag/lib/Block/tree_menu.php [deleted file]
news/content_edit.php
trean/lib/Application.php
trean/lib/Block/tree_menu.php [deleted file]
turba/lib/Application.php
turba/lib/Block/tree_menu.php [deleted file]
whups/lib/Application.php
whups/lib/Block/tree_menu.php [deleted file]
whups/mybugs_edit.php

index 0496407..4fab2b5 100644 (file)
@@ -10,7 +10,7 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('ansel');
 
 // Instantiate the blocks objects.
-$blocks = Horde_Block_Collection::singleton('myphotos', array('ansel'));
+$blocks = Horde_Block_Collection::singleton(array('ansel'));
 $layout = Horde_Block_Layout_Manager::singleton('myphotos', $blocks, @unserialize($prefs->getValue('myansel_layout')));
 
 // Handle requested actions.
index 1b9b5ec..8ec9a28 100644 (file)
@@ -205,4 +205,39 @@ class Chora_Application extends Horde_Registry_Application
         return Chora::getMenu();
     }
 
+    /* Sidebar method. */
+
+    /**
+     * Add node(s) to the sidebar tree.
+     *
+     * @param Horde_Tree_Base $tree  Tree object.
+     * @param string $parent         The current parent element.
+     * @param array $params          Additional parameters.
+     *
+     * @throws Horde_Exception
+     */
+    public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
+                                  array $params = array())
+    {
+        define('CHORA_ERROR_HANDLER', true);
+
+        $arr = array();
+        asort($GLOBALS['sourceroots']);
+
+        foreach ($GLOBALS['sourceroots'] as $key => $val) {
+            if (Chora::checkPerms($key)) {
+                $tree->addNode($parent . $key,
+                    $parent,
+                    $val['name'],
+                    1,
+                    false,
+                    array(
+                        'icon' => Horde_Themes::img('tree/folder.png'),
+                        'url' => Chora::url('browsedir', '', array('rt' => $key))
+                    )
+                );
+            }
+        }
+    }
+
 }
diff --git a/chora/lib/Block/tree_menu.php b/chora/lib/Block/tree_menu.php
deleted file mode 100644 (file)
index dc74c72..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-$block_name = _("Menu List");
-$block_type = 'tree';
-
-class Horde_Block_chora_tree_menu extends Horde_Block
-{
-    var $_app = 'chora';
-
-    function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        define('CHORA_ERROR_HANDLER', true);
-
-        $arr = array();
-        asort($GLOBALS['sourceroots']);
-
-        foreach ($GLOBALS['sourceroots'] as $key => $val) {
-            if (Chora::checkPerms($key)) {
-                $tree->addNode($parent . $key,
-                    $parent,
-                    $val['name'],
-                    $indent + 1,
-                    false,
-                    array(
-                        'icon' => Horde_Themes::img('tree/folder.png'),
-                        'url' => Chora::url('browsedir', '', array('rt' => $key))
-                    )
-                );
-            }
-        }
-    }
-
-}
index f0fb113..fcaf444 100644 (file)
@@ -191,28 +191,6 @@ class Horde_Block
     }
 
     /**
-     * TODO
-     */
-    public function buildTree($tree, $indent = 0, $parent = null)
-    {
-        /* Switch application contexts, if necessary. Return an error
-         * immediately if pushApp() fails. */
-        try {
-            $app_pushed = $GLOBALS['registry']->pushApp($this->_app, array('check_perms' => true, 'logintasks' => false));
-        } catch (Horde_Exception $e) {
-            return $e->getMessage();
-        }
-
-        $this->_buildTree($tree, $indent, $parent);
-
-        /* If we changed application context in the course of this
-         * call, undo that change now. */
-        if ($app_pushed) {
-            $GLOBALS['registry']->popApp();
-        }
-    }
-
-    /**
      * Returns the title to go in this block.
      *
      * @return string  The block title.
@@ -242,11 +220,4 @@ class Horde_Block
         return '';
     }
 
-    /**
-     * Returns this block's content.
-     */
-    protected function _buildTree($tree, $indent = 0, $parent = null)
-    {
-    }
-
 }
index 6501871..604f0a1 100644 (file)
@@ -30,13 +30,6 @@ class Horde_Block_Collection
     static protected $_blocksCache = array();
 
     /**
-     * What kind of blocks are we collecting? Defaults to any.
-     *
-     * @var string
-     */
-    protected $_type = 'portal';
-
-    /**
      * A hash storing the information about all available blocks from
      * all applications.
      *
@@ -47,17 +40,17 @@ class Horde_Block_Collection
     /**
      * Returns a single instance of the Horde_Blocks class.
      *
-     * @param string $type  The kind of blocks to list.
-     * @param array $apps   The applications whose blocks to list.
+     * @param array $apps  The applications whose blocks to list.
      *
      * @return Horde_Block_Collection  The Horde_Block_Collection instance.
      */
     static public function singleton($type = null, $apps = array())
     {
         sort($apps);
-        $signature = serialize(array($type, $apps));
+        $signature = hash('md5', serialize($apps));
+
         if (!isset(self::$_instances[$signature])) {
-            self::$_instances[$signature] = new self($type, $apps);
+            self::$_instances[$signature] = new self($apps);
         }
 
         return self::$_instances[$signature];
@@ -66,15 +59,10 @@ class Horde_Block_Collection
     /**
      * Constructor.
      *
-     * @param string $type  The kind of blocks to list.
-     * @param array $apps   The applications whose blocks to list.
+     * @param array $apps  The applications whose blocks to list.
      */
-    public function __construct($type = null, $apps = array())
+    public function __construct($apps = array())
     {
-        if (!is_null($type)) {
-            $this->_type = $type;
-        }
-
         $signature = serialize($apps);
         if (isset($_SESSION['horde']['blocks'][$signature])) {
             $this->_blocks = &$_SESSION['horde']['blocks'][$signature];
@@ -100,16 +88,13 @@ class Horde_Block_Collection
                         continue;
                     }
 
-                    $block_name = $block_type = null;
+                    $block_name = null;
 
                     if (is_readable($blockdir . '/' . $file)) {
                         include_once $blockdir . '/' . $file;
                     }
 
-                    if (!empty($block_name) &&
-                        (is_null($block_type) ||
-                         is_null($this->_type) ||
-                         ($block_type == $this->_type))) {
+                    if (!empty($block_name)) {
                         $this->_blocks[$app][substr($file, 0, -4)]['name'] = $block_name;
                     }
                 }
index 7ba7112..d70f5e1 100644 (file)
@@ -32,7 +32,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Initial Horde 4 package.
+ <notes>* Removed sidebar-specifc code.
+ * Initial Horde 4 package.
  </notes>
  <contents>
   <dir name="/">
index a01d1b9..e9881b9 100644 (file)
@@ -1557,7 +1557,7 @@ class Horde_Config
             return array_map(create_function('$val', 'return preg_replace(array("/&#x([0-9a-f]{4});/ie", "/(&[^;]+;)/e"), array("Horde_String::convertCharset(pack(\"H*\", \"$1\"), \"ucs-2\", \"' . $GLOBALS['registry']->getCharset() . '\")", "Horde_String::convertCharset(html_entity_decode(\"$1\", ENT_COMPAT, \"iso-8859-1\"), \"iso-8859-1\", \"' . $GLOBALS['registry']->getCharset() . '\")"), $val);'), $GLOBALS['registry']->nlsconfig['languages']);
 
         case 'list-blocks':
-            $collection = Horde_Block_Collection::singleton('portal');
+            $collection = Horde_Block_Collection::singleton();
             return $collection->getBlocksList();
 
         case 'list-client-fields':
diff --git a/framework/Core/lib/Horde/Core/Sidebar.php b/framework/Core/lib/Horde/Core/Sidebar.php
new file mode 100644 (file)
index 0000000..11a6261
--- /dev/null
@@ -0,0 +1,174 @@
+<?php
+/**
+ * This class provides the code needed to generate the Horde sidebar.
+ *
+ * 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  Core
+ */
+class Horde_Core_Sidebar
+{
+    /**
+     * Generate the sidebar tree object.
+     *
+     * @return Horde_Tree_Base  The sidebar tree object.
+     */
+    public function getTree()
+    {
+        global $injector, $registry;
+
+        $isAdmin = $registry->isAdmin();
+        $menu = $parents = array();
+
+        foreach ($registry->listApps(array('active', 'admin', 'heading', 'notoolbar', 'sidebar'), true) as $app => $params) {
+            /* Check if the current user has permisson to see this
+             * application, and if the application is active. Headings are
+             * visible to everyone (but get filtered out later if they
+             * have no children). Administrators always see all
+             * applications except those marked 'inactive'. */
+            if ($isAdmin ||
+                ($params['status'] == 'heading') ||
+                ($registry->hasPermission($app, Horde_Perms::SHOW) &&
+                 in_array($params['status'], array('active', 'sidebar')))) {
+                $menu[$app] = $params;
+
+                if (isset($params['menu_parent'])) {
+                    $children[$params['menu_parent']] = true;
+                }
+            }
+        }
+
+        foreach (array_keys($menu) as $key) {
+            if (($menu[$key]['status'] == 'heading') &&
+                !isset($children[$key])) {
+                unset($menu[$key]);
+            }
+        }
+
+        // Add the administration menu if the user is an admin.
+        if ($isAdmin) {
+            $menu['administration'] = array(
+                'name' => _("Administration"),
+                'icon' => Horde_Themes::img('administration.png'),
+                'status' => 'heading'
+            );
+
+            try {
+                foreach ($registry->callByPackage('horde', 'admin_list') as $method => $val) {
+                    $menu['administration_' . $method] = array(
+                        'icon' => $val['icon'],
+                        'menu_parent' => 'administration',
+                        'name' => Horde::stripAccessKey($val['name']),
+                        'status' => 'active',
+                        'url' => Horde::url($registry->applicationWebPath($val['link'], 'horde')),
+                    );
+                }
+            } catch (Horde_Exception $e) {}
+        }
+
+        if (Horde_Menu::showService('options') &&
+            !($injector->getInstance('Horde_Prefs')->getPrefs() instanceof Horde_Prefs_Session)) {
+            $menu['options'] = array(
+                'icon' => Horde_Themes::img('prefs.png'),
+                'name' => _("Options"),
+                'status' => 'active'
+            );
+
+            /* Get a list of configurable applications. */
+            $prefs_apps = $registry->listApps(array('active', 'admin'), true, Horde_Perms::READ);
+
+            if (!empty($prefs_apps['horde'])) {
+                $menu['options_' . 'horde'] = array(
+                    'icon' => $registry->get('icon', 'horde'),
+                    'menu_parent' => 'options',
+                    'name' => _("Global Options"),
+                    'status' => 'active',
+                    'url' => Horde::getServiceLink('options', 'horde')
+                );
+                unset($prefs_apps['horde']);
+            }
+
+            asort($prefs_apps);
+            foreach ($prefs_apps as $app => $params) {
+                $menu['options_' . $app] = array(
+                    'icon' => $registry->get('icon', $app),
+                    'menu_parent' => 'options',
+                    'name' => $params['name'],
+                    'status' => 'active',
+                    'url' => Horde::getServiceLink('options', $app)
+                );
+            }
+        }
+
+        if ($registry->getAuth()) {
+            $menu['logout'] = array(
+                'icon' => Horde_Themes::img('logout.png'),
+                'name' => _("Log out"),
+                'status' => 'active',
+                'url' => Horde::getServiceLink('logout', 'horde')
+            );
+        } else {
+            $menu['login'] = array(
+                'icon' => Horde_Themes::img('login.png'),
+                'name' => _("Log in"),
+                'status' => 'active',
+                'url' => Horde::getServiceLink('login', 'horde')
+            );
+        }
+
+        // Set up the tree.
+        $tree = $injector->getInstance('Horde_Tree')->getTree('horde_sidebar', 'Javascript', array('jsvar' => 'HordeSidebar.tree'));
+
+        foreach ($menu as $app => $params) {
+            switch ($params['status']) {
+            case 'sidebar':
+                try {
+                    $registry->callAppMethod($params['app'], 'sidebarCreate', array('args' => array($tree, empty($params['menu_parent']) ? null : $params['menu_parent'], isset($params['sidebar_params']) ? $params['sidebar_params'] : array())));
+                } catch (Horde_Exception $e) {
+                    Horde::logMessage($e, 'ERR');
+                }
+                break;
+
+            default:
+                // Need to run the name through gettext since the user's
+                // locale may not have been loaded when registry.php was
+                // parsed.
+                $name = _($params['name']);
+
+                // Headings have no webroot; they're just containers for other
+                // menu items.
+                if (isset($params['url'])) {
+                    $url = $params['url'];
+                } elseif (($params['status'] == 'heading') ||
+                          !isset($params['webroot'])) {
+                    $url = null;
+                } else {
+                    $url = Horde::url($registry->getInitialPage($app));
+                }
+
+                $tree->addNode(
+                    $app,
+                    empty($params['menu_parent']) ? null : $params['menu_parent'],
+                    $name,
+                    0,
+                    false,
+                    array(
+                        'icon' => strval((isset($params['icon']) ? $params['icon'] : $registry->get('icon', $app))),
+                        'target' => isset($params['target']) ? $params['target'] : null,
+                        'url' => $url
+                    )
+                );
+                break;
+            }
+        }
+
+        return $tree;
+    }
+
+}
index cc4807a..94a3319 100644 (file)
@@ -253,6 +253,21 @@ class Horde_Registry_Application
     // public function prefsSpecialUpdate($ui, $item) {}
 
 
+    // Horde_Core_Sidebar method.
+
+    /**
+     * Add node(s) to the sidebar tree.
+     *
+     * @param Horde_Tree_Base $tree  Tree object.
+     * @param string $parent         The current parent element.
+     * @param array $params          Additional parameters.
+     *
+     * @throws Horde_Exception
+     */
+    // public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
+    //                               array $params = array()) {}
+
+
     // Language change callback.
 
     /**
index a179722..83ab840 100644 (file)
@@ -202,6 +202,7 @@ Application Framework.</description>
        <file name="Identity.php" role="php" />
        <file name="Ui.php" role="php" />
       </dir> <!-- /lib/Horde/Core/Prefs -->
+      <file name="Sidebar.php" role="php" />
       <dir name="Text">
        <dir name="Filter">
         <file name="Bbcode.php" role="php" />
@@ -503,6 +504,7 @@ Application Framework.</description>
    <install as="Horde/Core/Prefs/Identity.php" name="lib/Horde/Core/Prefs/Identity.php" />
    <install as="Horde/Core/Prefs/Ui.php" name="lib/Horde/Core/Prefs/Ui.php" />
    <install as="Horde/Core/Prefs/Ui/Widgets.php" name="lib/Horde/Core/Prefs/Ui/Widgets.php" />
+   <install as="Horde/Core/Sidebar.php" name="lib/Horde/Core/Sidebar.php" />
    <install as="Horde/Core/Text/Filter/Bbcode.php" name="lib/Horde/Core/Text/Filter/Bbcode.php" />
    <install as="Horde/Core/Text/Filter/Emails.php" name="lib/Horde/Core/Text/Filter/Emails.php" />
    <install as="Horde/Core/Text/Filter/Emoticons.php" name="lib/Horde/Core/Text/Filter/Emoticons.php" />
index 7d5629d..f766eae 100644 (file)
@@ -195,4 +195,40 @@ class Gollem_Application extends Horde_Registry_Application
         return Gollem::getMenu();
     }
 
+    /* Sidebar method. */
+
+    /**
+     * Add node(s) to the sidebar tree.
+     *
+     * @param Horde_Tree_Base $tree  Tree object.
+     * @param string $parent         The current parent element.
+     * @param array $params          Additional parameters.
+     *
+     * @throws Horde_Exception
+     */
+    public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
+                                  array $params = array())
+    {
+        // TODO
+        return;
+
+        $login_url = Horde::applicationUrl('login.php');
+
+        foreach ($GLOBALS['gollem_backends'] as $key => $val) {
+            if (Gollem::checkPermissions('backend', Horde_Perms::SHOW, $key)) {
+                $tree->addNode(
+                    $parent . $key,
+                    $parent,
+                    $val['name'],
+                    1,
+                    false,
+                    array(
+                        'icon' => Horde_Themes::img('gollem.png'),
+                        'url' => $login_url->copy()->add(array('backend_key' => $key, 'change_backend' => 1))
+                    )
+                );
+            }
+        }
+    }
+
 }
diff --git a/gollem/lib/Block/tree_menu.php b/gollem/lib/Block/tree_menu.php
deleted file mode 100644 (file)
index fd223c3..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-$block_name = _("Menu List");
-$block_type = 'tree';
-
-/**
- * Gollem tree block.
- *
- * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Gollem
- */
-class Horde_Block_gollem_tree_menu extends Horde_Block
-{
-    protected $_app = 'gollem';
-
-    protected function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        // TODO
-        return;
-
-        $login_url = Horde::applicationUrl('login.php');
-
-        foreach ($GLOBALS['gollem_backends'] as $key => $val) {
-            if (Gollem::checkPermissions('backend', Horde_Perms::SHOW, $key)) {
-                $tree->addNode(
-                    $parent . $key,
-                    $parent,
-                    $val['name'],
-                    $indent + 1,
-                    false,
-                    array(
-                        'icon' => Horde_Themes::img('gollem.png'),
-                        'url' => $login_url->copy()->add(array('backend_key' => $key, 'change_backend' => 1))
-                    )
-                );
-            }
-        }
-    }
-
-}
index 476a4ec..c9482ec 100644 (file)
@@ -87,4 +87,82 @@ class Hermes_Application extends Horde_Registry_Application
         return self::$_perms;
     }
 
+    /* Sidebar method. */
+
+    /**
+     * Add node(s) to the sidebar tree.
+     *
+     * @param Horde_Tree_Base $tree  Tree object.
+     * @param string $parent         The current parent element.
+     * @param array $params          Additional parameters.
+     *
+     * @throws Horde_Exception
+     */
+    public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
+                                  array $params = array())
+    {
+        switch ($params['id']) {
+        case 'menu':
+            $tree->addNode(
+                $parent . '__add',
+                $parent,
+                _("Enter Time"),
+                1,
+                false,
+                array(
+                    'icon' => 'hermes.png',
+                    'url' => Horde::applicationUrl('entry.php')
+                )
+            );
+
+            $tree->addNode(
+                $parent . '__search',
+                $parent,
+                _("Search Time"),
+                1,
+                false,
+                array(
+                    'icon' => 'search.png',
+                    'url' => Horde::applicationUrl('search.php')
+                )
+            );
+            break;
+
+        case 'stopwatch':
+            Horde::addScriptFile('popup.js', 'horde');
+            $entry = Horde::applicationUrl('entry.php');
+
+            $tree->addNode(
+                $parent . '__start',
+                $parent,
+                _("Start Watch"),
+                1,
+                false,
+                array(
+                    'icon' => 'timer-start.png',
+                    'onclick' => "popup('" . Horde::applicationUrl('start.php') . "', 400, 100); return false;",
+                    'url' => '#'
+                )
+            );
+
+            if ($timers = @unserialize($GLOBALS['prefs']->getValue('running_timers', false))) {
+                foreach ($timers as $i => $timer) {
+                    $hours = round((float)(time() - $i) / 3600, 2);
+                    $tree->addNode(
+                        $parent . '__timer_' . $i,
+                        $parent,
+                        Horde_String::convertCharset($timer['name'], $prefs->getCharset()) . sprintf(" (%s)", $hours),
+                        1,
+                        false,
+                        array(
+                            'icon' => 'timer-stop.png',
+                            'url' => $entry->add('timer', $i)
+                        )
+                    );
+                }
+            }
+            break;
+        }
+    }
+
 }
diff --git a/hermes/lib/Block/tree_menu.php b/hermes/lib/Block/tree_menu.php
deleted file mode 100644 (file)
index 98e5bc4..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-$block_name = _("Enter Time");
-$block_type = 'tree';
-
-/**
- * @package Horde_Block
- */
-class Horde_Block_hermes_tree_menu extends Horde_Block
-{
-    protected $_app = 'hermes';
-
-    protected function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        $tree->addNode($parent . '__add',
-                       $parent,
-                       _("Enter Time"),
-                       $indent + 1,
-                       false,
-                       array('icon' => 'hermes.png',
-                             'url' => Horde::applicationUrl('entry.php')));
-        $tree->addNode($parent . '__search',
-                       $parent,
-                       _("Search Time"),
-                       $indent + 1,
-                       false,
-                       array('icon' => 'search.png',
-                             'url' => Horde::applicationUrl('search.php')));
-    }
-
-}
diff --git a/hermes/lib/Block/tree_stopwatch.php b/hermes/lib/Block/tree_stopwatch.php
deleted file mode 100644 (file)
index faf18cd..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-$block_name = _("Stop Watch");
-$block_type = 'tree';
-
-/**
- * @package Horde_Block
- */
-class Horde_Block_hermes_tree_stopwatch extends Horde_Block
-{
-    protected $_app = 'hermes';
-
-    protected function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        global $registry, $prefs;
-
-        Horde::addScriptFile('popup.js', 'horde', true);
-
-        $entry = Horde::applicationUrl('entry.php');
-
-        $tree->addNode($parent . '__start',
-                       $parent,
-                       _("Start Watch"),
-                       $indent + 1,
-                       false,
-                       array('icon' => 'timer-start.png',
-                             'url' => '#',
-                             'onclick' => "popup('" . Horde::applicationUrl('start.php') . "', 400, 100); return false;"));
-
-        $timers = @unserialize($prefs->getValue('running_timers', false));
-        if ($timers) {
-            foreach ($timers as $i => $timer) {
-                $hours = round((float)(time() - $i) / 3600, 2);
-                $tname = Horde_String::convertCharset($timer['name'], $prefs->getCharset()) . sprintf(" (%s)", $hours);
-                $tree->addNode($parent . '__timer_' . $i,
-                               $parent,
-                               $tname,
-                               $indent + 1,
-                               false,
-                               array('icon' => 'timer-stop.png',
-                                     'url' => Horde_Util::addParameter($entry, 'timer', $i)));
-            }
-        }
-    }
-
-}
index 28fe597..4aed999 100644 (file)
  * menu_parent: (string) The name of the 'heading' group that this app should
  *              show up under. This can be left out or set to null for
  *              top-level items.
- * status: (string) 'inactive', 'hidden', 'notoolbar', 'heading',
- *         'block', 'admin', or 'active'.
+ * status: (string) One of the following:
+ *         'active'
+ *         'admin'
+ *         'heading'
+ *         'hidden'
+ *         'inactive'
+ *         'notoolbar'
+ *         'sidebar'
  * webroot: (string) The base URI path for the module.
  *          Usually the default should be fine (applications will occur one
  *          level below the horde directory). However, this setting is useful
  * jsfs: (string) The base filesystem path for static javascript files.
  * jsuri: (string) The base URI for static javascript files.
  * provides: (mixed) Service types the module provides.
+ * sidebar_prefs: (array) Additional params to pass to the sidebar generation
+                  function.
  * target: (string) The target frame for the link.
  * templates: (string) The filesystem path to the templates directory.
  * themesfs: (string) The base file system directory for the themes.
  * themesuri: (string) The base URI for the themes. This can be used to serve
- *                     all icons and style sheets from a separate server.
+ *            all icons and style sheets from a separate server.
  * url: (string) The URL of 'heading' entries.
  *
  *
@@ -117,10 +125,9 @@ $this->applications['vacation'] = array(
     'menu_parent' => 'imp'
 );
 
-$this->applications['imp-folders'] = array(
-    'status' => 'block',
+$this->applications['imp-menu'] = array(
+    'status' => 'sidebar',
     'app' => 'imp',
-    'blockname' => 'tree_folders',
     'menu_parent' => 'imp',
 );
 
@@ -139,9 +146,8 @@ $this->applications['turba'] = array(
 );
 
 $this->applications['turba-menu'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'turba',
-    'blockname' => 'tree_menu',
     'menu_parent' => 'turba',
 );
 
@@ -155,16 +161,20 @@ $this->applications['kronolith'] = array(
 );
 
 $this->applications['kronolith-alarms'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'kronolith',
-    'blockname' => 'tree_alarms',
+    'sidebar_params' => array(
+        'id' => 'alarms'
+    ),
     'menu_parent' => 'kronolith',
 );
 
 $this->applications['kronolith-menu'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'kronolith',
-    'blockname' => 'tree_menu',
+    'sidebar_params' => array(
+        'id' => 'menu'
+    ),
     'menu_parent' => 'kronolith',
 );
 
@@ -178,16 +188,20 @@ $this->applications['nag'] = array(
 );
 
 $this->applications['nag-alarms'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'nag',
-    'blockname' => 'tree_alarms',
+    'sidebar_params' => array(
+        'id' => 'alarms'
+    ),
     'menu_parent' => 'nag',
 );
 
 $this->applications['nag-menu'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'nag',
-    'blockname' => 'tree_menu',
+    'sidebar_params' => array(
+        'id' => 'menu'
+    ),
     'menu_parent' => 'nag',
 );
 
@@ -201,9 +215,8 @@ $this->applications['mnemo'] = array(
 );
 
 $this->applications['mnemo-menu'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'mnemo',
-    'blockname' => 'tree_menu',
     'menu_parent' => 'mnemo',
 );
 
@@ -226,9 +239,8 @@ $this->applications['trean'] = array(
 );
 
 $this->applications['trean-menu'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'trean',
-    'blockname' => 'tree_menu',
     'menu_parent' => 'trean',
 );
 
@@ -246,9 +258,8 @@ $this->applications['chora'] = array(
 );
 
 $this->applications['chora-menu'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'chora',
-    'blockname' => 'tree_menu',
     'menu_parent' => 'chora',
 );
 
@@ -262,9 +273,8 @@ $this->applications['whups'] = array(
 );
 
 $this->applications['whups-menu'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'whups',
-    'blockname' => 'tree_menu',
     'menu_parent' => 'whups',
 );
 
@@ -308,9 +318,8 @@ $this->applications['jonah'] = array(
 );
 
 $this->applications['jonah-menu'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'jonah',
-    'blockname' => 'tree_menu',
     'menu_parent' => 'jonah',
 );
 
@@ -365,16 +374,20 @@ $this->applications['hermes'] = array(
 );
 
 $this->applications['hermes-stopwatch'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'hermes',
-    'blockname' => 'tree_stopwatch',
+    'sidebar_params' => array(
+        'id' => 'stopwatch',
+    ),
     'menu_parent' => 'hermes',
 );
 
 $this->applications['hermes-menu'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'hermes',
-    'blockname' => 'tree_menu',
+    'sidebar_params' => array(
+        'id' => 'menu'
+    ),
     'menu_parent' => 'hermes',
 );
 
@@ -393,9 +406,8 @@ $this->applications['gollem'] = array(
 );
 
 $this->applications['gollem-menu'] = array(
-    'status' => 'block',
+    'status' => 'sidebar',
     'app' => 'gollem',
-    'blockname' => 'tree_menu',
     'menu_parent' => 'gollem',
 );
 
index bba5669..d154937 100644 (file)
@@ -51,6 +51,8 @@ Removed support for krb5 authentication driver.
 
 Removed Mime Viewer drivers: Enscript & Webcpp. Use 'Srchighlite' instead.
 
+The registry.php file has changed ('status' => 'sidebar').
+
 
 Upgrading Horde from 3.3.x to 3.3.5
 ===================================
index 542c2db..7bade2e 100644 (file)
@@ -21,8 +21,7 @@ class Horde_Ajax_Application extends Horde_Core_Ajax_Application
      */
     public function sidebarUpdate()
     {
-        $sidebar = new Horde_Ui_Sidebar();
-        return $sidebar->getTree()->renderNodeDefinitions();
+        return $sidebar->getInstance('Horde_Core_Sidebar')->getTree()->renderNodeDefinitions();
     }
 
 }
index 7ba249c..c04e713 100644 (file)
 class Horde_Api extends Horde_Registry_Api
 {
     /**
-     * Returns a list of adminstrative links
+     * Returns a list of adminstrative links.
+     *
+     * @return array  Keys are link labels, values are array with these keys:
+     * <pre>
+     * 'link' - (string) Registry encoded link to page.
+     * 'name' - (string) Gettext label for page.
+     * 'icon' - (string) Graphic for page.
+     * </pre>
      */
     public function admin_list()
     {
@@ -18,52 +25,52 @@ class Horde_Api extends Horde_Registry_Api
             'configuration' => array(
                 'link' => '%application%/admin/setup/',
                 'name' => _("_Setup"),
-                'icon' => 'config.png'
+                'icon' => Horde_Themes::img('config.png')
             ),
             'users' => array(
                 'link' => '%application%/admin/user.php',
                 'name' => _("_Users"),
-                'icon' => 'user.png'
+                'icon' => Horde_Themes::img('user.png')
             ),
             'groups' => array(
                 'link' => '%application%/admin/groups.php',
                 'name' => _("_Groups"),
-                'icon' => 'group.png'
+                'icon' => Horde_Themes::img('group.png')
             ),
             'perms' => array(
                 'link' => '%application%/admin/perms/index.php',
                 'name' => _("_Permissions"),
-                'icon' => 'perms.png'
+                'icon' => Horde_Themes::img('perms.png')
             ),
             'alarms' => array(
                 'link' => '%application%/admin/alarms.php',
                 'name' => _("_Alarms"),
-                'icon' => 'alerts/alarm.png'
+                'icon' => Horde_Themes::img('alerts/alarm.png')
             ),
             'datatree' => array(
                 'link' => '%application%/admin/datatree.php',
                 'name' => _("_DataTree"),
-                'icon' => 'datatree.png'
+                'icon' => Horde_Themes::img('datatree.png')
             ),
             'sessions' => array(
                 'link' => '%application%/admin/sessions.php',
                 'name' => _("Sessions"),
-                'icon' => 'user.png'
+                'icon' => Horde_Themes::img('user.png')
             ),
             'phpshell' => array(
                 'link' => '%application%/admin/phpshell.php',
                 'name' => _("P_HP Shell"),
-                'icon' => 'mime/php.png'
+                'icon' => Horde_Themes::img('mime/php.png')
             ),
             'sqlshell' => array(
                 'link' => '%application%/admin/sqlshell.php',
                 'name' => _("S_QL Shell"),
-                'icon' => 'sql.png'
+                'icon' => Horde_Themes::img('sql.png')
             ),
             'cmdshell' => array(
                 'link' => '%application%/admin/cmdshell.php',
                 'name' => _("_CLI"),
-                'icon' => 'shell.png'
+                'icon' => Horde_Themes::img('shell.png')
             )
         );
 
@@ -71,7 +78,7 @@ class Horde_Api extends Horde_Registry_Api
             $admin['activesync'] = array(
                 'link' => '%application%/admin/activesync.php',
                 'name' => _("ActiveSync Devices"),
-                'icon' => 'mobile.png'
+                'icon' => Horde_Themes::img('mobile.png')
             );
         }
 
diff --git a/horde/lib/Ui/Sidebar.php b/horde/lib/Ui/Sidebar.php
deleted file mode 100644 (file)
index 2a3c581..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-<?php
-/**
- * The Horde_Ui_Sidebar:: class is designed to provide a place to store common
- * code for sidebar generation.
- *
- * 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  Horde
- */
-class Horde_Ui_Sidebar
-{
-    /**
-     * Generate the sidebar tree object.
-     *
-     * @return Horde_Tree  The sidebar tree object.
-     */
-    public function getTree()
-    {
-        global $conf, $injector, $prefs, $registry, $notification;
-
-        $apps = $cache = $children = $menu = array();
-
-        $isAdmin = $registry->isAdmin();
-        $user = $registry->getAuth();
-        foreach ($registry->applications as $app => $params) {
-            $curr_app = empty($params['app'])
-                ? $app
-                : $params['app'];
-
-            if (!isset($cache[$curr_app])) {
-                /* Check if the current user has permisson to see this
-                 * application, and if the application is active. Headings are
-                 * visible to everyone (but get filtered out later if they
-                 * have no children). Administrators always see all
-                 * applications except those marked 'inactive'. Anyone with
-                 * SHOW permissions can see an application, but READ is needed
-                 * to actually use the application. You can use this
-                 * distinction to show applications to guests that they need
-                 * to log in to use. If you don't want them to see apps they
-                 * can't use, then don't give guests SHOW permissions to
-                 * anything. */
-
-                /* Don't show applications that aren't installed, even if
-                 * they're configured.
-                 * -OR-
-                 * Don't show blocks of applications that aren't installed.
-                 * -OR-
-                 * Filter out entries that are disabled, hidden or shouldn't
-                 * show up in the menu. */
-                if ((isset($params['fileroot']) &&
-                     !is_dir($params['fileroot'])) ||
-                    (($params['status'] == 'block') &&
-                     !is_dir($registry->get('fileroot', $params['app']))) ||
-                    (in_array($params['status'], array('hidden', 'inactive', 'notoolbar')))) {
-                    $cache[$curr_app] = false;
-                } elseif (($params['status'] == 'heading') ||
-                          ($isAdmin ||
-                           ($registry->hasPermission($curr_app, Horde_Perms::SHOW) &&
-                            (($params['status'] == 'active') ||
-                             ($params['status'] == 'block'))))) {
-                    $cache[$curr_app] = true;
-
-                    // Note that the parent node, if any, has children.
-                    if (isset($params['menu_parent'])) {
-                        $children[$params['menu_parent']] = true;
-                    }
-                } else {
-                    // Catch anything that fell through, and don't show it.
-                    $cache[$curr_app] = false;
-                }
-            }
-
-            if ($cache[$curr_app]) {
-                $apps[$app] = $params;
-            }
-        }
-
-        foreach ($apps as $app => $params) {
-            // Filter out all headings without children.
-            if (($params['status'] != 'heading') || !empty($children[$app])) {
-                $menu[$app] = $params;
-            }
-        }
-
-        // Add the administration menu if the user is an admin.
-        if ($registry->isAdmin()) {
-            $menu['administration'] = array(
-                'name' => _("Administration"),
-                'icon' => strval(Horde_Themes::img('administration.png')),
-                'status' => 'heading'
-            );
-
-            try {
-                $list = $registry->callByPackage('horde', 'admin_list');
-                foreach ($list as $method => $vals) {
-                    $name = Horde::stripAccessKey($vals['name']);
-                    $icon = isset($vals['icon'])
-                        ? Horde_Themes::img($vals['icon'])
-                        : $registry->get('icon');
-
-                    $menu['administration_' . $method] = array(
-                        'name' => $name,
-                        'icon' => strval($icon),
-                        'status' => 'active',
-                        'menu_parent' => 'administration',
-                        'url' => Horde::url($registry->applicationWebPath($vals['link'], 'horde')),
-                    );
-                }
-            } catch (Horde_Exception $e) {}
-        }
-
-        if (Horde_Menu::showService('options') &&
-            ($conf['prefs']['driver'] != '') &&
-            ($conf['prefs']['driver'] != 'none')) {
-            $menu['options'] = array(
-                'name' => _("Options"),
-                'icon' => strval(Horde_Themes::img('prefs.png')),
-                'status' => 'active'
-            );
-
-            /* Get a list of configurable applications. */
-            $prefs_apps = array();
-            foreach ($registry->applications as $application => $params) {
-                if (($params['status'] == 'heading') ||
-                    ($params['status'] == 'block') ||
-                    !file_exists($registry->get('fileroot', $application) . '/config/prefs.php')) {
-                    continue;
-                }
-
-                /* Check if the current user has permission to see this
-                 * application, and if the application is active.
-                 * Administrators always see all applications. */
-                try {
-                    if (($registry->isAdmin() &&
-                         ($params['status'] != 'inactive')) ||
-                        ($registry->hasPermission($application) &&
-                         ($params['status'] == 'active'))) {
-                        $prefs_apps[$application] = _($params['name']);
-                    }
-                } catch (Horde_Exception $e) {
-                    /* @todo Remove or log instead of notifying when all apps
-                     * have been H4-ified. */
-                    $notification->push($e);
-                }
-            }
-
-            if (!empty($prefs_apps['horde'])) {
-                $menu['options_' . 'horde'] = array(
-                    'name' => _("Global Options"),
-                    'status' => 'active',
-                    'menu_parent' => 'options',
-                    'icon' => strval($registry->get('icon', 'horde')),
-                    'url' => strval(Horde::getServiceLink('options', 'horde'))
-                );
-                unset($prefs_apps['horde']);
-            }
-
-            asort($prefs_apps);
-            foreach ($prefs_apps as $app => $name) {
-                $menu['options_' . $app] = array(
-                    'name' => $name,
-                    'status' => 'active',
-                    'menu_parent' => 'options',
-                    'icon' => strval($registry->get('icon', $app)),
-                    'url' => strval(Horde::getServiceLink('options', $app))
-                );
-            }
-        }
-
-        if ($registry->getAuth()) {
-            $menu['logout'] = array(
-                'name' => _("Log out"),
-                'status' => 'active',
-                'icon' => strval(Horde_Themes::img('logout.png')),
-                'url' => Horde::getServiceLink('logout', 'horde'),
-                'target' => '_parent'
-            );
-        } else {
-            $menu['login'] = array(
-                'name' => _("Log in"),
-                'status' => 'active',
-                'icon' => strval(Horde_Themes::img('login.png')),
-                'url' => Horde::getServiceLink('login', 'horde')
-            );
-        }
-
-        // Set up the tree.
-        $tree = $injector->getInstance('Horde_Tree')->getTree('horde_sidebar', 'Javascript', array('jsvar' => 'HordeSidebar.tree'));
-
-        foreach ($menu as $app => $params) {
-            if ($params['status'] == 'block') {
-                if ($registry->get('status', $params['app']) == 'inactive') {
-                    continue;
-                }
-
-                try {
-                    $block = Horde_Block_Collection::getBlock($params['app'], $params['blockname']);
-                } catch (Horde_Exception $e) {
-                    Horde::logMessage($e, 'ERR');
-                    continue;
-                }
-
-                try {
-                    $block->buildTree($tree, 0, isset($params['menu_parent']) ? $params['menu_parent'] : null);
-                } catch (Horde_Exception $e) {
-                    Horde::logMessage($e, 'ERR');
-                    continue;
-                }
-            } else {
-                // Need to run the name through gettext since the user's
-                // locale may not have been loaded when registry.php was
-                // parsed.
-                $name = _($params['name']);
-
-                // Headings have no webroot; they're just containers for other
-                // menu items.
-                if (isset($params['url'])) {
-                    $url = $params['url'];
-                } elseif (($params['status'] == 'heading') ||
-                          !isset($params['webroot'])) {
-                    $url = null;
-                } else {
-                    $url = Horde::url($params['webroot'] . '/' . (isset($params['initial_page']) ? $params['initial_page'] : ''));
-                }
-
-                $node_params = array(
-                    'icon' => strval((isset($params['icon']) ? $params['icon'] : $registry->get('icon', $app))),
-                    'target' => isset($params['target']) ? $params['target'] : null,
-                    'url' => $url
-                );
-
-                $tree->addNode($app, empty($params['menu_parent']) ? null : $params['menu_parent'], $name, 0, false, $node_params);
-            }
-        }
-
-        return $tree;
-    }
-
-}
index d135d60..95c6e52 100644 (file)
@@ -14,7 +14,7 @@ require_once dirname(__FILE__) . '/../../lib/Application.php';
 Horde_Registry::appInit('horde');
 
 // Instantiate the blocks objects.
-$blocks = Horde_Block_Collection::singleton('portal');
+$blocks = Horde_Block_Collection::singleton();
 $layout_pref = @unserialize($prefs->getValue('portal_layout'));
 if (!is_array($layout_pref)) {
     $layout_pref = array();
index 0fb0489..5cbdbc9 100644 (file)
@@ -19,13 +19,12 @@ Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 /* We may not be in global scope since this file can be included from other
  * scripts. */
-global $conf, $language, $prefs, $registry;
+global $conf, $injector, $language, $prefs, $registry;
 
 if (!Horde_Util::getFormData('ajaxui') &&
     ($conf['menu']['always'] ||
      ($registry->getAuth() && $prefs->getValue('show_sidebar')))) {
-    $sidebar = new Horde_Ui_Sidebar();
-    $tree = $sidebar->getTree();
+    $tree = $injector->getInstance('Horde_Core_Sidebar')->getTree();
 
     Horde::addScriptFile('prototype.js', 'horde');
     Horde::addScriptFile('sidebar.js', 'horde');
index 8fbaf71..fecaf87 100644 (file)
@@ -4,10 +4,7 @@
     $menu = new Horde_Menu(Horde_Menu::MASK_NONE);
     try {
         foreach ($registry->callByPackage('horde', 'admin_list') as $val) {
-            $img = isset($val['icon'])
-                ? Horde_Themes::img($val['icon'])
-                : $registry->get('icon');
-            $menu->add(Horde::url($registry->applicationWebPath($val['link'])), $val['name'], $img, '');
+            $menu->add(Horde::url($registry->applicationWebPath($val['link'])), $val['name'], $val['icon'], '');
         }
     } catch (Horde_Exception $e) {}
 
index c514422..275489c 100644 (file)
@@ -458,6 +458,95 @@ class IMP_Application extends Horde_Registry_Application
         return $GLOBALS['injector']->getInstance('IMP_Prefs_Ui')->prefsMenu($ui);
     }
 
+    /* Sidebar method. */
+
+    /**
+     * Add node(s) to the sidebar tree.
+     *
+     * @param Horde_Tree_Base $tree  Tree object.
+     * @param string $parent         The current parent element.
+     * @param array $params          Additional parameters.
+     *
+     * @throws Horde_Exception
+     */
+    public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
+                                  array $params = array())
+    {
+        global $injector, $prefs, $registry;
+
+        /* Run filters now */
+        if ($prefs->getValue('filter_on_display')) {
+            $injector->getInstance('IMP_Filter')->filter('INBOX');
+        }
+
+        $tree->addNode(
+            strval($parent) . 'compose',
+            $parent,
+            _("New Message"),
+            0,
+            false,
+            array(
+                'icon' => Horde_Themes::img('compose.png'),
+                'url' => IMP::composeLink()
+            )
+        );
+
+        /* Add link to the search page. */
+        $tree->addNode(
+            strval($parent) . 'search',
+            $parent,
+            _("Search"),
+            0,
+            false,
+            array(
+                'icon' => Horde_Themes::img('search.png'),
+                'url' => Horde::applicationUrl('search.php')
+            )
+        );
+
+        if ($_SESSION['imp']['protocol'] == 'pop') {
+            return;
+        }
+
+        $name_url = Horde::applicationUrl('mailbox.php');
+
+        /* Initialize the IMP_Tree object. */
+        $imaptree = $injector->getInstance('IMP_Imap_Tree');
+        $imaptree->setIteratorFilter(IMP_Imap_Tree::FLIST_VFOLDER);
+        $imaptree->createTree($tree, array(
+            'parent' => $parent,
+            'poll_info' => true
+        ));
+
+        /* We want to rewrite the parent node of the INBOX to include new mail
+         * notification. */
+        if (!($url = $registry->get('url', $parent))) {
+            $url = (($registry->get('status', $parent) == 'heading') || !$registry->get('webroot'))
+                ? null
+                : $registry->getInitialPage($parent);
+        }
+
+        $node_params = array(
+            'icon' => $registry->get('icon', $parent),
+            'url' => $url
+        );
+        $name = $registry->get('name', $parent);
+
+        if ($imaptree->unseen) {
+            $node_params['icon'] = Horde_Themes::img('newmail.png');
+            $name = sprintf('<strong>%s</strong> (%s)', $name, $imaptree->unseen);
+        }
+
+        $tree->addNode(
+            strval($parent),
+            $registry->get('menu_parent', $parent),
+            $name,
+            0,
+            $imaptree->isOpen($parent),
+            $node_params
+        );
+    }
+
     /* Language change callback. */
 
     /**
diff --git a/imp/lib/Block/tree_folders.php b/imp/lib/Block/tree_folders.php
deleted file mode 100644 (file)
index 78744df..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-/**
- * Block: menu folder list.
- *
- * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author   Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license  http://www.fsf.org/copyleft/gpl.html GPL
- * @package  IMP
- */
-
-$block_name = _("Menu Folder List");
-$block_type = 'tree';
-
-class Horde_Block_imp_tree_folders extends Horde_Block
-{
-    protected $_app = 'imp';
-
-    protected function _buildTree($tree, $indent = 0, $parent = '')
-    {
-        global $injector, $prefs, $registry;
-
-        /* Run filters now */
-        if ($prefs->getValue('filter_on_display')) {
-            $injector->getInstance('IMP_Filter')->filter('INBOX');
-        }
-
-        $tree->addNode(
-            $parent . 'compose',
-            $parent,
-            _("New Message"),
-            $indent,
-            false,
-            array(
-                'icon' => Horde_Themes::img('compose.png'),
-                'url' => IMP::composeLink()
-            )
-        );
-
-        /* Add link to the search page. */
-        $tree->addNode(
-            $parent . 'search',
-            $parent,
-            _("Search"),
-            $indent,
-            false,
-            array(
-                'icon' => Horde_Themes::img('search.png'),
-                'url' => Horde::applicationUrl('search.php')
-            )
-        );
-
-        if ($_SESSION['imp']['protocol'] == 'pop') {
-            return;
-        }
-
-        $name_url = Horde::applicationUrl('mailbox.php');
-
-        /* Initialize the IMP_Tree object. */
-        $imaptree = $injector->getInstance('IMP_Imap_Tree');
-        $imaptree->setIteratorFilter(IMP_Imap_Tree::FLIST_VFOLDER);
-        $imaptree->createTree($tree, array(
-            'indent' => $indent,
-            'parent' => $parent,
-            'poll_info' => true
-        ));
-
-        /* We want to rewrite the parent node of the INBOX to include new mail
-         * notification. */
-        if (!($url = $registry->get('url', $parent))) {
-            $url = (($registry->get('status', $parent) == 'heading') || !$registry->get('webroot'))
-                ? null
-                : $registry->getInitialPage($parent);
-        }
-
-        $node_params = array(
-            'icon' => $registry->get('icon', $parent),
-            'url' => $url
-        );
-        $name = $registry->get('name', $parent);
-
-        if ($imaptree->unseen) {
-            $node_params['icon'] = Horde_Themes::img('newmail.png');
-            $name = sprintf('<strong>%s</strong> (%s)', $name, $imaptree->unseen);
-        }
-
-        $tree->addNode(
-            $parent,
-            $registry->get('menu_parent', $parent),
-            $name,
-            $indent - 1,
-            $imaptree->isOpen($parent),
-            $node_params
-        );
-    }
-
-}
index 959cb11..5ac76e5 100644 (file)
@@ -1467,8 +1467,6 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator
      *              DEFAULT: false
      * 'editvfolder' - (boolean) Display vfolder edit links?
      *                 DEFAULT: false
-     * 'indent' - (integer) The base level to add nodes to.
-     *            DEFAULT: 0
      * 'parent' - (string) The parent object of the current level.
      *            DEFAULT: null (add to base level)
      * 'poll_info' - (boolean) Include poll information?
@@ -1490,7 +1488,6 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator
 
         if ($name instanceof Horde_Tree_Base) {
             $tree = $name;
-            $indent = $opts['indent'];
             $parent = $opts['parent'];
         } else {
             $tree = $GLOBALS['injector']->getInstance('Horde_Tree')->getTree($name, $opts['render_type'], array(
@@ -1499,7 +1496,6 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator
                 'lines_base' => true,
                 'nosession' => true
             ));
-            $indent = 0;
             $parent = null;
         }
 
@@ -1575,7 +1571,7 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator
                 strval($parent) . $val->value,
                 ($val->level) ? strval($parent) . $val->parent : $parent,
                 $label,
-                $indent + $val->level,
+                $val->level,
                 $is_open,
                 $params,
                 $after,
index 4e6a2db..5e57a60 100644 (file)
@@ -93,4 +93,46 @@ class Jonah_Application extends Horde_Registry_Application
         return Jonah::getMenu();
     }
 
+    /* Sidebar method. */
+
+    /**
+     * Add node(s) to the sidebar tree.
+     *
+     * @param Horde_Tree_Base $tree  Tree object.
+     * @param string $parent         The current parent element.
+     * @param array $params          Additional parameters.
+     *
+     * @throws Horde_Exception
+     */
+    public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
+                                  array $params = array())
+    {
+        if (!Jonah::checkPermissions('jonah:news', Horde_Perms::EDIT) ||
+            !in_array('internal', $GLOBALS['conf']['news']['enable'])) {
+            return;
+        }
+
+        $url = Horde::applicationUrl('stories/');
+        $news = Jonah_News::factory();
+        $channels = $news->getChannels('internal');
+        if ($channels instanceof PEAR_Error) {
+            return;
+        }
+        $channels = Jonah::checkPermissions('channels', Horde_Perms::SHOW, $channels);
+
+        foreach ($channels as $channel) {
+            $tree->addNode(
+                $parent . $channel['channel_id'],
+                $parent,
+                $channel['channel_name'],
+                1,
+                false,
+                array(
+                    'icon' => Horde_Themes::img('editstory.png'),
+                    'url' => $url->add('channel_id', $channel['channel_id'])
+                )
+            );
+        }
+    }
+
 }
diff --git a/jonah/lib/Block/tree_menu.php b/jonah/lib/Block/tree_menu.php
deleted file mode 100644 (file)
index 22a4672..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-$block_name = _("Menu List");
-$block_type = 'tree';
-
-/**
- * @package Horde_Block
- */
-class Horde_Block_jonah_tree_menu extends Horde_Block {
-
-    var $_app = 'jonah';
-
-    function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        if (!Jonah::checkPermissions('jonah:news', Horde_Perms::EDIT) ||
-            !in_array('internal', $GLOBALS['conf']['news']['enable'])) {
-            return;
-        }
-
-        $url = Horde::applicationUrl('stories/');
-        $news = Jonah_News::factory();
-        $channels = $news->getChannels('internal');
-        if (is_a($channels, 'PEAR_Error')) {
-            return;
-        }
-        $channels = Jonah::checkPermissions('channels', Horde_Perms::SHOW, $channels);
-
-        foreach ($channels as $channel) {
-            $tree->addNode(
-                $parent . $channel['channel_id'],
-                $parent,
-                $channel['channel_name'],
-                $indent + 1,
-                false,
-                array(
-                    'icon' => Horde_Themes::img('editstory.png'),
-                    'url' => $url->add('channel_id', $channel['channel_id'])
-                )
-            );
-        }
-    }
-
-}
index aac36b8..e3dd66a 100644 (file)
@@ -454,4 +454,104 @@ class Kronolith_Application extends Horde_Registry_Application
         }
     }
 
+    /* Sidebar method. */
+
+    /**
+     * Add node(s) to the sidebar tree.
+     *
+     * @param Horde_Tree_Base $tree  Tree object.
+     * @param string $parent         The current parent element.
+     * @param array $params          Additional parameters.
+     *
+     * @throws Horde_Exception
+     */
+    public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
+                                  array $params = array())
+    {
+        switch ($params['id']) {
+        case 'alarms':
+            try {
+                $alarms = Kronolith::listAlarms(new Horde_Date($_SERVER['REQUEST_TIME']), $GLOBALS['display_calendars'], true);
+            } catch (Kronolith_Exception $e) {
+                return;
+            }
+
+            $alarmCount = 0;
+            $horde_alarm = $GLOBALS['injector']->getInstance('Horde_Alarm');
+
+            foreach ($alarms as $calId => $calAlarms) {
+                foreach ($calAlarms as $event) {
+                    if ($horde_alarm->isSnoozed($event->uid, $GLOBALS['registry']->getAuth())) {
+                        continue;
+                    }
+                    ++$alarmCount;
+                    $tree->addNode(
+                        $parent . $calId . $event->id,
+                        $parent,
+                        htmlspecialchars($event->getTitle(), ENT_COMPAT, $GLOBALS['registry']->getCharset()),
+                        1,
+                        false,
+                        array(
+                            'icon' => Horde_Themes::img('alarm.png'),
+                            'url' => $event->getViewUrl()
+                        )
+                    );
+                }
+            }
+
+            if ($GLOBALS['registry']->get('url', $parent)) {
+                $purl = $GLOBALS['registry']->get('url', $parent);
+            } elseif ($GLOBALS['registry']->get('status', $parent) == 'heading' ||
+                      !$GLOBALS['registry']->get('webroot')) {
+                $purl = null;
+            } else {
+                $purl = Horde::url($GLOBALS['registry']->getInitialPage($parent));
+            }
+
+            $pnode_name = $GLOBALS['registry']->get('name', $parent);
+            if ($alarmCount) {
+                $pnode_name = '<strong>' . $pnode_name . '</strong>';
+            }
+
+            $tree->addNode(
+                $parent,
+                $GLOBALS['registry']->get('menu_parent', $parent),
+                $pnode_name,
+                0,
+                false,
+                array(
+                    'icon' => $GLOBALS['registry']->get('icon', $parent),
+                    'url' => $purl,
+                )
+            );
+            break;
+
+        case 'menu':
+            $menus = array(
+                array('new', _("New Event"), 'new.png', Horde::applicationUrl('new.php')),
+                array('day', _("Day"), 'dayview.png', Horde::applicationUrl('day.php')),
+                array('work', _("Work Week"), 'workweekview.png', Horde::applicationUrl('workweek.php')),
+                array('week', _("Week"), 'weekview.png', Horde::applicationUrl('week.php')),
+                array('month', _("Month"), 'monthview.png', Horde::applicationUrl('month.php')),
+                array('year', _("Year"), 'yearview.png', Horde::applicationUrl('year.php')),
+                array('search', _("Search"), 'search.png', Horde::applicationUrl('search.php'))
+            );
+
+            foreach ($menus as $menu) {
+                $tree->addNode(
+                    $parent . $menu[0],
+                    $parent,
+                    $menu[1],
+                    1,
+                    false,
+                    array(
+                        'icon' => Horde_Themes::img($menu[2]),
+                        'url' => $menu[3]
+                    )
+                );
+            }
+            break;
+        }
+    }
+
 }
diff --git a/kronolith/lib/Block/tree_alarms.php b/kronolith/lib/Block/tree_alarms.php
deleted file mode 100644 (file)
index 42b344c..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-
-$block_name = _("Menu Alarms");
-$block_type = 'tree';
-
-/**
- * @package Horde_Block
- */
-class Horde_Block_kronolith_tree_alarms extends Horde_Block
-{
-    protected $_app = 'kronolith';
-
-    protected function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        $horde_alarm = $GLOBALS['injector']->getInstance('Horde_Alarm');
-
-        $alarmCount = 0;
-        try {
-            $alarms = Kronolith::listAlarms(new Horde_Date($_SERVER['REQUEST_TIME']),
-                                            $GLOBALS['display_calendars'],
-                                            true);
-        } catch (Exception $e) {
-            return;
-        }
-        foreach ($alarms as $calId => $calAlarms) {
-            foreach ($calAlarms as $event) {
-                if ($horde_alarm->isSnoozed($event->uid, $GLOBALS['registry']->getAuth())) {
-                    continue;
-                }
-                $alarmCount++;
-                $tree->addNode(
-                    $parent . $calId . $event->id,
-                    $parent,
-                    htmlspecialchars($event->getTitle(), ENT_COMPAT, $GLOBALS['registry']->getCharset()),
-                    $indent + 1,
-                    false,
-                    array(
-                        'icon' => Horde_Themes::img('alarm.png'),
-                        'url' => $event->getViewUrl()
-                    )
-                );
-            }
-        }
-
-        if ($GLOBALS['registry']->get('url', $parent)) {
-            $purl = $GLOBALS['registry']->get('url', $parent);
-        } elseif ($GLOBALS['registry']->get('status', $parent) == 'heading' ||
-                  !$GLOBALS['registry']->get('webroot')) {
-            $purl = null;
-        } else {
-            $purl = Horde::url($GLOBALS['registry']->getInitialPage($parent));
-        }
-
-        $pnode_name = $GLOBALS['registry']->get('name', $parent);
-        if ($alarmCount) {
-            $pnode_name = '<strong>' . $pnode_name . '</strong>';
-        }
-
-        $tree->addNode(
-            $parent,
-            $GLOBALS['registry']->get('menu_parent', $parent),
-            $pnode_name,
-            $indent,
-            false,
-            array(
-                'icon' => $GLOBALS['registry']->get('icon', $parent),
-                'url' => $purl,
-            )
-        );
-    }
-
-}
diff --git a/kronolith/lib/Block/tree_menu.php b/kronolith/lib/Block/tree_menu.php
deleted file mode 100644 (file)
index 2319eed..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-$block_name = _("Menu List");
-$block_type = 'tree';
-
-/**
- * @package Horde_Block
- */
-class Horde_Block_kronolith_tree_menu extends Horde_Block
-{
-    protected $_app = 'kronolith';
-
-    protected function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        $menus = array(
-            array('new', _("New Event"), 'new.png', Horde::applicationUrl('new.php')),
-            array('day', _("Day"), 'dayview.png', Horde::applicationUrl('day.php')),
-            array('work', _("Work Week"), 'workweekview.png', Horde::applicationUrl('workweek.php')),
-            array('week', _("Week"), 'weekview.png', Horde::applicationUrl('week.php')),
-            array('month', _("Month"), 'monthview.png', Horde::applicationUrl('month.php')),
-            array('year', _("Year"), 'yearview.png', Horde::applicationUrl('year.php')),
-            array('search', _("Search"), 'search.png', Horde::applicationUrl('search.php'))
-        );
-
-        foreach ($menus as $menu) {
-            $tree->addNode(
-                $parent . $menu[0],
-                $parent,
-                $menu[1],
-                $indent + 1,
-                false,
-                array(
-                    'icon' => Horde_Themes::img($menu[2]),
-                    'url' => $menu[3]
-                )
-            );
-        }
-    }
-
-}
index a45754c..7bf71dc 100644 (file)
@@ -117,4 +117,66 @@ class Mnemo_Application extends Horde_Registry_Application
         return Mnemo::getMenu();
     }
 
+    /* Sidebar method. */
+
+    /**
+     * Add node(s) to the sidebar tree.
+     *
+     * @param Horde_Tree_Base $tree  Tree object.
+     * @param string $parent         The current parent element.
+     * @param array $params          Additional parameters.
+     *
+     * @throws Horde_Exception
+     */
+    public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
+                                  array $params = array())
+    {
+        $add = Horde::applicationUrl('memo.php')->add('actionID', 'add_memo');
+
+        $tree->addNode(
+            $parent . '__new',
+            $parent,
+            _("New Note"),
+            1,
+            false,
+            array(
+                'icon' => Horde_Themes::img('add.png'),
+                'url' => $add
+            )
+        );
+
+        foreach (Mnemo::listNotepads() as $name => $notepad) {
+            if ($notepad->get('owner') != $GLOBALS['registry']->getAuth() &&
+                !empty($GLOBALS['conf']['share']['hidden']) &&
+                !in_array($notepad->getName(), $GLOBALS['display_notepads'])) {
+
+                continue;
+            }
+
+            $tree->addNode(
+                $parent . $name . '__new',
+                $parent . '__new',
+                sprintf(_("in %s"), $notepad->get('name')),
+                2,
+                false,
+                array(
+                    'icon' => Horde_Themes::img('add.png'),
+                    'url' => $add->copy()->add('memolist', $name)
+                )
+            );
+        }
+
+        $tree->addNode(
+            $parent . '__search',
+            $parent,
+            _("Search"),
+            1,
+            false,
+            array(
+                'icon' => Horde_Themes::img('search.png'),
+                'url' => Horde::applicationUrl('search.php')
+            )
+        );
+    }
+
 }
diff --git a/mnemo/lib/Block/tree_menu.php b/mnemo/lib/Block/tree_menu.php
deleted file mode 100644 (file)
index 28b470f..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-$block_name = _("Menu List");
-$block_type = 'tree';
-
-/**
- *
- * @package Horde_Block
- */
-class Horde_Block_mnemo_tree_menu extends Horde_Block
-{
-    protected $_app = 'mnemo';
-
-    protected function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        $add = Horde::applicationUrl('memo.php')->add('actionID', 'add_memo');
-
-        $tree->addNode(
-            $parent . '__new',
-            $parent,
-            _("New Note"),
-            $indent + 1,
-            false,
-            array(
-                'icon' => Horde_Themes::img('add.png'),
-                'url' => $add
-            )
-        );
-
-        foreach (Mnemo::listNotepads() as $name => $notepad) {
-            if ($notepad->get('owner') != $GLOBALS['registry']->getAuth() &&
-                !empty($GLOBALS['conf']['share']['hidden']) &&
-                !in_array($notepad->getName(), $GLOBALS['display_notepads'])) {
-
-                continue;
-            }
-
-            $tree->addNode(
-                $parent . $name . '__new',
-                $parent . '__new',
-                sprintf(_("in %s"), $notepad->get('name')),
-                $indent + 2,
-                false,
-                array(
-                    'icon' => Horde_Themes::img('add.png'),
-                    'url' => $add->copy()->add('memolist', $name)
-                )
-            );
-        }
-
-        $tree->addNode(
-            $parent . '__search',
-            $parent,
-            _("Search"),
-            $indent + 1,
-            false,
-            array(
-                'icon' => Horde_Themes::img('search.png'),
-                'url' => Horde::applicationUrl('search.php')
-            )
-        );
-    }
-
-}
index 9823538..8f3bdfa 100644 (file)
@@ -281,4 +281,138 @@ class Nag_Application extends Horde_Registry_Application
         }
     }
 
+    /* Sidebar method. */
+
+    /**
+     * Add node(s) to the sidebar tree.
+     *
+     * @param Horde_Tree_Base $tree  Tree object.
+     * @param string $parent         The current parent element.
+     * @param array $params          Additional parameters.
+     *
+     * @throws Horde_Exception
+     */
+    public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
+                                  array $params = array())
+    {
+        global $registry;
+
+        switch ($params['id']) {
+        case 'alarms':
+            // Get any alarms in the next hour.
+            $now = time();
+            $alarms = Nag::listAlarms($now);
+            if ($alarms instanceof PEAR_Error) {
+                return;
+            }
+
+            $alarmCount = 0;
+            $horde_alarm = $GLOBALS['injector']->getInstance('Horde_Alarm');
+
+            foreach ($alarms as $taskId => $task) {
+                if ($horde_alarm->isSnoozed($task->uid, $registry->getAuth())) {
+                    continue;
+                }
+                ++$alarmCount;
+
+                $differential = $task->due - $now;
+                $title = ($differential >= 60)
+                    ? sprintf(_("%s is due in %s"), $task->name, Nag::secondsToString($differential))
+                    : sprintf(_("%s is due now."), $task->name);
+                $url = Horde::applicationUrl('view.php')->add(array(
+                    'task' => $task->id,
+                    'tasklist' => $task->tasklist
+                ));
+
+                $tree->addNode(
+                    $parent . $taskId,
+                    $parent,
+                    $task->name,
+                    1,
+                    false,
+                    array(
+                        'icon' => Horde_Themes::img('alarm.png'),
+                        'title' => $title,
+                        'url' => $url
+                    )
+                );
+            }
+
+            if ($registry->get('url', $parent)) {
+                $purl = $registry->get('url', $parent);
+            } elseif ($registry->get('status', $parent) == 'heading' ||
+                      !$registry->get('webroot')) {
+                $purl = null;
+            } else {
+                $purl = Horde::url($registry->getInitialPage($parent));
+            }
+
+            $pnode_name = $registry->get('name', $parent);
+            if ($alarmCount) {
+                $pnode_name = '<strong>' . $pnode_name . '</strong>';
+            }
+
+            $tree->addNode(
+                $parent,
+                $registry->get('menu_parent', $parent),
+                $pnode_name,
+                0,
+                false,
+                array(
+                    'icon' => strval($registry->get('icon', $parent)),
+                    'url' => $purl
+                )
+            );
+            break;
+
+        case 'menu':
+            $add = Horde::applicationUrl('task.php')->add('actionID', 'add_task');
+
+            $tree->addNode(
+                $parent . '__new',
+                $parent,
+                _("New Task"),
+                1,
+                false,
+                array(
+                    'icon' => Horde_Themes::img('add.png'),
+                    'url' => $add
+                )
+            );
+
+            foreach (Nag::listTasklists() as $name => $tasklist) {
+                if ($tasklist->get('owner') != $registry->getAuth() &&
+                    !empty($GLOBALS['conf']['share']['hidden']) &&
+                    !in_array($tasklist->getName(), $GLOBALS['display_tasklists'])) {
+                    continue;
+                }
+
+                $tree->addNode(
+                    $parent . $name . '__new',
+                    $parent . '__new',
+                    sprintf(_("in %s"), $tasklist->get('name')),
+                    2,
+                    false,
+                    array(
+                        'icon' => Horde_Themes::img('add.png'),
+                        'url' => $add->copy()->add('tasklist_id', $name)
+                    )
+                );
+            }
+
+            $tree->addNode(
+                $parent . '__search',
+                $parent,
+                _("Search"),
+                1,
+                false,
+                array(
+                    'icon' => Horde_Themes::img('search.png'),
+                    'url' => Horde::applicationUrl('search.php')
+                )
+            );
+            break;
+        }
+    }
+
 }
diff --git a/nag/lib/Block/tree_alarms.php b/nag/lib/Block/tree_alarms.php
deleted file mode 100644 (file)
index 239a648..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-<?php
-
-$block_name = _("Menu Alarms");
-$block_type = 'tree';
-
-/**
- * @package Horde_Block
- */
-class Horde_Block_nag_tree_alarms extends Horde_Block
-{
-    protected$_app = 'nag';
-
-    protected function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        $horde_alarm = $GLOBALS['injector']->getInstance('Horde_Alarm');
-
-        // Get any alarms in the next hour.
-        $now = time();
-        $alarms = Nag::listAlarms($now);
-        if (is_a($alarms, 'PEAR_Error')) {
-            return;
-        }
-
-        $alarmCount = 0;
-        foreach ($alarms as $taskId => $task) {
-            if ($horde_alarm->isSnoozed($task->uid, $GLOBALS['registry']->getAuth())) {
-                continue;
-            }
-            $alarmCount++;
-            $differential = $task->due - $now;
-            if ($differential >= 60) {
-                $title = sprintf(_("%s is due in %s"), $task->name, Nag::secondsToString($differential));
-            } else {
-                $title = sprintf(_("%s is due now."), $task->name);
-            }
-
-            $url = Horde_Util::addParameter(Horde::applicationUrl('view.php'),
-                                      array('task' => $task->id,
-                                            'tasklist' => $task->tasklist));
-            $tree->addNode(
-                $parent . $taskId,
-                $parent,
-                $task->name,
-                $indent + 1,
-                false,
-                array(
-                    'icon' => Horde_Themes::img('alarm.png'),
-                    'title' => $title,
-                    'url' => $url
-                )
-            );
-        }
-
-        if ($GLOBALS['registry']->get('url', $parent)) {
-            $purl = $GLOBALS['registry']->get('url', $parent);
-        } elseif ($GLOBALS['registry']->get('status', $parent) == 'heading' ||
-                  !$GLOBALS['registry']->get('webroot')) {
-            $purl = null;
-        } else {
-            $purl = Horde::url($GLOBALS['registry']->getInitialPage($parent));
-        }
-        $pnode_params = array(
-            'url' => $purl,
-            'icon' => (string)$GLOBALS['registry']->get('icon', $parent)
-        );
-        $pnode_name = $GLOBALS['registry']->get('name', $parent);
-        if ($alarmCount) {
-            $pnode_name = '<strong>' . $pnode_name . '</strong>';
-        }
-
-        $tree->addNode($parent,
-                       $GLOBALS['registry']->get('menu_parent', $parent),
-                       $pnode_name,
-                       $indent,
-                       false,
-                       $pnode_params);
-    }
-
-}
diff --git a/nag/lib/Block/tree_menu.php b/nag/lib/Block/tree_menu.php
deleted file mode 100644 (file)
index 24840bb..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-$block_name = _("Menu List");
-$block_type = 'tree';
-
-/**
- * @package Horde_Block
- */
-class Horde_Block_nag_tree_menu extends Horde_Block
-{
-    protected $_app = 'nag';
-
-    protected function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        $add = Horde::applicationUrl('task.php')->add('actionID', 'add_task');
-
-        $tree->addNode(
-            $parent . '__new',
-            $parent,
-            _("New Task"),
-            $indent + 1,
-            false,
-            array(
-                'icon' => Horde_Themes::img('add.png'),
-                'url' => $add
-            )
-        );
-
-        foreach (Nag::listTasklists() as $name => $tasklist) {
-            if ($tasklist->get('owner') != $GLOBALS['registry']->getAuth() &&
-                !empty($GLOBALS['conf']['share']['hidden']) &&
-                !in_array($tasklist->getName(), $GLOBALS['display_tasklists'])) {
-                continue;
-            }
-            $tree->addNode(
-                $parent . $name . '__new',
-                $parent . '__new',
-                sprintf(_("in %s"), $tasklist->get('name')),
-                $indent + 2,
-                false,
-                array(
-                    'icon' => Horde_Themes::img('add.png'),
-                    'url' => $add->copy()->add('tasklist_id', $name)
-                )
-            );
-        }
-
-        $tree->addNode(
-            $parent . '__search',
-            $parent,
-            _("Search"),
-            $indent + 1,
-            false,
-            array(
-                'icon' => Horde_Themes::img('search.png'),
-                'url' => Horde::applicationUrl('search.php')
-            )
-        );
-    }
-
-}
index 5e9b049..a1a8f67 100644 (file)
@@ -14,7 +14,7 @@
 require_once dirname(__FILE__) . '/lib/base.php';
 
 // Instantiate the blocks objects.
-$blocks = &Horde_Block_Collection::singleton('news_layout', array('news'));
+$blocks = &Horde_Block_Collection::singleton(array('news'));
 $layout = &Horde_Block_Layout_Manager::singleton('news_layout', $blocks, unserialize($prefs->getValue('news_layout')));
 
 // Handle requested actions.
index 12129ba..049785d 100644 (file)
@@ -88,4 +88,64 @@ class Trean_Application extends Horde_Registry_Application
     {
         return Trean::getMenu();
     }
+
+    /* Sidebar method. */
+
+    /**
+     * Add node(s) to the sidebar tree.
+     *
+     * @param Horde_Tree_Base $tree  Tree object.
+     * @param string $parent         The current parent element.
+     * @param array $params          Additional parameters.
+     *
+     * @throws Horde_Exception
+     */
+    public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
+                                  array $params = array())
+    {
+        $tree->addNode(
+            $parent . '__new',
+            $parent,
+            _("Add"),
+            1,
+            false,
+            array(
+                'icon' => Horde_Themes::img('add.png'),
+                'url' => Horde::applicationUrl('add.php')
+            )
+        );
+
+        $tree->addNode(
+            $parent . '__search',
+            $parent,
+            _("Search"),
+            1,
+            false,
+            array(
+                'icon' => Horde_Themes::img('search.png'),
+                'url' => Horde::applicationUrl('search.php')
+            )
+        );
+
+        $folders = Trean::listFolders();
+        if (!($folders instanceof PEAR_Error)) {
+            $browse = Horde::applicationUrl('browse.php');
+
+            foreach ($folders as $folder) {
+                $parent_id = $folder->getParent();
+                $tree->addNode(
+                    $parent . $folder->getId(),
+                    $parent . $parent_id,
+                    $folder->get('name'),
+                    substr_count($folder->getName(), ':') + 1,
+                    false,
+                    array(
+                        'icon' => Horde_Themes::img('tree/folder.png'),
+                        'url' => $browse->copy()->add('f', $folder->getId())
+                    )
+                );
+            }
+        }
+    }
+
 }
diff --git a/trean/lib/Block/tree_menu.php b/trean/lib/Block/tree_menu.php
deleted file mode 100644 (file)
index 11e2dfb..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-$block_name = _("Menu List");
-$block_type = 'tree';
-
-/**
- */
-class Horde_Block_trean_tree_menu extends Horde_Block
-{
-    protected $_app = 'trean';
-
-    protected function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        $tree->addNode(
-            $parent . '__new',
-            $parent,
-            _("Add"),
-            $indent + 1,
-            false,
-            array(
-                'icon' => Horde_Themes::img('add.png'),
-                'url' => Horde::applicationUrl('add.php')
-            )
-        );
-
-        $tree->addNode(
-            $parent . '__search',
-            $parent,
-            _("Search"),
-            $indent + 1,
-            false,
-            array(
-                'icon' => Horde_Themes::img('search.png'),
-                'url' => Horde::applicationUrl('search.php')
-            )
-        );
-
-        $folders = Trean::listFolders();
-        if ($folders instanceof PEAR_Error) {
-            $browse = Horde::applicationUrl('browse.php');
-
-            foreach ($folders as $folder) {
-                $parent_id = $folder->getParent();
-                $tree->addNode(
-                    $parent . $folder->getId(),
-                    $parent . $parent_id,
-                    $folder->get('name'),
-                    $indent + substr_count($folder->getName(), ':') + 1,
-                    false,
-                    array(
-                        'icon' => Horde_Themes::img('tree/folder.png'),
-                        'url' => $browse->copy()->add('f', $folder->getId())
-                    )
-                );
-            }
-        }
-    }
-
-}
index efa52a4..73b3bd3 100644 (file)
@@ -455,4 +455,80 @@ class Turba_Application extends Horde_Registry_Application
         }
     }
 
+    /* Sidebar method. */
+
+    /**
+     * Add node(s) to the sidebar tree.
+     *
+     * @param Horde_Tree_Base $tree  Tree object.
+     * @param string $parent         The current parent element.
+     * @param array $params          Additional parameters.
+     *
+     * @throws Horde_Exception
+     */
+    public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
+                                  array $params = array())
+    {
+        $add = Horde::applicationUrl('add.php');
+        $browse = Horde::applicationUrl('browse.php');
+
+        if ($GLOBALS['addSources']) {
+            $newimg = Horde_Themes::img('menu/new.png');
+
+            $tree->addNode(
+                $parent . '__new',
+                $parent,
+                _("New Contact"),
+                1,
+                false,
+                array(
+                    'icon' => $newimg,
+                    'url' => $add
+                )
+            );
+
+            foreach ($GLOBALS['addSources'] as $addressbook => $config) {
+                $tree->addNode(
+                    $parent . $addressbook . '__new',
+                    $parent . '__new',
+                    sprintf(_("in %s"), $config['title']),
+                    2,
+                    false,
+                    array(
+                        'icon' => $newimg,
+                        'url' => $add->copy()->add('source', $addressbook)
+                    )
+                );
+            }
+        }
+
+        foreach (Turba::getAddressBooks() as $addressbook => $config) {
+            if (!empty($config['browse'])) {
+                $tree->addNode(
+                    $parent . $addressbook,
+                    $parent,
+                    $config['title'],
+                    1,
+                    false,
+                    array(
+                        'icon' => Horde_Themes::img('menu/browse.png'),
+                        'url' => $browse->copy()->add('source', $addressbook)
+                    )
+                );
+            }
+        }
+
+        $tree->addNode(
+            $parent . '__search',
+            $parent,
+            _("Search"),
+            1,
+            false,
+            array(
+                'icon' => Horde_Themes::img('search.png'),
+                'url' => Horde::applicationUrl('search.php')
+            )
+        );
+    }
+
 }
diff --git a/turba/lib/Block/tree_menu.php b/turba/lib/Block/tree_menu.php
deleted file mode 100644 (file)
index 1054084..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-$block_name = _("Menu List");
-$block_type = 'tree';
-
-/**
- * @package Horde_Block
- */
-class Horde_Block_turba_tree_menu extends Horde_Block
-{
-    protected $_app = 'turba';
-
-    protected function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        $browse = Horde::applicationUrl('browse.php');
-        $add = Horde::applicationUrl('add.php');
-
-        if ($GLOBALS['addSources']) {
-            $newimg = Horde_Themes::img('menu/new.png');
-
-            $tree->addNode(
-                $parent . '__new',
-                $parent,
-                _("New Contact"),
-                $indent + 1,
-                false,
-                array(
-                    'icon' => $newimg,
-                    'url' => $add
-                )
-            );
-
-            foreach ($GLOBALS['addSources'] as $addressbook => $config) {
-                $tree->addNode(
-                    $parent . $addressbook . '__new',
-                    $parent . '__new',
-                    sprintf(_("in %s"), $config['title']),
-                    $indent + 2,
-                    false,
-                    array(
-                        'icon' => $newimg,
-                        'url' => $add->copy()->add('source', $addressbook)
-                    )
-                );
-            }
-        }
-
-        foreach (Turba::getAddressBooks() as $addressbook => $config) {
-            if (!empty($config['browse'])) {
-                $tree->addNode(
-                    $parent . $addressbook,
-                    $parent,
-                    $config['title'],
-                    $indent + 1,
-                    false,
-                    array(
-                        'icon' => Horde_Themes::img('menu/browse.png'),
-                        'url' => $browse->copy()->add('source', $addressbook)
-                    )
-                );
-            }
-        }
-
-        $tree->addNode(
-            $parent . '__search',
-            $parent,
-            _("Search"),
-            $indent + 1,
-            false,
-            array(
-                'icon' => Horde_Themes::img('search.png'),
-                'url' => Horde::applicationUrl('search.php')
-            )
-        );
-    }
-
-}
index dda5efb..ceb8d49 100644 (file)
@@ -192,4 +192,43 @@ class Whups_Application extends Horde_Registry_Application
         return $updated;
     }
 
+    /* Sidebar method. */
+
+    /**
+     * Add node(s) to the sidebar tree.
+     *
+     * @param Horde_Tree_Base $tree  Tree object.
+     * @param string $parent         The current parent element.
+     * @param array $params          Additional parameters.
+     *
+     * @throws Horde_Exception
+     */
+    public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
+                                  array $params = array())
+    {
+        $tree->addNode(
+            $parent . '__new',
+            $parent,
+            _("New Ticket"),
+            1,
+            false,
+            array(
+                'icon' => Horde_Themes::img('create.png'),
+                'url' => Horde::applicationUrl('ticket/create.php')
+            )
+        );
+
+        $tree->addNode(
+            $parent . '__search',
+            $parent,
+            _("Search"),
+            1,
+            false,
+            array(
+                'icon' => Horde_Themes::img('search.png'),
+                'url' => Horde::applicationUrl('search.php')
+            )
+        );
+    }
+
 }
diff --git a/whups/lib/Block/tree_menu.php b/whups/lib/Block/tree_menu.php
deleted file mode 100644 (file)
index 49bbccc..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-$block_name = _("Menu List");
-$block_type = 'tree';
-
-/**
- * @package Horde_Block
- */
-class Horde_Block_whups_tree_menu extends Horde_Block
-{
-    protected $_app = 'whups';
-
-    protected function _buildTree(&$tree, $indent = 0, $parent = null)
-    {
-        $tree->addNode(
-            $parent . '__new',
-            $parent,
-            _("New Ticket"),
-            $indent + 1,
-            false,
-            array(
-                'icon' => Horde_Themes::img('create.png'),
-                'url' => Horde::applicationUrl('ticket/create.php')
-            )
-        );
-
-        $tree->addNode(
-            $parent . '__search',
-            $parent,
-            _("Search"),
-            $indent + 1,
-            false,
-            array(
-                'icon' => Horde_Themes::img('search.png'),
-                'url' => Horde::applicationUrl('search.php')
-            )
-        );
-    }
-
-}
index 9b182c3..a9f0ee5 100644 (file)
@@ -14,7 +14,7 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('whups');
 
 // Instantiate the blocks objects.
-$blocks = Horde_Block_Collection::singleton('mybugs', array('whups'));
+$blocks = Horde_Block_Collection::singleton(array('whups'));
 $layout = Horde_Block_Layout_Manager::singleton('mybugs', $blocks, @unserialize($prefs->getValue('mybugs_layout')));
 
 // Handle requested actions.