1: <?php
2: /**
3: * This class is designed to provide a place to store common code for the
4: * advanced search page.
5: *
6: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (GPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/gpl.
10: *
11: * @author Michael Slusarz <slusarz@horde.org>
12: * @category Horde
13: * @license http://www.horde.org/licenses/gpl GPL
14: * @package IMP
15: */
16: class IMP_Ui_Search
17: {
18: /**
19: * Create SELECT list of mailboxes for advanced search page.
20: *
21: * @param boolean $unsub Include unsubcribed mailboxes?
22: *
23: * @return object Object with the following properties:
24: * - folder_list: (array) Mapping of mailbox name (key) to display
25: * string (values).
26: * - tree: (IMP_Tree_Flist) Tree object.
27: */
28: public function getSearchMboxList($unsub = false)
29: {
30: global $injector;
31:
32: $ob = new stdClass;
33:
34: $imap_tree = $injector->getInstance('IMP_Imap_Tree');
35: $imap_tree->setIteratorFilter($unsub ? IMP_Imap_Tree::FLIST_UNSUB : 0);
36:
37: $t2 = $injector->createInstance('Horde_Template');
38: $t2->setOption('gettext', true);
39: $t2->set('allsearch', IMP_Mailbox::formTo(IMP_Search_Query::ALLSEARCH));
40:
41: $ob->tree = $imap_tree->createTree('imp_search', array(
42: 'render_params' => array(
43: 'abbrev' => 0,
44: 'container_select' => true,
45: 'customhtml' => $t2->fetch(IMP_TEMPLATES . '/imp/search/search-all.html'),
46: 'heading' => _("Add search folder:")
47: ),
48: 'render_type' => 'IMP_Tree_Flist'
49: ));
50:
51: $folder_list = array();
52: foreach ($imap_tree as $val) {
53: $folder_list[$val->form_to] = $val->display;
54: }
55: $ob->folder_list = $folder_list;
56:
57: return $ob;
58: }
59:
60: }
61: