Completed
Push — master ( 1d731f...7fdc08 )
by
unknown
10s
created
src/PageTypes/BasePage.php 1 patch
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -26,143 +26,143 @@
 block discarded – undo
26 26
 
27 27
 class BasePage extends SiteTree
28 28
 {
29
-    private static $icon = 'cwp/cwp:images/icons/sitetree_images/page.png';
30
-
31
-    /**
32
-     * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide"
33
-     *
34
-     * {@inheritDoc}
35
-     */
36
-    private static $hide_ancestor = BasePage::class;
37
-
38
-    private static $api_access = [
39
-        'view' => [
40
-            'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
41
-            'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
42
-        ],
43
-        'edit' => [
44
-            'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
45
-            'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
46
-        ],
47
-    ];
48
-
49
-    private static $table_name = 'BasePage';
50
-
51
-    /**
52
-     * @config
53
-     * @var string
54
-     */
55
-    private static $related_pages_title = 'Related pages';
56
-
57
-    private static $many_many = [
58
-        'Terms' => TaxonomyTerm::class,
59
-        'RelatedPages' => BasePage::class,
60
-    ];
61
-
62
-    private static $many_many_extraFields = [
63
-        'RelatedPages' => [
64
-            'SortOrder' => 'Int',
65
-        ],
66
-    ];
67
-
68
-    private static $plural_name = 'Base Pages';
69
-
70
-    /**
71
-     * Get the footer holder.
72
-     */
73
-    public function getFooter()
74
-    {
75
-        return FooterHolder::get_one(FooterHolder::class);
76
-    }
77
-
78
-    public function RelatedPages()
79
-    {
80
-        return $this->getManyManyComponents('RelatedPages')->sort('SortOrder');
81
-    }
82
-
83
-    public function RelatedPagesTitle()
84
-    {
85
-        return $this->config()->get('related_pages_title');
86
-    }
87
-
88
-    public function getCMSFields()
89
-    {
90
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
91
-            // Related Pages
92
-            $components = GridFieldConfig_RelationEditor::create();
93
-            $components->removeComponentsByType(GridFieldAddNewButton::class);
94
-            $components->removeComponentsByType(GridFieldEditButton::class);
95
-            $components->removeComponentsByType(GridFieldFilterHeader::class);
96
-            $components->addComponent(new GridFieldSortableRows('SortOrder'));
97
-
98
-            /** @var GridFieldDataColumns $dataColumns */
99
-            $dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
100
-            $dataColumns->setDisplayFields([
101
-                'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'),
102
-                'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type')
103
-            ]);
104
-
105
-            $fields->findOrMakeTab(
106
-                'Root.RelatedPages',
107
-                _t(__CLASS__ . '.RelatedPages', 'Related pages')
108
-            );
109
-            $fields->addFieldToTab(
110
-                'Root.RelatedPages',
111
-                GridField::create(
112
-                    'RelatedPages',
113
-                    _t(__CLASS__ . '.RelatedPages', 'Related pages'),
114
-                    $this->RelatedPages(),
115
-                    $components
116
-                )
117
-            );
118
-
119
-            // Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc)
120
-            $hasMany = $this->hasMany();
121
-            $manyMany = $this->manyMany();
122
-            if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) {
123
-                $components = GridFieldConfig_RelationEditor::create();
124
-                $components->removeComponentsByType(GridFieldAddNewButton::class);
125
-                $components->removeComponentsByType(GridFieldEditButton::class);
126
-
127
-                /** @var GridFieldAddExistingAutocompleter $autoCompleter */
128
-                $autoCompleter = $components->getComponentByType(GridFieldAddExistingAutocompleter::class);
129
-                $autoCompleter->setResultsFormat('$Name ($TaxonomyName)');
130
-
131
-                /** @var GridFieldDataColumns $dataColumns */
132
-                $dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
133
-                $dataColumns->setDisplayFields([
134
-                    'Name' => _t(__CLASS__ . '.Term', 'Term'),
135
-                    'TaxonomyName' => _t(__CLASS__ . '.Taxonomy', 'Taxonomy')
136
-                ]);
137
-
138
-                $fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags'));
139
-                $fields->addFieldToTab(
140
-                    'Root.Tags',
141
-                    TreeMultiselectField::create(
142
-                        'Terms',
143
-                        _t(__CLASS__ . '.Terms', 'Terms'),
144
-                        TaxonomyTerm::class
145
-                    )->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms'))
146
-                );
147
-            }
148
-        });
149
-        return parent::getCMSFields();
150
-    }
151
-
152
-    /**
153
-     * Returns the native language name for the selected locale/language, empty string if Fluent is not available
154
-     *
155
-     * @return string
156
-     */
157
-    public function getSelectedLanguage()
158
-    {
159
-        if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) {
160
-            return '';
161
-        }
162
-
163
-        /** @var ArrayData $information */
164
-        $information = $this->LocaleInformation(FluentState::singleton()->getLocale());
165
-
166
-        return $information->LanguageNative;
167
-    }
29
+	private static $icon = 'cwp/cwp:images/icons/sitetree_images/page.png';
30
+
31
+	/**
32
+	 * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide"
33
+	 *
34
+	 * {@inheritDoc}
35
+	 */
36
+	private static $hide_ancestor = BasePage::class;
37
+
38
+	private static $api_access = [
39
+		'view' => [
40
+			'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
41
+			'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
42
+		],
43
+		'edit' => [
44
+			'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
45
+			'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
46
+		],
47
+	];
48
+
49
+	private static $table_name = 'BasePage';
50
+
51
+	/**
52
+	 * @config
53
+	 * @var string
54
+	 */
55
+	private static $related_pages_title = 'Related pages';
56
+
57
+	private static $many_many = [
58
+		'Terms' => TaxonomyTerm::class,
59
+		'RelatedPages' => BasePage::class,
60
+	];
61
+
62
+	private static $many_many_extraFields = [
63
+		'RelatedPages' => [
64
+			'SortOrder' => 'Int',
65
+		],
66
+	];
67
+
68
+	private static $plural_name = 'Base Pages';
69
+
70
+	/**
71
+	 * Get the footer holder.
72
+	 */
73
+	public function getFooter()
74
+	{
75
+		return FooterHolder::get_one(FooterHolder::class);
76
+	}
77
+
78
+	public function RelatedPages()
79
+	{
80
+		return $this->getManyManyComponents('RelatedPages')->sort('SortOrder');
81
+	}
82
+
83
+	public function RelatedPagesTitle()
84
+	{
85
+		return $this->config()->get('related_pages_title');
86
+	}
87
+
88
+	public function getCMSFields()
89
+	{
90
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
91
+			// Related Pages
92
+			$components = GridFieldConfig_RelationEditor::create();
93
+			$components->removeComponentsByType(GridFieldAddNewButton::class);
94
+			$components->removeComponentsByType(GridFieldEditButton::class);
95
+			$components->removeComponentsByType(GridFieldFilterHeader::class);
96
+			$components->addComponent(new GridFieldSortableRows('SortOrder'));
97
+
98
+			/** @var GridFieldDataColumns $dataColumns */
99
+			$dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
100
+			$dataColumns->setDisplayFields([
101
+				'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'),
102
+				'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type')
103
+			]);
104
+
105
+			$fields->findOrMakeTab(
106
+				'Root.RelatedPages',
107
+				_t(__CLASS__ . '.RelatedPages', 'Related pages')
108
+			);
109
+			$fields->addFieldToTab(
110
+				'Root.RelatedPages',
111
+				GridField::create(
112
+					'RelatedPages',
113
+					_t(__CLASS__ . '.RelatedPages', 'Related pages'),
114
+					$this->RelatedPages(),
115
+					$components
116
+				)
117
+			);
118
+
119
+			// Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc)
120
+			$hasMany = $this->hasMany();
121
+			$manyMany = $this->manyMany();
122
+			if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) {
123
+				$components = GridFieldConfig_RelationEditor::create();
124
+				$components->removeComponentsByType(GridFieldAddNewButton::class);
125
+				$components->removeComponentsByType(GridFieldEditButton::class);
126
+
127
+				/** @var GridFieldAddExistingAutocompleter $autoCompleter */
128
+				$autoCompleter = $components->getComponentByType(GridFieldAddExistingAutocompleter::class);
129
+				$autoCompleter->setResultsFormat('$Name ($TaxonomyName)');
130
+
131
+				/** @var GridFieldDataColumns $dataColumns */
132
+				$dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
133
+				$dataColumns->setDisplayFields([
134
+					'Name' => _t(__CLASS__ . '.Term', 'Term'),
135
+					'TaxonomyName' => _t(__CLASS__ . '.Taxonomy', 'Taxonomy')
136
+				]);
137
+
138
+				$fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags'));
139
+				$fields->addFieldToTab(
140
+					'Root.Tags',
141
+					TreeMultiselectField::create(
142
+						'Terms',
143
+						_t(__CLASS__ . '.Terms', 'Terms'),
144
+						TaxonomyTerm::class
145
+					)->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms'))
146
+				);
147
+			}
148
+		});
149
+		return parent::getCMSFields();
150
+	}
151
+
152
+	/**
153
+	 * Returns the native language name for the selected locale/language, empty string if Fluent is not available
154
+	 *
155
+	 * @return string
156
+	 */
157
+	public function getSelectedLanguage()
158
+	{
159
+		if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) {
160
+			return '';
161
+		}
162
+
163
+		/** @var ArrayData $information */
164
+		$information = $this->LocaleInformation(FluentState::singleton()->getLocale());
165
+
166
+		return $information->LanguageNative;
167
+	}
168 168
 }
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.