From: Michael M Slusarz Date: Tue, 15 Sep 2009 09:57:26 +0000 (-0600) Subject: Various search improvements X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=17714b4df6764e02d0b5876d1a7b97a3176387a7;p=horde.git Various search improvements --- diff --git a/imp/js/search.js b/imp/js/search.js index 1c9152737..8a494270a 100644 --- a/imp/js/search.js +++ b/imp/js/search.js @@ -7,7 +7,8 @@ var ImpSearch = { // The following variables are defined in search.php: - // loading, months, need_criteria, need_folder, types + // loading, months, need_criteria, need_folder, need_vfolder_label, + // types criteria: {}, saved_searches: {}, show_unsub: false, @@ -20,7 +21,9 @@ var ImpSearch = { selectFolders: function(checked) { this._getAll().each(function(e) { - e.checked = checked; + if (!e.disabled) { + e.checked = Boolean(checked); + } }); }, @@ -94,7 +97,7 @@ var ImpSearch = { resetCriteria: function() { - $('search_criteria').siblings().invoke('remove'); + $('search_criteria_table').childElements().invoke('remove'); }, changeHandler: function(e) @@ -138,45 +141,51 @@ var ImpSearch = { return $('search_criteria').down('[value=' + id + ']').getText() + ': '; }, - insertCriteria: function(elt) + insertCriteria: function(tds) { - var div = new Element('DIV').insert(elt.writeAttribute('id', null).show()).insert($($('delete_criteria').cloneNode(true)).writeAttribute('id', null).show()); - $('search_criteria').insert({ before: div }).setValue(''); - return div.identify(); + var tr = new Element('TR'); + tds.each(function(td) { + tr.insert(new Element('TD').insert(td)); + }); + tr.childElements().last().insert(new Element('A', { href: '#', className: 'searchuiImg searchuiDelete' })); + $('search_criteria').setValue(''); + $('search_criteria_table').insert(tr); + return tr.identify(); }, insertText: function(id, text, not) { - var tmp = $($('text_criteria').cloneNode(true)); - tmp.down('EM').insert(this.getLabel(id)); - tmp.down('INPUT').setValue(text); - if (not) { - tmp.down('INPUT', 1).writeAttribute('checked', true); - } + var tmp = [ + new Element('EM').insert(this.getLabel(id)), + new Element('INPUT', { type: 'text', size: 25 }), + new Element('SPAN').insert(new Element('INPUT', { checked: Boolean(not), className: 'checkbox', type: 'checkbox' })).insert(this.not_match) + ]; this.criteria[this.insertCriteria(tmp)] = { t: id }; }, insertSize: function(id, size) { - var tmp = $($('text_criteria').cloneNode(true)); - tmp.down('EM').insert(this.getLabel(id)); - // Convert from bytes to KB - tmp.down('INPUT').writeAttribute('size', 10).setValue(Object.isNumber(size) ? Math.round(size / 1024) : ''); - tmp.down('SPAN').hide(); + var tmp = [ + new Element('EM').insert(this.getLabel(id)), + // Convert from bytes to KB + new Element('INPUT', { type: 'text', size: 10 }).setValue(Object.isNumber(size) ? Math.round(size / 1024) : '') + ]; this.criteria[this.insertCriteria(tmp)] = { t: id }; }, insertDate: function(id, data) { var d = (data ? new Date(data.y, data.m, data.d) : new Date()), - tmp = $($('date_criteria').cloneNode(true)); - tmp.down('EM').insert(this.getLabel(id)); + tmp = [ + new Element('EM').insert(this.getLabel(id)), + new Element('SPAN').insert(new Element('SPAN')).insert(new Element('A', { href: '#', className: 'calendarPopup', title: this.dateselection }).insert(new Element('SPAN', { className: 'searchuiImg searchuiCalendar' }))) + ]; this.replaceDate(this.insertCriteria(tmp), id, { y: d.getFullYear(), m: d.getMonth(), d: d.getDate() }); }, replaceDate: function(id, type, data) { - $(id).down('SPAN', 1).update(this.months[data.m] + ' ' + data.d + ', ' + data.y); + $(id).down('TD SPAN SPAN').update(this.months[data.m] + ' ' + data.d + ', ' + data.y); // Need to store date information at all times in criteria, since we // have no other way to track this information (there is not form // field for this type). @@ -185,7 +194,10 @@ var ImpSearch = { insertFlag: function(id) { - var tmp = $($('flag_criteria').cloneNode(true)).insert({ bottom: this.getLabel(id) } ); + var tmp = [ + new Element('EM').insert(this.flag), + this.getLabel(id).slice(0, -2) + ]; this.criteria[this.insertCriteria(tmp)] = { t: id }; }, @@ -196,7 +208,7 @@ var ImpSearch = { if (!this._getAll().findAll(function(i) { return i.checked; }).size()) { alert(this.need_folder); } else { - tmp = $('search_criteria').siblings().pluck('id'); + tmp = $('search_criteria_table').childElements().pluck('id'); if (tmp.size()) { tmp.each(function(c) { var tmp2; @@ -282,17 +294,17 @@ var ImpSearch = { elt.hasClassName('arrowCollapsed')) { elt.up().down().toggle().next().toggle().up().next().toggle(); if (elt.descendantOf('search_folders_hdr')) { - elt.next('SPAN.item').toggle(); + elt.next('SPAN.searchFoldersActions').toggle(); } } else if (elt.hasClassName('searchuiDelete')) { - tmp = elt.up('DIV'); + tmp = elt.up('TR'); delete this.criteria[tmp.identify()]; tmp.remove(); e.stop(); return; } else if (elt.hasClassName('searchuiCalendar')) { - tmp = this.criteria[elt.up('DIV').identify()]; - Horde_Calendar.open(elt.identify(), { y: tmp.v.y, m: tmp.v.m + 1, d: tmp.v.d }, this.replaceDate.bind(this, elt.up('DIV').identify(), tmp.t)); + tmp = this.criteria[elt.up('TR').identify()]; + Horde_Calendar.open(elt.identify(), { y: tmp.v.y, m: tmp.v.m + 1, d: tmp.v.d }, this.replaceDate.bind(this, elt.up('TR').identify(), tmp.t)); e.stop(); return; } diff --git a/imp/lib/LoginTasks/SystemTask/UpgradeFromImp4.php b/imp/lib/LoginTasks/SystemTask/UpgradeFromImp4.php index dfee404bb..2ef3fc5ad 100644 --- a/imp/lib/LoginTasks/SystemTask/UpgradeFromImp4.php +++ b/imp/lib/LoginTasks/SystemTask/UpgradeFromImp4.php @@ -26,8 +26,7 @@ class IMP_LoginTasks_SystemTask_UpgradeFromImp4 extends Horde_LoginTasks_SystemT { IMP::initialize(); - /* IMP 4 upgrade: check for old, non-existent sort values. - * See Bug #7296. */ + /* Check for old, non-existent sort values. See Bug #7296. */ $sortby = $GLOBALS['prefs']->getValue('sortby'); if ($sortby > 10) { $GLOBALS['prefs']->setValue('sortby', Horde_Imap_Client::SORT_ARRIVAL); @@ -44,6 +43,8 @@ class IMP_LoginTasks_SystemTask_UpgradeFromImp4 extends Horde_LoginTasks_SystemT if ($update) { $GLOBALS['prefs']->setValue('sortpref', serialize($sortpref)); } + + /* Upgrade old virtual folders. */ } } diff --git a/imp/lib/Search.php b/imp/lib/Search.php index da1db54ab..33e35f1fa 100644 --- a/imp/lib/Search.php +++ b/imp/lib/Search.php @@ -130,15 +130,20 @@ class IMP_Search 'type' => 'header', 'not' => true ), + 'custom' => array( + 'label' => _("Custom Header"), + 'type' => 'customhdr', + 'not' => true + ), 'body' => array( 'label' => _("Body"), 'type' => 'body', - 'not' => true + 'not' => true ), 'text' => array( 'label' => _("Entire Message"), 'type' => 'text', - 'not' => true + 'not' => true ), 'date_on' => array( 'label' => _("Date ="), diff --git a/imp/lib/UI/Search.php b/imp/lib/UI/Search.php index 9cc82e239..34feb3a06 100644 --- a/imp/lib/UI/Search.php +++ b/imp/lib/UI/Search.php @@ -94,10 +94,15 @@ class IMP_UI_Search $c_list = array(); if ($criteria) { + $search_fields = $GLOBALS['imp_search']->searchFields(); $tmp = new stdClass; $tmp->t = $criteria; - $tmp->v = $text; - $tmp->n = $not; + $tmp->v = ($search_fields[$criteria]['type'] == 'size') + ? floatval($text) * 1024 + : $text; + if ($search_fields[$criteria]['not']) { + $tmp->n = (bool)$not; + } $c_list[] = $tmp; } diff --git a/imp/search-basic.php b/imp/search-basic.php index ae05418a3..ac1fedd36 100644 --- a/imp/search-basic.php +++ b/imp/search-basic.php @@ -39,7 +39,7 @@ $f_fields = $s_fields = array(); $search_mailbox = Horde_Util::getFormData('search_mailbox'); foreach ($imp_search->searchFields() as $key => $val) { - if ($val['type'] != 'date') { + if (!in_array($val['type'], array('customhdr', 'date'))) { $s_fields[] = array( 'val' => $key, 'label' => $val['label'] diff --git a/imp/search.php b/imp/search.php index 043eca615..54f45e0be 100644 --- a/imp/search.php +++ b/imp/search.php @@ -8,15 +8,14 @@ * --------------- * 'criteria_form' - (string) JSON representation of the search query. * 'edit_query' - (string) The search query to edit. + * 'edit_query_vfolder' - (string) The name of the vfolder being edited. + * 'search_folders_form' - (array) The list of folders to add to the query. * 'search_mailbox' - (string) Use this mailbox as the default value. * DEFAULT: INBOX - * - * TODO: - * 'edit_query_vfolder' - * 'search_folders_form[]' - * 'show_unsub' - * 'vfolder_label' - * 'vfolder_save' + * 'show_unsub' - (integer) If set, return a JSON object with folder + * information used to create the folder list. + * 'vfolder_label' - (string) The label to use when saving as a virtual folder. + * 'vfolder_save' - (boolean) If set, save search as a virtual folder. * * Copyright 1999-2009 The Horde Project (http://www.horde.org/) * @@ -41,8 +40,7 @@ if (!$browser->hasFeature('javascript') || $charset = Horde_Nls::getCharset(); $criteria = Horde_Util::getFormData('criteria_form'); -$edit_query = Horde_Util::getFormData('edit_query'); -$imp_search_fields = $imp_search->searchFields(); +$search_fields = $imp_search->searchFields(); /* Generate the search query if 'criteria_form' is present in the form * data. */ @@ -114,8 +112,10 @@ $t = new Horde_Template(); $t->setOption('gettext', true); $t->set('action', Horde::applicationUrl('search.php')); $t->set('subscribe', $subscribe); +$t->set('virtualfolder', $_SESSION['imp']['protocol'] != 'pop'); /* Determine if we are editing a current search folder. */ +$edit_query = Horde_Util::getFormData('edit_query'); if (!is_null($edit_query) && $imp_search->isSearchMbox($edit_query)) { if ($imp_search->isVFolder($edit_query)) { if (!$imp_search->isEditableVFolder($edit_query)) { @@ -131,7 +131,7 @@ if (!is_null($edit_query) && $imp_search->isSearchMbox($edit_query)) { $f_fields = $s_fields = $types = array(); /* Process the list of fields. */ -foreach ($imp_search_fields as $key => $val) { +foreach ($search_fields as $key => $val) { $s_fields[] = array( 'val' => $key, 'label' => $val['label'] @@ -149,16 +149,17 @@ foreach ($imp_search->flagFields() as $key => $val) { } $t->set('f_fields', $f_fields); -$t->set('virtualfolder', $_SESSION['imp']['protocol'] != 'pop'); - Horde_UI_JsCalendar::init(); Horde::addInlineScript(array( + 'ImpSearch.dateselection = ' . Horde_Serialize::serialize(_("Date Selection"), Horde_Serialize::JSON, $charset), + 'ImpSearch.flag = ' . Horde_Serialize::serialize(_("Flag:"), Horde_Serialize::JSON, $charset), 'ImpSearch.loading = ' . Horde_Serialize::serialize(_("Loading..."), Horde_Serialize::JSON, $charset), 'ImpSearch.months = ' . Horde_Serialize::serialize(Horde_UI_JsCalendar::months(), Horde_Serialize::JSON, $charset), 'ImpSearch.need_criteria = ' . Horde_Serialize::serialize(_("Please select at least one search criteria."), Horde_Serialize::JSON, $charset), 'ImpSearch.need_folder = ' . Horde_Serialize::serialize(_("Please select at least one folder to search."), Horde_Serialize::JSON, $charset), 'ImpSearch.need_vfolder_label = ' . Horde_Serialize::serialize(_("Virtual Folders require a label."), Horde_Serialize::JSON, $charset), + 'ImpSearch.not_match = ' . Horde_Serialize::serialize(_("Do NOT Match"), Horde_Serialize::JSON, $charset), 'ImpSearch.types = ' . Horde_Serialize::serialize($types, Horde_Serialize::JSON, $charset) )); Horde::addInlineScript($on_domload, 'dom'); diff --git a/imp/templates/search/search.html b/imp/templates/search/search.html index e45157926..b81ffe490 100644 --- a/imp/templates/search/search.html +++ b/imp/templates/search/search.html @@ -25,6 +25,7 @@
+
- Do NOT Match - - - - - - - - diff --git a/imp/themes/screen.css b/imp/themes/screen.css index 47fc99dc0..b9c8be518 100644 --- a/imp/themes/screen.css +++ b/imp/themes/screen.css @@ -164,6 +164,10 @@ div.msgActions, #fmanager div.folderActions { .searchuiCalendar { background-image: url("graphics/calendar.png"); } +.searchFoldersActions { + margin-left: 20px; + font-size: 90%; +} /* Folder view. */ #fmanager div, #fmanager div input {