Completed
Push — master ( 7e40c5...c119bf )
by Robbie
18s queued 10s
created
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.