You are here

class UserpointsTransactionTypeUIController in User Points 7.2

Transaction type UI.

Hierarchy

Expanded class hierarchy of UserpointsTransactionTypeUIController

Related topics

1 string reference to 'UserpointsTransactionTypeUIController'
userpoints_entity_info in ./userpoints.module
Implements hook_entity_info().

File

./userpoints.transaction.inc, line 1477
Contains the UserpointsTransaction and related classes.

View source
class UserpointsTransactionTypeUIController extends EntityDefaultUIController {

  /**
   * Implements EntityDefaultUIController::hook_menu().
   *
   * Make transaction type UI fit into userpoints menu structure.
   */
  public function hook_menu() {
    $items = parent::hook_menu();
    $items[$this->path]['title'] = 'Transaction Types';
    $items[$this->path]['description'] = strtr('Manage !Points transaction types.', userpoints_translation());
    $items[$this->path]['type'] = MENU_LOCAL_TASK;
    $items[$this->path]['weight'] = 10;
    foreach ($items as $path => $item) {
      if (substr($path, strlen($this->path) + 1, 6) == 'manage') {

        // Field UI doesn't render local tasks well when the main ui is a local
        // task itself. This places all admin interfaces directly under types
        // instead.
        $new_path = preg_replace('/\\/manage/', '', $path);
        $items[$new_path] = $items[$path];
        $items[$new_path]['page arguments'][1] = 5;
        if (isset($items[$new_path]['page arguments'][0]) && $items[$new_path]['page arguments'][0] == 'userpoints_transaction_type_operation_form') {

          // Entity API fails to use the correct bundle argument defined in
          // entity info.
          $items[$new_path]['page arguments'] = array(
            'entity_ui_operation_form',
            'userpoints_transaction_type',
            5,
            6,
          );
        }
        unset($items[$path]);
      }
    }
    return $items;
  }

  /**
   * Implements EntityDefaultUIController::overviewTableRow().
   *
   * This is pretty much a straight rip from Entity API except the links are
   * generated without 'manage' in the path.
   */
  protected function overviewTableRow($conditions, $id, $entity, $additional_cols = array()) {
    $entity_uri = entity_uri($this->entityType, $entity);
    $row[] = array(
      'data' => array(
        '#theme' => 'entity_ui_overview_item',
        '#label' => entity_label($this->entityType, $entity),
        '#name' => !empty($this->entityInfo['exportable']) ? entity_id($this->entityType, $entity) : FALSE,
        '#url' => $entity_uri ? $entity_uri : FALSE,
        '#entity_type' => $this->entityType,
      ),
    );

    // Add in any passed additional cols.
    foreach ($additional_cols as $col) {
      $row[] = $col;
    }

    // Add a row for the exportable status.
    if (!empty($this->entityInfo['exportable'])) {
      $row[] = array(
        'data' => array(
          '#theme' => 'entity_status',
          '#status' => $entity->{$this->statusKey},
        ),
      );
    }

    // In case this is a bundle, we add links to the field ui tabs.
    $field_ui = !empty($this->entityInfo['bundle of']) && entity_type_is_fieldable($this->entityInfo['bundle of']) && module_exists('field_ui');

    // For exportable entities we add an export link.
    $exportable = !empty($this->entityInfo['exportable']);

    // If i18n integration is enabled, add a link to the translate tab.
    $i18n = !empty($this->entityInfo['i18n controller class']);

    // Add operations depending on the status.
    if (entity_has_status($this->entityType, $entity, ENTITY_FIXED)) {
      $row[] = array(
        'data' => l(t('clone'), $this->path . '/' . $id . '/clone'),
        'colspan' => $this
          ->operationCount(),
      );
    }
    else {
      $row[] = l(t('edit'), $this->path . '/' . $id);
      if ($field_ui) {
        $row[] = l(t('manage fields'), $this->path . '/' . $id . '/fields');
        $row[] = l(t('manage display'), $this->path . '/' . $id . '/display');
      }
      if ($i18n) {
        $row[] = l(t('translate'), $this->path . '/' . $id . '/translate');
      }
      if ($exportable) {
        $row[] = l(t('clone'), $this->path . '/' . $id . '/clone');
      }
      if (empty($this->entityInfo['exportable']) || !entity_has_status($this->entityType, $entity, ENTITY_IN_CODE)) {
        $row[] = l(t('delete'), $this->path . '/' . $id . '/delete', array(
          'query' => drupal_get_destination(),
        ));
      }
      elseif (entity_has_status($this->entityType, $entity, ENTITY_OVERRIDDEN)) {
        $row[] = l(t('revert'), $this->path . '/' . $id . '/revert', array(
          'query' => drupal_get_destination(),
        ));
      }
      else {
        $row[] = '';
      }
    }
    if ($exportable) {
      $row[] = l(t('export'), $this->path . '/' . $id . '/export');
    }
    return $row;
  }

}

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::__construct public function
UserpointsTransactionTypeUIController::hook_menu public function Implements EntityDefaultUIController::hook_menu(). Overrides EntityDefaultUIController::hook_menu
UserpointsTransactionTypeUIController::overviewTableRow protected function Implements EntityDefaultUIController::overviewTableRow(). Overrides EntityDefaultUIController::overviewTableRow