Passed
Push — master ( a57a6a...d09a18 )
by
unknown
01:58
created
tests/Report/CwpStatsReportTest.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -11,42 +11,42 @@
 block discarded – undo
11 11
 
12 12
 class CwpStatsReportTest extends SapphireTest
13 13
 {
14
-    protected static $fixture_file = 'CwpStatsReportTest.yml';
15
-
16
-    protected function setUp()
17
-    {
18
-        Config::modify()->set(SiteTree::class, 'create_default_pages', false);
19
-
20
-        parent::setUp();
21
-    }
22
-
23
-    public function testCount()
24
-    {
25
-        // Publish all pages apart from page3.
26
-        $this->objFromFixture(Page::class, 'page1')->publishRecursive();
27
-        $this->objFromFixture(Page::class, 'page2')->publishRecursive();
28
-        $this->objFromFixture(Page::class, 'page3')->publishRecursive();
29
-
30
-        // Add page5s to a subsite, if the module is installed.
31
-        $page5s = $this->objFromFixture(Page::class, 'page5s');
32
-        if (class_exists(Subsite::class)) {
33
-            $subsite = Subsite::create();
34
-            $subsite->Title = 'subsite';
35
-            $subsite->write();
36
-
37
-            $page5s->SubsiteID = $subsite->ID;
38
-            $page5s->write();
39
-        }
40
-        $page5s->publishRecursive();
41
-
42
-        $report = CwpStatsReport::create();
43
-        $records = $report->sourceRecords([])->toArray();
44
-        $i = 0;
45
-        $this->assertEquals(4, $records[$i++]['Count'], 'Four pages in total, across locales, subsites, live only.');
46
-        if (class_exists(Subsite::class)) {
47
-            $this->assertEquals(3, $records[$i++]['Count'], 'Three pages in the main site, if subsites installed.');
48
-            $this->assertEquals(1, $records[$i++]['Count'], 'One page in the subsite, if subsites installed');
49
-        }
50
-        $this->assertEquals(1, $records[$i++]['Count'], 'One file in total.');
51
-    }
14
+	protected static $fixture_file = 'CwpStatsReportTest.yml';
15
+
16
+	protected function setUp()
17
+	{
18
+		Config::modify()->set(SiteTree::class, 'create_default_pages', false);
19
+
20
+		parent::setUp();
21
+	}
22
+
23
+	public function testCount()
24
+	{
25
+		// Publish all pages apart from page3.
26
+		$this->objFromFixture(Page::class, 'page1')->publishRecursive();
27
+		$this->objFromFixture(Page::class, 'page2')->publishRecursive();
28
+		$this->objFromFixture(Page::class, 'page3')->publishRecursive();
29
+
30
+		// Add page5s to a subsite, if the module is installed.
31
+		$page5s = $this->objFromFixture(Page::class, 'page5s');
32
+		if (class_exists(Subsite::class)) {
33
+			$subsite = Subsite::create();
34
+			$subsite->Title = 'subsite';
35
+			$subsite->write();
36
+
37
+			$page5s->SubsiteID = $subsite->ID;
38
+			$page5s->write();
39
+		}
40
+		$page5s->publishRecursive();
41
+
42
+		$report = CwpStatsReport::create();
43
+		$records = $report->sourceRecords([])->toArray();
44
+		$i = 0;
45
+		$this->assertEquals(4, $records[$i++]['Count'], 'Four pages in total, across locales, subsites, live only.');
46
+		if (class_exists(Subsite::class)) {
47
+			$this->assertEquals(3, $records[$i++]['Count'], 'Three pages in the main site, if subsites installed.');
48
+			$this->assertEquals(1, $records[$i++]['Count'], 'One page in the subsite, if subsites installed');
49
+		}
50
+		$this->assertEquals(1, $records[$i++]['Count'], 'One file in total.');
51
+	}
52 52
 }
Please login to merge, or discard this patch.
src/Extensions/CwpCommentingExtension.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -14,20 +14,20 @@
 block discarded – undo
14 14
  */
15 15
 class CwpCommentingExtension extends Extension
16 16
 {
17
-    public function alterCommentForm(Form $form)
18
-    {
19
-        $fields = $form->Fields();
17
+	public function alterCommentForm(Form $form)
18
+	{
19
+		$fields = $form->Fields();
20 20
 
21
-        if ($emailField = $fields->dataFieldByName('Email')) {
22
-            $emailField
23
-                ->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', 'Email'))
24
-                ->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.'));
25
-        }
21
+		if ($emailField = $fields->dataFieldByName('Email')) {
22
+			$emailField
23
+				->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', 'Email'))
24
+				->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.'));
25
+		}
26 26
 
27
-        if ($urlField = $fields->dataFieldByName('URL')) {
28
-            $urlField
29
-                ->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)'))
30
-                ->setAttribute('placeholder', 'http://');
31
-        }
32
-    }
27
+		if ($urlField = $fields->dataFieldByName('URL')) {
28
+			$urlField
29
+				->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)'))
30
+				->setAttribute('placeholder', 'http://');
31
+		}
32
+	}
33 33
 }
Please login to merge, or discard this patch.
src/PageTypes/BasePage.php 1 patch
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -31,158 +31,158 @@
 block discarded – undo
31 31
 
32 32
 class BasePage extends SiteTree
33 33
 {
34
-    private static $icon = 'cwp/cwp:images/icons/sitetree_images/page.png';
35
-
36
-    /**
37
-     * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide"
38
-     *
39
-     * {@inheritDoc}
40
-     */
41
-    private static $hide_ancestor = BasePage::class;
42
-
43
-    private static $api_access = [
44
-        'view' => [
45
-            'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
46
-            'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
47
-        ],
48
-        'edit' => [
49
-            'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
50
-            'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
51
-        ],
52
-    ];
53
-
54
-    private static $table_name = 'BasePage';
55
-
56
-    /**
57
-     * @config
58
-     * @var string
59
-     */
60
-    private static $related_pages_title = 'Related pages';
61
-
62
-    private static $many_many = [
63
-        'Terms' => TaxonomyTerm::class,
64
-        'RelatedPagesThrough' => [
65
-            'through' => RelatedPageLink::class,
66
-            'from' => 'BasePage',
67
-            'to' => 'Child',
68
-        ]
69
-    ];
70
-
71
-    private static $belongs_many_many = [
72
-        'SimilarPages' => BasePage::class
73
-    ];
74
-
75
-    /**
76
-     * @var array
77
-     * @config
78
-     */
79
-    private static $many_many_extraFields = [
80
-        'RelatedPages' => [
81
-            'SortOrder' => 'Int',
82
-        ],
83
-    ];
84
-
85
-    private static $plural_name = 'Base Pages';
86
-
87
-    /**
88
-     * Get the footer holder.
89
-     */
90
-    public function getFooter()
91
-    {
92
-        return FooterHolder::get_one(FooterHolder::class);
93
-    }
94
-
95
-    /**
96
-     * @deprecated 2.2.0:3.0.0 Please use RelatedPagesThrough() instead
97
-     */
98
-    public function RelatedPages()
99
-    {
100
-        return $this->getManyManyComponents('RelatedPagesThrough');
101
-    }
102
-
103
-    public function RelatedPagesTitle()
104
-    {
105
-        return $this->config()->get('related_pages_title');
106
-    }
107
-
108
-    public function getCMSFields()
109
-    {
110
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
111
-            // Related Pages
112
-            $components = GridFieldConfig_RelationEditor::create();
113
-            $components->removeComponentsByType(GridFieldAddNewButton::class);
114
-            $components->removeComponentsByType(GridFieldEditButton::class);
115
-            $components->removeComponentsByType(GridFieldFilterHeader::class);
116
-            $components->addComponent(new GridFieldOrderableRows('SortOrder'));
117
-
118
-            /** @var GridFieldDataColumns $dataColumns */
119
-            $dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
120
-            $dataColumns->setDisplayFields([
121
-                'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'),
122
-                'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type')
123
-            ]);
124
-
125
-            $fields->findOrMakeTab(
126
-                'Root.RelatedPages',
127
-                _t(__CLASS__ . '.RelatedPages', 'Related pages')
128
-            );
129
-            $fields->addFieldToTab(
130
-                'Root.RelatedPages',
131
-                GridField::create(
132
-                    'RelatedPages',
133
-                    _t(__CLASS__ . '.RelatedPages', 'Related pages'),
134
-                    $this->RelatedPagesThrough(),
135
-                    $components
136
-                )
137
-            );
138
-
139
-            // Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc)
140
-            $hasMany = $this->hasMany();
141
-            $manyMany = $this->manyMany();
142
-            if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) {
143
-                $components = GridFieldConfig_RelationEditor::create();
144
-                $components->removeComponentsByType(GridFieldAddNewButton::class);
145
-                $components->removeComponentsByType(GridFieldEditButton::class);
146
-
147
-                /** @var GridFieldAddExistingAutocompleter $autoCompleter */
148
-                $autoCompleter = $components->getComponentByType(GridFieldAddExistingAutocompleter::class);
149
-                $autoCompleter->setResultsFormat('$Name ($TaxonomyName)');
150
-
151
-                /** @var GridFieldDataColumns $dataColumns */
152
-                $dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
153
-                $dataColumns->setDisplayFields([
154
-                    'Name' => _t(__CLASS__ . '.Term', 'Term'),
155
-                    'TaxonomyName' => _t(__CLASS__ . '.Taxonomy', 'Taxonomy')
156
-                ]);
157
-
158
-                $fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags'));
159
-                $fields->addFieldToTab(
160
-                    'Root.Tags',
161
-                    TreeMultiselectField::create(
162
-                        'Terms',
163
-                        _t(__CLASS__ . '.Terms', 'Terms'),
164
-                        TaxonomyTerm::class
165
-                    )->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms'))
166
-                );
167
-            }
168
-        });
169
-        return parent::getCMSFields();
170
-    }
171
-
172
-    /**
173
-     * Returns the native language name for the selected locale/language, empty string if Fluent is not available
174
-     *
175
-     * @return string
176
-     */
177
-    public function getSelectedLanguage()
178
-    {
179
-        if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) {
180
-            return '';
181
-        }
182
-
183
-        /** @var ArrayData $information */
184
-        $information = $this->LocaleInformation(FluentState::singleton()->getLocale());
185
-
186
-        return $information->LanguageNative;
187
-    }
34
+	private static $icon = 'cwp/cwp:images/icons/sitetree_images/page.png';
35
+
36
+	/**
37
+	 * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide"
38
+	 *
39
+	 * {@inheritDoc}
40
+	 */
41
+	private static $hide_ancestor = BasePage::class;
42
+
43
+	private static $api_access = [
44
+		'view' => [
45
+			'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
46
+			'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
47
+		],
48
+		'edit' => [
49
+			'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
50
+			'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
51
+		],
52
+	];
53
+
54
+	private static $table_name = 'BasePage';
55
+
56
+	/**
57
+	 * @config
58
+	 * @var string
59
+	 */
60
+	private static $related_pages_title = 'Related pages';
61
+
62
+	private static $many_many = [
63
+		'Terms' => TaxonomyTerm::class,
64
+		'RelatedPagesThrough' => [
65
+			'through' => RelatedPageLink::class,
66
+			'from' => 'BasePage',
67
+			'to' => 'Child',
68
+		]
69
+	];
70
+
71
+	private static $belongs_many_many = [
72
+		'SimilarPages' => BasePage::class
73
+	];
74
+
75
+	/**
76
+	 * @var array
77
+	 * @config
78
+	 */
79
+	private static $many_many_extraFields = [
80
+		'RelatedPages' => [
81
+			'SortOrder' => 'Int',
82
+		],
83
+	];
84
+
85
+	private static $plural_name = 'Base Pages';
86
+
87
+	/**
88
+	 * Get the footer holder.
89
+	 */
90
+	public function getFooter()
91
+	{
92
+		return FooterHolder::get_one(FooterHolder::class);
93
+	}
94
+
95
+	/**
96
+	 * @deprecated 2.2.0:3.0.0 Please use RelatedPagesThrough() instead
97
+	 */
98
+	public function RelatedPages()
99
+	{
100
+		return $this->getManyManyComponents('RelatedPagesThrough');
101
+	}
102
+
103
+	public function RelatedPagesTitle()
104
+	{
105
+		return $this->config()->get('related_pages_title');
106
+	}
107
+
108
+	public function getCMSFields()
109
+	{
110
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
111
+			// Related Pages
112
+			$components = GridFieldConfig_RelationEditor::create();
113
+			$components->removeComponentsByType(GridFieldAddNewButton::class);
114
+			$components->removeComponentsByType(GridFieldEditButton::class);
115
+			$components->removeComponentsByType(GridFieldFilterHeader::class);
116
+			$components->addComponent(new GridFieldOrderableRows('SortOrder'));
117
+
118
+			/** @var GridFieldDataColumns $dataColumns */
119
+			$dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
120
+			$dataColumns->setDisplayFields([
121
+				'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'),
122
+				'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type')
123
+			]);
124
+
125
+			$fields->findOrMakeTab(
126
+				'Root.RelatedPages',
127
+				_t(__CLASS__ . '.RelatedPages', 'Related pages')
128
+			);
129
+			$fields->addFieldToTab(
130
+				'Root.RelatedPages',
131
+				GridField::create(
132
+					'RelatedPages',
133
+					_t(__CLASS__ . '.RelatedPages', 'Related pages'),
134
+					$this->RelatedPagesThrough(),
135
+					$components
136
+				)
137
+			);
138
+
139
+			// Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc)
140
+			$hasMany = $this->hasMany();
141
+			$manyMany = $this->manyMany();
142
+			if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) {
143
+				$components = GridFieldConfig_RelationEditor::create();
144
+				$components->removeComponentsByType(GridFieldAddNewButton::class);
145
+				$components->removeComponentsByType(GridFieldEditButton::class);
146
+
147
+				/** @var GridFieldAddExistingAutocompleter $autoCompleter */
148
+				$autoCompleter = $components->getComponentByType(GridFieldAddExistingAutocompleter::class);
149
+				$autoCompleter->setResultsFormat('$Name ($TaxonomyName)');
150
+
151
+				/** @var GridFieldDataColumns $dataColumns */
152
+				$dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
153
+				$dataColumns->setDisplayFields([
154
+					'Name' => _t(__CLASS__ . '.Term', 'Term'),
155
+					'TaxonomyName' => _t(__CLASS__ . '.Taxonomy', 'Taxonomy')
156
+				]);
157
+
158
+				$fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags'));
159
+				$fields->addFieldToTab(
160
+					'Root.Tags',
161
+					TreeMultiselectField::create(
162
+						'Terms',
163
+						_t(__CLASS__ . '.Terms', 'Terms'),
164
+						TaxonomyTerm::class
165
+					)->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms'))
166
+				);
167
+			}
168
+		});
169
+		return parent::getCMSFields();
170
+	}
171
+
172
+	/**
173
+	 * Returns the native language name for the selected locale/language, empty string if Fluent is not available
174
+	 *
175
+	 * @return string
176
+	 */
177
+	public function getSelectedLanguage()
178
+	{
179
+		if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) {
180
+			return '';
181
+		}
182
+
183
+		/** @var ArrayData $information */
184
+		$information = $this->LocaleInformation(FluentState::singleton()->getLocale());
185
+
186
+		return $information->LanguageNative;
187
+	}
188 188
 }
Please login to merge, or discard this patch.
src/Model/RelatedPageLink.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -8,30 +8,30 @@
 block discarded – undo
8 8
 
9 9
 class RelatedPageLink extends DataObject
10 10
 {
11
-    private static $table_name = 'BasePage_RelatedPages';
11
+	private static $table_name = 'BasePage_RelatedPages';
12 12
 
13
-    private static $extensions = [
14
-        Versioned::class,
15
-    ];
13
+	private static $extensions = [
14
+		Versioned::class,
15
+	];
16 16
 
17
-    private static $db = [
18
-        'SortOrder' => 'Int',
19
-    ];
17
+	private static $db = [
18
+		'SortOrder' => 'Int',
19
+	];
20 20
 
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
-     *
28
-     * {@see SilverStripe\ORM\DataObjectSchema->parseManyManyComponent()}
29
-     *
30
-     * @var array
31
-     * @config
32
-     */
33
-    private static $has_one = [
34
-        'BasePage' => BasePage::class,
35
-        'Child' => BasePage::class,
36
-    ];
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
+	 *
28
+	 * {@see SilverStripe\ORM\DataObjectSchema->parseManyManyComponent()}
29
+	 *
30
+	 * @var array
31
+	 * @config
32
+	 */
33
+	private static $has_one = [
34
+		'BasePage' => BasePage::class,
35
+		'Child' => BasePage::class,
36
+	];
37 37
 }
Please login to merge, or discard this patch.