You are here

function diff_menu in Diff 7.3

Same name and namespace in other branches
  1. 5.2 diff.module \diff_menu()
  2. 5 diff.module \diff_menu()
  3. 6.2 diff.module \diff_menu()
  4. 6 diff.module \diff_menu()
  5. 7.2 diff.module \diff_menu()

Implements hook_menu().

@todo: Review this.

File

./diff.module, line 70
Provides functionality to show a diff between two node revisions.

Code

function diff_menu() {

  /*
   * By using MENU_LOCAL_TASK (and 'tab_parent') we can get the various
   * revision-views to show the View|Edit|Revision-tabs of the node on top,
   * and have the Revisions-tab open. To avoid creating/showing any extra tabs
   * or sub-tabs (tasks below top level) for the various paths (i.e. "Diff",
   * "Show latest" and "Show a specific revision") that need a revision-id (vid)
   * parameter, we make sure to set 'tab_parent' a bit odd. This solution may
   * not be the prettiest one, but by avoiding having two _LOCAL_TASKs sharing
   * a parent that can be accessed by its full path, it seems to work as
   * desired. Breadcrumbs work decently, at least the node link is among the
   * crumbs. For some reason any breadcrumbs "before/above" the node is only
   * seen at 'node/%node/revisions/%/view'.
   */

  // Not used directly, but was created to get the other menu items to work.
  $items['node/%node/revisions/list'] = array(
    'title' => 'List revisions',
    'page callback' => 'diff_diffs_overview',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'access callback' => 'diff_node_revision_access',
    'access arguments' => array(
      1,
    ),
    'file' => 'diff.pages.inc',
  );
  $items['node/%node/revisions/view'] = array(
    'title' => 'Compare revisions',
    'page callback' => 'diff_diffs_show',
    'page arguments' => array(
      1,
      4,
      5,
      6,
    ),
    'type' => MENU_LOCAL_TASK,
    'access callback' => 'diff_node_revision_access',
    'access arguments' => array(
      1,
    ),
    'tab_parent' => 'node/%/revisions/list',
    'file' => 'diff.pages.inc',
  );
  $items['node/%node/revisions/view/latest'] = array(
    'title' => 'Show latest difference',
    'page callback' => 'diff_latest',
    'page arguments' => array(
      1,
    ),
    'type' => MENU_LOCAL_TASK,
    'access arguments' => array(
      'access content',
    ),
    'tab_parent' => 'node/%/revisions/view',
    'file' => 'diff.pages.inc',
  );

  // Administrative settings.
  $items['admin/config/content/diff'] = array(
    'title' => 'Diff',
    'description' => 'Diff settings.',
    'file' => 'diff.admin.inc',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'diff_admin_settings',
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
  );
  $items['admin/config/content/diff/settings'] = array(
    'title' => 'Settings',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/config/content/diff/fields'] = array(
    'title' => 'Fields',
    'description' => 'Field support and settings overview.',
    'file' => 'diff.admin.inc',
    'page callback' => 'diff_admin_field_overview',
    'access arguments' => array(
      'administer site configuration',
    ),
    'type' => MENU_LOCAL_TASK,
  );
  $items['admin/config/content/diff/fields/%'] = array(
    'title' => 'Global field settings',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'diff_admin_global_field_settings',
      5,
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
    'type' => MENU_VISIBLE_IN_BREADCRUMB,
    'file' => 'diff.admin.inc',
  );
  $items['admin/config/content/diff/entities'] = array(
    'title' => 'Entities',
    'description' => 'Entity settings.',
    'file' => 'diff.admin.inc',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'diff_admin_global_entity_settings',
      'node',
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
    'type' => MENU_LOCAL_TASK,
  );
  $items['admin/config/content/diff/entities/node'] = array(
    'title' => 'Nodes',
    'description' => 'Node comparison settings.',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/config/content/diff/entities/user'] = array(
    'title' => 'Users',
    'description' => 'User diff settings.',
    'file' => 'diff.admin.inc',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'diff_admin_global_entity_settings',
      'user',
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}