You are here

protected function GroupTypeUIController::typeTable in Group 7

Generates the render array for an overview table for group types.

Builds a tabledrag without having to write a theme function for it. See http://dropbucket.org/node/204.

Return value

array A renderable array.

1 call to GroupTypeUIController::typeTable()
GroupTypeUIController::overviewForm in classes/group_type.ui_controller.inc
Builds the entity overview form.

File

classes/group_type.ui_controller.inc, line 161
Defines the Entity API UI class for group types.

Class

GroupTypeUIController
UI class for group types.

Code

protected function typeTable() {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'group_type');
  $query
    ->propertyOrderBy('weight');
  if ($this->overviewPagerLimit) {
    $query
      ->pager($this->overviewPagerLimit);
  }
  $result = $query
    ->execute();
  $rows = $weights = array();
  if (isset($result['group_type'])) {
    $group_types = group_types(array_keys($result['group_type']));
    foreach ($group_types as $name => $group_type) {
      $row = $this
        ->typeTableRow($name, $group_type);
      $rows[$name] = $row;
      $weights[$name] = array(
        'weight' => &$rows[$name]['data']['weight']['data'],
      );
    }
  }
  $table = array(
    '#theme' => 'table',
    '#header' => $this
      ->typeTableHeaders(),
    '#rows' => $rows,
    '#empty' => t('There are no group types available.'),
    '#attributes' => array(
      'id' => 'group-type-table',
    ),
    'elements' => $weights,
  );
  drupal_add_tabledrag('group-type-table', 'order', 'sibling', 'group-type-weight');
  return $table;
}