You are here

protected function BatBookingUIController::overviewTableRow in Booking and Availability Management Tools for Drupal 7

Overrides overviewTableRow() defaults.

Overrides EntityDefaultUIController::overviewTableRow

File

modules/bat_booking/bat_booking.admin.inc, line 66
BatBooking editing UI.

Class

BatBookingUIController
UI controller.

Code

protected function overviewTableRow($conditions, $id, $entity, $additional_cols = array()) {
  $entity_uri = entity_uri($this->entityType, $entity);
  $row[] = $id;
  $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,
    ),
  );
  $booking_type = bat_booking_type_load($entity->type);
  $row[] = $booking_type->label;

  // 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 . '/manage/' . $id . '/clone'),
      'colspan' => $this
        ->operationCount(),
    );
  }
  else {
    $row[] = l(t('edit'), $this->path . '/manage/' . $id);
    if ($field_ui) {
      $row[] = l(t('manage fields'), $this->path . '/manage/' . $id . '/fields');
      $row[] = l(t('manage display'), $this->path . '/manage/' . $id . '/display');
    }
    if ($i18n) {
      $row[] = l(t('translate'), $this->path . '/manage/' . $id . '/translate');
    }
    if ($exportable) {
      $row[] = l(t('clone'), $this->path . '/manage/' . $id . '/clone');
    }
    if (empty($this->entityInfo['exportable']) || !entity_has_status($this->entityType, $entity, ENTITY_IN_CODE)) {
      $row[] = l(t('delete'), $this->path . '/manage/' . $id . '/delete', array(
        'query' => drupal_get_destination(),
      ));
    }
    elseif (entity_has_status($this->entityType, $entity, ENTITY_OVERRIDDEN)) {
      $row[] = l(t('revert'), $this->path . '/manage/' . $id . '/revert', array(
        'query' => drupal_get_destination(),
      ));
    }
    else {
      $row[] = '';
    }
  }
  if ($exportable) {
    $row[] = l(t('export'), $this->path . '/manage/' . $id . '/export');
  }
  return $row;
}