|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace CWP\CWP\PageTypes; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\AssetAdmin\Forms\UploadField; |
|
|
|
|
|
|
6
|
|
|
use SilverStripe\Assets\Image; |
|
7
|
|
|
use SilverStripe\Forms\FieldList; |
|
8
|
|
|
use SilverStripe\Forms\TextField; |
|
9
|
|
|
use SilverStripe\ORM\FieldType\DBField; |
|
10
|
|
|
|
|
11
|
|
|
class NewsPage extends DatedUpdatePage |
|
12
|
|
|
{ |
|
13
|
|
|
private static $description = 'Describes an item of news'; |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
private static $default_parent = 'NewsHolderPage'; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
private static $can_be_root = false; |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
private static $icon_class = 'font-icon-p-news-item'; |
|
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
private static $singular_name = 'News Page'; |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
private static $plural_name = 'News Pages'; |
|
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
private static $db = [ |
|
|
|
|
|
|
26
|
|
|
'Author' => 'Varchar(255)', |
|
27
|
|
|
]; |
|
28
|
|
|
|
|
29
|
|
|
private static $has_one = [ |
|
|
|
|
|
|
30
|
|
|
'FeaturedImage' => Image::class, |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
private static $owns = [ |
|
|
|
|
|
|
34
|
|
|
'FeaturedImage', |
|
35
|
|
|
]; |
|
36
|
|
|
|
|
37
|
|
|
private static $table_name = 'NewsPage'; |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
public function fieldLabels($includerelations = true) |
|
40
|
|
|
{ |
|
41
|
|
|
$labels = parent::fieldLabels($includerelations); |
|
42
|
|
|
$labels['Author'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.AuthorFieldLabel', 'Author'); |
|
43
|
|
|
$labels['FeaturedImageID'] = _t( |
|
44
|
|
|
'CWP\\CWP\\PageTypes\\DateUpdatePage.FeaturedImageFieldLabel', |
|
45
|
|
|
'Featured Image' |
|
46
|
|
|
); |
|
47
|
|
|
|
|
48
|
|
|
return $labels; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function getCMSFields() |
|
52
|
|
|
{ |
|
53
|
|
|
$this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
54
|
|
|
$fields->addFieldToTab( |
|
55
|
|
|
'Root.Main', |
|
56
|
|
|
TextField::create('Author', $this->fieldLabel('Author')), |
|
57
|
|
|
'Abstract' |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
$fields->addFieldToTab( |
|
61
|
|
|
'Root.Main', |
|
62
|
|
|
UploadField::create('FeaturedImage', $this->fieldLabel('FeaturedImageID')), |
|
63
|
|
|
'Abstract' |
|
64
|
|
|
); |
|
65
|
|
|
}); |
|
66
|
|
|
return parent::getCMSFields(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Returns the Author DB field for this page type. |
|
71
|
|
|
* |
|
72
|
|
|
* Used to avoid conflicts with `Versioned::Author()` |
|
73
|
|
|
* |
|
74
|
|
|
* @return DBField |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getNewsPageAuthor() |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->dbObject('Author'); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
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