From 02f762831461233809c95189b1b4e9a647e22944 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 3 Sep 2014 13:01:38 +0200 Subject: Fix page title when using search filter (#1490023) --- CHANGELOG | 1 + program/localization/en_US/labels.inc | 2 +- program/steps/mail/func.inc | 27 ++++++++++++++++++++++----- program/steps/mail/list.inc | 10 +++++----- program/steps/mail/search.inc | 9 +++++++-- 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f2dcaded7..d59ae5bc7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -47,6 +47,7 @@ CHANGELOG Roundcube Webmail - Optimize some framed pages content for better performance (#1489792) - Improve text messages display and conversion to HTML (#1488937) - Don't remove links when html signature is converted to text (#1489621) +- Fix page title when using search filter (#1490023) - Fix mbox files import - Fix some mime-type to extension mapping checks in Installer (#1489983) - Fix errors when using localStorage in Safari's private browsing mode (#1489996) diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc index 720d7ab99..f1ef5f436 100644 --- a/program/localization/en_US/labels.inc +++ b/program/localization/en_US/labels.inc @@ -338,7 +338,7 @@ $labels['assistant'] = 'Assistant'; $labels['spouse'] = 'Spouse'; $labels['allfields'] = 'All fields'; $labels['search'] = 'Search'; -$labels['searchfor'] = 'Search for "$q"'; +$labels['searchresult'] = 'Search result'; $labels['advsearch'] = 'Advanced Search'; $labels['advanced'] = 'Advanced'; $labels['other'] = 'Other'; diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index a7c483bba..25f2e3175 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -79,6 +79,8 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') { if (!empty($_SESSION['search_scope'])) $OUTPUT->set_env('search_scope', $_SESSION['search_scope']); + + rcmail_list_pagetitle(); } $threading = (bool) $RCMAIL->storage->get_threading(); @@ -119,11 +121,6 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') { 'flagged', 'unflagged', 'unread', 'deleted', 'replied', 'forwarded', 'priority', 'withattachment', 'fileuploaderror'); } - - $pagetitle = $RCMAIL->localize_foldername($mbox_name, true); - $pagetitle = str_replace($delimiter, " \xC2\xBB ", $pagetitle); - - $OUTPUT->set_pagetitle($pagetitle); } // register UI objects @@ -217,6 +214,26 @@ function rcmail_init_env() $RCMAIL->storage->set_threading($threading); } +/** + * Sets page title + */ +function rcmail_list_pagetitle() +{ + global $RCMAIL; + + if ($RCMAIL->output->get_env('search_request')) { + $pagetitle = $RCMAIL->gettext('searchresult'); + } + else { + $mbox_name = $RCMAIL->storage->get_folder(); + $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); + $pagetitle = $RCMAIL->localize_foldername($mbox_name, true); + $pagetitle = str_replace($delimiter, " \xC2\xBB ", $pagetitle); + } + + $RCMAIL->output->set_pagetitle($pagetitle); +} + /** * Returns default search mods */ diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc index 2dcc40d17..32197bde3 100644 --- a/program/steps/mail/list.inc +++ b/program/steps/mail/list.inc @@ -81,6 +81,7 @@ if ($count = $RCMAIL->storage->count($mbox_name, $threading ? 'THREADS' : 'ALL', if (!empty($_REQUEST['_search']) && isset($_SESSION['search']) && $_SESSION['search_request'] == $_REQUEST['_search'] ) { + $search_request = $_REQUEST['_search']; $_SESSION['search'] = $RCMAIL->storage->get_search_set(); } // remove old search data @@ -88,13 +89,12 @@ else if (empty($_REQUEST['_search']) && isset($_SESSION['search'])) { $RCMAIL->session->remove('search'); } -// empty result? we'll skip UNSEEN counting in rcmail_send_unread_count() -if (empty($search_request) && empty($a_headers)) { - $unseen = 0; -} +rcmail_list_pagetitle(); // update mailboxlist -rcmail_send_unread_count($mbox_name, !empty($_REQUEST['_refresh']), $unseen); +if (empty($search_request)) { + rcmail_send_unread_count($mbox_name, !empty($_REQUEST['_refresh']), empty($a_headers) ? 0 : null); +} // update message count display $pages = ceil($count/$RCMAIL->storage->get_pagesize()); diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc index b50593480..d88e57568 100644 --- a/program/steps/mail/search.inc +++ b/program/steps/mail/search.inc @@ -187,8 +187,6 @@ else { } } -$OUTPUT->set_pagetitle($RCMAIL->gettext(array('name' => 'searchfor', 'vars' => array('q' => $str)))); - // update message count display $OUTPUT->set_env('search_request', $search_str ? $search_request : ''); $OUTPUT->set_env('search_filter', $_SESSION['search_filter']); @@ -198,6 +196,13 @@ $OUTPUT->set_env('pagecount', ceil($count/$RCMAIL->storage->get_pagesize())); $OUTPUT->set_env('exists', $mbox === null ? 0 : $RCMAIL->storage->count($mbox, 'EXISTS')); $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count, 1), $mbox); +rcmail_list_pagetitle(); + +// update unseen messages count +if (empty($search_str)) { + rcmail_send_unread_count($mbox, false, empty($result_h) ? 0 : null); +} + if (!$result->incomplete) { $OUTPUT->command('set_quota', $RCMAIL->quota_content(null, $result->multi ? 'INBOX' : $mbox)); } -- cgit v1.2.3