public function field_timer_text_date_field_base::renderItems in Field Timer 7.2
@inheritdoc
Overrides field_timer_text_base::renderItems
File
- includes/
field_timer_text.inc, line 390 - Contains help classes to perform field_timer_text formatter related actions.
Class
- field_timer_text_date_field_base
- Base class for field_timer_text formatter and date field types.
Code
public function renderItems($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$settings = $display['settings'];
$elements = $settings['fromto'] != 'to' ? parent::renderItems($entity_type, $entity, $field, $instance, $langcode, $items, $display) : array();
$granularity_option = $settings['granularity_' . $settings['granularity_type2'] . '2'];
foreach ($items as $delta => $item) {
if ($settings['fromto'] != 'to' && !empty($settings['title'])) {
$elements[$delta]['#markup'] = '<span class="field-timer-start-date-title">' . $settings['title'] . '</span> ' . $elements[$delta]['#markup'];
}
if ($settings['fromto'] == 'both' && !empty($field['settings']['todate'])) {
$elements[$delta]['#markup'] = '<div class="field-timer-start-date">' . $elements[$delta]['#markup'] . '</div>';
}
if ($settings['fromto'] != 'from' && !empty($field['settings']['todate'])) {
$title = !empty($settings['title2']) ? '<span class="field-timer-end-date-title">' . $settings['title2'] . '</span> ' : '';
$time = $this
->renderItem($settings['type2'], $settings['granularity_type2'], $granularity_option, $this
->getTimestamp($item, $field, 'value2'));
if ($settings['fromto'] == 'to') {
$elements[$delta] = array(
'#type' => 'markup',
'#markup' => $title . $time,
);
}
else {
$elements[$delta]['#markup'] .= '<div class="field-timer-end-date">' . $title . $time . '</div>';
}
}
}
return $elements;
}