1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CWP\CWP\PageTypes; |
4
|
|
|
|
5
|
|
|
use Page; |
|
|
|
|
6
|
|
|
use SilverStripe\Forms\DatetimeField; |
7
|
|
|
use SilverStripe\Forms\FieldList; |
8
|
|
|
use SilverStripe\Forms\TextareaField; |
9
|
|
|
use SilverStripe\ORM\FieldType\DBDatetime; |
10
|
|
|
|
11
|
|
|
class DatedUpdatePage extends Page |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Meant as an abstract base class. |
15
|
|
|
* |
16
|
|
|
* {@inheritDoc} |
17
|
|
|
*/ |
18
|
|
|
private static $hide_ancestor = DatedUpdatePage::class; |
|
|
|
|
19
|
|
|
|
20
|
|
|
private static $singular_name = 'Dated Update Page'; |
|
|
|
|
21
|
|
|
|
22
|
|
|
private static $plural_name = 'Dated Update Pages'; |
|
|
|
|
23
|
|
|
|
24
|
|
|
private static $table_name = 'DatedUpdatePage'; |
|
|
|
|
25
|
|
|
|
26
|
|
|
private static $defaults = [ |
|
|
|
|
27
|
|
|
'ShowInMenus' => false, |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
private static $db = [ |
|
|
|
|
31
|
|
|
'Abstract' => 'Text', |
32
|
|
|
'Date' => 'Datetime', |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Add the default for the Date being the current day. |
37
|
|
|
*/ |
38
|
|
|
public function populateDefaults() |
39
|
|
|
{ |
40
|
|
|
parent::populateDefaults(); |
41
|
|
|
|
42
|
|
|
if (!isset($this->Date) || $this->Date === null) { |
43
|
|
|
$this->Date = DBDatetime::now()->Format('y-MM-dd 09:00:00'); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function fieldLabels($includerelations = true) |
48
|
|
|
{ |
49
|
|
|
$labels = parent::fieldLabels($includerelations); |
50
|
|
|
$labels['Date'] = _t(__CLASS__ . '.DateLabel', 'Date'); |
51
|
|
|
$labels['Abstract'] = _t(__CLASS__ . '.AbstractTextFieldLabel', 'Abstract'); |
52
|
|
|
|
53
|
|
|
return $labels; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function getCMSFields() |
57
|
|
|
{ |
58
|
|
|
$this->beforeUpdateCMSFields(function (FieldList $fields) { |
59
|
|
|
$fields->addFieldToTab( |
60
|
|
|
'Root.Main', |
61
|
|
|
$dateTimeField = DatetimeField::create('Date', $this->fieldLabel('Date')), |
62
|
|
|
'Content' |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
$fields->addfieldToTab( |
66
|
|
|
'Root.Main', |
67
|
|
|
$abstractField = TextareaField::create('Abstract', $this->fieldLabel('Abstract')), |
68
|
|
|
'Content' |
69
|
|
|
); |
70
|
|
|
$abstractField->setAttribute('maxlength', '160'); |
71
|
|
|
$abstractField->setRightTitle(_t( |
72
|
|
|
__CLASS__ . '.AbstractDesc', |
73
|
|
|
'The abstract is used as a summary on the listing pages. It is limited to 160 characters.' |
74
|
|
|
)); |
75
|
|
|
$abstractField->setRows(6); |
76
|
|
|
}); |
77
|
|
|
return parent::getCMSFields(); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths