You are here

class TMGMTJobItemUIController in Translation Management Tool 7

Entity UI controller for the Job Entity.

Hierarchy

Expanded class hierarchy of TMGMTJobItemUIController

1 string reference to 'TMGMTJobItemUIController'
tmgmt_ui_entity_info in ui/tmgmt_ui.module
Implements hook_entity_info().

File

ui/includes/tmgmt_ui.controller.job_item.inc, line 11
Contains the job item UI controller.

View source
class TMGMTJobItemUIController extends EntityDefaultUIController {

  /**
   * {@inheritdoc}
   */
  public function hook_menu() {
    $id_count = count(explode('/', $this->path));
    $wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%entity_object';
    $items[$this->path . '/' . $wildcard] = array(
      'title callback' => 'entity_label',
      'title arguments' => array(
        $this->entityType,
        $id_count,
      ),
      'page callback' => 'tmgmt_ui_job_item_view',
      'page arguments' => array(
        $id_count,
      ),
      'load arguments' => array(
        $this->entityType,
      ),
      'access callback' => 'entity_access',
      'access arguments' => array(
        'view',
        'tmgmt_job_item',
        $id_count,
      ),
      'file' => $this->entityInfo['admin ui']['file'],
      'file path' => $this->entityInfo['admin ui']['file path'],
    );
    $items[$this->path . '/' . $wildcard . '/view'] = array(
      'title' => 'View',
      'load arguments' => array(
        $this->entityType,
      ),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -10,
    );
    $items[$this->path . '/' . $wildcard . '/reject/%'] = array(
      'title' => 'Reject',
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'tmgmt_ui_translation_review_form_reject_confirm',
        $id_count,
        $id_count + 2,
      ),
      'load arguments' => array(
        $this->entityType,
      ),
      'access callback' => 'entity_access',
      'access arguments' => array(
        'accept',
        $this->entityType,
        $id_count,
      ),
      'type' => MENU_VISIBLE_IN_BREADCRUMB,
      'file' => $this->entityInfo['admin ui']['file'],
      'file path' => $this->entityInfo['admin ui']['file path'],
    );
    $items[$this->path . '/' . $wildcard . '/delete'] = array(
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        $this->entityType . '_operation_form',
        $this->entityType,
        $id_count,
        $id_count + 1,
      ),
      'load arguments' => array(
        $this->entityType,
      ),
      'access callback' => 'entity_access',
      'access arguments' => array(
        'delete',
        $this->entityType,
        $id_count,
      ),
      'type' => MENU_CALLBACK,
    );
    $items[$this->path . '/' . $wildcard . '/accept'] = array(
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        $this->entityType . '_operation_form',
        $this->entityType,
        $id_count,
        $id_count + 1,
      ),
      'load arguments' => array(
        $this->entityType,
      ),
      'access callback' => 'entity_access',
      'access arguments' => array(
        'accept',
        $this->entityType,
        $id_count,
      ),
      'type' => MENU_CALLBACK,
    );
    return $items;
  }

  /**
   * {@inheritdoc}
   */
  public function operationForm($form, &$form_state, $entity, $op) {
    $controller = $entity
      ->getSourceController();
    $info = $controller
      ->pluginInfo();
    switch ($op) {
      case 'delete':
        $confirm_question = t('Are you sure you want to delete the %plugin translation job item for %label?', array(
          '%plugin' => $info['label'],
          '%label' => $entity
            ->label(),
        ));
        return confirm_form($form, $confirm_question, $this->path);
      case 'accept':
        $confirm_question = t('Are you sure you want to accept the %plugin translation job item for %label?', array(
          '%plugin' => $info['label'],
          '%label' => $entity
            ->label(),
        ));
        return confirm_form($form, $confirm_question, $this->path);
    }
    drupal_not_found();
    exit;
  }

  /**
   * {@inheritdoc}
   */
  public function applyOperation($op, $entity) {
    switch ($op) {
      case 'delete':
        $entity
          ->delete();
        return t('The translation job item %label has been deleted.', array(
          '%label' => $entity
            ->label(),
        ));
      case 'accept':
        $entity
          ->accepted('The translation job item has been accepted by !user.', array(
          '!user' => theme('username', array(
            'account' => $GLOBALS['user'],
          )),
        ));
        return t('The translation job item %label has been accepted.', array(
          '%label' => $entity
            ->label(),
        ));
    }
    return FALSE;
  }

}

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::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::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
TMGMTJobItemUIController::applyOperation public function Applies an operation to the given entity. Overrides EntityDefaultUIController::applyOperation
TMGMTJobItemUIController::hook_menu public function Provides definitions for implementing hook_menu(). Overrides EntityDefaultUIController::hook_menu
TMGMTJobItemUIController::operationForm public function Builds the operation form. Overrides EntityDefaultUIController::operationForm