Passed
Pull Request — 2.9 (#308)
by Steve
02:42
created
src/PageTypes/EventPage.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -12,81 +12,81 @@
 block discarded – undo
12 12
 
13 13
 class EventPage extends DatedUpdatePage
14 14
 {
15
-    private static $description = 'Describes an event occurring on a specific date.';
16
-
17
-    private static $default_parent = EventHolder::class;
18
-
19
-    private static $can_be_root = false;
20
-
21
-    private static $icon_class = 'font-icon-p-event';
22
-
23
-    private static $singular_name = 'Event Page';
24
-
25
-    private static $plural_name = 'Event Pages';
26
-
27
-    private static $db = [
28
-        'StartTime' => 'Time',
29
-        'EndTime' => 'Time',
30
-        'Location' => 'Text',
31
-    ];
32
-
33
-    private static $table_name = 'EventPage';
34
-
35
-    public function fieldLabels($includerelations = true)
36
-    {
37
-        $labels = parent::fieldLabels($includerelations);
38
-        $labels['StartTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.StartTimeFieldLabel', 'Start Time');
39
-        $labels['EndTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.EndTimeFieldLabel', 'End Time');
40
-        $labels['Location'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.LocationFieldLabel', 'Location');
41
-
42
-        return $labels;
43
-    }
44
-
45
-    /**
46
-     * Add the default for the Date being the current day.
47
-     */
48
-    public function populateDefaults()
49
-    {
50
-        if (!isset($this->Date) || $this->Date === null) {
51
-            $this->Date = DBDatetime::now()->Format('y-MM-dd');
52
-        }
53
-
54
-        if (!isset($this->StartTime) || $this->StartTime === null) {
55
-            $this->StartTime = '09:00:00';
56
-        }
57
-
58
-        if (!isset($this->EndTime) || $this->EndTime === null) {
59
-            $this->EndTime = '17:00:00';
60
-        }
61
-
62
-        parent::populateDefaults();
63
-    }
64
-
65
-    public function getCMSFields()
66
-    {
67
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
68
-            $fields->removeByName('Date');
69
-
70
-            $dateTimeFields = array();
71
-
72
-            $dateTimeFields[] = $dateField = DateField::create('Date', 'Date');
73
-            $dateTimeFields[] = $startTimeField = TimeField::create(
74
-                'StartTime',
75
-                $this->fieldLabel('StartTime')
76
-            );
77
-            $dateTimeFields[] = $endTimeField = TimeField::create('EndTime', $this->fieldLabel('EndTime'));
78
-
79
-            $fields->addFieldsToTab('Root.Main', [
80
-                $dateTimeField = FieldGroup::create('Date and time', $dateTimeFields),
81
-                $locationField = TextareaField::create('Location', $this->fieldLabel('Location'))
82
-            ], 'Abstract');
83
-            $locationField->setRows(4);
84
-        });
85
-        return parent::getCMSFields();
86
-    }
87
-
88
-    public function NiceLocation()
89
-    {
90
-        return nl2br(Convert::raw2xml($this->Location), true);
91
-    }
15
+	private static $description = 'Describes an event occurring on a specific date.';
16
+
17
+	private static $default_parent = EventHolder::class;
18
+
19
+	private static $can_be_root = false;
20
+
21
+	private static $icon_class = 'font-icon-p-event';
22
+
23
+	private static $singular_name = 'Event Page';
24
+
25
+	private static $plural_name = 'Event Pages';
26
+
27
+	private static $db = [
28
+		'StartTime' => 'Time',
29
+		'EndTime' => 'Time',
30
+		'Location' => 'Text',
31
+	];
32
+
33
+	private static $table_name = 'EventPage';
34
+
35
+	public function fieldLabels($includerelations = true)
36
+	{
37
+		$labels = parent::fieldLabels($includerelations);
38
+		$labels['StartTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.StartTimeFieldLabel', 'Start Time');
39
+		$labels['EndTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.EndTimeFieldLabel', 'End Time');
40
+		$labels['Location'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.LocationFieldLabel', 'Location');
41
+
42
+		return $labels;
43
+	}
44
+
45
+	/**
46
+	 * Add the default for the Date being the current day.
47
+	 */
48
+	public function populateDefaults()
49
+	{
50
+		if (!isset($this->Date) || $this->Date === null) {
51
+			$this->Date = DBDatetime::now()->Format('y-MM-dd');
52
+		}
53
+
54
+		if (!isset($this->StartTime) || $this->StartTime === null) {
55
+			$this->StartTime = '09:00:00';
56
+		}
57
+
58
+		if (!isset($this->EndTime) || $this->EndTime === null) {
59
+			$this->EndTime = '17:00:00';
60
+		}
61
+
62
+		parent::populateDefaults();
63
+	}
64
+
65
+	public function getCMSFields()
66
+	{
67
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
68
+			$fields->removeByName('Date');
69
+
70
+			$dateTimeFields = array();
71
+
72
+			$dateTimeFields[] = $dateField = DateField::create('Date', 'Date');
73
+			$dateTimeFields[] = $startTimeField = TimeField::create(
74
+				'StartTime',
75
+				$this->fieldLabel('StartTime')
76
+			);
77
+			$dateTimeFields[] = $endTimeField = TimeField::create('EndTime', $this->fieldLabel('EndTime'));
78
+
79
+			$fields->addFieldsToTab('Root.Main', [
80
+				$dateTimeField = FieldGroup::create('Date and time', $dateTimeFields),
81
+				$locationField = TextareaField::create('Location', $this->fieldLabel('Location'))
82
+			], 'Abstract');
83
+			$locationField->setRows(4);
84
+		});
85
+		return parent::getCMSFields();
86
+	}
87
+
88
+	public function NiceLocation()
89
+	{
90
+		return nl2br(Convert::raw2xml($this->Location), true);
91
+	}
92 92
 }
Please login to merge, or discard this patch.
src/PageTypes/BaseHomePage.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -26,137 +26,137 @@
 block discarded – undo
26 26
  */
27 27
 class BaseHomePage extends Page
28 28
 {
29
-    private static $icon_class = 'font-icon-p-home';
30
-
31
-    private static $hide_ancestor = BaseHomePage::class;
32
-
33
-    private static $singular_name = 'Home Page';
34
-
35
-    private static $plural_name = 'Home Pages';
36
-
37
-    private static $table_name = 'BaseHomePage';
38
-
39
-    private static $db = [
40
-        'FeatureOneTitle' => 'Varchar(255)',
41
-        'FeatureOneCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')",
42
-        'FeatureOneContent' => 'HTMLText',
43
-        'FeatureOneButtonText' => 'Varchar(255)',
44
-        'FeatureTwoTitle' => 'Varchar(255)',
45
-        'FeatureTwoCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')",
46
-        'FeatureTwoContent' => 'HTMLText',
47
-        'FeatureTwoButtonText' => 'Varchar(255)'
48
-    ];
49
-
50
-    private static $has_one = [
51
-        'LearnMorePage' => SiteTree::class,
52
-        'FeatureOneLink' => SiteTree::class,
53
-        'FeatureTwoLink' => SiteTree::class,
54
-    ];
55
-
56
-    private static $has_many = [
57
-        'Quicklinks' => Quicklink::class . '.Parent',
58
-    ];
59
-
60
-    public function Quicklinks()
61
-    {
62
-        return $this->getComponents('Quicklinks')->sort('SortOrder');
63
-    }
64
-
65
-    public function getCMSFields()
66
-    {
67
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
68
-            // Main Content tab
69
-            $fields->addFieldToTab(
70
-                'Root.Main',
71
-                TreeDropdownField::create(
72
-                    'LearnMorePageID',
73
-                    _t(__CLASS__ . '.LearnMoreLink', 'Page to link the "Learn More" button to:'),
74
-                    SiteTree::class
75
-                ),
76
-                'Metadata'
77
-            );
78
-
79
-            $gridField = GridField::create(
80
-                'Quicklinks',
81
-                'Quicklinks',
82
-                $this->Quicklinks(),
83
-                GridFieldConfig_RelationEditor::create()
84
-            );
85
-            $gridConfig = $gridField->getConfig();
86
-            $gridConfig->getComponentByType(GridFieldAddNewButton::class)->setButtonName(
87
-                _t(__CLASS__ . '.AddNewButton', 'Add new')
88
-            );
89
-
90
-            $injector = Injector::inst();
91
-
92
-            $gridConfig->removeComponentsByType(GridFieldAddExistingAutocompleter::class);
93
-            $gridConfig->removeComponentsByType(GridFieldDeleteAction::class);
94
-            $gridConfig->addComponent($injector->create(GridFieldDeleteAction::class));
95
-            $gridConfig->addComponent($injector->create(GridFieldOrderableRows::class, 'SortOrder'));
96
-            $gridField->setModelClass(Quicklink::class);
97
-
98
-            $fields->addFieldToTab('Root.Quicklinks', $gridField);
99
-
100
-            $fields->removeByName('Import');
101
-
102
-            $fields->addFieldToTab(
103
-                'Root.Features',
104
-                ToggleCompositeField::create(
105
-                    'FeatureOne',
106
-                    _t(__CLASS__ . '.FeatureOne', 'Feature One'),
107
-                    array(
108
-                        TextField::create('FeatureOneTitle', _t(__CLASS__ . '.Title', 'Title')),
109
-                        $dropdownField = DropdownField::create(
110
-                            'FeatureOneCategory',
111
-                            _t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'),
112
-                            singleton(BaseHomePage::class)->dbObject('FeatureOneCategory')->enumValues()
113
-                        ),
114
-                        HTMLEditorField::create(
115
-                            'FeatureOneContent',
116
-                            _t(__CLASS__ . '.FeatureContentFieldLabel', 'Content')
117
-                        ),
118
-                        TextField::create(
119
-                            'FeatureOneButtonText',
120
-                            _t(__CLASS__ . '.FeatureButtonText', 'Button text')
121
-                        ),
122
-                        TreeDropdownField::create(
123
-                            'FeatureOneLinkID',
124
-                            _t(__CLASS__ . '.FeatureLink', 'Page to link to'),
125
-                            SiteTree::class
126
-                        )->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in'))
127
-                    )
128
-                )->setHeadingLevel(3)
129
-            );
130
-            $dropdownField->setEmptyString('none');
131
-
132
-            $fields->addFieldToTab('Root.Features', ToggleCompositeField::create(
133
-                'FeatureTwo',
134
-                _t(__CLASS__ . '.FeatureTwo', 'Feature Two'),
135
-                array(
136
-                    TextField::create('FeatureTwoTitle', _t(__CLASS__ . '.Title', 'Title')),
137
-                    $dropdownField = DropdownField::create(
138
-                        'FeatureTwoCategory',
139
-                        _t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'),
140
-                        singleton(BaseHomePage::class)->dbObject('FeatureTwoCategory')->enumValues()
141
-                    ),
142
-                    HTMLEditorField::create(
143
-                        'FeatureTwoContent',
144
-                        _t(__CLASS__ . '.FeatureContentFieldLabel', 'Content')
145
-                    ),
146
-                    TextField::create(
147
-                        'FeatureTwoButtonText',
148
-                        _t(__CLASS__ . '.FeatureButtonText', 'Button text')
149
-                    ),
150
-                    TreeDropdownField::create(
151
-                        'FeatureTwoLinkID',
152
-                        _t(__CLASS__ . '.FeatureLink', 'Page to link to'),
153
-                        SiteTree::class
154
-                    )->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in'))
155
-                )
156
-            )->setHeadingLevel(3));
157
-            $dropdownField->setEmptyString('none');
158
-        });
159
-
160
-        return parent::getCMSFields();
161
-    }
29
+	private static $icon_class = 'font-icon-p-home';
30
+
31
+	private static $hide_ancestor = BaseHomePage::class;
32
+
33
+	private static $singular_name = 'Home Page';
34
+
35
+	private static $plural_name = 'Home Pages';
36
+
37
+	private static $table_name = 'BaseHomePage';
38
+
39
+	private static $db = [
40
+		'FeatureOneTitle' => 'Varchar(255)',
41
+		'FeatureOneCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')",
42
+		'FeatureOneContent' => 'HTMLText',
43
+		'FeatureOneButtonText' => 'Varchar(255)',
44
+		'FeatureTwoTitle' => 'Varchar(255)',
45
+		'FeatureTwoCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')",
46
+		'FeatureTwoContent' => 'HTMLText',
47
+		'FeatureTwoButtonText' => 'Varchar(255)'
48
+	];
49
+
50
+	private static $has_one = [
51
+		'LearnMorePage' => SiteTree::class,
52
+		'FeatureOneLink' => SiteTree::class,
53
+		'FeatureTwoLink' => SiteTree::class,
54
+	];
55
+
56
+	private static $has_many = [
57
+		'Quicklinks' => Quicklink::class . '.Parent',
58
+	];
59
+
60
+	public function Quicklinks()
61
+	{
62
+		return $this->getComponents('Quicklinks')->sort('SortOrder');
63
+	}
64
+
65
+	public function getCMSFields()
66
+	{
67
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
68
+			// Main Content tab
69
+			$fields->addFieldToTab(
70
+				'Root.Main',
71
+				TreeDropdownField::create(
72
+					'LearnMorePageID',
73
+					_t(__CLASS__ . '.LearnMoreLink', 'Page to link the "Learn More" button to:'),
74
+					SiteTree::class
75
+				),
76
+				'Metadata'
77
+			);
78
+
79
+			$gridField = GridField::create(
80
+				'Quicklinks',
81
+				'Quicklinks',
82
+				$this->Quicklinks(),
83
+				GridFieldConfig_RelationEditor::create()
84
+			);
85
+			$gridConfig = $gridField->getConfig();
86
+			$gridConfig->getComponentByType(GridFieldAddNewButton::class)->setButtonName(
87
+				_t(__CLASS__ . '.AddNewButton', 'Add new')
88
+			);
89
+
90
+			$injector = Injector::inst();
91
+
92
+			$gridConfig->removeComponentsByType(GridFieldAddExistingAutocompleter::class);
93
+			$gridConfig->removeComponentsByType(GridFieldDeleteAction::class);
94
+			$gridConfig->addComponent($injector->create(GridFieldDeleteAction::class));
95
+			$gridConfig->addComponent($injector->create(GridFieldOrderableRows::class, 'SortOrder'));
96
+			$gridField->setModelClass(Quicklink::class);
97
+
98
+			$fields->addFieldToTab('Root.Quicklinks', $gridField);
99
+
100
+			$fields->removeByName('Import');
101
+
102
+			$fields->addFieldToTab(
103
+				'Root.Features',
104
+				ToggleCompositeField::create(
105
+					'FeatureOne',
106
+					_t(__CLASS__ . '.FeatureOne', 'Feature One'),
107
+					array(
108
+						TextField::create('FeatureOneTitle', _t(__CLASS__ . '.Title', 'Title')),
109
+						$dropdownField = DropdownField::create(
110
+							'FeatureOneCategory',
111
+							_t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'),
112
+							singleton(BaseHomePage::class)->dbObject('FeatureOneCategory')->enumValues()
113
+						),
114
+						HTMLEditorField::create(
115
+							'FeatureOneContent',
116
+							_t(__CLASS__ . '.FeatureContentFieldLabel', 'Content')
117
+						),
118
+						TextField::create(
119
+							'FeatureOneButtonText',
120
+							_t(__CLASS__ . '.FeatureButtonText', 'Button text')
121
+						),
122
+						TreeDropdownField::create(
123
+							'FeatureOneLinkID',
124
+							_t(__CLASS__ . '.FeatureLink', 'Page to link to'),
125
+							SiteTree::class
126
+						)->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in'))
127
+					)
128
+				)->setHeadingLevel(3)
129
+			);
130
+			$dropdownField->setEmptyString('none');
131
+
132
+			$fields->addFieldToTab('Root.Features', ToggleCompositeField::create(
133
+				'FeatureTwo',
134
+				_t(__CLASS__ . '.FeatureTwo', 'Feature Two'),
135
+				array(
136
+					TextField::create('FeatureTwoTitle', _t(__CLASS__ . '.Title', 'Title')),
137
+					$dropdownField = DropdownField::create(
138
+						'FeatureTwoCategory',
139
+						_t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'),
140
+						singleton(BaseHomePage::class)->dbObject('FeatureTwoCategory')->enumValues()
141
+					),
142
+					HTMLEditorField::create(
143
+						'FeatureTwoContent',
144
+						_t(__CLASS__ . '.FeatureContentFieldLabel', 'Content')
145
+					),
146
+					TextField::create(
147
+						'FeatureTwoButtonText',
148
+						_t(__CLASS__ . '.FeatureButtonText', 'Button text')
149
+					),
150
+					TreeDropdownField::create(
151
+						'FeatureTwoLinkID',
152
+						_t(__CLASS__ . '.FeatureLink', 'Page to link to'),
153
+						SiteTree::class
154
+					)->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in'))
155
+				)
156
+			)->setHeadingLevel(3));
157
+			$dropdownField->setEmptyString('none');
158
+		});
159
+
160
+		return parent::getCMSFields();
161
+	}
162 162
 }
Please login to merge, or discard this patch.
src/PageTypes/NewsHolder.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -7,50 +7,50 @@
 block discarded – undo
7 7
 
8 8
 class NewsHolder extends DatedUpdateHolder
9 9
 {
10
-    private static $description = 'Container page for News Pages, provides news filtering and pagination';
11
-
12
-    private static $allowed_children = [
13
-        NewsPage::class,
14
-    ];
15
-
16
-    private static $default_child = NewsPage::class;
17
-
18
-    private static $update_name = 'News';
19
-
20
-    private static $update_class = NewsPage::class;
21
-
22
-    private static $icon_class = 'font-icon-news';
23
-
24
-    private static $singular_name = 'News Holder';
25
-
26
-    private static $plural_name = 'News Holders';
27
-
28
-    private static $table_name = 'NewsHolder';
29
-
30
-    /**
31
-     * Find all site's news items, based on some filters.
32
-     * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
33
-     *
34
-     * @param string $className The name of the class to fetch.
35
-     * @param int $parentID The ID of the holder to extract the news items from.
36
-     * @param int $tagID The ID of the tag to filter the news items by.
37
-     * @param string $dateFrom The beginning of a date filter range.
38
-     * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for.
39
-     * @param int $year Numeric value of the year to show.
40
-     * @param int $monthNumber Numeric value of the month to show.
41
-     *
42
-     * @returns DataList|PaginatedList
43
-     */
44
-    public static function AllUpdates(
45
-        $className = NewsPage::class,
46
-        $parentID = null,
47
-        $tagID = null,
48
-        $dateFrom = null,
49
-        $dateTo = null,
50
-        $year = null,
51
-        $monthNumber = null
52
-    ) {
53
-        return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber)
54
-            ->Sort('Date', 'DESC');
55
-    }
10
+	private static $description = 'Container page for News Pages, provides news filtering and pagination';
11
+
12
+	private static $allowed_children = [
13
+		NewsPage::class,
14
+	];
15
+
16
+	private static $default_child = NewsPage::class;
17
+
18
+	private static $update_name = 'News';
19
+
20
+	private static $update_class = NewsPage::class;
21
+
22
+	private static $icon_class = 'font-icon-news';
23
+
24
+	private static $singular_name = 'News Holder';
25
+
26
+	private static $plural_name = 'News Holders';
27
+
28
+	private static $table_name = 'NewsHolder';
29
+
30
+	/**
31
+	 * Find all site's news items, based on some filters.
32
+	 * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
33
+	 *
34
+	 * @param string $className The name of the class to fetch.
35
+	 * @param int $parentID The ID of the holder to extract the news items from.
36
+	 * @param int $tagID The ID of the tag to filter the news items by.
37
+	 * @param string $dateFrom The beginning of a date filter range.
38
+	 * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for.
39
+	 * @param int $year Numeric value of the year to show.
40
+	 * @param int $monthNumber Numeric value of the month to show.
41
+	 *
42
+	 * @returns DataList|PaginatedList
43
+	 */
44
+	public static function AllUpdates(
45
+		$className = NewsPage::class,
46
+		$parentID = null,
47
+		$tagID = null,
48
+		$dateFrom = null,
49
+		$dateTo = null,
50
+		$year = null,
51
+		$monthNumber = null
52
+	) {
53
+		return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber)
54
+			->Sort('Date', 'DESC');
55
+	}
56 56
 }
Please login to merge, or discard this patch.
src/PageTypes/SitemapPage.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@
 block discarded – undo
6 6
 
7 7
 class SitemapPage extends Page
8 8
 {
9
-    private static $description = 'Lists all pages on the site';
9
+	private static $description = 'Lists all pages on the site';
10 10
 
11
-    private static $singular_name = 'Sitemap Page';
11
+	private static $singular_name = 'Sitemap Page';
12 12
 
13
-    private static $plural_name = 'Sitemap Pages';
13
+	private static $plural_name = 'Sitemap Pages';
14 14
 
15
-    private static $table_name = 'SitemapPage';
15
+	private static $table_name = 'SitemapPage';
16 16
 
17
-    private static $icon_class = 'font-icon-sitemap';
17
+	private static $icon_class = 'font-icon-sitemap';
18 18
 }
Please login to merge, or discard this patch.
src/PageTypes/EventHolder.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -7,57 +7,57 @@
 block discarded – undo
7 7
 
8 8
 class EventHolder extends DatedUpdateHolder
9 9
 {
10
-    private static $description = 'Container page for Event Pages, provides event filtering and pagination';
11
-
12
-    private static $allowed_children = [
13
-        EventPage::class,
14
-    ];
15
-
16
-    private static $default_child = EventPage::class;
17
-
18
-    private static $update_name = 'Events';
19
-
20
-    private static $update_class = EventPage::class;
21
-
22
-    private static $icon_class = 'font-icon-p-event-alt';
23
-
24
-    private static $singular_name = 'Event Holder';
25
-
26
-    private static $plural_name = 'Event Holders';
27
-
28
-    private static $table_name = 'EventHolder';
29
-
30
-    /**
31
-     * Find all site's news items, based on some filters.
32
-     * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
33
-     *
34
-     * @param string $className The name of the class to fetch.
35
-     * @param int $parentID The ID of the holder to extract the news items from.
36
-     * @param int $tagID The ID of the tag to filter the news items by.
37
-     * @param string $dateFrom The beginning of a date filter range.
38
-     * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for.
39
-     * @param int $year Numeric value of the year to show.
40
-     * @param int $monthNumber Numeric value of the month to show.
41
-     *
42
-     * @returns DataList|PaginatedList
43
-     */
44
-    public static function AllUpdates(
45
-        $className = 'Events',
46
-        $parentID = null,
47
-        $tagID = null,
48
-        $dateFrom = null,
49
-        $dateTo = null,
50
-        $year = null,
51
-        $monthNumber = null
52
-    ) {
53
-        return parent::AllUpdates(
54
-            $className,
55
-            $parentID,
56
-            $tagID,
57
-            $dateFrom,
58
-            $dateTo,
59
-            $year,
60
-            $monthNumber
61
-        )->Sort('Date', 'ASC');
62
-    }
10
+	private static $description = 'Container page for Event Pages, provides event filtering and pagination';
11
+
12
+	private static $allowed_children = [
13
+		EventPage::class,
14
+	];
15
+
16
+	private static $default_child = EventPage::class;
17
+
18
+	private static $update_name = 'Events';
19
+
20
+	private static $update_class = EventPage::class;
21
+
22
+	private static $icon_class = 'font-icon-p-event-alt';
23
+
24
+	private static $singular_name = 'Event Holder';
25
+
26
+	private static $plural_name = 'Event Holders';
27
+
28
+	private static $table_name = 'EventHolder';
29
+
30
+	/**
31
+	 * Find all site's news items, based on some filters.
32
+	 * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
33
+	 *
34
+	 * @param string $className The name of the class to fetch.
35
+	 * @param int $parentID The ID of the holder to extract the news items from.
36
+	 * @param int $tagID The ID of the tag to filter the news items by.
37
+	 * @param string $dateFrom The beginning of a date filter range.
38
+	 * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for.
39
+	 * @param int $year Numeric value of the year to show.
40
+	 * @param int $monthNumber Numeric value of the month to show.
41
+	 *
42
+	 * @returns DataList|PaginatedList
43
+	 */
44
+	public static function AllUpdates(
45
+		$className = 'Events',
46
+		$parentID = null,
47
+		$tagID = null,
48
+		$dateFrom = null,
49
+		$dateTo = null,
50
+		$year = null,
51
+		$monthNumber = null
52
+	) {
53
+		return parent::AllUpdates(
54
+			$className,
55
+			$parentID,
56
+			$tagID,
57
+			$dateFrom,
58
+			$dateTo,
59
+			$year,
60
+			$monthNumber
61
+		)->Sort('Date', 'ASC');
62
+	}
63 63
 }
Please login to merge, or discard this patch.
src/PageTypes/BasePage.php 1 patch
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -31,145 +31,145 @@
 block discarded – undo
31 31
 
32 32
 class BasePage extends SiteTree
33 33
 {
34
-    /**
35
-     * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide"
36
-     *
37
-     * {@inheritDoc}
38
-     */
39
-    private static $hide_ancestor = BasePage::class;
40
-
41
-    private static $api_access = [
42
-        'view' => [
43
-            'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
44
-            'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
45
-        ],
46
-        'edit' => [
47
-            'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
48
-            'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
49
-        ],
50
-    ];
51
-
52
-    private static $table_name = 'BasePage';
53
-
54
-    /**
55
-     * @config
56
-     * @var string
57
-     */
58
-    private static $related_pages_title = 'Related pages';
59
-
60
-    private static $many_many = [
61
-        'Terms' => TaxonomyTerm::class,
62
-        'RelatedPagesThrough' => [
63
-            'through' => RelatedPageLink::class,
64
-            'from' => 'BasePage',
65
-            'to' => 'Child',
66
-        ]
67
-    ];
68
-
69
-    private static $owns = [
70
-        'RelatedPagesThrough',
71
-    ];
72
-
73
-    private static $belongs_many_many = [
74
-        'SimilarPages' => BasePage::class
75
-    ];
76
-
77
-    /**
78
-     * @var array
79
-     * @config
80
-     */
81
-    private static $many_many_extraFields = [
82
-        'RelatedPages' => [
83
-            'SortOrder' => 'Int',
84
-        ],
85
-    ];
86
-
87
-    private static $plural_name = 'Base Pages';
88
-
89
-    /**
90
-     * Get the footer holder.
91
-     */
92
-    public function getFooter()
93
-    {
94
-        return FooterHolder::get_one(FooterHolder::class);
95
-    }
96
-
97
-    /**
98
-     * @deprecated 2.2.0:3.0.0 Please use RelatedPagesThrough() instead
99
-     */
100
-    public function RelatedPages()
101
-    {
102
-        return $this->getManyManyComponents('RelatedPagesThrough');
103
-    }
104
-
105
-    public function RelatedPagesTitle()
106
-    {
107
-        return $this->config()->get('related_pages_title');
108
-    }
109
-
110
-    public function getCMSFields()
111
-    {
112
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
113
-            // Related Pages
114
-            $components = GridFieldConfig_RelationEditor::create();
115
-            $components->removeComponentsByType(GridFieldAddNewButton::class);
116
-            $components->removeComponentsByType(GridFieldEditButton::class);
117
-            $components->removeComponentsByType(GridFieldFilterHeader::class);
118
-            $components->addComponent(new GridFieldOrderableRows('SortOrder'));
119
-
120
-            /** @var GridFieldDataColumns $dataColumns */
121
-            $dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
122
-            $dataColumns->setDisplayFields([
123
-                'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'),
124
-                'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type')
125
-            ]);
126
-
127
-            $fields->findOrMakeTab(
128
-                'Root.RelatedPages',
129
-                _t(__CLASS__ . '.RelatedPages', 'Related pages')
130
-            );
131
-            $fields->addFieldToTab(
132
-                'Root.RelatedPages',
133
-                GridField::create(
134
-                    'RelatedPages',
135
-                    _t(__CLASS__ . '.RelatedPages', 'Related pages'),
136
-                    $this->RelatedPagesThrough(),
137
-                    $components
138
-                )
139
-            );
140
-
141
-            // Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc)
142
-            $hasMany = $this->hasMany();
143
-            $manyMany = $this->manyMany();
144
-            if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) {
145
-                $fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags'));
146
-                $fields->addFieldToTab(
147
-                    'Root.Tags',
148
-                    TreeMultiselectField::create(
149
-                        'Terms',
150
-                        _t(__CLASS__ . '.Terms', 'Terms'),
151
-                        TaxonomyTerm::class
152
-                    )->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms'))
153
-                );
154
-            }
155
-        });
156
-        return parent::getCMSFields();
157
-    }
158
-
159
-    /**
160
-     * Returns the native language name for the selected locale/language, empty string if Fluent is not available
161
-     *
162
-     * @return string
163
-     */
164
-    public function getSelectedLanguage()
165
-    {
166
-        if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) {
167
-            return '';
168
-        }
169
-
170
-        /** @var ArrayData $information */
171
-        $information = $this->LocaleInformation(FluentState::singleton()->getLocale());
172
-
173
-        return $information->LanguageNative;
174
-    }
34
+	/**
35
+	 * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide"
36
+	 *
37
+	 * {@inheritDoc}
38
+	 */
39
+	private static $hide_ancestor = BasePage::class;
40
+
41
+	private static $api_access = [
42
+		'view' => [
43
+			'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
44
+			'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
45
+		],
46
+		'edit' => [
47
+			'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
48
+			'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
49
+		],
50
+	];
51
+
52
+	private static $table_name = 'BasePage';
53
+
54
+	/**
55
+	 * @config
56
+	 * @var string
57
+	 */
58
+	private static $related_pages_title = 'Related pages';
59
+
60
+	private static $many_many = [
61
+		'Terms' => TaxonomyTerm::class,
62
+		'RelatedPagesThrough' => [
63
+			'through' => RelatedPageLink::class,
64
+			'from' => 'BasePage',
65
+			'to' => 'Child',
66
+		]
67
+	];
68
+
69
+	private static $owns = [
70
+		'RelatedPagesThrough',
71
+	];
72
+
73
+	private static $belongs_many_many = [
74
+		'SimilarPages' => BasePage::class
75
+	];
76
+
77
+	/**
78
+	 * @var array
79
+	 * @config
80
+	 */
81
+	private static $many_many_extraFields = [
82
+		'RelatedPages' => [
83
+			'SortOrder' => 'Int',
84
+		],
85
+	];
86
+
87
+	private static $plural_name = 'Base Pages';
88
+
89
+	/**
90
+	 * Get the footer holder.
91
+	 */
92
+	public function getFooter()
93
+	{
94
+		return FooterHolder::get_one(FooterHolder::class);
95
+	}
96
+
97
+	/**
98
+	 * @deprecated 2.2.0:3.0.0 Please use RelatedPagesThrough() instead
99
+	 */
100
+	public function RelatedPages()
101
+	{
102
+		return $this->getManyManyComponents('RelatedPagesThrough');
103
+	}
104
+
105
+	public function RelatedPagesTitle()
106
+	{
107
+		return $this->config()->get('related_pages_title');
108
+	}
109
+
110
+	public function getCMSFields()
111
+	{
112
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
113
+			// Related Pages
114
+			$components = GridFieldConfig_RelationEditor::create();
115
+			$components->removeComponentsByType(GridFieldAddNewButton::class);
116
+			$components->removeComponentsByType(GridFieldEditButton::class);
117
+			$components->removeComponentsByType(GridFieldFilterHeader::class);
118
+			$components->addComponent(new GridFieldOrderableRows('SortOrder'));
119
+
120
+			/** @var GridFieldDataColumns $dataColumns */
121
+			$dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
122
+			$dataColumns->setDisplayFields([
123
+				'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'),
124
+				'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type')
125
+			]);
126
+
127
+			$fields->findOrMakeTab(
128
+				'Root.RelatedPages',
129
+				_t(__CLASS__ . '.RelatedPages', 'Related pages')
130
+			);
131
+			$fields->addFieldToTab(
132
+				'Root.RelatedPages',
133
+				GridField::create(
134
+					'RelatedPages',
135
+					_t(__CLASS__ . '.RelatedPages', 'Related pages'),
136
+					$this->RelatedPagesThrough(),
137
+					$components
138
+				)
139
+			);
140
+
141
+			// Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc)
142
+			$hasMany = $this->hasMany();
143
+			$manyMany = $this->manyMany();
144
+			if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) {
145
+				$fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags'));
146
+				$fields->addFieldToTab(
147
+					'Root.Tags',
148
+					TreeMultiselectField::create(
149
+						'Terms',
150
+						_t(__CLASS__ . '.Terms', 'Terms'),
151
+						TaxonomyTerm::class
152
+					)->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms'))
153
+				);
154
+			}
155
+		});
156
+		return parent::getCMSFields();
157
+	}
158
+
159
+	/**
160
+	 * Returns the native language name for the selected locale/language, empty string if Fluent is not available
161
+	 *
162
+	 * @return string
163
+	 */
164
+	public function getSelectedLanguage()
165
+	{
166
+		if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) {
167
+			return '';
168
+		}
169
+
170
+		/** @var ArrayData $information */
171
+		$information = $this->LocaleInformation(FluentState::singleton()->getLocale());
172
+
173
+		return $information->LanguageNative;
174
+	}
175 175
 }
Please login to merge, or discard this patch.
src/Model/Quicklink.php 1 patch
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -15,121 +15,121 @@
 block discarded – undo
15 15
  */
16 16
 class Quicklink extends DataObject
17 17
 {
18
-    private static $db = [
19
-        'Name' => 'Varchar(255)',
20
-        'ExternalLink' => 'Varchar(255)',
21
-        'SortOrder' => 'Int',
22
-    ];
23
-
24
-    private static $has_one = [
25
-        'Parent' => BaseHomePage::class,
26
-        'InternalLink' => SiteTree::class,
27
-    ];
28
-
29
-    private static $summary_fields = [
30
-        'Name' => 'Name',
31
-        'InternalLink.Title' => 'Internal Link',
32
-        'ExternalLink' => 'External Link',
33
-    ];
34
-
35
-    private static $table_name = 'Quicklink';
36
-
37
-    public function fieldLabels($includerelations = true)
38
-    {
39
-        $labels = parent::fieldLabels($includerelations);
40
-        $labels['Name'] = _t(__CLASS__ . '.NameLabel', 'Name');
41
-        $labels['ExternalLink'] = _t(__CLASS__ . '.ExternalLinkLabel', 'External Link');
42
-        $labels['SortOrder'] = _t(__CLASS__ . '.SortOrderLabel', 'Sort Order');
43
-        $labels['ParentID'] = _t(__CLASS__ . '.ParentRelationLabel', 'Parent');
44
-        $labels['InternalLinkID'] = _t(__CLASS__ . '.InternalLinkLabel', 'Internal Link');
45
-
46
-        return $labels;
47
-    }
48
-
49
-    public function getLink()
50
-    {
51
-        if ($this->ExternalLink) {
52
-            $url = parse_url($this->ExternalLink);
53
-
54
-            // if no scheme set in the link, default to http
55
-            if (!isset($url['scheme'])) {
56
-                return 'http://' . $this->ExternalLink;
57
-            }
58
-
59
-            return $this->ExternalLink;
60
-        }
61
-
62
-        if ($this->InternalLinkID) {
63
-            return $this->InternalLink()->Link();
64
-        }
65
-    }
66
-
67
-    public function canCreate($member = null, $context = [])
68
-    {
69
-        // Creating quick links should not be the same permission level as creating parent pages for them, they're
70
-        // essentially content in the context of the page, so use the edit permission instead.
71
-        return $this->canEdit($member);
72
-    }
73
-
74
-    public function canEdit($member = null)
75
-    {
76
-        return $this->Parent()->canEdit($member);
77
-    }
78
-
79
-    public function canDelete($member = null)
80
-    {
81
-        return $this->Parent()->canDelete($member);
82
-    }
83
-
84
-    public function canView($member = null)
85
-    {
86
-        return $this->Parent()->canView($member);
87
-    }
88
-
89
-    public function getCMSFields()
90
-    {
91
-        $fields = parent::getCMSFields();
92
-
93
-        $fields->removeByName('ParentID');
94
-
95
-        $externalLinkField = $fields->fieldByName('Root.Main.ExternalLink');
96
-
97
-        $fields->removeByName('ExternalLink');
98
-        $fields->removeByName('InternalLinkID');
99
-        $fields->removeByName('SortOrder');
100
-        $externalLinkField->addExtraClass('noBorder');
101
-
102
-        $fields->addFieldToTab('Root.Main', CompositeField::create(
103
-            array(
104
-                TreeDropdownField::create(
105
-                    'InternalLinkID',
106
-                    $this->fieldLabel('InternalLinkID'),
107
-                    SiteTree::class
108
-                ),
109
-                $externalLinkField,
110
-                $wrap = CompositeField::create(
111
-                    $extraLabel = LiteralField::create(
112
-                        'NoteOverride',
113
-                        sprintf('<div class="message good notice">%s</div>', _t(
114
-                            __CLASS__ . '.Note',
115
-                            'Note: If you specify an External Link, the Internal Link will be ignored.'
116
-                        ))
117
-                    )
118
-                )
119
-            )
120
-        ));
121
-        $fields->insertBefore(
122
-            'Name',
123
-            LiteralField::create(
124
-                'Note',
125
-                sprintf('<p>%s</p>', _t(
126
-                    __CLASS__ . '.Note2',
127
-                    'Use this to specify a link to a page either on this site '
128
-                        . '(Internal Link) or another site (External Link).'
129
-                ))
130
-            )
131
-        );
132
-
133
-        return $fields;
134
-    }
18
+	private static $db = [
19
+		'Name' => 'Varchar(255)',
20
+		'ExternalLink' => 'Varchar(255)',
21
+		'SortOrder' => 'Int',
22
+	];
23
+
24
+	private static $has_one = [
25
+		'Parent' => BaseHomePage::class,
26
+		'InternalLink' => SiteTree::class,
27
+	];
28
+
29
+	private static $summary_fields = [
30
+		'Name' => 'Name',
31
+		'InternalLink.Title' => 'Internal Link',
32
+		'ExternalLink' => 'External Link',
33
+	];
34
+
35
+	private static $table_name = 'Quicklink';
36
+
37
+	public function fieldLabels($includerelations = true)
38
+	{
39
+		$labels = parent::fieldLabels($includerelations);
40
+		$labels['Name'] = _t(__CLASS__ . '.NameLabel', 'Name');
41
+		$labels['ExternalLink'] = _t(__CLASS__ . '.ExternalLinkLabel', 'External Link');
42
+		$labels['SortOrder'] = _t(__CLASS__ . '.SortOrderLabel', 'Sort Order');
43
+		$labels['ParentID'] = _t(__CLASS__ . '.ParentRelationLabel', 'Parent');
44
+		$labels['InternalLinkID'] = _t(__CLASS__ . '.InternalLinkLabel', 'Internal Link');
45
+
46
+		return $labels;
47
+	}
48
+
49
+	public function getLink()
50
+	{
51
+		if ($this->ExternalLink) {
52
+			$url = parse_url($this->ExternalLink);
53
+
54
+			// if no scheme set in the link, default to http
55
+			if (!isset($url['scheme'])) {
56
+				return 'http://' . $this->ExternalLink;
57
+			}
58
+
59
+			return $this->ExternalLink;
60
+		}
61
+
62
+		if ($this->InternalLinkID) {
63
+			return $this->InternalLink()->Link();
64
+		}
65
+	}
66
+
67
+	public function canCreate($member = null, $context = [])
68
+	{
69
+		// Creating quick links should not be the same permission level as creating parent pages for them, they're
70
+		// essentially content in the context of the page, so use the edit permission instead.
71
+		return $this->canEdit($member);
72
+	}
73
+
74
+	public function canEdit($member = null)
75
+	{
76
+		return $this->Parent()->canEdit($member);
77
+	}
78
+
79
+	public function canDelete($member = null)
80
+	{
81
+		return $this->Parent()->canDelete($member);
82
+	}
83
+
84
+	public function canView($member = null)
85
+	{
86
+		return $this->Parent()->canView($member);
87
+	}
88
+
89
+	public function getCMSFields()
90
+	{
91
+		$fields = parent::getCMSFields();
92
+
93
+		$fields->removeByName('ParentID');
94
+
95
+		$externalLinkField = $fields->fieldByName('Root.Main.ExternalLink');
96
+
97
+		$fields->removeByName('ExternalLink');
98
+		$fields->removeByName('InternalLinkID');
99
+		$fields->removeByName('SortOrder');
100
+		$externalLinkField->addExtraClass('noBorder');
101
+
102
+		$fields->addFieldToTab('Root.Main', CompositeField::create(
103
+			array(
104
+				TreeDropdownField::create(
105
+					'InternalLinkID',
106
+					$this->fieldLabel('InternalLinkID'),
107
+					SiteTree::class
108
+				),
109
+				$externalLinkField,
110
+				$wrap = CompositeField::create(
111
+					$extraLabel = LiteralField::create(
112
+						'NoteOverride',
113
+						sprintf('<div class="message good notice">%s</div>', _t(
114
+							__CLASS__ . '.Note',
115
+							'Note: If you specify an External Link, the Internal Link will be ignored.'
116
+						))
117
+					)
118
+				)
119
+			)
120
+		));
121
+		$fields->insertBefore(
122
+			'Name',
123
+			LiteralField::create(
124
+				'Note',
125
+				sprintf('<p>%s</p>', _t(
126
+					__CLASS__ . '.Note2',
127
+					'Use this to specify a link to a page either on this site '
128
+						. '(Internal Link) or another site (External Link).'
129
+				))
130
+			)
131
+		);
132
+
133
+		return $fields;
134
+	}
135 135
 }
Please login to merge, or discard this patch.
tests/PageTypes/NewsPageTest.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -9,21 +9,21 @@
 block discarded – undo
9 9
 
10 10
 class NewsPageTest extends SapphireTest
11 11
 {
12
-    protected $usesDatabase = true;
12
+	protected $usesDatabase = true;
13 13
 
14
-    public function testGetNewsPageAuthor()
15
-    {
16
-        $holder = new NewsHolder();
17
-        $holder->Title = 'Holder';
18
-        $holder->write();
14
+	public function testGetNewsPageAuthor()
15
+	{
16
+		$holder = new NewsHolder();
17
+		$holder->Title = 'Holder';
18
+		$holder->write();
19 19
 
20
-        $page = new NewsPage();
21
-        $page->Author = 'Leslie Lawless';
22
-        $page->ParentID = $holder->ID;
23
-        $page->write();
20
+		$page = new NewsPage();
21
+		$page->Author = 'Leslie Lawless';
22
+		$page->ParentID = $holder->ID;
23
+		$page->write();
24 24
 
25
-        $field = $page->getNewsPageAuthor();
26
-        $this->assertInstanceOf(DBField::class, $field);
27
-        $this->assertSame('Leslie Lawless', $field->getValue());
28
-    }
25
+		$field = $page->getNewsPageAuthor();
26
+		$this->assertInstanceOf(DBField::class, $field);
27
+		$this->assertSame('Leslie Lawless', $field->getValue());
28
+	}
29 29
 }
Please login to merge, or discard this patch.
src/PageTypes/NewsPage.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -10,71 +10,71 @@
 block discarded – undo
10 10
 
11 11
 class NewsPage extends DatedUpdatePage
12 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
-    }
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 80
 }
Please login to merge, or discard this patch.