You are here

function page_manager_menu_alter in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 page_manager/page_manager.module \page_manager_menu_alter()

Implements hook_menu_alter.

Get a list of all tasks and delegate to them.

File

page_manager/page_manager.module, line 194
The page manager module provides a UI and API to manage pages.

Code

function page_manager_menu_alter(&$items) {

  // For some reason, some things can activate modules without satisfying
  // dependencies. I don't know how, but this helps prevent things from
  // whitescreening when this happens.
  if (!module_exists('ctools')) {
    return;
  }
  $tasks = page_manager_get_tasks();
  foreach ($tasks as $task) {
    if ($function = ctools_plugin_get_function($task, 'hook menu alter')) {
      $function($items, $task);
    }

    // Let the subtasks alter the menu items too.
    foreach (page_manager_get_task_subtasks($task) as $subtask_id => $subtask) {
      if ($function = ctools_plugin_get_function($subtask, 'hook menu alter')) {
        $function($items, $subtask);
      }
    }
  }

  // Override the core node revisions display to use the configured Page
  // display handler.
  if (!variable_get('page_manager_node_view_disabled', TRUE) && isset($items['node/%node/revisions/%/view'])) {

    // Abstract the basic settings.
    $item = array(
      // Handle the page arguments.
      'load arguments' => array(
        3,
      ),
      'page arguments' => array(
        1,
        TRUE,
      ),
      // Replace the normal node_show call with Page Manager's node view.
      'page callback' => 'page_manager_node_view_page',
      // Provide the correct path to the Page Manager file.
      'file' => 'node_view.inc',
      'file path' => drupal_get_path('module', 'page_manager') . '/plugins/tasks',
    );

    // Re-build the menu item using the normal values from node.module.
    $items['node/%node/revisions/%/view'] = array(
      'title' => 'Revisions',
      'access callback' => '_node_revision_access',
      'access arguments' => array(
        1,
      ),
    ) + $item;
  }
  return $items;
}