function page_manager_search_menu_alter

Callback defined by page_manager_search_page_manager_tasks().

Alter the search tabs to work with page manager. The search flow is quite odd, and tracing through the code takes hours to realize that the tab you click on does not normally actually handle the search. This tries to account for that.

Note to module authors: This tends to work a lot better with modules that override their own search pages if their _alter runs *before* this one.

1 string reference to 'page_manager_search_menu_alter'
page_manager_search_page_manager_tasks in page_manager/plugins/tasks/search.inc
Specialized implementation of hook_page_manager_task_tasks().

File

page_manager/plugins/tasks/search.inc, line 57

Code

function page_manager_search_menu_alter(&$items, $task) {
    // We are creating two sets of tabs. One set is for searching without
    // keywords. A second set is for searching *with* keywords. This
    // is necessary because search/node/% and search/node need to be
    // different due to the way the search menu items function.
    $default_info = search_get_default_module_info();
    if (empty($default_info)) {
        // Nothing to do.
        return;
    }
    // Go through each search module item.
    foreach (search_get_info() as $module => $info) {
        if (variable_get('page_manager_search_disabled_' . $module, TRUE)) {
            continue;
        }
        $path = 'search/' . $info['path'];
        $callback = $items["{$path}/%menu_tail"]['page callback'];
        if ($callback == 'search_view' || variable_get('page_manager_override_anyway', FALSE)) {
            $items["{$path}"]['page callback'] = 'page_manager_search_page';
            $items["{$path}"]['file path'] = $task['path'];
            $items["{$path}"]['file'] = $task['file'];
            $items["{$path}/%menu_tail"]['page callback'] = 'page_manager_search_page';
            $items["{$path}/%menu_tail"]['file path'] = $task['path'];
            $items["{$path}/%menu_tail"]['file'] = $task['file'];
        }
        else {
            // Automatically disable this task if it cannot be enabled.
            variable_set('page_manager_search_disabled_' . $module, TRUE);
            if (!empty($GLOBALS['page_manager_enabling_search'])) {
                drupal_set_message(t('Page manager module is unable to enable @path because some other module already has overridden with %callback.', array(
                    '%callback' => $callback,
                    '@path' => $path,
                )), 'error');
            }
        }
    }
}