From d44f2159acb7196e432ee6e3fb1588b0f655a51b Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 16 Sep 2009 00:02:49 -0600 Subject: [PATCH] Request #6875: Add advanced search interface to DIMP It works, but various UI elements remain to be tweaked to reflect the fact this is a search mailbox rather than a real mailbox. --- imp/docs/CHANGES | 1 + imp/js/DimpBase.js | 20 ++++++++++++++------ imp/search.php | 20 +++++++++++++++++--- imp/templates/javascript_defs_dimp.php | 1 + 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 2c6b25477..327f3ed99 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,7 @@ v5.0-git -------- +[mms] Add advanced search query interface to DIMP (Request #6875). [mms] Add ability to search by a custom defined header (Request #6875). [mms] Improved advanced search query interface (Request #6875). [mms] More intelligent ordering of autocomplete search results. diff --git a/imp/js/DimpBase.js b/imp/js/DimpBase.js index d5b034cbc..9d3832cb9 100644 --- a/imp/js/DimpBase.js +++ b/imp/js/DimpBase.js @@ -254,6 +254,12 @@ var DimpBase = { } switch (loc) { + case 'search': + this.highlightSidebar(); + DimpCore.setTitle(DIMP.text.search); + this.iframeContent(loc, DimpCore.addURLParam(DIMP.conf.URI_SEARCH, { search_mailbox: this.folder })); + break; + case 'portal': this.highlightSidebar('appportal'); this._addHistory(loc); @@ -288,11 +294,11 @@ var DimpBase = { var curr = $('sidebarPanel').down('.on'), elt = $(id); - if (!elt || curr == elt) { + if (curr == elt) { return; } - if (!elt.match('LI')) { + if (elt && !elt.match('LI')) { elt = elt.up(); if (!elt) { return; @@ -302,9 +308,11 @@ var DimpBase = { if (curr) { curr.removeClassName('on'); } - elt.addClassName('on'); - this._toggleSubFolder(elt, 'exp'); + if (elt) { + elt.addClassName('on'); + this._toggleSubFolder(elt, 'exp'); + } }, iframeContent: function(name, loc) @@ -768,7 +776,7 @@ var DimpBase = { break; case 'ctx_qsearchopts_advanced': - alert('Placeholder for advanced search'); + this.go('search'); break; case 'ctx_qsearchopts_all': @@ -863,7 +871,7 @@ var DimpBase = { var elt, unseen, label = this.viewport.getMetaData('label'); - if (this.isSearch()) { + if (this.isSearch() && this.sfolder) { label += ' (' + this.sfolder + ')'; } else { elt = $(this.getFolderId(this.folder)); diff --git a/imp/search.php b/imp/search.php index a9b8a0aab..eb1f78438 100644 --- a/imp/search.php +++ b/imp/search.php @@ -40,6 +40,7 @@ if (!$browser->hasFeature('javascript') || $charset = Horde_Nls::getCharset(); $criteria = Horde_Util::getFormData('criteria_form'); +$dimp_view = ($_SESSION['imp']['view'] == 'dimp'); $search_fields = $imp_search->searchFields(); /* Generate the search query if 'criteria_form' is present in the form @@ -64,7 +65,16 @@ if (!empty($criteria)) { } /* Redirect to the mailbox page. */ - header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('mailbox.php', true), array('mailbox' => $GLOBALS['imp_search']->createSearchID($id)), null, false)); + $id = $GLOBALS['imp_search']->createSearchID($id); + if ($dimp_view) { + /* Output javascript code to close the IFRAME and load the search + * mailbox in DIMP. */ + print '' . + Horde::wrapInlineScript(array('window.parent.DimpBase.go(' . Horde_Serialize::serialize('folder:' . $id, Horde_Serialize::JSON, $charset) . ')')) . + ''; + } else { + header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('mailbox.php', true), array('mailbox' => $$id), null, false)); + } exit; } @@ -174,9 +184,13 @@ Horde::addInlineScript($on_domload, 'dom'); $title = _("Search"); Horde::addScriptFile('horde.js', 'horde', true); Horde::addScriptFile('search.js', 'imp', true); -IMP::prepareMenu(); +if (!$dimp_view) { + IMP::prepareMenu(); +} require IMP_TEMPLATES . '/common-header.inc'; -IMP::menu(); +if (!$dimp_view) { + IMP::menu(); +} IMP::status(); echo $t->fetch(IMP_TEMPLATES . '/search/search.html'); diff --git a/imp/templates/javascript_defs_dimp.php b/imp/templates/javascript_defs_dimp.php index e1ae82abe..80390046c 100644 --- a/imp/templates/javascript_defs_dimp.php +++ b/imp/templates/javascript_defs_dimp.php @@ -50,6 +50,7 @@ $code['conf'] = array_filter(array( 'URI_PREFS' => Horde::getServiceLink('prefsapi', 'imp'), 'URI_PREFS_IMP' => str_replace('&', '&', Horde::getServiceLink('options', 'imp')), 'URI_SEARCH_BASIC' => Horde::applicationUrl('search-basic.php'), + 'URI_SEARCH' => Horde::applicationUrl('search.php'), 'URI_VIEW' => Horde::applicationUrl('view.php'), 'SESSION_ID' => defined('SID') ? SID : '', -- 2.11.0