You are here

function _noderelationships_menu in Node Relationships 6

Implementation of hook_menu().

1 call to _noderelationships_menu()
noderelationships_menu in ./noderelationships.module
Implementation of hook_menu().

File

./noderelationships.system.inc, line 95
Implementation of system related functions that are not executed during normal site operation.

Code

function _noderelationships_menu() {
  $items = array();

  // Include common module functions.
  module_load_include('inc', 'noderelationships');

  // Any event which causes a menu_rebuild could potentially mean that the
  // relationships data is updated -- content type changes, etc.
  noderelationships_cache_clear();

  // Build new menu items for each content type (relationships management).
  foreach (array_keys(node_get_types()) as $type_name) {
    $type_url_str = str_replace('_', '-', $type_name);
    $items['admin/content/node-type/' . $type_url_str . '/relationships'] = array(
      'title' => 'Relationships',
      'page callback' => 'noderelationships_admin_page',
      'page arguments' => array(
        5,
        $type_name,
      ),
      'access arguments' => array(
        'administer content types',
      ),
      'type' => MENU_LOCAL_TASK,
      'weight' => 10,
      'file' => 'noderelationships.admin.inc',
    );
    $admin_tabs = array(
      'erd' => 'Entity relations diagram',
      'noderef' => 'Node reference extras',
      'backref' => 'Back reference settings',
    );
    $item_weight = 0;
    foreach ($admin_tabs as $op => $title) {
      $items['admin/content/node-type/' . $type_url_str . '/relationships/' . $op] = array(
        // Coder note: the content of $title is a literal string, which is fine.
        'title' => $title,
        'page callback' => 'noderelationships_admin_page',
        'page arguments' => array(
          5,
          $type_name,
        ),
        'access arguments' => array(
          'administer content types',
        ),
        'type' => $item_weight == 0 ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
        'weight' => $item_weight,
        'file' => 'noderelationships.admin.inc',
      );
      $item_weight++;
    }
  }

  // Add back reference tab to nodes. Note this tab is added for all nodes,
  // but visibility is controlled by the access callback function.
  $items['node/%node/relationships'] = array(
    'title' => 'Relationships',
    'page callback' => 'noderelationships_backref_page',
    'page arguments' => array(
      1,
    ),
    'access callback' => 'noderelationships_backref_access',
    'access arguments' => array(
      1,
    ),
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,
    'file' => 'noderelationships.pages.inc',
  );

  // Search or Create and reference.
  $items['noderelationships/search'] = array(
    'title' => 'Search and reference',
    'page callback' => 'noderelationships_noderef_page',
    'page arguments' => array(
      1,
    ),
    'access arguments' => array(
      'access content',
    ),
    'type' => MENU_CALLBACK,
    'file' => 'noderelationships.pages.inc',
  );
  $items['noderelationships/create'] = array(
    'title' => 'Create and reference',
    'page callback' => 'noderelationships_noderef_page',
    'page arguments' => array(
      1,
    ),
    'access callback' => '_node_add_access',
    'type' => MENU_CALLBACK,
    'file' => 'noderelationships.pages.inc',
  );
  $items['noderelationships/ahah/search'] = array(
    'title' => 'Search and reference',
    'page callback' => 'noderelationships_noderef_ahah_search',
    'access arguments' => array(
      'access content',
    ),
    'type' => MENU_CALLBACK,
    'file' => 'noderelationships.pages.inc',
  );
  return $items;
}