Passed
Pull Request — master (#93)
by
unknown
02:12
created
src/Model/RelatedPageLink.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -9,24 +9,24 @@
 block discarded – undo
9 9
 
10 10
 class RelatedPageLink extends DataObject
11 11
 {
12
-    private static $table_name = 'BasePage_RelatedPages';
12
+	private static $table_name = 'BasePage_RelatedPages';
13 13
 
14
-    private static $extensions = [
15
-        Versioned::class
16
-    ];
14
+	private static $extensions = [
15
+		Versioned::class
16
+	];
17 17
 
18
-    private static $db = [
19
-        'SortOrder' => DBInt::class
20
-    ];
18
+	private static $db = [
19
+		'SortOrder' => DBInt::class
20
+	];
21 21
 
22
-    // For backwards compatibility these must match a traditional 'many_many' definition.
23
-    // This was BasePage.RelatedPages => BasePage
24
-    // ManyMany relations are normally joined by ${DefiningClass}ID && ${RelatedClass}ID
25
-    // excepting in the case where ${DefiningClass} === ${RelatedClass}
26
-    // Then the 'related class' column changes from ${RelatedClass}ID to "ChildID".
27
-    // {@see SilverStripe\ORM\DataObjectSchema->parseManyManyComponent()}
28
-    private static $has_one = [
29
-        'BasePage' => BasePage::class,
30
-        'Child' => BasePage::class,
31
-    ];
22
+	// For backwards compatibility these must match a traditional 'many_many' definition.
23
+	// This was BasePage.RelatedPages => BasePage
24
+	// ManyMany relations are normally joined by ${DefiningClass}ID && ${RelatedClass}ID
25
+	// excepting in the case where ${DefiningClass} === ${RelatedClass}
26
+	// Then the 'related class' column changes from ${RelatedClass}ID to "ChildID".
27
+	// {@see SilverStripe\ORM\DataObjectSchema->parseManyManyComponent()}
28
+	private static $has_one = [
29
+		'BasePage' => BasePage::class,
30
+		'Child' => BasePage::class,
31
+	];
32 32
 }
Please login to merge, or discard this patch.
src/PageTypes/BasePage.php 1 patch
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -32,155 +32,155 @@
 block discarded – undo
32 32
 
33 33
 class BasePage extends SiteTree
34 34
 {
35
-    private static $icon = 'cwp/cwp:images/icons/sitetree_images/page.png';
36
-
37
-    /**
38
-     * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide"
39
-     *
40
-     * {@inheritDoc}
41
-     */
42
-    private static $hide_ancestor = BasePage::class;
43
-
44
-    private static $api_access = [
45
-        'view' => [
46
-            'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
47
-            'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
48
-        ],
49
-        'edit' => [
50
-            'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
51
-            'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
52
-        ],
53
-    ];
54
-
55
-    private static $table_name = 'BasePage';
56
-
57
-    /**
58
-     * @config
59
-     * @var string
60
-     */
61
-    private static $related_pages_title = 'Related pages';
62
-
63
-    private static $many_many = [
64
-        'Terms' => TaxonomyTerm::class,
65
-        'RelatedPages' => [
66
-            'through' => RelatedPageLink::class,
67
-            'from' => 'BasePage',
68
-            'to' => 'Child',
69
-        ]
70
-    ];
71
-
72
-    private static $belongs_many_many = [
73
-        'SimilarPages' => BasePage::class
74
-    ];
75
-
76
-    /**
77
-     * @var array
78
-     * @config
79
-     */
80
-    private static $many_many_extraFields = [
81
-        'RelatedPages' => [
82
-            'SortOrder' => DBInt::class,
83
-        ],
84
-    ];
85
-
86
-    private static $plural_name = 'Base Pages';
87
-
88
-    /**
89
-     * Get the footer holder.
90
-     */
91
-    public function getFooter()
92
-    {
93
-        return FooterHolder::get_one(FooterHolder::class);
94
-    }
95
-
96
-    public function RelatedPages()
97
-    {
98
-        return $this->getManyManyComponents('RelatedPages')->sort('SortOrder');
99
-    }
100
-
101
-    public function RelatedPagesTitle()
102
-    {
103
-        return $this->config()->get('related_pages_title');
104
-    }
105
-
106
-    public function getCMSFields()
107
-    {
108
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
109
-            // Related Pages
110
-            $components = GridFieldConfig_RelationEditor::create();
111
-            $components->removeComponentsByType(GridFieldAddNewButton::class);
112
-            $components->removeComponentsByType(GridFieldEditButton::class);
113
-            $components->removeComponentsByType(GridFieldFilterHeader::class);
114
-            $components->addComponent(new GridFieldOrderableRows('SortOrder'));
115
-
116
-            /** @var GridFieldDataColumns $dataColumns */
117
-            $dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
118
-            $dataColumns->setDisplayFields([
119
-                'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'),
120
-                'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type')
121
-            ]);
122
-
123
-            $fields->findOrMakeTab(
124
-                'Root.RelatedPages',
125
-                _t(__CLASS__ . '.RelatedPages', 'Related pages')
126
-            );
127
-            $fields->addFieldToTab(
128
-                'Root.RelatedPages',
129
-                GridField::create(
130
-                    'RelatedPages',
131
-                    _t(__CLASS__ . '.RelatedPages', 'Related pages'),
132
-                    $this->RelatedPages(),
133
-                    $components
134
-                )
135
-            );
136
-
137
-            // Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc)
138
-            $hasMany = $this->hasMany();
139
-            $manyMany = $this->manyMany();
140
-            if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) {
141
-                $components = GridFieldConfig_RelationEditor::create();
142
-                $components->removeComponentsByType(GridFieldAddNewButton::class);
143
-                $components->removeComponentsByType(GridFieldEditButton::class);
144
-
145
-                /** @var GridFieldAddExistingAutocompleter $autoCompleter */
146
-                $autoCompleter = $components->getComponentByType(GridFieldAddExistingAutocompleter::class);
147
-                $autoCompleter->setResultsFormat('$Name ($TaxonomyName)');
148
-
149
-                /** @var GridFieldDataColumns $dataColumns */
150
-                $dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
151
-                $dataColumns->setDisplayFields([
152
-                    'Name' => _t(__CLASS__ . '.Term', 'Term'),
153
-                    'TaxonomyName' => _t(__CLASS__ . '.Taxonomy', 'Taxonomy')
154
-                ]);
155
-
156
-                $fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags'));
157
-                $fields->addFieldToTab(
158
-                    'Root.Tags',
159
-                    TreeMultiselectField::create(
160
-                        'Terms',
161
-                        _t(__CLASS__ . '.Terms', 'Terms'),
162
-                        TaxonomyTerm::class
163
-                    )->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms'))
164
-                );
165
-            }
166
-        });
167
-        return parent::getCMSFields();
168
-    }
169
-
170
-    /**
171
-     * Returns the native language name for the selected locale/language, empty string if Fluent is not available
172
-     *
173
-     * @return string
174
-     */
175
-    public function getSelectedLanguage()
176
-    {
177
-        if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) {
178
-            return '';
179
-        }
180
-
181
-        /** @var ArrayData $information */
182
-        $information = $this->LocaleInformation(FluentState::singleton()->getLocale());
183
-
184
-        return $information->LanguageNative;
185
-    }
35
+	private static $icon = 'cwp/cwp:images/icons/sitetree_images/page.png';
36
+
37
+	/**
38
+	 * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide"
39
+	 *
40
+	 * {@inheritDoc}
41
+	 */
42
+	private static $hide_ancestor = BasePage::class;
43
+
44
+	private static $api_access = [
45
+		'view' => [
46
+			'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
47
+			'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
48
+		],
49
+		'edit' => [
50
+			'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
51
+			'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
52
+		],
53
+	];
54
+
55
+	private static $table_name = 'BasePage';
56
+
57
+	/**
58
+	 * @config
59
+	 * @var string
60
+	 */
61
+	private static $related_pages_title = 'Related pages';
62
+
63
+	private static $many_many = [
64
+		'Terms' => TaxonomyTerm::class,
65
+		'RelatedPages' => [
66
+			'through' => RelatedPageLink::class,
67
+			'from' => 'BasePage',
68
+			'to' => 'Child',
69
+		]
70
+	];
71
+
72
+	private static $belongs_many_many = [
73
+		'SimilarPages' => BasePage::class
74
+	];
75
+
76
+	/**
77
+	 * @var array
78
+	 * @config
79
+	 */
80
+	private static $many_many_extraFields = [
81
+		'RelatedPages' => [
82
+			'SortOrder' => DBInt::class,
83
+		],
84
+	];
85
+
86
+	private static $plural_name = 'Base Pages';
87
+
88
+	/**
89
+	 * Get the footer holder.
90
+	 */
91
+	public function getFooter()
92
+	{
93
+		return FooterHolder::get_one(FooterHolder::class);
94
+	}
95
+
96
+	public function RelatedPages()
97
+	{
98
+		return $this->getManyManyComponents('RelatedPages')->sort('SortOrder');
99
+	}
100
+
101
+	public function RelatedPagesTitle()
102
+	{
103
+		return $this->config()->get('related_pages_title');
104
+	}
105
+
106
+	public function getCMSFields()
107
+	{
108
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
109
+			// Related Pages
110
+			$components = GridFieldConfig_RelationEditor::create();
111
+			$components->removeComponentsByType(GridFieldAddNewButton::class);
112
+			$components->removeComponentsByType(GridFieldEditButton::class);
113
+			$components->removeComponentsByType(GridFieldFilterHeader::class);
114
+			$components->addComponent(new GridFieldOrderableRows('SortOrder'));
115
+
116
+			/** @var GridFieldDataColumns $dataColumns */
117
+			$dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
118
+			$dataColumns->setDisplayFields([
119
+				'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'),
120
+				'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type')
121
+			]);
122
+
123
+			$fields->findOrMakeTab(
124
+				'Root.RelatedPages',
125
+				_t(__CLASS__ . '.RelatedPages', 'Related pages')
126
+			);
127
+			$fields->addFieldToTab(
128
+				'Root.RelatedPages',
129
+				GridField::create(
130
+					'RelatedPages',
131
+					_t(__CLASS__ . '.RelatedPages', 'Related pages'),
132
+					$this->RelatedPages(),
133
+					$components
134
+				)
135
+			);
136
+
137
+			// Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc)
138
+			$hasMany = $this->hasMany();
139
+			$manyMany = $this->manyMany();
140
+			if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) {
141
+				$components = GridFieldConfig_RelationEditor::create();
142
+				$components->removeComponentsByType(GridFieldAddNewButton::class);
143
+				$components->removeComponentsByType(GridFieldEditButton::class);
144
+
145
+				/** @var GridFieldAddExistingAutocompleter $autoCompleter */
146
+				$autoCompleter = $components->getComponentByType(GridFieldAddExistingAutocompleter::class);
147
+				$autoCompleter->setResultsFormat('$Name ($TaxonomyName)');
148
+
149
+				/** @var GridFieldDataColumns $dataColumns */
150
+				$dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
151
+				$dataColumns->setDisplayFields([
152
+					'Name' => _t(__CLASS__ . '.Term', 'Term'),
153
+					'TaxonomyName' => _t(__CLASS__ . '.Taxonomy', 'Taxonomy')
154
+				]);
155
+
156
+				$fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags'));
157
+				$fields->addFieldToTab(
158
+					'Root.Tags',
159
+					TreeMultiselectField::create(
160
+						'Terms',
161
+						_t(__CLASS__ . '.Terms', 'Terms'),
162
+						TaxonomyTerm::class
163
+					)->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms'))
164
+				);
165
+			}
166
+		});
167
+		return parent::getCMSFields();
168
+	}
169
+
170
+	/**
171
+	 * Returns the native language name for the selected locale/language, empty string if Fluent is not available
172
+	 *
173
+	 * @return string
174
+	 */
175
+	public function getSelectedLanguage()
176
+	{
177
+		if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) {
178
+			return '';
179
+		}
180
+
181
+		/** @var ArrayData $information */
182
+		$information = $this->LocaleInformation(FluentState::singleton()->getLocale());
183
+
184
+		return $information->LanguageNative;
185
+	}
186 186
 }
Please login to merge, or discard this patch.