You are here

function page_manager_search_page in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 page_manager/plugins/tasks/search.inc \page_manager_search_page()

Entry point for our overridden node view.

This function asks its assigned handlers who, if anyone, would like to run with it. If no one does, it passes through to Drupal core's node view, which is node_page_view().

1 string reference to 'page_manager_search_page'
page_manager_search_menu_alter in page_manager/plugins/tasks/search.inc
Callback defined by page_manager_search_page_manager_tasks().

File

page_manager/plugins/tasks/search.inc, line 167
Handle the 'node view' override task.

Code

function page_manager_search_page($type) {
  ctools_include('menu');
  menu_set_active_trail(ctools_get_menu_trail('search/' . $type));

  // Get the arguments and construct a keys string out of them.
  $args = func_get_args();

  // We have to remove the $type.
  array_shift($args);

  // And implode() it all back together.
  $keys = $args ? implode('/', $args) : '';

  // Load my task plugin
  $task = page_manager_get_task('search');
  $subtask = page_manager_get_task_subtask($task, $type);

  // Load the node into a context.
  ctools_include('context');
  ctools_include('context-task-handler');
  $contexts = ctools_context_handler_get_task_contexts($task, $subtask, array(
    $keys,
  ));
  $output = ctools_context_handler_render($task, $subtask, $contexts, array(
    $keys,
  ));
  if ($output !== FALSE) {
    return $output;
  }
  $function = 'search_view';
  foreach (module_implements('page_manager_override') as $module) {
    $call = $module . '_page_manager_override';
    if (($rc = $call('search')) && function_exists($rc)) {
      $function = $rc;
      break;
    }
  }

  // Otherwise, fall back.
  // Put the $type back on the arguments.
  module_load_include('inc', 'search', 'search.pages');
  array_unshift($args, $type);
  return call_user_func_array($function, $args);
}