You are here

function panels_node_menu in Panels 5.2

Same name and namespace in other branches
  1. 6.3 panels_node/panels_node.module \panels_node_menu()
  2. 6.2 panels_node/panels_node.module \panels_node_menu()
  3. 7.3 panels_node/panels_node.module \panels_node_menu()

Implementation of hook_menu().

File

panels_node/panels_node.module, line 25
panels_node.module

Code

function panels_node_menu($may_cache) {
  if ($may_cache) {
    $items[] = array(
      'path' => 'node/add/panel',
      'title' => t('Panel'),
      'access' => user_access('create panel-nodes'),
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'admin/panels/panel-nodes',
      'title' => t('Panel nodes'),
      'access' => user_access('create panel-nodes') && user_access('access administration pages'),
      'type' => MENU_NORMAL_ITEM,
      'callback' => 'panels_node_admin',
      'description' => t('Information about panel nodes.'),
    );
    $items[] = array(
      'path' => 'admin/panels/panel-nodes/information',
      'title' => t('Information'),
      'access' => user_access('create panel-nodes') && user_access('access administration pages'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/panels/panel-nodes/settings',
      'title' => t('Settings'),
      'description' => t('Configure panel node content availability.'),
      'access' => user_access('administer panel-nodes'),
      'callback' => 'panels_node_settings',
      'type' => MENU_LOCAL_TASK,
    );
  }
  else {
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = node_load(arg(1));
      if ($node && $node->type == 'panel' && node_access('update', $node)) {
        $base = 'node/' . arg(1) . '/panel_';
        $items[] = array(
          'path' => $base . 'layout',
          'title' => t('Panel layout'),
          'access' => TRUE,
          'callback' => 'panels_node_edit_layout',
          'callback arguments' => array(
            $node,
          ),
          'weight' => 2,
          'type' => MENU_LOCAL_TASK,
        );
        $items[] = array(
          'path' => $base . 'settings',
          'title' => t('Panel layout settings'),
          'access' => TRUE,
          'callback' => 'panels_node_edit_layout_settings',
          'callback arguments' => array(
            $node,
          ),
          'weight' => 2,
          'type' => MENU_LOCAL_TASK,
        );
        $items[] = array(
          'path' => $base . 'content',
          'title' => t('Panel content'),
          'access' => TRUE,
          'callback' => 'panels_node_edit_content',
          'callback arguments' => array(
            $node,
          ),
          'weight' => 3,
          'type' => MENU_LOCAL_TASK,
        );
        $items[] = array(
          'path' => $base . 'context',
          'title' => t('Context'),
          'access' => TRUE,
          'callback' => 'panels_node_context_edit',
          'callback arguments' => array(
            $node,
          ),
          'weight' => 4,
          'type' => MENU_LOCAL_TASK,
        );
      }
    }

    // Hard override of node/add
    if (arg(0) == 'node' && arg(1) == 'add' && arg(2) == 'panel' && arg(3) == NULL) {
      $items[] = array(
        'path' => 'node/add/panel',
        'title' => t('Panel'),
        'access' => user_access('create panel-nodes'),
        'callback' => 'panels_node_add',
        'type' => MENU_NORMAL_ITEM,
      );
    }
  }
  return $items;
}