You are here

function content_menu in Content Construction Kit (CCK) 6

Same name and namespace in other branches
  1. 5 content.module \content_menu()
  2. 6.3 content.module \content_menu()
  3. 6.2 content.module \content_menu()

Implementation of hook_menu().

File

./content.module, line 112
Allows administrators to associate custom fields to content types.

Code

function content_menu() {
  $items = array();
  $items['admin/content/types/fields'] = array(
    'title' => 'Fields',
    'page callback' => '_content_admin_type_fields',
    'access arguments' => array(
      'administer content types',
    ),
    'file' => 'includes/content.admin.inc',
    'type' => MENU_LOCAL_TASK,
  );

  // Callback for AHAH add more buttons.
  $items['content/js_add_more'] = array(
    'page callback' => 'content_add_more_js',
    // TODO : access rule ?
    'access arguments' => array(
      'access content',
    ),
    'file' => 'includes/content.node_form.inc',
    'type' => MENU_CALLBACK,
  );

  // Make sure this doesn't fire until content_types is working,
  // needed to avoid errors on initial installation.
  if (!defined('MAINTENANCE_MODE')) {
    foreach (node_get_types() as $type) {
      $type_name = $type->type;
      $content_type = content_types($type_name);
      $type_url_str = $content_type['url_str'];
      $items['admin/content/node-type/' . $type_url_str . '/fields'] = array(
        'title' => 'Manage fields',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
          'content_admin_field_overview_form',
          $type_name,
        ),
        'access arguments' => array(
          'administer content types',
        ),
        'file' => 'includes/content.admin.inc',
        'type' => MENU_LOCAL_TASK,
        'weight' => 1,
      );
      $items['admin/content/node-type/' . $type_url_str . '/display'] = array(
        'title' => 'Display fields',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
          'content_admin_display_overview_form',
          $type_name,
        ),
        'access arguments' => array(
          'administer content types',
        ),
        'file' => 'includes/content.admin.inc',
        'type' => MENU_LOCAL_TASK,
        'weight' => 2,
      );
      $items['admin/content/node-type/' . $type_url_str . '/display/general'] = array(
        'title' => 'General',
        'page arguments' => array(
          'content_admin_display_overview_form',
          $type_name,
        ),
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'weight' => 0,
      );
      $items['admin/content/node-type/' . $type_url_str . '/display/advanced'] = array(
        'title' => 'Advanced',
        'page arguments' => array(
          'content_admin_display_overview_form',
          $type_name,
          (string) CONTENT_CONTEXTS_ADVANCED,
        ),
        'access arguments' => array(
          'administer content types',
        ),
        'type' => MENU_LOCAL_TASK,
        'weight' => 1,
      );
      $items['admin/content/node-type/' . $type_url_str . '/add_field'] = array(
        'title' => 'Add field',
        'page callback' => '_content_admin_field_add',
        'page arguments' => array(
          $type_name,
        ),
        'access arguments' => array(
          'administer content types',
        ),
        'file' => 'includes/content.admin.inc',
        'type' => MENU_LOCAL_TASK,
        'weight' => 3,
      );
      foreach ($content_type['fields'] as $field) {
        $field_name = $field['field_name'];
        $items['admin/content/node-type/' . $type_url_str . '/fields/' . $field_name] = array(
          'title' => $field['widget']['label'],
          'page callback' => 'drupal_get_form',
          'page arguments' => array(
            '_content_admin_field',
            $type_name,
            $field_name,
          ),
          'access arguments' => array(
            'administer content types',
          ),
          'file' => 'includes/content.admin.inc',
          'type' => MENU_LOCAL_TASK,
        );
        $items['admin/content/node-type/' . $type_url_str . '/fields/' . $field_name . '/remove'] = array(
          'title' => 'Remove field',
          'page callback' => 'drupal_get_form',
          'page arguments' => array(
            '_content_admin_field_remove',
            $type_name,
            $field_name,
          ),
          'access arguments' => array(
            'administer content types',
          ),
          'file' => 'includes/content.admin.inc',
          'type' => MENU_CALLBACK,
        );
      }
    }
  }
  return $items;
}