You are here

public function FlexiformUIController::hook_menu in Flexiform 7

Overrides hook_menu() defaults.

Overrides EntityDefaultUIController::hook_menu

File

./flexiform.admin.inc, line 188
Model type editing UI.

Class

FlexiformUIController
UI controller.

Code

public function hook_menu() {
  $wildcard = '%flexiform';
  $items = parent::hook_menu();
  $items[$this->path]['description'] = 'Manage flexiforms, including adding
		and removing fields and the display of fields.';

  // Change the way they clone things.
  $items["{$this->path}/manage/%entity_object/clone"]['page callback'] = 'flexiform_ui_get_clone_form';

  // Tags autocomplete pages.
  $items["{$this->path}/autocomplete_tags"] = array(
    'title' => 'Flexiform tags autocomplete',
    'page callback' => 'flexiform_autocomplete_tags',
    'page arguments' => array(
      4,
    ),
    'type' => MENU_CALLBACK,
    'file' => 'flexiform.admin.inc',
    'file path' => drupal_get_path('module', 'flexiform'),
    'access arguments' => array(
      'administer flexiforms',
    ),
  );
  $items["{$this->path}/manage/%entity_object/edit"]['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
  $items["{$this->path}/manage/{$wildcard}/form-fields"] = array(
    'title' => 'Manage form fields',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'flexiform_manage_form_fields_form',
      4,
    ),
    'access callback' => 'flexiform_builder_admin_access',
    'access arguments' => array(
      4,
      'elements',
    ),
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    'weight' => 2,
    'file' => 'flexiform.admin.inc',
    'file path' => drupal_get_path('module', 'flexiform'),
  );
  $items["{$this->path}/manage/{$wildcard}/form-fields/%flexiform_formfield"] = array(
    'title' => 'Edit Field',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'flexiform_field_configure_form',
      4,
      6,
    ),
    'file' => 'flexiform.admin.inc',
    'file path' => drupal_get_path('module', 'flexiform'),
    'access arguments' => array(
      'administer flexiforms',
    ),
  );
  $items["{$this->path}/manage/{$wildcard}/form-fields/%flexiform_formfield/edit"] = array(
    'title' => 'Configure',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'flexiform_field_configure_form',
      4,
      6,
    ),
    'file' => 'flexiform.admin.inc',
    'file path' => drupal_get_path('module', 'flexiform'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'access arguments' => array(
      'administer flexiforms',
    ),
  );
  $items["{$this->path}/manage/{$wildcard}/form-fields/%flexiform_formfield/widget-type"] = array(
    'title' => 'Widget type',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'flexiform_field_widget_type_form',
      4,
      6,
    ),
    'access callback' => 'flexiform_field_widget_type_form_access',
    'access arguments' => array(
      4,
      6,
    ),
    'file' => 'flexiform.admin.inc',
    'file path' => drupal_get_path('module', 'flexiform'),
    'type' => MENU_LOCAL_TASK,
  );
  $items["{$this->path}/manage/{$wildcard}/form-fields/%flexiform_formfield/remove"] = array(
    'title' => 'Remove',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'flexiform_field_remove_form',
      4,
      6,
    ),
    'file' => 'flexiform.admin.inc',
    'file path' => drupal_get_path('module', 'flexiform'),
    'type' => MENU_LOCAL_TASK,
    'access arguments' => array(
      'administer flexiforms',
    ),
  );
  $items["{$this->path}/manage/{$wildcard}/form-entities"] = array(
    'title' => 'Manage form entities',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'flexiform_manage_form_entities_form',
      4,
    ),
    'access callback' => 'flexiform_builder_admin_access',
    'access arguments' => array(
      4,
      'entities',
    ),
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    'weight' => 3,
    'file' => 'flexiform.admin.inc',
    'file path' => drupal_get_path('module', 'flexiform'),
  );
  $items["{$this->path}/manage/{$wildcard}/form-entities/%"] = array(
    'title' => 'Configure',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'flexiform_entity_configure_form',
      4,
      6,
    ),
    'type' => MENU_CALLBACK,
    'weight' => 3,
    'file' => 'flexiform.admin.inc',
    'file path' => drupal_get_path('module', 'flexiform'),
    'access arguments' => array(
      'administer flexiforms',
    ),
  );
  $items["{$this->path}/manage/{$wildcard}/form-entities/%/configure"] = array(
    'title' => 'Configure',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => 3,
  );
  $items["{$this->path}/manage/{$wildcard}/form-entities/%/remove"] = array(
    'title' => 'Remove',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'flexiform_entity_remove_form',
      4,
      6,
    ),
    'type' => MENU_LOCAL_TASK,
    'weight' => 4,
    'file' => 'flexiform.admin.inc',
    'file path' => drupal_get_path('module', 'flexiform'),
    'access arguments' => array(
      'administer flexiforms',
    ),
  );
  if (module_exists('rules_admin')) {
    $items["{$this->path}/manage/{$wildcard}/rules/add-action"] = array(
      'title' => 'Add Action',
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'rules_admin_add_reaction_rule',
        "{$this->path}/manage/{$wildcard}/rules/add-action",
      ),
      'access callback' => TRUE,
      'file' => 'rules_admin.inc',
      'file path' => drupal_get_path('module', 'rules_admin'),
    );
  }

  // Generate paths for all other entity types with field UI.
  // @see field_ui_menu
  $entity_info = entity_get_info();
  foreach ($entity_info as $entity_type => $info) {

    // Only do this if the bundle is set.
    if (empty($info['bundles'])) {
      continue;
    }
    foreach ($info['bundles'] as $bundle_name => $bundle_info) {

      // Only act if there is an admin page set.
      if (empty($bundle_info['admin'])) {
        continue;
      }

      // Get the path for this bundle.
      $path = $bundle_info['admin']['path'];

      // The bundle arg could be either a position in the path or an actual
      // bundle.
      if (isset($bundle_info['admin']['bundle argument'])) {
        $bundle_arg = $bundle_info['admin']['bundle argument'];
      }
      else {
        $bundle_arg = $bundle_name;
      }

      // Extract access information, providing defaults.
      $access = array_intersect_key($bundle_info['admin'], drupal_map_assoc(array(
        'access callback',
        'access arguments',
      )));
      $access += array(
        'access callback' => 'user_access',
        'access arguments' => array(
          'administer site configuration',
        ),
      );
      $items["{$path}/forms"] = array(
        'title' => t('Manage Forms'),
        'type' => MENU_LOCAL_TASK,
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
          'flexiform_overview_form',
          'flexiform',
          $entity_type,
          $bundle_arg,
        ),
        'description' => 'Manage ' . $info['label'] . ' Forms',
        'weight' => 3,
        'file' => 'includes/entity.ui.inc',
      ) + $access;
      $items["{$path}/forms/add"] = array(
        'title' => t('Add Form'),
        'type' => MENU_LOCAL_ACTION,
        'page callback' => 'flexiform_add_for_entity',
        'page arguments' => array(
          $entity_type,
          $bundle_arg,
        ),
        'description' => t('Add Form'),
        'file' => 'flexiform.admin.inc',
        'file path' => drupal_get_path('module', 'flexiform'),
      ) + $access;
    }
  }
  return $items;
}