You are here

class PartyActivityUIController in Party 7

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

UI Controller

Hierarchy

Expanded class hierarchy of PartyActivityUIController

1 string reference to 'PartyActivityUIController'
party_activity_entity_info in modules/party_activity/party_activity.module
Implements hook_entity_info().

File

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

View source
class PartyActivityUIController extends EntityDefaultUIController {

  /**
   * Overrides hook_menu() defaults. Main reason for doing this is that parent
   * class hook_menu is optimized for entity type administration.
   */
  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;
  }

  /**
   * Create the markup for the add Party Activity Entities page within the class
   * so it can easily be extended/overriden.
   */
  public function addPage() {
    $item = menu_get_item();
    $content = system_admin_menu_block($item);
    if (count($content) == 1) {
      $item = array_shift($content);
      drupal_goto($item['href']);
    }
    return theme('party_activity_add_list', array(
      'content' => $content,
    ));
  }

  /**
   * Get the modal add path.
   */
  public function getModalAddPath() {
    return $this->path . '/modal/add/nojs';
  }

  /**
   * Get the modal edit path for a given entity.
   *
   * @param int $id
   *   The id of the entity to find the modal edit path for.
   */
  public function getModalEditPath($id) {
    return $this->path . '/modal/edit/' . $id . '/nojs';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityDefaultUIController::$entityInfo protected property
EntityDefaultUIController::$entityType protected property
EntityDefaultUIController::$id_count protected property
EntityDefaultUIController::$overviewPagerLimit public property Defines the number of entries to show per page in overview table.
EntityDefaultUIController::applyOperation public function Applies an operation to the given entity.
EntityDefaultUIController::entityFormSubmitBuildEntity public function Entity submit builder invoked via entity_ui_form_submit_build_entity().
EntityDefaultUIController::hook_forms public function Provides definitions for implementing hook_forms().
EntityDefaultUIController::operationCount protected function Returns the operation count for calculating colspans.
EntityDefaultUIController::operationForm public function Builds the operation form.
EntityDefaultUIController::operationFormSubmit public function Operation form submit callback. 1
EntityDefaultUIController::operationFormValidate public function Operation form validation callback.
EntityDefaultUIController::overviewForm public function Builds the entity overview form.
EntityDefaultUIController::overviewFormSubmit public function Overview form submit callback.
EntityDefaultUIController::overviewFormValidate public function Overview form validation callback.
EntityDefaultUIController::overviewTable public function Generates the render array for a overview table for arbitrary entities matching the given conditions.
EntityDefaultUIController::overviewTableHeaders protected function Generates the table headers for the overview table.
EntityDefaultUIController::overviewTableRow protected function Generates the row for the passed entity and may be overridden in order to customize the rows.
EntityDefaultUIController::__construct public function
PartyActivityUIController::addPage public function Create the markup for the add Party Activity Entities page within the class so it can easily be extended/overriden.
PartyActivityUIController::getModalAddPath public function Get the modal add path.
PartyActivityUIController::getModalEditPath public function Get the modal edit path for a given entity.
PartyActivityUIController::hook_menu public function 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