| Total Complexity | 5 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class DateField_Disabled extends DateField |
||
| 13 | { |
||
| 14 | |||
| 15 | protected $disabled = true; |
||
| 16 | |||
| 17 | public function Field($properties = []) |
||
| 18 | { |
||
| 19 | // Default display value |
||
| 20 | $displayValue = '<i>(' . _t(DateField::class . '.NOTSET', 'not set') . ')</i>'; |
||
| 21 | |||
| 22 | $value = $this->dataValue(); |
||
| 23 | |||
| 24 | if ($value) { |
||
| 25 | $value = $this->tidyInternal($value); |
||
| 26 | $df = new DBDate($this->name); |
||
| 27 | $df->setValue($value); |
||
| 28 | |||
| 29 | if ($df->IsToday()) { |
||
| 30 | // e.g. 2018-06-01 (today) |
||
| 31 | $format = '%s (%s)'; |
||
| 32 | $infoComplement = _t(DateField::class . '.TODAY', 'today'); |
||
| 33 | } else { |
||
| 34 | // e.g. 2018-06-01, 5 days ago |
||
| 35 | $format = '%s, %s'; |
||
| 36 | $infoComplement = $df->Ago(); |
||
| 37 | } |
||
| 38 | |||
| 39 | // Render the display value with some complement of info |
||
| 40 | $displayValue = Convert::raw2xml(sprintf( |
||
| 41 | $format, |
||
| 42 | $this->Value(), |
||
| 43 | $infoComplement |
||
| 44 | )); |
||
| 45 | } |
||
| 46 | |||
| 47 | return sprintf( |
||
| 48 | "<span class=\"readonly\" id=\"%s\">%s</span>", |
||
| 49 | $this->ID(), |
||
| 50 | $displayValue |
||
| 51 | ); |
||
| 52 | } |
||
| 53 | |||
| 54 | public function Type() |
||
| 57 | } |
||
| 58 | |||
| 59 | public function getHTML5() |
||
| 63 | } |
||
| 64 | } |
||
| 65 |