You are here

protected function GroupTypeUIController::typeTableRow in Group 7

Generates the row for the passed type.

1 call to GroupTypeUIController::typeTableRow()
GroupTypeUIController::typeTable in classes/group_type.ui_controller.inc
Generates the render array for an overview table for group types.

File

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

Class

GroupTypeUIController
UI class for group types.

Code

protected function typeTableRow($name, GroupType $group_type) {

  // Check if the group type is ENTITY_FIXED.
  $type_fixed = entity_has_status('group_type', $group_type, ENTITY_FIXED);

  // Create the row container array.
  $row = array(
    'data' => array(),
    'class' => array(
      'draggable',
    ),
  );

  // Cell for the cross drag&drop element.
  $row['data']['drag'] = array(
    'class' => array(
      'entry-cross',
    ),
  );

  // Weight item for the tabledrag.
  $row['data']['weight'] = array(
    'data' => array(
      '#type' => 'weight',
      '#title' => t('Weight'),
      '#title_display' => 'invisible',
      '#default_value' => $group_type->weight,
      '#parents' => array(
        'weights',
        $name,
      ),
      '#attributes' => array(
        'class' => array(
          'group-type-weight',
        ),
      ),
      '#disabled' => $type_fixed,
    ),
  );

  // Add the type label.
  $row['data']['label'] = $group_type
    ->label();

  // Permissions related links.
  $what = $type_fixed ? t('view permissions') : t('edit permissions');
  $row['data']['permissions'] = l($what, "{$this->path}/manage/{$name}/permissions");
  $row['data']['roles'] = l(t('roles'), "{$this->path}/manage/{$name}/permissions/roles");

  // Add the status column.
  $row['data']['status'] = array(
    'data' => array(
      '#theme' => 'entity_status',
      '#status' => $group_type->status,
    ),
  );

  // Add the edit action.
  $row['data']['edit'] = $type_fixed ? '' : l(t('edit'), "{$this->path}/manage/{$name}");

  // Add the config action.
  $row['data']['config'] = $type_fixed ? '' : l(t('config'), "{$this->path}/manage/{$name}/config");

  // Add the Field UI actions.
  if (module_exists('field_ui')) {
    $row['data']['manage fields'] = l(t('manage fields'), "{$this->path}/manage/{$name}/fields");
    $row['data']['manage display'] = l(t('manage display'), "{$this->path}/manage/{$name}/display");
  }

  // Add the Group Translation action.
  if (module_exists('i18n_string')) {
    $row['data']['translate'] = l(t('translate'), "{$this->path}/manage/{$name}/translate");
  }

  // Add the clone action.
  $row['data']['clone'] = l(t('clone'), "{$this->path}/manage/{$name}/clone");

  // Don't show delete action for fixed or default types.
  if ($type_fixed || $group_type->status == ENTITY_IN_CODE) {
    $row['data']['delete'] = '';
  }
  else {

    // Show revert action for overridden roles.
    if (entity_has_status('group_type', $group_type, ENTITY_OVERRIDDEN)) {
      $what = t('revert');
      $path = "{$this->path}/manage/{$name}/revert";
    }
    else {
      $what = t('delete');
      $path = "{$this->path}/manage/{$name}/delete";
    }
    $row['data']['delete'] = l($what, $path, array(
      'query' => drupal_get_destination(),
    ));
  }

  // Add the export action.
  $row['data']['export'] = l(t('export'), "{$this->path}/manage/{$name}/export");
  return $row;
}