You are here

function node_gallery_api_menu in Node Gallery 7

Implements hook_menu().

File

./node_gallery_api.module, line 27
Node Gallery module.

Code

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

  /* Admin pages */
  $items['admin/config/content/node-gallery'] = array(
    'title' => 'Node Gallery',
    'description' => 'Create and manage your Node Gallery relationships.',
    'page callback' => 'node_gallery_api_relationship_type_list',
    'access arguments' => array(
      NODE_GALLERY_PERM_ADMIN_GALLERY,
    ),
    'file' => 'node_gallery_api.admin.inc',
    'type' => MENU_NORMAL_ITEM,
  );
  $items['admin/config/content/node-gallery/list'] = array(
    'title' => 'Relationship Types',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/config/content/node-gallery/settings'] = array(
    'title' => 'Global Settings',
    'description' => "Manage node gallery's global settings.",
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'node_gallery_api_settings_form',
    ),
    'access arguments' => array(
      NODE_GALLERY_PERM_ADMIN_GALLERY,
    ),
    'file' => 'node_gallery_api.admin.inc',
    'type' => MENU_LOCAL_TASK,
  );
  $items['admin/config/content/node-gallery/add'] = array(
    'title' => 'Add a Gallery Relationship Type',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'node_gallery_api_relationship_type_content_types_form',
    ),
    'access arguments' => array(
      NODE_GALLERY_PERM_ADMIN_GALLERY,
    ),
    'file' => 'node_gallery_api.admin.inc',
    'type' => MENU_LOCAL_ACTION,
  );
  $items['admin/config/content/node-gallery/relationship-type/content_types/%node_gallery_api_relationship_type'] = array(
    'title' => 'Node Gallery - Edit Relationship Type Content Types',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'node_gallery_api_relationship_type_content_types_form',
      6,
    ),
    'access arguments' => array(
      NODE_GALLERY_PERM_ADMIN_GALLERY,
    ),
    'file' => 'node_gallery_api.admin.inc',
    'type' => MENU_CALLBACK,
  );
  $items['admin/config/content/node-gallery/relationship-type/settings/%node_gallery_api_relationship_type'] = array(
    'title' => 'Node Gallery - Edit Relationship Type Settings',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'node_gallery_api_relationship_type_settings_form',
      6,
    ),
    'access arguments' => array(
      NODE_GALLERY_PERM_ADMIN_GALLERY,
    ),
    'file' => 'node_gallery_api.admin.inc',
    'type' => MENU_CALLBACK,
  );
  $items['admin/config/content/node-gallery/delete/%node_gallery_api_relationship_type'] = array(
    'title' => 'Node Gallery - Delete Relationship Type',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'node_gallery_api_relationship_type_delete_form',
      5,
    ),
    'access arguments' => array(
      NODE_GALLERY_PERM_ADMIN_GALLERY,
    ),
    'file' => 'node_gallery_api.admin.inc',
    'type' => MENU_CALLBACK,
  );

  /* User-facing pages */
  $items['node/%node_gallery_api_gallery/browse'] = array(
    'title' => 'Browse Items',
    'page callback' => 'node_gallery_api_browse_items',
    'page arguments' => array(
      1,
    ),
    'access arguments' => array(
      NODE_GALLERY_PERM_VIEW_GALLERY,
    ),
    'file' => 'node_gallery_api.pages.inc',
    'type' => MENU_CALLBACK,
  );
  $items['node/%node_gallery_api_gallery/sort'] = array(
    'title' => 'Sort Items',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'node_gallery_api_sort_items_form',
      1,
      3,
    ),
    'access callback' => 'node_gallery_api_user_access',
    'access arguments' => array(
      'edit item',
      1,
    ),
    'file' => 'node_gallery_api.pages.inc',
    'weight' => -4,
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  );
  $items['node-gallery/json/item/create/%/%/%'] = array(
    'page callback' => 'node_gallery_api_json_create_item',
    'page arguments' => array(
      4,
      5,
      6,
    ),
    'access callback' => TRUE,
    'file' => 'node_gallery_api.pages.inc',
    'type' => MENU_CALLBACK,
  );
  $items['node-gallery/json/gallery/create/%/%'] = array(
    'page callback' => 'node_gallery_json_create_gallery',
    'page arguments' => array(
      4,
      5,
    ),
    'access callback' => TRUE,
    'file' => 'node_gallery.pages.inc',
    'type' => MENU_CALLBACK,
  );
  $items['node-gallery/json/gallery/%node_gallery_api_gallery/sort'] = array(
    'page callback' => 'node_gallery_json_get_sorted_images',
    'page arguments' => array(
      3,
      5,
      6,
    ),
    'access callback' => 'node_gallery_user_access',
    'access arguments' => array(
      'edit item',
      3,
    ),
    'file' => 'node_gallery.pages.inc',
    'type' => MENU_CALLBACK,
  );
  $items['node-gallery/json/gallery/%node_gallery_api_gallery/images'] = array(
    'page callback' => 'node_gallery_json_get_images',
    'page arguments' => array(
      3,
      5,
      6,
      7,
    ),
    'access callback' => 'node_gallery_user_access',
    'access arguments' => array(
      'view',
      3,
    ),
    'file' => 'node_gallery.pages.inc',
    'type' => MENU_CALLBACK,
  );
  $items['node/%node_gallery_api_gallery/items'] = array(
    'title' => 'Manage Items',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'node_gallery_api_manage_items_form',
      1,
    ),
    'access callback' => 'node_gallery_api_user_access',
    'access arguments' => array(
      'edit item',
      1,
    ),
    'file' => 'node_gallery_api.pages.inc',
    'weight' => -3,
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  );

  // Alias /manage to /images
  $items['node/%node_gallery_api_gallery/manage'] = $items['node/%node_gallery_api_gallery/items'];
  $items['node/%node_gallery_api_gallery/manage']['type'] = MENU_CALLBACK;

  // Callback for AHAH add more buttons.
  $items['node-gallery/json/js_add_more'] = array(
    'page callback' => 'node_gallery_content_add_more_js',
    'access arguments' => array(
      'access content',
    ),
    'file' => 'node_gallery.pages.inc',
    'type' => MENU_CALLBACK,
  );
  $item_types = array();
  $relationship_types = node_gallery_api_get_relationship_type(NULL, NULL, NULL, TRUE);
  if (!empty($relationship_types)) {
    foreach ($relationship_types as $relationship) {
      foreach ($relationship->item_types as $item_type) {
        $type_info = node_type_load($item_type);
        if (!empty($type_info)) {
          $items['node/%node_gallery_api_gallery/upload/' . $item_type] = array(
            'title' => $type_info->name,
            'page callback' => 'node_gallery_api_upload_items_form',
            'page arguments' => array(
              1,
              $item_type,
            ),
            'access callback' => 'node_gallery_api_upload_access',
            'access arguments' => array(
              1,
              $item_type,
            ),
            'file' => 'node_gallery_api.pages.inc',
            'weight' => -2,
            'type' => empty($item_types) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
          );
        }
        $item_types[] = $item_type;
      }
    }
  }
  $items['node/%node_gallery_api_gallery/upload'] = array(
    'title' => 'Upload New Items',
    'page callback' => 'node_gallery_api_upload_items_form',
    'page arguments' => array(
      1,
    ),
    'access callback' => 'node_gallery_api_upload_access',
    'access arguments' => array(
      1,
    ),
    'file' => 'node_gallery_api.pages.inc',
    'weight' => -2,
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  );
  return $items;
}