/** * @see http://symphony-cms.com/learn/api/2.2/toolkit/field/#prepareTableValue */ function prepareTableValue($data, XMLElement $link = NULL) { if (!is_array($data['start'])) { $data['start'] = array($data['start']); } if (!is_array($data['end'])) { $data['end'] = array($data['end']); } // Handle empty dates if (empty($data['start'][0])) { if ($link) { $href = $link->getAttribute('href'); return '<a href="' . $href . '">' . __('No Date') . '</a>'; } else { return __('No Date'); } } // Get schema if ($this->get('time') == 1) { $scheme = __SYM_DATETIME_FORMAT__; } else { $scheme = __SYM_DATE_FORMAT__; } // Parse dates $value = array(); for ($i = 0; $i < count($data['start']); $i++) { $start = new DateTime($data['start'][$i]); $separator = ' – '; // Date range if ($data['end'][$i] != $data['start'][$i]) { $end = new DateTime($data['end'][$i]); // Different start and end days if ($start->format('D-M-Y') != $end->format('D-M-Y')) { $value[] = LANG::localizeDate($start->format($scheme) . $separator . $end->format($scheme)); } else { // Show time if ($this->get('time') == 1) { // Adjust separator if (Symphony::Configuration()->get('time_format', 'region') == 'H:i') { $separator = '–'; } $value[] = LANG::localizeDate($start->format($scheme) . $separator . $end->format(Symphony::Configuration()->get('time_format', 'region'))); } else { $value[] = LANG::localizeDate($start->format($scheme)); } } } else { $value[] = LANG::localizeDate($start->format($scheme)); } } // Link? if ($link) { $href = $link->getAttribute('href'); return '<a href="' . $href . '">' . implode($value, ', <br />') . '</a>'; } else { return implode($value, ', <br />'); } }
public function getDatetime($date, $scheme, $html) { if (!$html) { return LANG::localizeDate($date->format($scheme)); } return '<time datetime="' . $date->format('Y-m-d\\TH:i:s\\Z') . '">' . LANG::localizeDate($date->format($scheme)) . '</time>'; }