From: Michael M Slusarz Date: Fri, 1 Oct 2010 08:04:30 +0000 (-0600) Subject: Move PHP logic out of DIMP templates. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=ce50d85f06abba483246630ba364630c3bb19385;p=horde.git Move PHP logic out of DIMP templates. --- diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 7b6d7d0bc..7f8fe8c27 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -251,7 +251,7 @@ if (!($prefs->isLocked('default_encrypt')) && IMP::status(); IMP_Dimp::header($title, $scripts); -echo $t->fetch(IMP_TEMPLATES . '/dimp/compose/compose.html'); +echo $t->fetch(IMP_TEMPLATES . '/dimp/compose/compose-base.html'); Horde::includeScriptFiles(); Horde::outputInlineScript(); echo "\n"; diff --git a/imp/config/hooks.php.dist b/imp/config/hooks.php.dist index 3c46f3159..e2520ec61 100644 --- a/imp/config/hooks.php.dist +++ b/imp/config/hooks.php.dist @@ -725,7 +725,7 @@ class IMP_Hooks /** * DIMP: Allow additional information to be added to the array that is * passed to the message text display template: - * imp/templates/dimp/chunks/message.php. + * imp/templates/dimp/message/message.html. * * @param array $msg The current entry array (see the showMessage() * function in lib/Views/ShowMessage.php for the diff --git a/imp/js/compose-dimp.js b/imp/js/compose-dimp.js index daebfece0..315540ed8 100644 --- a/imp/js/compose-dimp.js +++ b/imp/js/compose-dimp.js @@ -18,13 +18,21 @@ var DimpCompose = { confirmCancel: function() { + var cc, + sbd = $('send_button_redirect'); + if (window.confirm(DIMP.text_compose.cancel)) { if ((this.is_popup || DIMP.conf_compose.popup) && DimpCore.base && !DIMP.conf_compose.qreply) { DimpCore.base.focus(); } - DimpCore.doAction(DIMP.conf_compose.auto_save_interval_val ? 'deleteDraft' : 'cancelCompose', { imp_compose: $F('composeCache') }, { ajaxopts: { asynchronous: DIMP.conf_compose.qreply } }); + + cc = (sbd && sbd.visible()) + ? $F('composeCacheRedirect') + : $F('composeCache'); + + DimpCore.doAction(DIMP.conf_compose.auto_save_interval_val ? 'deleteDraft' : 'cancelCompose', { imp_compose: cc }, { ajaxopts: { asynchronous: DIMP.conf_compose.qreply } }); this.updateDraftsMailbox(); return this.closeCompose(); } diff --git a/imp/lib/Views/Compose.php b/imp/lib/Views/Compose.php index 701b9c44e..07b050fd0 100644 --- a/imp/lib/Views/Compose.php +++ b/imp/lib/Views/Compose.php @@ -33,31 +33,32 @@ class IMP_Views_Compose */ static public function showCompose($args) { + global $conf, $injector, $prefs, $registry; + $result = array( 'html' => '', 'js' => array(), 'jsonload' => array() ); - $compose_html = $redirect = $rte = false; + $t = $injector->createInstance('Horde_Template'); + $t->setOption('gettext', true); - if (empty($args['composeCache'])) { - $composeCache = null; - } else { - $imp_compose = $GLOBALS['injector']->getInstance('IMP_Compose')->getOb($args['composeCache']); - $composeCache = $args['composeCache']; + if (!empty($args['composeCache'])) { + $imp_compose = $injector->getInstance('IMP_Compose')->getOb($args['composeCache']); + $t->set('composeCache', $args['composeCache']); } if (empty($args['redirect'])) { /* Load Identity. */ - $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); - $selected_identity = $identity->getDefault(); + $identity = $injector->getInstance('IMP_Identity'); + $t->set('selected_identity', intval($identity->getDefault())); /* Generate identities list. */ - $imp_ui = $GLOBALS['injector']->getInstance('IMP_Ui_Compose'); + $imp_ui = $injector->getInstance('IMP_Ui_Compose'); $result['js'] = array_merge($result['js'], $imp_ui->identityJs()); - if ($composeCache && + if ($t->get('composeCache') && $imp_compose->numberOfAttachments()) { foreach ($imp_compose->getAttachments() as $num => $atc) { $mime = $atc['part']; @@ -66,7 +67,7 @@ class IMP_Views_Compose 'num' => intval($num), 'size' => $mime->getSize(), 'type' => $mime->getType() - ), Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()); + ), Horde_Serialize::JSON, $registry->getCharset()); $result['jsonload'][] = 'DimpCompose.addAttach(' . $opts . ')'; } } @@ -76,16 +77,16 @@ class IMP_Views_Compose } if ($_SESSION['imp']['rteavail']) { - $compose_html = $GLOBALS['prefs']->getValue('compose_html'); - $rte = true; + $t->set('compose_html', $prefs->getValue('compose_html')); + $t->set('rte', true); - $imp_ui->initRTE(!$compose_html); + $imp_ui->initRTE(!$t->get('compose_html')); } /* Create list for sent-mail selection. */ - if (!empty($GLOBALS['conf']['user']['select_sentmail_folder']) && - !$GLOBALS['prefs']->isLocked('sent_mail_folder')) { - $imp_folder = $GLOBALS['injector']->getInstance('IMP_Folder'); + if (!empty($conf['user']['select_sentmail_folder']) && + !$prefs->isLocked('sent_mail_folder')) { + $imp_folder = $injector->getInstance('IMP_Folder'); /* Check to make sure the sent-mail folders are created - they * need to exist to show up in drop-down list. */ @@ -97,7 +98,7 @@ class IMP_Views_Compose } $flist = array(); - $imaptree = $GLOBALS['injector']->getInstance('IMP_Imap_Tree'); + $imaptree = $injector->getInstance('IMP_Imap_Tree'); foreach ($imaptree as $val) { $tmp = array( @@ -114,17 +115,70 @@ class IMP_Views_Compose 'DIMP.conf_compose.flist' => $flist ), true)); } + + $compose_link = Horde::getServiceLink('ajax', 'imp'); + $compose_link->pathInfo = 'addAttachment'; + $t->set('compose_link', $compose_link); + + $t->set('send_button', IMP_Dimp::actionButton(array( + 'icon' => 'Forward', + 'id' => 'send_button', + 'title' => _("Send") + ))); + $t->set('spell_button', IMP_Dimp::actionButton(array( + 'icon' => 'Spellcheck', + 'id' => 'spellcheck', + 'title' => _("Check Spelling") + ))); + $t->set('draft_button', IMP_Dimp::actionButton(array( + 'icon' => 'Drafts', + 'id' => 'draft_button', + 'title' => _("Save as Draft") + ))); + + $d_read = $prefs->getValue('disposition_request_read'); + if ($conf['compose']['allow_receipts'] && + ($d_read != 'never')) { + $t->set('read_receipt', true); + $t->set('read_receipt_set', $d_read != 'ask'); + } + + $t->set('save_sent_mail', ($conf['user']['allow_folders'] && !$prefs->isLocked('save_sent_mail'))); + $t->set('priority', $prefs->getValue('set_priority')); + if (!$prefs->isLocked('default_encrypt') && + ($prefs->getValue('use_pgp') || $prefs->getValue('use_smime'))) { + $t->set('encrypt', IMP::ENCRYPT_NONE); + } + + $select_list = array(); + foreach ($identity->getSelectList() as $id => $from) { + $select_list[] = array( + 'label' => htmlspecialchars($from), + 'sel' => ($id == $t->get('selected_identity')), + 'val' => htmlspecialchars($id) + ); + } + $t->set('select_list', $select_list); + + $save_attach = $prefs->getValue('save_attachments'); + if (strpos($save_attach, 'prompt') !== false) { + $t->set('save_attach', true); + $t->set('save_attach_set', strpos($save_attach, 'yes') !== false); + } } else { $result['js'] = array_merge($result['js'], Horde::addInlineJsVars(array( '-DIMP.conf_compose.redirect' => 1 ), true)); - $redirect = true; } - // Buffer output so that we can return a string from this function - Horde::startBuffer(); - require IMP_TEMPLATES . '/dimp/chunks/compose.php'; - $result['html'] .= Horde::endBuffer(); + $t->set('compose_enable', IMP::canCompose()); + $t->set('forminput', Horde_Util::formInput()); + $t->set('redirect_button', IMP_Dimp::actionButton(array( + 'icon' => 'Forward', + 'id' => 'send_button_redirect', + 'title' => _("Redirect") + ))); + $result['html'] = $t->fetch(IMP_TEMPLATES . '/dimp/compose/compose.html'); return $result; } diff --git a/imp/message-dimp.php b/imp/message-dimp.php index c88c7eafa..6afe93c5f 100644 --- a/imp/message-dimp.php +++ b/imp/message-dimp.php @@ -114,10 +114,85 @@ Horde::addInlineScript(array_filter($js_onload), 'load'); Horde::noDnsPrefetch(); +$t = $injector->createInstance('Horde_Template'); +$t->setOption('gettext', true); + +$t->set('reply_button', IMP_Dimp::actionButton(array( + 'class' => 'hasmenu', + 'icon' => 'Reply', + 'id' => 'reply_link', + 'title' => _("Reply") +))); +$t->set('forward_button', IMP_Dimp::actionButton(array( + 'class' => 'hasmenu', + 'icon' => 'Forward', + 'id' => 'forward_link', + 'title' => _("Forward") +))); + +if (!empty($conf['spam']['reporting']) && + (!$conf['spam']['spamfolder'] || + ($vars->folder != IMP::folderPref($prefs->getValue('spam_folder'), true)))) { + $t->set('spam_button', IMP_Dimp::actionButton(array( + 'icon' => 'Spam', + 'id' => 'button_spam', + 'title' => _("Spam") + ))); +} + +if (!empty($conf['notspam']['reporting']) && + (!$conf['notspam']['spamfolder'] || + ($vars->folder == IMP::folderPref($prefs->getValue('spam_folder'), true)))) { + $t->set('ham_button', IMP_Dimp::actionButton(array( + 'icon' => 'Ham', + 'id' => 'button_ham', + 'title' => _("Innocent") + ))); +} + +if (!$readonly) { + $t->set('delete_button', IMP_Dimp::actionButton(array( + 'icon' => 'Delete', + 'id' => 'button_deleted', + 'title' => _("Delete") + ))); +} + +$t->set('view_source', !empty($conf['user']['allow_view_source'])); +$t->set('save_as', $show_msg_result['save_as']); +$t->set('subject', $show_msg_result['subject']); + +$hdrs = array(); +foreach ($show_msg_result['headers'] as $val) { + $hdrs[] = array_filter(array( + 'id' => (isset($val['id']) ? 'msgHeader' . $val['id'] : null), + 'label' => $val['name'], + 'val' => $val['value'] + )); +} +$t->set('hdrs', $hdrs); + +if (isset($show_msg_result['atc_label'])) { + $t->set('atc_label', $show_msg_result['atc_label']); + if (isset($show_msg_result['atc_list'])) { + $t->set('atc_list', $show_msg_result['atc_list']); + } + $t->set('atc_download', isset($show_msg_result['atc_download']) ? $show_msg_result['atc_download'] : ''); +} + +$t->set('msgtext', $show_msg_result['msgtext']); + +if (!$disable_compose) { + $t->set('html', $compose_result['html']) { + $t->set('reply_list', $show_msg_result['list_info']['exists']); + $t->set('forward_select', !$prefs->isLocked('forward_default')); +} + IMP::status(); IMP_Dimp::header($show_msg_result['title'], $scripts); -echo "\n"; -require IMP_TEMPLATES . '/dimp/chunks/message.php'; + +echo $t->fetch(IMP_TEMPLATES . '/dimp/message/message.html'); + Horde::includeScriptFiles(); Horde::outputInlineScript(); echo "\n"; diff --git a/imp/templates/dimp/chunks/compose.php b/imp/templates/dimp/chunks/compose.php deleted file mode 100644 index dbadbd14c..000000000 --- a/imp/templates/dimp/chunks/compose.php +++ /dev/null @@ -1,184 +0,0 @@ -getValue('disposition_request_read'); -$encrypt_list = (!$GLOBALS['prefs']->isLocked('default_encrypt') && ($GLOBALS['prefs']->getValue('use_pgp') || $GLOBALS['prefs']->getValue('use_smime'))); -$save_attach = $GLOBALS['prefs']->getValue('save_attachments'); - -/* Determine if compose mode is disabled. */ -$compose_disable = !IMP::canCompose(); - -$compose_link = Horde::getServiceLink('ajax', 'imp'); -$compose_link->pathInfo = 'addAttachment'; - -?> - -
- - - - - -
- -
'Forward', 'id' => 'send_button', 'title' => _("Send"))); ?>
- -
'Spellcheck', 'id' => 'spellcheck', 'title' => _("Check Spelling"))); ?>
-
'Drafts', 'id' => 'draft_button', 'title' => _("Save as Draft"))); ?>
-
- -
-
-
-
- -
-
- -
- -
- -
- - -
- -
- -isLocked('save_sent_mail')): ?> -
- - -
- -getValue('set_priority')): ?> -
- - -
- - -
- - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
: - - - - - - -
- - -
-
- -
- -
-
-
- - - - - - - - - diff --git a/imp/templates/dimp/chunks/message.php b/imp/templates/dimp/chunks/message.php deleted file mode 100644 index 06637feeb..000000000 --- a/imp/templates/dimp/chunks/message.php +++ /dev/null @@ -1,151 +0,0 @@ - -
- - - - - - - - - -
- - - [] - - - - -
diff --git a/imp/templates/dimp/compose/compose-base.html b/imp/templates/dimp/compose/compose-base.html new file mode 100644 index 000000000..bb42ada2f --- /dev/null +++ b/imp/templates/dimp/compose/compose-base.html @@ -0,0 +1,9 @@ + +
Loading...
+ diff --git a/imp/templates/dimp/compose/compose.html b/imp/templates/dimp/compose/compose.html index bb42ada2f..11c1bbbc3 100644 --- a/imp/templates/dimp/compose/compose.html +++ b/imp/templates/dimp/compose/compose.html @@ -1,9 +1,202 @@ - -
Loading...
-