protected function CerUIController::overviewTableRow in Corresponding Entity References 7.3
Generates the row for the passed entity and may be overridden in order to customize the rows.
Parameters
$additional_cols: Additional columns to be added after the entity label column.
Overrides EntityDefaultUIController::overviewTableRow
1 call to CerUIController::overviewTableRow()
- CerUIController::overviewTable in includes/
CerUIController.inc - Generates the render array for a overview table for arbitrary entities matching the given conditions.
File
- includes/
CerUIController.inc, line 133
Class
- CerUIController
- Contains the controller class for CER's UI (i.e., preset management pages), used by Entity API.
Code
protected function overviewTableRow($conditions, $id, $entity, $additional_cols = array()) {
$render_fields = field_attach_view($this->entityType, $entity, 'default');
$render_fields['cer_left']['#label_display'] = 'inline';
$render_fields['cer_left']['#title'] = $entity->wrapper->cer_left->chain
->value()
->end()->fieldTypeLabel;
$row['cer_left'] = $render_fields['cer_left'];
$render_fields['cer_right']['#label_display'] = 'inline';
$render_fields['cer_right']['#title'] = $entity->wrapper->cer_right->chain
->value()
->end()->fieldTypeLabel;
$row['cer_right'] = $render_fields['cer_right'];
$row['status'] = array(
'#theme' => 'entity_status',
'#status' => $entity->status,
);
$form_fields = array();
$form_state = form_state_defaults();
$form_state['build_info']['form_id'] = 'cer_overview_form';
field_attach_form($this->entityType, $entity, $form_fields, $form_state);
unset($form_fields['cer_enabled'][LANGUAGE_NONE]['#title']);
$row['cer_enabled'] = $form_fields['cer_enabled'];
unset($form_fields['cer_bidirectional'][LANGUAGE_NONE]['#title']);
$row['cer_bidirectional'] = $form_fields['cer_bidirectional'];
unset($form_fields['cer_weight'][LANGUAGE_NONE]['#title']);
$form_fields['cer_weight'][LANGUAGE_NONE]['#attributes']['class'][] = 'cer-weight';
$row['cer_weight'] = $form_fields['cer_weight'];
// Add in any passed additional cols.
foreach ($additional_cols as $key => $col) {
$row[$key] = $col;
}
// I like drop buttons more than an inline set of links.
$links = array(
'toggle' => array(
'title' => $entity->wrapper->cer_enabled
->value() ? t('disable') : t('enable'),
'href' => "{$this->path}/manage/{$id}/toggle",
'query' => drupal_get_destination(),
),
'edit' => array(
'title' => t('edit'),
'href' => "{$this->path}/manage/{$id}",
),
);
// If the preset is one-directional, expose a link to invert it.
if (!$entity->wrapper->cer_bidirectional
->value()) {
$links['invert'] = array(
'title' => t('invert'),
'href' => "{$this->path}/manage/{$id}/invert",
'query' => drupal_get_destination(),
);
}
if (entity_has_status($this->entityType, $entity, ENTITY_OVERRIDDEN)) {
$links['revert'] = array(
'title' => t('revert'),
'href' => "{$this->path}/manage/{$id}/revert",
'query' => drupal_get_destination(),
);
}
else {
$links['delete'] = array(
'title' => t('delete'),
'href' => "{$this->path}/manage/{$id}/delete",
'query' => drupal_get_destination(),
);
}
$links['export'] = array(
'title' => t('export'),
'href' => "{$this->path}/manage/{$id}/export",
);
$row['operations'] = array(
'#theme' => 'links__ctools_dropbutton',
'#links' => $links,
);
$row['#attributes']['class'][] = 'draggable';
return $row;
}