function tmgmt_language_combination_field_formatter_view in Translation Management Tool 7
Implements hook_field_formatter_view().
File
- translators/
tmgmt_local/ skills/ tmgmt_language_combination.module, line 166
Code
function tmgmt_language_combination_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'tmgmt_language_combination_default':
$element['#theme'] = 'item_list';
$element['#items'] = array();
foreach ($items as $delta => $item) {
$from = tmgmt_language_combination_language_label($item['language_from']);
$to = tmgmt_language_combination_language_label($item['language_to']);
$element['#items'][$delta]['data'] = t('From @from to @to', array(
'@from' => $from,
'@to' => $to,
));
$element['#items'][$delta]['class'][] = drupal_html_class($from . '-' . $to) . '">';
}
break;
case 'tmgmt_language_combination_table':
$rows = array();
foreach ($items as $item) {
$to = tmgmt_language_combination_language_label($item['language_to']);
$from = tmgmt_language_combination_language_label($item['language_from']);
$row[] = array(
'data' => $from,
'class' => array(
'from-language',
drupal_html_class('language-' . $from),
),
);
$row[] = array(
'data' => $to,
'class' => array(
'to-language',
drupal_html_class('language-' . $to),
),
);
$rows[] = array(
'data' => $row,
'class' => array(
drupal_html_class($from . '-' . $to),
),
);
}
$element = array(
'#theme' => 'table',
'#header' => array(
t('From'),
t('To'),
),
'#rows' => $rows,
);
break;
}
return $element;
}