You are here

function nodehierarchy_menu in Node Hierarchy 5

Same name and namespace in other branches
  1. 6.3 nodehierarchy.module \nodehierarchy_menu()
  2. 6 nodehierarchy.module \nodehierarchy_menu()
  3. 6.2 nodehierarchy.module \nodehierarchy_menu()
  4. 7.4 nodehierarchy.module \nodehierarchy_menu()
  5. 7.2 nodehierarchy.module \nodehierarchy_menu()

Implementation of hook_menu().

File

./nodehierarchy.module, line 51
A module to make nodes hierarchical.

Code

function nodehierarchy_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'hierarchy',
      'title' => t('hierarchy'),
      'callback' => 'nodehierarchy_callback',
      'type' => MENU_CALLBACK,
      'access' => 1,
    );
    $items[] = array(
      'path' => 'nodehierarchy/ajax',
      'title' => t('Node hierarchy ajax callback'),
      'access' => user_access('access content'),
      'type' => MENU_CALLBACK,
      'callback' => 'nodehierarchy_callback_ajax',
    );
    $items[] = array(
      'path' => 'admin/content/nodehierarchy',
      'title' => t('Site Outline'),
      'description' => t('Display an hierarchical outline of the site.'),
      'callback' => 'nodehierarchy_site_outline',
      'access' => user_access('view site outline'),
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'admin/settings/nodehierarchy',
      'title' => t('Node Hierarchy'),
      'description' => t('Administer default Node Hierarchy settings.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'nodehierarchy_admin_settings',
      ),
      'access' => user_access('administer site configuration'),
      'type' => MENU_NORMAL_ITEM,
    );
  }
  else {
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = node_load(arg(1));
      if ($node->nid && variable_get('nh_parent_' . $node->type, FALSE)) {
        $items[] = array(
          'path' => 'node/' . arg(1) . '/children',
          'title' => t('Children'),
          'callback' => 'nodehierarchy_view_children',
          'callback arguments' => array(
            arg(1),
          ),
          'access' => node_access('update', $node),
          'type' => MENU_LOCAL_TASK,
          'weight' => 5,
        );
      }
    }
  }
  return $items;
}