You are here

public function PETUIController::overviewTable in Previewable email templates 7

Copy of EntityDefaultUIController::overviewTable() sorts.

Overrides EntityDefaultUIController::overviewTable

See also

EntityDefaultUIController::overviewTable();

File

./pet.module, line 155
Previewable Email Template module.

Class

PETUIController
PET UI controller.

Code

public function overviewTable($conditions = array()) {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', $this->entityType);

  // PET: Adding table sorts.
  $tableSort = array(
    'name' => array(
      'data' => 'Label',
      'type' => 'property',
      'specifier' => 'name',
    ),
    'status' => array(
      'data' => 'Status',
      'type' => 'property',
      'specifier' => 'status',
    ),
  );
  $query
    ->tableSort($tableSort);

  // Add all conditions to query.
  foreach ($conditions as $key => $value) {
    $query
      ->propertyCondition($key, $value);
  }
  if ($this->overviewPagerLimit) {
    $query
      ->pager($this->overviewPagerLimit);
  }
  $results = $query
    ->execute();
  $ids = isset($results[$this->entityType]) ? array_keys($results[$this->entityType]) : array();
  $entities = $ids ? entity_load($this->entityType, $ids) : array();

  // PET: This removes harcoded sort (only change in this func)

  //ksort($entities);
  $rows = array();
  foreach ($entities as $entity) {
    $rows[] = $this
      ->overviewTableRow($conditions, entity_id($this->entityType, $entity), $entity);
  }
  $render = array(
    '#theme' => 'table',
    '#header' => $this
      ->overviewTableHeaders($conditions, $rows),
    '#rows' => $rows,
    '#empty' => t('None.'),
  );
  return $render;
}