Passed
Push — master ( d7fd6a...9124ff )
by Robbie
11:58
created

NewsPage::getCMSFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
class NewsPage extends DatedUpdatePage {
4
5
	private static $description = 'Describes an item of news';
0 ignored issues
show
introduced by
The private property $description is not used, and could be removed.
Loading history...
6
7
	private static $default_parent = 'NewsHolderPage';
0 ignored issues
show
introduced by
The private property $default_parent is not used, and could be removed.
Loading history...
8
9
	private static $can_be_root = false;
0 ignored issues
show
introduced by
The private property $can_be_root is not used, and could be removed.
Loading history...
10
11
	private static $icon = 'cwp/images/icons/sitetree_images/news.png';
0 ignored issues
show
introduced by
The private property $icon is not used, and could be removed.
Loading history...
12
13
	private static $singular_name = 'News Page';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
14
15
	private static $plural_name = 'News Pages';
0 ignored issues
show
introduced by
The private property $plural_name is not used, and could be removed.
Loading history...
16
17
	private static $db = array(
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
18
		'Author' => 'Varchar(255)'
19
	);
20
21
	private static $has_one = array(
0 ignored issues
show
introduced by
The private property $has_one is not used, and could be removed.
Loading history...
22
		'FeaturedImage' => 'Image'
23
	);
24
25
	public $pageIcon =  'images/icons/sitetree_images/news.png';
26
27
	public function fieldLabels($includerelations = true) {
28
		$labels = parent::fieldLabels($includerelations);
29
		$labels['Author'] = _t('DateUpdatePage.AuthorFieldLabel', 'Author');
30
		$labels['FeaturedImageID'] = _t('DateUpdatePage.FeaturedImageFieldLabel', 'Featured Image');
31
32
		return $labels;
33
	}
34
35
	public function getCMSFields() {
36
		$this->beforeUpdateCMSFields(function (FieldList $fields) {
37
			$fields->addFieldToTab(
38
				'Root.Main',
39
				TextField::create('Author', $this->fieldLabel('Author')),
40
				'Abstract'
41
			);
42
43
			$fields->addFieldToTab(
44
				'Root.Main',
45
				UploadField::create('FeaturedImage', $this->fieldLabel('FeaturedImageID')),
46
				'Abstract'
47
			);
48
		});
49
		return parent::getCMSFields();
50
	}
51
}
52
53
class NewsPage_Controller extends DatedUpdatePage_Controller {
54
55
}
56