/** */ protected function _initPages() { global $injector; $this->view->list = array(); if ($GLOBALS['browse_source_count']) { foreach (Turba::getAddressBooks() as $key => $val) { if (!empty($val['browse'])) { try { $driver = $injector->getInstance('Turba_Factory_Driver')->create($key); } catch (Turba_Exception $e) { continue; } try { $contacts = $driver->search(array(), null, 'AND', array('__key', 'name')); $contacts->reset(); } catch (Turba_Exception $e) { continue; } $url = new Horde_Core_Smartmobile_Url(); $url->add('source', $key); $url->setAnchor('entry'); $tmp = array(); while ($contact = $contacts->next()) { $name = Turba::formatName($contact); $tmp[] = array('group' => $contact->isGroup(), 'name' => strlen($name) ? $name : '[' . _("No Name") . ']', 'url' => strval($url->add('key', $contact->getValue('__key')))); } $this->view->list[$val['title']] = $tmp; } } } }
public function testBaseUrlWithParametersWithoutAnchor() { $base = new Horde_Url('test'); $base->add('foo', 0); $url = new Horde_Core_Smartmobile_Url($base); $url->add(array('foo' => 1, 'bar' => 2)); $this->assertEquals('test?foo=1&bar=2', (string) $url); }
/** */ protected function _initPages() { global $injector, $session; $this->view->list = array(); $filters = Ingo_Storage_FilterIterator_Match::create($injector->getInstance('Ingo_Factory_Storage')->create(), $session->get('ingo', 'script_categories')); foreach ($filters as $val) { // Skip disabled rules. if ($val->disable) { continue; } switch (get_class($val)) { case 'Ingo_Rule_System_Blacklist': $img = 'blacklist.png'; break; case 'Ingo_Rule_System_Whitelist': $img = 'whitelist.png'; break; case 'Ingo_Rule_System_Vacation': $img = 'vacation.png'; break; case 'Ingo_Rule_System_Forward': $img = 'forward.png'; break; case 'Ingo_Rule_System_Spam': $img = 'spam.png'; break; default: $img = null; break; } $url = new Horde_Core_Smartmobile_Url(); $url->add('uid', $val->uid); $url->setAnchor('rule'); $this->view->list[] = array('img' => is_null($img) ? null : Horde_Themes_Image::tag($img, array('attr' => array('class' => 'ui-li-icon'))), 'name' => $val->name, 'url' => $url); } }
/** */ protected function _initPages() { global $injector, $session; $this->view->list = array(); $filters = $injector->getInstance('Ingo_Factory_Storage')->create()->retrieve(Ingo_Storage::ACTION_FILTERS)->getFilterList(); $s_categories = $session->get('ingo', 'script_categories'); foreach ($filters as $key => $val) { // For now, skip non-display categories and disabled rules. if (!empty($val['disable']) || !in_array($val['action'], $s_categories)) { continue; } switch ($val['action']) { case Ingo_Storage::ACTION_BLACKLIST: $img = 'blacklist.png'; $name = _("Blacklist"); break; case Ingo_Storage::ACTION_WHITELIST: $img = 'whitelist.png'; $name = _("Whitelist"); break; case Ingo_Storage::ACTION_VACATION: $img = 'vacation.png'; $name = _("Vacation"); break; case Ingo_Storage::ACTION_FORWARD: $img = 'forward.png'; $name = _("Forward"); break; case Ingo_Storage::ACTION_SPAM: $img = 'spam.png'; $name = _("Spam Filter"); break; default: $img = null; $name = $val['name']; break; } $url = new Horde_Core_Smartmobile_Url(); $url->add('rulenum', $key); $url->setAnchor('rule'); $this->view->list[] = array('img' => is_null($img) ? null : Horde_Themes_Image::tag($img, array('attr' => array('class' => 'ui-li-icon'))), 'name' => $name, 'url' => $url); } }
/** * Creates a Horde_Tree representation of the current tree. * * @param string|Horde_Tree $name Either the tree name, or a Horde_Tree * object to add nodes to. * @param array $opts Additional options: * - basename: (boolean) Use raw basename instead of abbreviated label? * DEFAULT: false * - checkbox: (boolean) Display checkboxes? * DEFAULT: false * - editvfolder: (boolean) Display vfolder edit links? * DEFAULT: false * - iterator: (Iterator) Tree iterator to use. * DEFAULT: Base iterator. * - open: (boolean) Force child mailboxes to this status. * DEFAULT: null * - parent: (string) The parent object of the current level. * DEFAULT: null (add to base level) * - poll_info: (boolean) Include poll information in output? * DEFAULT: false * - render_params: (array) List of params to pass to renderer if * auto-creating. * DEFAULT: 'alternate', 'lines', and 'lines_base' * are passed in with true values. * - render_type: (string) The renderer name. * DEFAULT: Javascript * * @return Horde_Tree The tree object. */ public function createTree($name, array $opts = array()) { global $injector, $registry; $opts = array_merge(array('parent' => null, 'render_params' => array(), 'render_type' => 'Javascript'), $opts); $view = $registry->getView(); if ($name instanceof Horde_Tree_Renderer_Base) { $tree = $name; $parent = $opts['parent']; } else { $tree = $injector->getInstance('Horde_Core_Factory_Tree')->create($name, $opts['render_type'], array_merge(array('alternate' => true, 'lines' => true, 'lines_base' => true, 'nosession' => true), $opts['render_params'])); $parent = null; } $iterator = empty($opts['iterator']) ? new IMP_Ftree_IteratorFilter($this) : $opts['iterator']; foreach ($iterator as $val) { $after = ''; $elt_parent = null; $mbox_ob = $val->mbox_ob; $params = array(); switch ($opts['render_type']) { case 'IMP_Tree_Flist': if ($mbox_ob->vfolder_container) { continue 2; } $is_open = true; $label = $params['orig_label'] = empty($opts['basename']) ? $mbox_ob->abbrev_label : $mbox_ob->basename; break; case 'IMP_Tree_Jquerymobile': $is_open = true; $label = $mbox_ob->display_html; $icon = $mbox_ob->icon; $params['icon'] = $icon->icon; $params['special'] = $mbox_ob->inbox || $mbox_ob->special; $params['class'] = 'imp-folder'; $params['urlattributes'] = array('id' => 'imp-mailbox-' . $mbox_ob->form_to); /* Force to flat tree so that non-polled parents don't cause * polled children to be skipped by renderer (see Bug * #11238). */ $elt_parent = $this[self::BASE_ELT]; break; case 'Javascript': $is_open = $val->open; $label = empty($opts['basename']) ? htmlspecialchars($mbox_ob->abbrev_label) : htmlspecialchars($mbox_ob->basename); $icon = $mbox_ob->icon; $params['icon'] = $icon->icon; $params['iconopen'] = $icon->iconopen; break; } if (!empty($opts['poll_info']) && $val->polled) { $poll_info = $mbox_ob->poll_info; if ($poll_info->unseen) { switch ($opts['render_type']) { case 'IMP_Tree_Jquerymobile': $after = $poll_info->unseen; break; default: $label = '<strong>' . $label . '</strong> (' . $poll_info->unseen . ')'; } } } if ($val->container) { $params['container'] = true; } else { switch ($view) { case $registry::VIEW_SMARTMOBILE: $url = new Horde_Core_Smartmobile_Url(); $url->add('mbox', $mbox_ob->form_to); $url->setAnchor('mailbox'); $params['url'] = strval($url); break; default: $params['url'] = $mbox_ob->url('mailbox')->setRaw(true); break; } if (!$val->subscribed) { $params['class'] = 'mboxunsub'; } } $checkbox = empty($opts['checkbox']) ? '' : '<input type="checkbox" class="checkbox" name="mbox_list[]" value="' . $mbox_ob->form_to . '"'; if ($val->nonimap) { $checkbox .= ' disabled="disabled"'; } if ($val->vfolder && !empty($opts['editvfolder']) && $val->container) { $after = ' [' . $registry->getServiceLink('prefs', 'imp')->add('group', 'searches')->link(array('title' => _("Edit Virtual Folder"))) . _("Edit") . '</a>' . ']'; } if (is_null($elt_parent)) { $elt_parent = $val->parent; } $tree->addNode(array('id' => $mbox_ob->form_to, 'parent' => $elt_parent->base_elt ? $parent : $elt_parent->mbox_ob->form_to, 'label' => $label, 'expanded' => isset($opts['open']) ? $opts['open'] : $is_open, 'params' => $params, 'right' => $after, 'left' => empty($opts['checkbox']) ? null : $checkbox . ' />')); } return $tree; }