Passed
Push — master ( a2a476...278f1c )
by Steve
14:06 queued 10:56
created
src/PageTypes/EventPage.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
 
65 65
     public function getCMSFields()
66 66
     {
67
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
67
+        $this->beforeUpdateCMSFields(function(FieldList $fields) {
68 68
             $fields->removeByName('Date');
69 69
 
70 70
             $dateTimeFields = array();
Please login to merge, or discard this 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/NewsPage.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 
46 46
     public function getCMSFields()
47 47
     {
48
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
48
+        $this->beforeUpdateCMSFields(function(FieldList $fields) {
49 49
             $fields->addFieldToTab(
50 50
                 'Root.Main',
51 51
                 TextField::create('Author', $this->fieldLabel('Author')),
Please login to merge, or discard this 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.
src/PageTypes/EventHolderController.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -19,53 +19,53 @@
 block discarded – undo
19 19
  */
20 20
 class EventHolderController extends DatedUpdateHolderController
21 21
 {
22
-    public function getUpdateName()
23
-    {
24
-        $params = $this->parseParams();
25
-        if ($params['upcomingOnly']) {
26
-            return _t(__CLASS__ . '.Upcoming', 'Upcoming events');
27
-        }
22
+	public function getUpdateName()
23
+	{
24
+		$params = $this->parseParams();
25
+		if ($params['upcomingOnly']) {
26
+			return _t(__CLASS__ . '.Upcoming', 'Upcoming events');
27
+		}
28 28
 
29
-        return _t(__CLASS__ . '.Events', 'Events');
30
-    }
29
+		return _t(__CLASS__ . '.Events', 'Events');
30
+	}
31 31
 
32
-    /**
33
-     * Parse URL parameters.
34
-     *
35
-     * @param boolean $produceErrorMessages Set to false to omit session messages.
36
-     */
37
-    public function parseParams($produceErrorMessages = true)
38
-    {
39
-        $params = parent::parseParams($produceErrorMessages);
32
+	/**
33
+	 * Parse URL parameters.
34
+	 *
35
+	 * @param boolean $produceErrorMessages Set to false to omit session messages.
36
+	 */
37
+	public function parseParams($produceErrorMessages = true)
38
+	{
39
+		$params = parent::parseParams($produceErrorMessages);
40 40
 
41
-        // We need to set whether or not we're supposed to be displaying only upcoming events or all events.
42
-        $params['upcomingOnly'] = !($params['from'] || $params['to'] || $params['year'] || $params['month']);
41
+		// We need to set whether or not we're supposed to be displaying only upcoming events or all events.
42
+		$params['upcomingOnly'] = !($params['from'] || $params['to'] || $params['year'] || $params['month']);
43 43
 
44
-        return $params;
45
-    }
44
+		return $params;
45
+	}
46 46
 
47
-    /**
48
-     * Get the events based on the current query.
49
-     */
50
-    public function FilteredUpdates($pageSize = 20)
51
-    {
52
-        $params = $this->parseParams();
47
+	/**
48
+	 * Get the events based on the current query.
49
+	 */
50
+	public function FilteredUpdates($pageSize = 20)
51
+	{
52
+		$params = $this->parseParams();
53 53
 
54
-        $items = $this->Updates(
55
-            $params['tag'],
56
-            $params['from'],
57
-            $params['to'],
58
-            $params['year'],
59
-            $params['month']
60
-        );
54
+		$items = $this->Updates(
55
+			$params['tag'],
56
+			$params['from'],
57
+			$params['to'],
58
+			$params['year'],
59
+			$params['month']
60
+		);
61 61
 
62
-        if ($params['upcomingOnly']) {
63
-            $items = $items->filter(['Date:LessThan:Not' => DBDatetime::now()->Format('y-MM-dd')]);
64
-        }
62
+		if ($params['upcomingOnly']) {
63
+			$items = $items->filter(['Date:LessThan:Not' => DBDatetime::now()->Format('y-MM-dd')]);
64
+		}
65 65
 
66
-        // Apply pagination
67
-        $list = PaginatedList::create($items, $this->getRequest());
68
-        $list->setPageLength($pageSize);
69
-        return $list;
70
-    }
66
+		// Apply pagination
67
+		$list = PaginatedList::create($items, $this->getRequest());
68
+		$list->setPageLength($pageSize);
69
+		return $list;
70
+	}
71 71
 }
Please login to merge, or discard this patch.
src/PageTypes/BasePage.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -186,7 +186,7 @@
 block discarded – undo
186 186
 
187 187
     public function getCMSFields()
188 188
     {
189
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
189
+        $this->beforeUpdateCMSFields(function(FieldList $fields) {
190 190
             // Related Pages
191 191
             $components = GridFieldConfig_RelationEditor::create();
192 192
             $components->removeComponentsByType(GridFieldAddNewButton::class);
Please login to merge, or discard this 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.
tests/PageTypes/SitemapPageTest.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -9,27 +9,27 @@
 block discarded – undo
9 9
 
10 10
 class SitemapPageTest extends FunctionalTest
11 11
 {
12
-    protected static $fixture_file = 'SitemapPageTest.yml';
12
+	protected static $fixture_file = 'SitemapPageTest.yml';
13 13
 
14
-    protected static $use_draft_site = true;
14
+	protected static $use_draft_site = true;
15 15
 
16
-    protected function setUp()
17
-    {
18
-        parent::setUp();
16
+	protected function setUp()
17
+	{
18
+		parent::setUp();
19 19
 
20
-        Config::modify()->set(SSViewer::class, 'themes', ['starter', '$default']);
21
-        Config::modify()->set(SSViewer::class, 'theme', 'starter');
22
-    }
20
+		Config::modify()->set(SSViewer::class, 'themes', ['starter', '$default']);
21
+		Config::modify()->set(SSViewer::class, 'theme', 'starter');
22
+	}
23 23
 
24
-    /**
25
-     * Note: this test depends on the "starter" theme being installed and configured as default
26
-     */
27
-    public function testSitemapShowsNavigationTitleNotNormalTitle()
28
-    {
29
-        $response = $this->get('sitemap');
30
-        $parser = new CSSContentParser($response->getBody());
31
-        $elements = $parser->getBySelector('.sitemap li.first .sitemap-link');
32
-        $this->assertNotEmpty($elements);
33
-        $this->assertEquals('Top page nav 1', (string) $elements[0]);
34
-    }
24
+	/**
25
+	 * Note: this test depends on the "starter" theme being installed and configured as default
26
+	 */
27
+	public function testSitemapShowsNavigationTitleNotNormalTitle()
28
+	{
29
+		$response = $this->get('sitemap');
30
+		$parser = new CSSContentParser($response->getBody());
31
+		$elements = $parser->getBySelector('.sitemap li.first .sitemap-link');
32
+		$this->assertNotEmpty($elements);
33
+		$this->assertEquals('Top page nav 1', (string) $elements[0]);
34
+	}
35 35
 }
Please login to merge, or discard this patch.
src/PageTypes/BasePageController.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@
 block discarded – undo
7 7
 
8 8
 class BasePageController extends ContentController
9 9
 {
10
-    /**
11
-     * Provide current year.
12
-     */
13
-    public function CurrentDatetime()
14
-    {
15
-        return DBDatetime::now();
16
-    }
10
+	/**
11
+	 * Provide current year.
12
+	 */
13
+	public function CurrentDatetime()
14
+	{
15
+		return DBDatetime::now();
16
+	}
17 17
 
18
-    public function getRSSLink()
19
-    {
20
-    }
18
+	public function getRSSLink()
19
+	{
20
+	}
21 21
 }
Please login to merge, or discard this patch.
src/Report/CwpStatsReport.php 2 patches
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -20,108 +20,108 @@
 block discarded – undo
20 20
  */
21 21
 class CwpStatsReport extends Report
22 22
 {
23
-    public function title()
24
-    {
25
-        return _t(__CLASS__ . '.Title', 'Summary statistics');
26
-    }
27
-
28
-    public function description()
29
-    {
30
-        return _t(
31
-            __CLASS__ . '.Description',
32
-            'This report provides various statistics for this site. The "total live page count" is the number that ' .
33
-                'can be compared against the instance size specifications.'
34
-        );
35
-    }
36
-
37
-    public function columns()
38
-    {
39
-        return [
40
-            'Name' => _t(__CLASS__ . '.Name', 'Name'),
41
-            'Count' => _t(__CLASS__ . '.Count', 'Count'),
42
-        ];
43
-    }
44
-
45
-    /**
46
-     * Manually create source records for the report. Agreggates cannot be provided as a column of a DataQuery result.
47
-     *
48
-     * {@inheritDoc}
49
-     */
50
-    public function sourceRecords($params = [], $sort = null, $limit = null)
51
-    {
52
-        $records = [];
53
-
54
-        // Get the query to apply across all variants: looks at all subsites, translations, live stage only.
55
-        $crossVariant = (function ($dataQuery) {
56
-            $params = [
57
-                'Subsite.filter' => false,
58
-                'Versioned.mode' => 'stage',
59
-                'Versioned.stage' => Versioned::LIVE,
60
-            ];
61
-
62
-            return $dataQuery->setDataQueryParam($params);
63
-        });
64
-
65
-        // Total.
66
-        $records[] = [
67
-            'Name' => _t(
68
-                __CLASS__ . '.TotalPageCount',
69
-                'Total live page count, across all translations and subsites'
70
-            ),
71
-            'Count' => $crossVariant(SiteTree::get())->count(),
72
-        ];
73
-
74
-        if (class_exists(Subsite::class)) {
75
-            // Main site.
76
-            $records[] = [
77
-                'Name' => _t(__CLASS__ . '.PagesForMainSite', '- in the main site'),
78
-                'Count' => $crossVariant(SiteTree::get())
79
-                    ->filter(['SubsiteID' => 0])
80
-                    ->count(),
81
-            ];
82
-
83
-            // Per subsite.
84
-            $subsites = Subsite::get();
85
-            foreach ($subsites as $subsite) {
86
-                $records[] = [
87
-                    'Name' => _t(
88
-                        __CLASS__ . '.PagesForSubsite',
89
-                        "- in the subsite '{SubsiteTitle}'",
90
-                        ['SubsiteTitle' => $subsite->Title]
91
-                    ),
92
-                    'Count' => $crossVariant(SiteTree::get())
93
-                        ->filter(['SubsiteID' => $subsite->ID])
94
-                        ->count(),
95
-                ];
96
-            }
97
-        }
98
-
99
-        // Files.
100
-        $records[] = [
101
-            'Name' => _t(__CLASS__ . '.FileCount', 'File count'),
102
-            'Count' => File::get()
103
-                ->setDataQueryParam('Subsite.filter', false)
104
-                ->filter(['ClassName:not' => Folder::class])
105
-                ->count(),
106
-        ];
107
-
108
-        return ArrayList::create($records);
109
-    }
110
-
111
-    /**
112
-     * @return GridField
113
-     */
114
-    public function getReportField()
115
-    {
116
-        /** @var GridField $gridField */
117
-        $gridField = parent::getReportField();
118
-
119
-        /** @var GridFieldConfig $gridConfig */
120
-        $gridConfig = $gridField->getConfig();
121
-        $gridConfig->removeComponentsByType(GridFieldPrintButton::class);
122
-        $gridConfig->removeComponentsByType(GridFieldExportButton::class);
123
-        $gridConfig->removeComponentsByType(GridFieldSortableHeader::class);
124
-
125
-        return $gridField;
126
-    }
23
+	public function title()
24
+	{
25
+		return _t(__CLASS__ . '.Title', 'Summary statistics');
26
+	}
27
+
28
+	public function description()
29
+	{
30
+		return _t(
31
+			__CLASS__ . '.Description',
32
+			'This report provides various statistics for this site. The "total live page count" is the number that ' .
33
+				'can be compared against the instance size specifications.'
34
+		);
35
+	}
36
+
37
+	public function columns()
38
+	{
39
+		return [
40
+			'Name' => _t(__CLASS__ . '.Name', 'Name'),
41
+			'Count' => _t(__CLASS__ . '.Count', 'Count'),
42
+		];
43
+	}
44
+
45
+	/**
46
+	 * Manually create source records for the report. Agreggates cannot be provided as a column of a DataQuery result.
47
+	 *
48
+	 * {@inheritDoc}
49
+	 */
50
+	public function sourceRecords($params = [], $sort = null, $limit = null)
51
+	{
52
+		$records = [];
53
+
54
+		// Get the query to apply across all variants: looks at all subsites, translations, live stage only.
55
+		$crossVariant = (function ($dataQuery) {
56
+			$params = [
57
+				'Subsite.filter' => false,
58
+				'Versioned.mode' => 'stage',
59
+				'Versioned.stage' => Versioned::LIVE,
60
+			];
61
+
62
+			return $dataQuery->setDataQueryParam($params);
63
+		});
64
+
65
+		// Total.
66
+		$records[] = [
67
+			'Name' => _t(
68
+				__CLASS__ . '.TotalPageCount',
69
+				'Total live page count, across all translations and subsites'
70
+			),
71
+			'Count' => $crossVariant(SiteTree::get())->count(),
72
+		];
73
+
74
+		if (class_exists(Subsite::class)) {
75
+			// Main site.
76
+			$records[] = [
77
+				'Name' => _t(__CLASS__ . '.PagesForMainSite', '- in the main site'),
78
+				'Count' => $crossVariant(SiteTree::get())
79
+					->filter(['SubsiteID' => 0])
80
+					->count(),
81
+			];
82
+
83
+			// Per subsite.
84
+			$subsites = Subsite::get();
85
+			foreach ($subsites as $subsite) {
86
+				$records[] = [
87
+					'Name' => _t(
88
+						__CLASS__ . '.PagesForSubsite',
89
+						"- in the subsite '{SubsiteTitle}'",
90
+						['SubsiteTitle' => $subsite->Title]
91
+					),
92
+					'Count' => $crossVariant(SiteTree::get())
93
+						->filter(['SubsiteID' => $subsite->ID])
94
+						->count(),
95
+				];
96
+			}
97
+		}
98
+
99
+		// Files.
100
+		$records[] = [
101
+			'Name' => _t(__CLASS__ . '.FileCount', 'File count'),
102
+			'Count' => File::get()
103
+				->setDataQueryParam('Subsite.filter', false)
104
+				->filter(['ClassName:not' => Folder::class])
105
+				->count(),
106
+		];
107
+
108
+		return ArrayList::create($records);
109
+	}
110
+
111
+	/**
112
+	 * @return GridField
113
+	 */
114
+	public function getReportField()
115
+	{
116
+		/** @var GridField $gridField */
117
+		$gridField = parent::getReportField();
118
+
119
+		/** @var GridFieldConfig $gridConfig */
120
+		$gridConfig = $gridField->getConfig();
121
+		$gridConfig->removeComponentsByType(GridFieldPrintButton::class);
122
+		$gridConfig->removeComponentsByType(GridFieldExportButton::class);
123
+		$gridConfig->removeComponentsByType(GridFieldSortableHeader::class);
124
+
125
+		return $gridField;
126
+	}
127 127
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
         $records = [];
53 53
 
54 54
         // Get the query to apply across all variants: looks at all subsites, translations, live stage only.
55
-        $crossVariant = (function ($dataQuery) {
55
+        $crossVariant = (function($dataQuery) {
56 56
             $params = [
57 57
                 'Subsite.filter' => false,
58 58
                 'Versioned.mode' => 'stage',
Please login to merge, or discard this patch.
tests/Extensions/WorkflowDefinitionExtensionTest.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -15,38 +15,38 @@
 block discarded – undo
15 15
 class WorkflowDefinitionExtensionTest extends FunctionalTest
16 16
 {
17 17
 
18
-    /**
19
-     * @var Boolean If set to TRUE, this will force a test database to be generated
20
-     * in {@link setUp()}. Note that this flag is overruled by the presence of a
21
-     * {@link $fixture_file}, which always forces a database build.
22
-     */
23
-    protected $usesDatabase = true;
24
-
25
-    /**
26
-     * Tests the config option that controls the creation of a default workflow definition
27
-     *
28
-     * @return void
29
-     */
30
-    public function testCreateDefaultWorkflowTest()
31
-    {
32
-        if (!class_exists(WorkflowDefinition::class)) {
33
-            $this->markTestSkipped('This test requires the advancedworkflow module to be installed');
34
-        }
35
-
36
-        DB::quiet();
37
-
38
-        // test disabling the default workflow definition
39
-        Config::modify()->set(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', false);
40
-        $workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class);
41
-        $workflowExtn->requireDefaultRecords();
42
-        $definition = WorkflowDefinition::get()->first();
43
-        $this->assertNull($definition);
44
-
45
-        // test enabling the default workflow definition
46
-        Config::modify()->set(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', true);
47
-        $workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class);
48
-        $workflowExtn->requireDefaultRecords();
49
-        $definition = WorkflowDefinition::get()->first();
50
-        $this->assertNotNull($definition);
51
-    }
18
+	/**
19
+	 * @var Boolean If set to TRUE, this will force a test database to be generated
20
+	 * in {@link setUp()}. Note that this flag is overruled by the presence of a
21
+	 * {@link $fixture_file}, which always forces a database build.
22
+	 */
23
+	protected $usesDatabase = true;
24
+
25
+	/**
26
+	 * Tests the config option that controls the creation of a default workflow definition
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function testCreateDefaultWorkflowTest()
31
+	{
32
+		if (!class_exists(WorkflowDefinition::class)) {
33
+			$this->markTestSkipped('This test requires the advancedworkflow module to be installed');
34
+		}
35
+
36
+		DB::quiet();
37
+
38
+		// test disabling the default workflow definition
39
+		Config::modify()->set(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', false);
40
+		$workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class);
41
+		$workflowExtn->requireDefaultRecords();
42
+		$definition = WorkflowDefinition::get()->first();
43
+		$this->assertNull($definition);
44
+
45
+		// test enabling the default workflow definition
46
+		Config::modify()->set(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', true);
47
+		$workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class);
48
+		$workflowExtn->requireDefaultRecords();
49
+		$definition = WorkflowDefinition::get()->first();
50
+		$this->assertNotNull($definition);
51
+	}
52 52
 }
Please login to merge, or discard this patch.
tests/Tasks/PopulateThemeSampleDataTaskTest.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -10,50 +10,50 @@
 block discarded – undo
10 10
 
11 11
 class PopulateThemeSampleDataTaskTest extends SapphireTest
12 12
 {
13
-    protected $usesDatabase = true;
14
-
15
-    /**
16
-     * Ensure that the "contact" user form is only created once
17
-     */
18
-    public function testOnlyCreateContactFormOnce()
19
-    {
20
-        if (!class_exists(UserDefinedForm::class)) {
21
-            $this->markTestSkipped('This test requires the userforms module to be installed');
22
-        }
23
-
24
-        $createdMessage = 'Created "contact" UserDefinedForm';
25
-
26
-        $task = new PopulateThemeSampleDataTask;
27
-
28
-        // Run the task
29
-        $this->assertContains($createdMessage, $this->bufferedTask($task));
30
-
31
-        // Run a second time
32
-        $this->assertNotContains($createdMessage, $this->bufferedTask($task));
33
-
34
-        // Change the page name
35
-        $form = UserDefinedForm::get()->filter('URLSegment', 'contact')->first();
36
-        $form->URLSegment = 'testing';
37
-        $form->write();
38
-
39
-        // Ensure the old version is still detected in draft, so not recreated
40
-        $this->assertNotContains($createdMessage, $this->bufferedTask($task));
41
-
42
-        // Delete the page, then ensure it's recreated again (DataObject::delete will remove staged versions)
43
-        $form->delete();
44
-        $this->assertContains($createdMessage, $this->bufferedTask($task));
45
-    }
46
-
47
-    /**
48
-     * Run a BuildTask while buffering its output, and return the result
49
-     *
50
-     * @param  BuildTask $task
51
-     * @return string
52
-     */
53
-    protected function bufferedTask(BuildTask $task)
54
-    {
55
-        ob_start();
56
-        $task->run(new HTTPRequest('GET', '/'));
57
-        return ob_get_clean();
58
-    }
13
+	protected $usesDatabase = true;
14
+
15
+	/**
16
+	 * Ensure that the "contact" user form is only created once
17
+	 */
18
+	public function testOnlyCreateContactFormOnce()
19
+	{
20
+		if (!class_exists(UserDefinedForm::class)) {
21
+			$this->markTestSkipped('This test requires the userforms module to be installed');
22
+		}
23
+
24
+		$createdMessage = 'Created "contact" UserDefinedForm';
25
+
26
+		$task = new PopulateThemeSampleDataTask;
27
+
28
+		// Run the task
29
+		$this->assertContains($createdMessage, $this->bufferedTask($task));
30
+
31
+		// Run a second time
32
+		$this->assertNotContains($createdMessage, $this->bufferedTask($task));
33
+
34
+		// Change the page name
35
+		$form = UserDefinedForm::get()->filter('URLSegment', 'contact')->first();
36
+		$form->URLSegment = 'testing';
37
+		$form->write();
38
+
39
+		// Ensure the old version is still detected in draft, so not recreated
40
+		$this->assertNotContains($createdMessage, $this->bufferedTask($task));
41
+
42
+		// Delete the page, then ensure it's recreated again (DataObject::delete will remove staged versions)
43
+		$form->delete();
44
+		$this->assertContains($createdMessage, $this->bufferedTask($task));
45
+	}
46
+
47
+	/**
48
+	 * Run a BuildTask while buffering its output, and return the result
49
+	 *
50
+	 * @param  BuildTask $task
51
+	 * @return string
52
+	 */
53
+	protected function bufferedTask(BuildTask $task)
54
+	{
55
+		ob_start();
56
+		$task->run(new HTTPRequest('GET', '/'));
57
+		return ob_get_clean();
58
+	}
59 59
 }
Please login to merge, or discard this patch.