1: <?php
2: /**
3: * Copyright 2011-2014 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (GPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/gpl.
7: *
8: * @category Horde
9: * @copyright 2011-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Common UI code used in the search pages.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2011-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Search_Ui
24: {
25: /**
26: * Create SELECT list of mailboxes for advanced search page.
27: *
28: * @param boolean $unsub Include unsubcribed mailboxes?
29: *
30: * @return object Object with the following properties:
31: * - mbox_list: (array) Mapping of mailbox name (key) to display
32: * string (values).
33: * - tree: (IMP_Tree_Flist) Tree object.
34: */
35: public function getSearchMboxList($unsub = false)
36: {
37: global $injector, $registry;
38:
39: $ob = new stdClass;
40:
41: $view = new Horde_View(array(
42: 'templatePath' => IMP_TEMPLATES . '/search'
43: ));
44: $view->allsearch = IMP_Mailbox::formTo(IMP_Search_Query::ALLSEARCH);
45:
46: $ftree = $injector->getInstance('IMP_Ftree');
47: $iterator = new IMP_Ftree_IteratorFilter($ftree);
48: if ($unsub) {
49: $ftree->loadUnsubscribed();
50: $iterator->remove($iterator::UNSUB);
51: }
52: if ($registry->getView() != $registry::VIEW_DYNAMIC) {
53: $iterator->add($iterator::REMOTE);
54: }
55:
56: $ob->tree = $ftree->createTree('imp_search', array(
57: 'iterator' => $iterator,
58: 'render_params' => array(
59: 'abbrev' => 0,
60: 'container_select' => true,
61: 'customhtml' => $view->render('search-all'),
62: 'heading' => _("Add search mailbox:")
63: ),
64: 'render_type' => 'IMP_Tree_Flist'
65: ));
66:
67: $mbox_list = array();
68: foreach ($iterator as $val) {
69: $mbox_ob = $val->mbox_ob;
70: $mbox_list[$mbox_ob->form_to] = $mbox_ob->display;
71: }
72: $ob->mbox_list = $mbox_list;
73:
74: return $ob;
75: }
76:
77: }
78: