You are here

class CaseTrackerCaseUIController in Case Tracker 7.2

UI controller.

Hierarchy

Expanded class hierarchy of CaseTrackerCaseUIController

1 string reference to 'CaseTrackerCaseUIController'
casetracker_entity_info in ./casetracker.module

File

includes/controller/ui/CaseTrackerCaseUIController.inc, line 6

View source
class CaseTrackerCaseUIController 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();
    $wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%' . $this->entityType;
    $case_path = 'project/%/case';

    // Change the add page menu to multiple types of entities
    $items[$case_path . '/add'] = array(
      'title' => t('Add a case'),
      'description' => t('Add a new case'),
      'page callback' => 'casetracker_case_add_page',
      'access callback' => 'casetracker_case_access',
      'access arguments' => array(
        'edit',
      ),
      'type' => MENU_NORMAL_ITEM,
      'weight' => 20,
      'file' => 'casetracker_case.inc',
      'file path' => drupal_get_path('module', $this->entityInfo['module']),
    );

    // Add menu items to add each different type of entity.
    foreach (casetracker_case_get_types() as $type) {
      $items[$case_path . '/add/' . $type->type] = array(
        'title' => t('Add @bundle', array(
          '@bundle' => $type->label,
        )),
        'page callback' => 'casetracker_case_form_wrapper',
        'page arguments' => array(
          casetracker_case_create(array(
            'type' => $type->type,
          )),
        ),
        'access callback' => 'casetracker_case_access',
        'access arguments' => array(
          'edit',
          'edit ' . $type->type,
        ),
        'file' => 'casetracker_case.inc',
        'file path' => drupal_get_path('module', $this->entityInfo['module']),
      );
    }
    $items[$case_path . '/' . $wildcard . '/edit'] = array(
      'title' => t('Edit'),
      'page callback' => 'casetracker_case_form_wrapper',
      'page arguments' => array(
        3,
      ),
      'access callback' => 'casetracker_case_access',
      'access arguments' => array(
        'edit',
        3,
      ),
      'type' => MENU_LOCAL_TASK,
      'weight' => 0,
      'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    );
    $items[$case_path . '/' . $wildcard . '/delete'] = array(
      'title' => t('Delete'),
      'page callback' => 'casetracker_case_delete_form_wrapper',
      'page arguments' => array(
        3,
      ),
      'access callback' => 'casetracker_case_access',
      'access arguments' => array(
        'edit',
        3,
      ),
      'type' => MENU_LOCAL_TASK,
      'context' => MENU_CONTEXT_INLINE,
      'weight' => 10,
      'file' => 'casetracker_case.inc',
      'file path' => drupal_get_path('module', $this->entityInfo['module']),
    );

    // Menu item for viewing casetracker_cases
    $items[$case_path . '/' . $wildcard] = array(
      'page callback' => 'casetracker_case_page_view',
      'page arguments' => array(
        3,
      ),
      'access callback' => 'casetracker_case_access',
      'access arguments' => array(
        'view',
        3,
      ),
    );
    $items[$case_path . '/' . $wildcard . '/view'] = array(
      'title' => t('View'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -10,
    );
    return $items;
  }

  /**
   * Create the markup for the add CaseTrackerCase 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) == 0) {
      drupal_set_message(t('There isn\'t any Case Type configured. To setup now, go to the <a href="@link">@link_text</a>.', array(
        '@link' => base_path() . 'admin/structure/casetracker/case-types',
        '@link_text' => 'administrative page',
      )), 'error');
    }
    elseif (count($content) == 1) {
      $item = array_shift($content);

      // Check to see if a project is being referenced, to pass the reference
      $project_ref = arg(5);
      if (is_numeric($project_ref)) {
        drupal_goto($item['href'] . '/' . $project_ref);
      }
      else {
        drupal_goto($item['href']);
      }
    }
    return theme('casetracker_case_add_list', array(
      'content' => $content,
    ));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CaseTrackerCaseUIController::addPage public function Create the markup for the add CaseTrackerCase Entities page within the class so it can easily be extended/overriden.
CaseTrackerCaseUIController::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
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