1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class IMP_Smartmobile
24: {
25: 26: 27:
28: public $vars;
29:
30: 31: 32:
33: public $view;
34:
35: 36:
37: public function __construct(Horde_Variables $vars)
38: {
39: global $notification, $page_output;
40:
41: $this->vars = $vars;
42:
43: $this->view = new Horde_View(array(
44: 'templatePath' => IMP_TEMPLATES . '/smartmobile'
45: ));
46: $this->view->addHelper('Horde_Core_Smartmobile_View_Helper');
47: $this->view->addHelper('Text');
48:
49: $this->_initPages();
50: $this->_addBaseVars();
51:
52: $page_output->addScriptFile('smartmobile.js');
53: $page_output->addScriptFile('json2.js', 'horde');
54: $page_output->addScriptFile('jquery.mobile/plugins/listviewtaphold.js');
55: $page_output->addScriptFile('jquery.mobile/plugins/unveil.js');
56: $page_output->addScriptFile('jquery.mobile/plugins/swipebutton.js', 'horde');
57: if (IMP_Compose::canCompose()) {
58: $page_output->addScriptFile('jquery.mobile/plugins/autocomplete.js', 'horde');
59: $page_output->addScriptFile('jquery.mobile/plugins/textchange.js');
60: if (IMP_Compose::canUploadAttachment()) {
61: $page_output->addScriptFile('jquery.mobile/plugins/form.js', 'horde');
62: }
63: }
64:
65: $page_output->smartmobileInit = array_merge(
66: $page_output->smartmobileInit,
67: array(
68: '$.mobile.buttonMarkup.hoverDelay = 80;',
69: '$.mobile.defaultPageTransition = \'none\';',
70: '$.event.special.tap.tapholdThreshold = 600;'
71: )
72: );
73:
74: $page_output->addStylesheet(
75: new Horde_Themes_Element('mime.css')
76: );
77:
78:
79:
80:
81: $notification->notify(array('listeners' => 'status'));
82: }
83:
84: 85:
86: public function render()
87: {
88: global $injector;
89:
90: $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
91:
92: echo $this->view->render('folders');
93: echo $this->view->render('mailbox');
94: echo $this->view->render('message');
95: if (IMP_Compose::canCompose()) {
96: echo $this->view->render('compose');
97: }
98: if ($imp_imap->access(IMP_Imap::ACCESS_SEARCH)) {
99: echo $this->view->render('search');
100: }
101: if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) {
102: echo $this->view->render('copymove');
103: }
104: }
105:
106: 107:
108: protected function _initPages()
109: {
110: global $injector, $registry, $session;
111:
112: $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
113:
114: $this->view->allowFolders = $imp_imap->access(IMP_Imap::ACCESS_FOLDERS);
115: $this->view->canInnocent = !empty($imp_imap->config->innocent_params);
116: $this->view->canSearch = $imp_imap->access(IMP_Imap::ACCESS_SEARCH);
117: $this->view->canSpam = !empty($imp_imap->config->spam_params);
118:
119: if ($this->view->canCompose = IMP_Compose::canCompose()) {
120:
121: $identity = $injector->getInstance('IMP_Identity');
122: $this->view->identities = array();
123: foreach ($identity->getSelectList() as $id => $from) {
124: $this->view->identities[] = array(
125: 'label' => $from,
126: 'sel' => ($id == $identity->getDefault()),
127: 'val' => $id
128: );
129: }
130:
131: $this->view->user = $registry->getAuth();
132:
133: $this->view->draft =
134: ($imp_imap->access(IMP_Imap::ACCESS_DRAFTS) &&
135: ($draft = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_DRAFTS)) &&
136: !$draft->readonly);
137:
138: if (IMP_Compose::canUploadAttachment()) {
139: $this->view->attach = true;
140: $this->view->max_size = $session->get('imp', 'file_upload');
141: }
142: }
143: }
144:
145: 146: 147:
148: protected function _addBaseVars()
149: {
150: global $injector, $page_output, $prefs;
151:
152: $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
153:
154: $code = array(
155:
156: 'conf' => array_filter(array(
157: 'allow_folders' => $imp_imap->access(IMP_Imap::ACCESS_FOLDERS),
158: 'disable_compose' => !IMP_Compose::canCompose(),
159: 'flags' => array(
160: 'deleted' => '\\deleted',
161: 'draft' => '\\draft',
162: 'seen' => '\\seen'
163: ),
164: 'mailbox_return' => $prefs->getValue('mailbox_return'),
165: 'qsearchid' => IMP_Mailbox::formTo(IMP_Search::MBOX_PREFIX . IMP_Search::DIMP_QUICKSEARCH),
166: 'refresh_time' => intval($prefs->getValue('refresh_time'))
167: )),
168:
169:
170: 'text' => array(
171: 'exitsearch' => _("Exit Search"),
172: 'folders' => _("Folders"),
173: 'message_0' => _("No messages"),
174: 'message_1' => _("1 message"),
175: 'message_2' => _("%d messages"),
176: 'more_msgs' => _("Load More Messages..."),
177: 'move_nombox' => _("Must enter a non-empty name for the new destination mailbox."),
178: 'new_message' => _("New Message"),
179: 'nofrom' => _("Invalid Address"),
180: 'nosubject' => _("The message does not have a Subject entered.") . "\n" . _("Send message without a Subject?"),
181: 'searchresults' => _("Search Results"),
182: 'subject' => _("Subject")
183: )
184: );
185:
186: $page_output->addInlineJsVars(array(
187: 'var IMP' => $code
188: ), array('top' => true));
189: }
190:
191: }
192: