summaryrefslogtreecommitdiff
path: root/modules/search
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-05-01 01:04:24 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-05-01 01:04:24 +0000
commit6ab3f16396b2472c1b41dcbdd258f451b3146b54 (patch)
tree12efb3916c61d9474303a7862729760de3520a03 /modules/search
parent1f3e11d44cc0849b4478a42cd52bac4e4808d75f (diff)
downloadbrdo-6ab3f16396b2472c1b41dcbdd258f451b3146b54.tar.gz
brdo-6ab3f16396b2472c1b41dcbdd258f451b3146b54.tar.bz2
#245103 by chx, jhodgdon, merlinofchaos, douggreen, jrbeeman: Fixed Search page tabs not highlighting.
Diffstat (limited to 'modules/search')
-rw-r--r--modules/search/search.module35
-rw-r--r--modules/search/search.pages.inc12
2 files changed, 36 insertions, 11 deletions
diff --git a/modules/search/search.module b/modules/search/search.module
index 62d75ab6c..7c94c0f95 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -246,18 +246,43 @@ function search_menu() {
'file path' => drupal_get_path('module', 'dblog'),
'file' => 'dblog.admin.inc',
);
+
+ // Add paths for searching. We add each module search path twice: once without
+ // and once with %menu_tail appended. The reason for this is that we want to
+ // preserve keywords when switching tabs, and also to have search tabs
+ // highlighted properly. The only way to do that within the Drupal menu
+ // system appears to be having two sets of tabs. See discussion on issue
+ // http://drupal.org/node/245103 for details.
+
drupal_static_reset('search_get_info');
- $search_hooks = search_get_info();
- foreach(variable_get('search_active_modules', array('node', 'user')) as $module) {
- if (isset($search_hooks[$module])) {
- $items['search/' . $search_hooks[$module]['path'] . '/%menu_tail'] = array(
- 'title' => $search_hooks[$module]['title'],
+ if ($active = variable_get('search_active_modules', array('node', 'user'))) {
+ foreach (array_intersect_key(search_get_info(), array_flip($active)) as $module => $search_info) {
+ $path = 'search/' . $search_info['path'];
+ $items[$path] = array(
+ 'title' => $search_info['title'],
+ 'page callback' => 'search_view',
+ 'page arguments' => array($module),
+ 'access callback' => '_search_menu_access',
+ 'access arguments' => array($module),
+ 'type' => $module == 'node' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
+ 'file' => 'search.pages.inc',
+ 'weight' => $module == 'node' ? -10 : 0,
+ );
+ $items["$path/%menu_tail"] = array(
+ 'title' => $search_info['title'],
'page callback' => 'search_view',
'page arguments' => array($module),
'access callback' => '_search_menu_access',
'access arguments' => array($module),
+ // The default local task points to its parent, but this item points to
+ // where it should so it should not be changed.
'type' => MENU_LOCAL_TASK,
'file' => 'search.pages.inc',
+ 'weight' => 0,
+ // These tabs are not subtabs.
+ 'tab_root' => 'search/node/%',
+ // These tabs need to display at the same level.
+ 'tab_parent' => 'search',
);
}
}
diff --git a/modules/search/search.pages.inc b/modules/search/search.pages.inc
index 6bbb88942..17245cef9 100644
--- a/modules/search/search.pages.inc
+++ b/modules/search/search.pages.inc
@@ -14,14 +14,14 @@ function search_view($type = 'node') {
// the search query URL clean as a whistle:
// search/type/keyword+keyword
if (!isset($_POST['form_id'])) {
- if ($type == '') {
- // Note: search/node can not be a default tab because it would take on the
- // path of its parent (search). It would prevent remembering keywords when
- // switching tabs. This is why we drupal_goto to it from the parent instead.
- drupal_goto('search/node');
+ $keys = search_get_keys();
+ if ($_GET['q'] != 'search' && $type == 'node' && !$keys) {
+ // Due to how search_menu() sets up the tabs, path search/node would
+ // display two sets of tabs. So instead, if there are no keywords and
+ // we're on the node tab, just redirect to the bare 'search' path.
+ drupal_goto('search');
}
- $keys = search_get_keys();
// Only perform search if there is non-whitespace search term:
$results = '';
if (trim($keys)) {