| Conditions | 3 |
| Paths | 3 |
| Total Lines | 34 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 | ); |
||
| 65 |