addNode() public method

Adds a node to the node tree array.
public addNode ( array $node )
$node array A hash with node properties: - id: (string) The unique node id. - parent: (string) The parent's unique node id. - label: (string) The text label for the node. - expanded: (boolean) Is this level expanded or not. - params: (array) Any other parameters to set (see addNodeParams() of the renderers for full details).
Esempio n. 1
0
 /**
  */
 public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
 {
     switch ($params['id']) {
         case 'menu':
             $tree->addNode(array('id' => $parent . '__add', 'parent' => $parent, 'label' => _("Enter Time"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('hermes.png'), 'url' => Horde::url('entry.php'))));
             $tree->addNode(array('id' => $parent . '__search', 'parent' => $parent, 'label' => _("Search Time"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('search.png'), 'url' => Horde::url('search.php'))));
             break;
         case 'stopwatch':
             $tree->addNode(array('id' => $parent . '__start', 'parent' => $parent, 'label' => _("Start Watch"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('timer-start.png'), 'url' => '#', 'onclick' => Horde::popupJs(Horde::url('start.php'), array('height' => 200, 'width' => 410)))));
             $timers = Hermes::listTimers();
             $entry = Horde::url('entry.php');
             foreach ($timers as $i => $timer) {
                 $tree->addNode(array('id' => $parent . '__timer_' . $i, 'parent' => $parent, 'label' => $timer['name'] . sprintf(" (%s)", $timer['elapsed']), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('timer-stop.png'), 'url' => $entry->add('timer', $timer['id']))));
             }
     }
 }
Esempio n. 2
0
 /**
  */
 public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
 {
     $icon = Horde_Themes::img('gollem.png');
     $url = Horde::url('manager.php');
     foreach (Gollem_Auth::getBackend() as $key => $val) {
         $tree->addNode(array('id' => $parent . $key, 'parent' => $parent, 'label' => $val['name'], 'expanded' => false, 'params' => array('icon' => $icon, 'url' => $url->add(array('backend_key' => $key)))));
     }
 }
Esempio n. 3
0
 /**
  */
 public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
 {
     $sourceroots = Chora::sourceroots();
     asort($sourceroots);
     foreach ($sourceroots as $key => $val) {
         $tree->addNode(array('id' => $parent . $key, 'parent' => $parent, 'label' => $val['name'], 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('tree/folder.png'), 'url' => Chora::url('browsedir', '', array('rt' => $key)))));
     }
 }
Esempio n. 4
0
 /**
  */
 public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
 {
     switch ($params['id']) {
         case 'menu':
             $menus = array(array('new', _("New Event"), 'new.png', Horde::url('new.php')), array('day', _("Day"), 'dayview.png', Horde::url('day.php')), array('work', _("Work Week"), 'workweekview.png', Horde::url('workweek.php')), array('week', _("Week"), 'weekview.png', Horde::url('week.php')), array('month', _("Month"), 'monthview.png', Horde::url('month.php')), array('year', _("Year"), 'yearview.png', Horde::url('year.php')));
             if (Kronolith::showAjaxView()) {
                 if (Kronolith::hasApiPermission('tasks')) {
                     $menus[] = array('tasks', _("Tasks"), 'tasks.png', $GLOBALS['registry']->get('webroot') . '#tasks');
                 }
                 $menus[] = array('agenda', _("Agenda"), 'agenda.png', $GLOBALS['registry']->get('webroot') . '#agenda');
             }
             // Dynamic view has no dedicated search page.
             if (!Kronolith::showAjaxView()) {
                 $menus[] = array('search', _("Search"), 'search.png', Horde::url('search.php'));
             }
             foreach ($menus as $menu) {
                 $tree->addNode(array('id' => $parent . $menu[0], 'parent' => $parent, 'label' => $menu[1], 'expanded' => false, 'params' => array('icon' => Horde_Themes::img($menu[2]), 'url' => $menu[3])));
             }
             break;
     }
 }
Esempio n. 5
0
 /**
  */
 public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
 {
     $add = Horde::url('add.php');
     $browse = Horde::url('browse.php');
     if ($GLOBALS['addSources']) {
         $newimg = Horde_Themes::img('menu/new.png');
         $tree->addNode(array('id' => $parent . '__new', 'parent' => $parent, 'label' => _("New Contact"), 'params' => array('icon' => $newimg, 'url' => $add)));
         foreach ($GLOBALS['addSources'] as $addressbook => $config) {
             $tree->addNode(array('id' => $parent . $addressbook . '__new', 'parent' => $parent . '__new', 'label' => sprintf(_("in %s"), $config['title']), 'expanded' => false, 'params' => array('icon' => $newimg, 'url' => $add->copy()->add('source', $addressbook))));
         }
     }
     foreach (Turba::getAddressBooks() as $addressbook => $config) {
         if (!empty($config['browse'])) {
             $tree->addNode(array('id' => $parent . $addressbook, 'parent' => $parent, 'label' => $config['title'], 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('menu/browse.png'), 'url' => $browse->copy()->add('source', $addressbook))));
         }
     }
     $tree->addNode(array('id' => $parent . '__search', 'parent' => $parent, 'label' => _("Search"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('search.png'), 'url' => Horde::url('search.php'))));
 }
Esempio n. 6
0
 /**
  */
 public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
 {
     $tree->addNode(array('id' => $parent . '__new', 'parent' => $parent, 'label' => _("New Ticket"), 'expanded' => false, 'params' => array('url' => Horde::url('ticket/create.php'))));
     $tree->addNode(array('id' => $parent . '__search', 'parent' => $parent, 'label' => _("Search"), 'expanded' => false, 'params' => array('url' => Horde::url('search.php'))));
 }
Esempio n. 7
0
 /**
  * Generates the topbar tree object.
  *
  * @return Horde_Tree_Renderer_Base  The topbar tree object.
  */
 public function getTree()
 {
     if ($this->_generated) {
         return $this->_tree;
     }
     global $injector, $prefs, $registry;
     $current = $registry->getApp();
     $isAdmin = $registry->isAdmin();
     $menu = array();
     foreach ($registry->listApps(array('active', 'admin', 'noadmin', 'heading', 'link', 'notoolbar', 'topbar'), true, null) 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 ($app != 'horde' && (in_array($params['status'], array('heading', 'link')) || in_array($params['status'], array('active', 'admin', 'noadmin', 'topbar')) && !($isAdmin && $params['status'] == 'noadmin') && $registry->hasPermission(!empty($params['app']) ? $params['app'] : $app, Horde_Perms::SHOW))) {
             $menu[$app] = $params;
         }
     }
     do {
         $children = array();
         foreach ($menu as $params) {
             if (isset($params['menu_parent'])) {
                 $children[$params['menu_parent']] = true;
             }
         }
         $found = false;
         foreach (array_keys($menu) as $key) {
             if ($menu[$key]['status'] == 'heading' && empty($children[$key])) {
                 unset($menu[$key]);
                 $found = true;
             }
         }
     } while ($found);
     /* Add the administration menu if the user is an admin or has any
      * admin permissions. */
     $perms = $injector->getInstance('Horde_Perms');
     $admin_item_count = 0;
     try {
         foreach ($registry->callByPackage('horde', 'admin_list') as $method => $val) {
             if ($isAdmin || $perms->hasPermission('horde:administration:' . $method, $registry->getAuth(), Horde_Perms::SHOW)) {
                 ++$admin_item_count;
                 $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 ($admin_item_count) {
         $menu['administration'] = array('name' => Horde_Core_Translation::t("Administration"), 'status' => 'heading', 'menu_parent' => 'settings');
     }
     $menu['settings'] = array('class' => 'horde-settings horde-icon-settings', 'name' => '', 'noarrow' => true, 'status' => 'active');
     /* Add preferences. */
     if ($registry->showService('prefs') && !$prefs instanceof Horde_Prefs_Session) {
         $menu['prefs'] = array('icon' => Horde_Themes::img('prefs.png'), 'menu_parent' => 'settings', 'name' => Horde_Core_Translation::t("Preferences"), 'status' => 'active', 'url' => $registry->getServiceLink('prefs', $current));
         /* Get a list of configurable applications. */
         $prefs_apps = $registry->listApps(array('active', 'admin'), true, Horde_Perms::READ);
         if (!empty($prefs_apps['horde'])) {
             $menu['prefs_' . 'horde'] = array('icon' => $registry->get('icon', 'horde'), 'menu_parent' => 'prefs', 'name' => Horde_Core_Translation::t("Global Preferences"), 'status' => 'active', 'url' => $registry->getServiceLink('prefs', 'horde'));
             unset($prefs_apps['horde']);
         }
         uasort($prefs_apps, array($this, '_sortByName'));
         foreach ($prefs_apps as $app => $params) {
             $menu['prefs_' . $app] = array('icon' => $registry->get('icon', $app), 'menu_parent' => 'prefs', 'name' => $params['name'], 'status' => 'active', 'url' => $registry->getServiceLink('prefs', $app));
         }
     }
     /* Add notification log. */
     $menu['growlerlog'] = array('icon' => 'info.png', 'menu_parent' => 'settings', 'name' => Horde_Core_Translation::t("Toggle Alerts Log"), 'status' => 'active', 'url' => 'javascript:void(HordeCore.Growler.toggleLog());');
     /* Add problem link. */
     if ($registry->showService('problem') && ($problem_link = $registry->getServiceLink('problem', $current))) {
         $menu['problem_' . $current] = array('icon' => 'problem.png', 'menu_parent' => 'settings', 'name' => Horde_Core_Translation::t("Problem"), 'status' => 'active', 'url' => $problem_link);
     }
     /* Add help link. */
     if ($registry->showService('help') && ($help_link = $registry->getServiceLink('help', $current))) {
         $menu['help_' . $current] = array('icon' => 'help_index.png', 'menu_parent' => 'settings', 'name' => Horde_Core_Translation::t("Help"), 'onclick' => Horde::popupJs($help_link, array('urlencode' => true)) . 'return false;', 'status' => 'active', 'target' => 'help', 'url' => $help_link);
     }
     foreach ($menu as $app => $params) {
         switch ($params['status']) {
             case 'topbar':
                 try {
                     $registry->callAppMethod($params['app'], 'topbarCreate', array('args' => array($this->_tree, empty($params['menu_parent']) ? null : $params['menu_parent'], isset($params['topbar_params']) ? $params['topbar_params'] : array())));
                 } catch (Horde_Exception_PushApp $e) {
                     // Ignore
                 } catch (Horde_Exception $e) {
                     Horde::log($e, 'ERR');
                 }
                 break;
             default:
                 /* Need to run the name through Horde's gettext since the
                  * user's locale may not have been loaded when registry.php was
                  * parsed, and the translations of the application names are
                  * not in the Core package. */
                 $name = strlen($params['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 = '';
                 } else {
                     $url = Horde::url($registry->getInitialPage($app), false, array('app' => $app));
                 }
                 $this->_tree->addNode(array('id' => $app, 'parent' => empty($params['menu_parent']) ? null : $params['menu_parent'], 'label' => $name, 'expanded' => false, 'params' => array('icon' => strval(isset($params['icon']) ? $params['icon'] : $registry->get('icon', $app)), 'class' => isset($params['class']) ? $params['class'] : ($app == $current ? 'horde-point-center-active' : 'horde-point-center'), 'noarrow' => !empty($params['noarrow']), 'onclick' => isset($params['onclick']) ? $params['onclick'] : null, 'target' => isset($params['target']) ? $params['target'] : null, 'url' => $url, 'active' => $app == $current)));
         }
     }
     $this->_generated = true;
     return $this->_tree;
 }
Esempio n. 8
0
 /**
  */
 public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
 {
     global $registry;
     switch ($params['id']) {
         case 'menu':
             $add = Horde::url('task.php', true)->add('actionID', 'add_task');
             $tree->addNode(array('id' => $parent . '__new', 'parent' => $parent, 'label' => _("New Task"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('add.png'), 'url' => $add)));
             $user = $registry->getAuth();
             foreach (Nag::listTasklists(false, Horde_Perms::SHOW, false) as $name => $tasklist) {
                 if (!$tasklist->hasPermission($user, Horde_Perms::EDIT)) {
                     continue;
                 }
                 $tree->addNode(array('id' => $parent . $name . '__new', 'parent' => $parent . '__new', 'label' => sprintf(_("in %s"), Nag::getLabel($tasklist)), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('add.png'), 'url' => $add->copy()->add('tasklist_id', $name))));
             }
             $tree->addNode(array('id' => $parent . '__search', 'parent' => $parent, 'label' => _("Search"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('search.png'), 'url' => Horde::url('search.php'))));
             break;
     }
 }
Esempio n. 9
0
 /**
  */
 public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
 {
     global $registry;
     $add = Horde::url('memo.php', true)->add('actionID', 'add_memo');
     $tree->addNode(array('id' => $parent . '__new', 'parent' => $parent, 'label' => _("New Note"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('add.png'), 'url' => $add)));
     $user = $registry->getAuth();
     foreach (Mnemo::listNotepads(false, Horde_Perms::SHOW) as $name => $notepad) {
         if (!$notepad->hasPermission($user, Horde_Perms::EDIT)) {
             continue;
         }
         $tree->addNode(array('id' => $parent . $name . '__new', 'parent' => $parent . '__new', 'label' => sprintf(_("in %s"), Mnemo::getLabel($notepad)), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('add.png'), 'url' => $add->copy()->add('memolist', $name))));
     }
     $tree->addNode(array('id' => $parent . '__search', 'parent' => $parent, 'label' => _("Search"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('search.png'), 'url' => Horde::url('search.php'))));
 }
Esempio n. 10
0
 /**
  */
 public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
 {
     if (!Jonah::checkPermissions('jonah:news', Horde_Perms::EDIT)) {
         return;
     }
     $url = Horde::url('stories/');
     $driver = $GLOBALS['injector']->getInstance('Jonah_Driver');
     try {
         $channels = $driver->getChannels('internal');
     } catch (Jonah_Exception $e) {
         return;
     }
     $channels = Jonah::checkPermissions('channels', Horde_Perms::SHOW, $channels);
     $story_img = Horde_Themes::img('editstory.png');
     foreach ($channels as $channel) {
         $tree->addNode(array('id' => $parent . $channel['channel_id'], 'parent' => $parent, 'label' => $channel['channel_name'], 'expanded' => false, 'params' => array('icon' => $story_img, 'url' => $url->add('channel_id', $channel['channel_id']))));
     }
 }
Esempio n. 11
0
 /**
  */
 public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
 {
     global $injector, $registry;
     if (IMP_Compose::canCompose()) {
         $clink = new IMP_Compose_Link();
         $tree->addNode(array('id' => strval($parent) . 'compose', 'parent' => $parent, 'label' => _("New Message"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('compose.png'), 'url' => $clink->link()->setRaw(true))));
     }
     $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
     if ($imp_imap->access(IMP_Imap::ACCESS_SEARCH)) {
         $onclick = null;
         switch ($registry->getView()) {
             case $registry::VIEW_DYNAMIC:
                 $url = Horde::url('dynamic.php', true)->add('page', 'mailbox')->setAnchor('search');
                 $onclick = 'if (window.DimpBase) { DimpBase.go(\'search\') }';
                 break;
             default:
                 $url = IMP_Basic_Search::url(array('full' => true));
                 break;
         }
         $tree->addNode(array('id' => strval($parent) . 'search', 'parent' => $parent, 'label' => _("Search"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('search.png'), 'url' => $url, 'onclick' => $onclick)));
     }
 }