mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
8dd644d25d
Namespace all templates Move difflib and BBCodeParser2 to thirdparty Remove deprecated API marked for removal in 4.0
41 lines
1015 B
PHP
41 lines
1015 B
PHP
<?php
|
|
|
|
namespace SilverStripe\Forms;
|
|
|
|
use SilverStripe\Core\Convert;
|
|
use SilverStripe\ORM\FieldType\DBDate;
|
|
|
|
/**
|
|
* Disabled version of {@link DateField}.
|
|
* Allows dates to be represented in a form, by showing in a user friendly format, eg, dd/mm/yyyy.
|
|
*/
|
|
class DateField_Disabled extends DateField
|
|
{
|
|
|
|
protected $disabled = true;
|
|
|
|
public function Field($properties = array())
|
|
{
|
|
if ($this->valueObj) {
|
|
if ($this->valueObj->isToday()) {
|
|
$val = Convert::raw2xml($this->valueObj->toString($this->getConfig('dateformat'))
|
|
. ' (' . _t('DateField.TODAY', 'today') . ')');
|
|
} else {
|
|
$df = new DBDate($this->name);
|
|
$df->setValue($this->dataValue());
|
|
$val = Convert::raw2xml($this->valueObj->toString($this->getConfig('dateformat'))
|
|
. ', ' . $df->Ago());
|
|
}
|
|
} else {
|
|
$val = '<i>(' . _t('DateField.NOTSET', 'not set') . ')</i>';
|
|
}
|
|
|
|
return "<span class=\"readonly\" id=\"" . $this->ID() . "\">$val</span>";
|
|
}
|
|
|
|
public function Type()
|
|
{
|
|
return "date_disabled readonly";
|
|
}
|
|
}
|