You are here

function search_api_page_search_api_page_page in Search API Pages 7

Page callback: Displays a search page as a page manager task.

1 string reference to 'search_api_page_search_api_page_page'
search_api_page_search_api_page_menu_alter in plugins/tasks/search_api_page.inc
Alters available menu items based on a defined task.

File

plugins/tasks/search_api_page.inc, line 80
Handles the 'search api page' override task.

Code

function search_api_page_search_api_page_page($type) {
  ctools_include('menu');

  // 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_api_page');
  $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;
  }

  // Otherwise, fall back.
  $function = 'search_api_page_view';
  foreach (module_implements('page_manager_override') as $module) {
    $call = $module . '_page_manager_override';
    if (($rc = $call('search_api_page')) && function_exists($rc)) {
      $function = $rc;
      break;
    }
  }

  // Load the search page results with the given keywords.
  module_load_include('inc', 'search_api_page', 'search_api_page.pages');
  $args = array(
    $type,
    $keys,
  );
  return call_user_func_array($function, $args);
}