_flagFrozen) {
return $this->getFrozenHtml();
}
$id = $this->getAttribute('id');
$dateRange = $this->getValue();
$value = '';
if (!empty($dateRange)) {
$dates = $this->parseDateRange($dateRange);
$value = api_format_date($dates['date'], DATE_FORMAT_LONG_NO_DAY);
}
return '
'.$this->getElementJS();
}
/**
* @param string $layout
*
* @return string
*/
public function getTemplate($layout)
{
$size = $this->calculateSize();
$id = $this->getAttribute('id');
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
return '
{element}
';
break;
case FormValidator::LAYOUT_HORIZONTAL:
return '
';
break;
case FormValidator::LAYOUT_BOX_NO_LABEL:
return '
{icon}
{element}
';
break;
}
}
/**
* @param array $dateRange
*
* @return array
*/
public function parseDateRange($dateRange)
{
$dateRange = Security::remove_XSS($dateRange);
$dates = explode('@@', $dateRange);
$dates = array_map('trim', $dates);
$start = isset($dates[0]) ? $dates[0] : '';
$end = isset($dates[1]) ? $dates[1] : '';
$date = substr($start, 0, 10);
$start = isset($dates[0]) ? $dates[0] : '';
//$start = substr($start, 11, strlen($start));
//$end = substr($end, 11, strlen($end));
return [
'date' => $date,
'start_time' => $start,
'end_time' => $end,
];
}
/**
* @param string $value
*/
public function setValue($value)
{
$this->updateAttributes(
[
'value' => $value,
]
);
}
/**
* Get the necessary javascript for this datepicker.
*
* @return string
*/
private function getElementJS()
{
$js = null;
$id = $this->getAttribute('id');
$dateRange = $this->getValue();
$defaultDate = '';
$startTime = '';
$endTime = '';
if (!empty($dateRange)) {
$dates = $this->parseDateRange($dateRange);
$defaultDate = $dates['date'];
$startTime = $dates['start_time'];
$endTime = $dates['end_time'];
}
$js .= "";
return $js;
}
}