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.
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))
+ )
+ );
+ }
+ }
+ }
+
}
+++ /dev/null
-<?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))
- )
- );
- }
- }
- }
-
-}
}
/**
- * 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.
return '';
}
- /**
- * Returns this block's content.
- */
- protected function _buildTree($tree, $indent = 0, $parent = null)
- {
- }
-
}
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.
*
/**
* 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];
/**
* 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];
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;
}
}
<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="/">
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':
--- /dev/null
+<?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;
+ }
+
+}
// 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.
/**
<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" />
<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" />
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))
+ )
+ );
+ }
+ }
+ }
+
}
+++ /dev/null
-<?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))
- )
- );
- }
- }
- }
-
-}
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;
+ }
+ }
+
}
+++ /dev/null
-<?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')));
- }
-
-}
+++ /dev/null
-<?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)));
- }
- }
- }
-
-}
* 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.
*
*
'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',
);
);
$this->applications['turba-menu'] = array(
- 'status' => 'block',
+ 'status' => 'sidebar',
'app' => 'turba',
- 'blockname' => 'tree_menu',
'menu_parent' => 'turba',
);
);
$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',
);
);
$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',
);
);
$this->applications['mnemo-menu'] = array(
- 'status' => 'block',
+ 'status' => 'sidebar',
'app' => 'mnemo',
- 'blockname' => 'tree_menu',
'menu_parent' => 'mnemo',
);
);
$this->applications['trean-menu'] = array(
- 'status' => 'block',
+ 'status' => 'sidebar',
'app' => 'trean',
- 'blockname' => 'tree_menu',
'menu_parent' => 'trean',
);
);
$this->applications['chora-menu'] = array(
- 'status' => 'block',
+ 'status' => 'sidebar',
'app' => 'chora',
- 'blockname' => 'tree_menu',
'menu_parent' => 'chora',
);
);
$this->applications['whups-menu'] = array(
- 'status' => 'block',
+ 'status' => 'sidebar',
'app' => 'whups',
- 'blockname' => 'tree_menu',
'menu_parent' => 'whups',
);
);
$this->applications['jonah-menu'] = array(
- 'status' => 'block',
+ 'status' => 'sidebar',
'app' => 'jonah',
- 'blockname' => 'tree_menu',
'menu_parent' => 'jonah',
);
);
$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',
);
);
$this->applications['gollem-menu'] = array(
- 'status' => 'block',
+ 'status' => 'sidebar',
'app' => 'gollem',
- 'blockname' => 'tree_menu',
'menu_parent' => 'gollem',
);
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
===================================
*/
public function sidebarUpdate()
{
- $sidebar = new Horde_Ui_Sidebar();
- return $sidebar->getTree()->renderNodeDefinitions();
+ return $sidebar->getInstance('Horde_Core_Sidebar')->getTree()->renderNodeDefinitions();
}
}
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()
{
'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')
)
);
$admin['activesync'] = array(
'link' => '%application%/admin/activesync.php',
'name' => _("ActiveSync Devices"),
- 'icon' => 'mobile.png'
+ 'icon' => Horde_Themes::img('mobile.png')
);
}
+++ /dev/null
-<?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;
- }
-
-}
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();
/* 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');
$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) {}
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. */
/**
+++ /dev/null
-<?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
- );
- }
-
-}
* 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?
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(
'lines_base' => true,
'nosession' => true
));
- $indent = 0;
$parent = null;
}
strval($parent) . $val->value,
($val->level) ? strval($parent) . $val->parent : $parent,
$label,
- $indent + $val->level,
+ $val->level,
$is_open,
$params,
$after,
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'])
+ )
+ );
+ }
+ }
+
}
+++ /dev/null
-<?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'])
- )
- );
- }
- }
-
-}
}
}
+ /* 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;
+ }
+ }
+
}
+++ /dev/null
-<?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,
- )
- );
- }
-
-}
+++ /dev/null
-<?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]
- )
- );
- }
- }
-
-}
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')
+ )
+ );
+ }
+
}
+++ /dev/null
-<?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')
- )
- );
- }
-
-}
}
}
+ /* 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;
+ }
+ }
+
}
+++ /dev/null
-<?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);
- }
-
-}
+++ /dev/null
-<?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')
- )
- );
- }
-
-}
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.
{
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())
+ )
+ );
+ }
+ }
+ }
+
}
+++ /dev/null
-<?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())
- )
- );
- }
- }
- }
-
-}
}
}
+ /* 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')
+ )
+ );
+ }
+
}
+++ /dev/null
-<?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')
- )
- );
- }
-
-}
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')
+ )
+ );
+ }
+
}
+++ /dev/null
-<?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')
- )
- );
- }
-
-}
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.