You are here

public function PartyActivityUIController::hook_menu in Party 7

Same name and namespace in other branches
  1. 8.2 modules/party_activity/party_activity.admin.inc \PartyActivityUIController::hook_menu()

Overrides hook_menu() defaults. Main reason for doing this is that parent class hook_menu is optimized for entity type administration.

Overrides EntityDefaultUIController::hook_menu

File

modules/party_activity/party_activity.admin.inc, line 16
Party Activity editing UI

Class

PartyActivityUIController
UI Controller

Code

public function hook_menu() {
  $items = array();
  $id_count = count(explode('/', $this->path));
  $wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%' . $this->entityType;
  $items[$this->path] = array(
    'title' => 'Activities',
    'description' => 'Add edit and update activities.',
    'page callback' => 'system_admin_menu_block_page',
    'access arguments' => array(
      'access administration pages',
    ),
    'file path' => drupal_get_path('module', 'system'),
    'file' => 'system.admin.inc',
  );

  // Change the overview menu type for the list of activities.
  $items[$this->path]['type'] = MENU_LOCAL_TASK;

  // Change the add page menu to multiple types of entities
  $items[$this->path . '/add'] = array(
    'title' => 'Add an activity',
    'description' => 'Add a new activity',
    'page callback' => 'party_activity_add_page',
    'access callback' => 'party_activity_access',
    'access arguments' => array(
      'edit',
    ),
    'type' => MENU_NORMAL_ITEM,
    'weight' => 20,
    'file' => 'party_activity.admin.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );

  // Add menu items to add each different type of entity.
  foreach (party_activity_get_types() as $type) {
    $items[$this->path . '/add/' . $type->type] = array(
      'title' => 'Add ' . $type->label,
      'page callback' => 'party_activity_form_wrapper',
      'page arguments' => array(
        party_activity_create(array(
          'type' => $type->type,
        )),
      ),
      'access callback' => 'party_activity_access',
      'access arguments' => array(
        'edit',
        'edit ' . $type->type,
      ),
      'file' => 'party_activity.admin.inc',
      'file path' => drupal_get_path('module', $this->entityInfo['module']),
    );
  }

  // Loading and editing party_activity entities
  $items[$this->path . '/activity/' . $wildcard] = array(
    'title callback' => 'party_activity_page_title',
    'title arguments' => array(
      $id_count + 1,
      'edit',
    ),
    'page callback' => 'party_activity_form_wrapper',
    'page arguments' => array(
      $id_count + 1,
    ),
    'access callback' => 'party_activity_access',
    'access arguments' => array(
      'edit',
      $id_count + 1,
    ),
    'weight' => 0,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    'file' => 'party_activity.admin.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );
  $items[$this->path . '/activity/' . $wildcard . '/edit'] = array(
    'title' => 'Edit',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  );
  $items[$this->path . '/activity/' . $wildcard . '/delete'] = array(
    'title' => 'Delete',
    'page callback' => 'party_activity_delete_form_wrapper',
    'page arguments' => array(
      $id_count + 1,
    ),
    'access callback' => 'party_activity_access',
    'access arguments' => array(
      'edit',
      $id_count + 1,
    ),
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_INLINE,
    'weight' => 10,
    'file' => 'party_activity.admin.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );

  // Menu item for viewing party activity
  $items['activity/' . $wildcard] = array(
    //'title' => 'Title',
    'title callback' => 'party_activity_page_title',
    'title arguments' => array(
      1,
    ),
    'page callback' => 'party_activity_page_view',
    'page arguments' => array(
      1,
    ),
    'access callback' => 'party_activity_access',
    'access arguments' => array(
      'view',
      1,
    ),
    'type' => MENU_CALLBACK,
  );

  // Modal items.
  $items[$this->path . '/modal/add/%ctools_js'] = $items[$this->path . '/modal/add/%/%ctools_js'] = array(
    'title' => t('Add !activity', array(
      '!activity' => $this->entityInfo['label'],
    )),
    'page callback' => 'party_activity_modal_add_form_wrapper',
    'page arguments' => array(
      NULL,
      $id_count + 2,
    ),
    'access callback' => 'party_activity_access',
    'access arguments' => array(
      'edit',
    ),
    'file' => 'party_activity.admin.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );
  $items[$this->path . '/modal/add/%/%ctools_js']['page arguments'] = array(
    $id_count + 2,
    $id_count + 3,
  );
  $items[$this->path . '/modal/edit/' . $wildcard . '/%ctools_js'] = array(
    'title' => t('Add !activity', array(
      '!activity' => $this->entityInfo['label'],
    )),
    'page callback' => 'party_activity_modal_form_wrapper',
    'page arguments' => array(
      $id_count + 2,
      $id_count + 3,
    ),
    'access callback' => 'party_activity_access',
    'access arguments' => array(
      'edit',
    ),
    'file' => 'party_activity.admin.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );
  return $items;
}