@@ -9,59 +9,59 @@ |
||
9 | 9 | |
10 | 10 | class NewsPage extends DatedUpdatePage |
11 | 11 | { |
12 | - private static $description = 'Describes an item of news'; |
|
12 | + private static $description = 'Describes an item of news'; |
|
13 | 13 | |
14 | - private static $default_parent = 'NewsHolderPage'; |
|
14 | + private static $default_parent = 'NewsHolderPage'; |
|
15 | 15 | |
16 | - private static $can_be_root = false; |
|
16 | + private static $can_be_root = false; |
|
17 | 17 | |
18 | - private static $icon = 'cwp/cwp:images/icons/sitetree_images/news.png'; |
|
18 | + private static $icon = 'cwp/cwp:images/icons/sitetree_images/news.png'; |
|
19 | 19 | |
20 | - private static $singular_name = 'News Page'; |
|
20 | + private static $singular_name = 'News Page'; |
|
21 | 21 | |
22 | - private static $plural_name = 'News Pages'; |
|
22 | + private static $plural_name = 'News Pages'; |
|
23 | 23 | |
24 | - private static $db = [ |
|
25 | - 'Author' => 'Varchar(255)', |
|
26 | - ]; |
|
24 | + private static $db = [ |
|
25 | + 'Author' => 'Varchar(255)', |
|
26 | + ]; |
|
27 | 27 | |
28 | - private static $has_one = [ |
|
29 | - 'FeaturedImage' => Image::class, |
|
30 | - ]; |
|
28 | + private static $has_one = [ |
|
29 | + 'FeaturedImage' => Image::class, |
|
30 | + ]; |
|
31 | 31 | |
32 | - private static $owns = [ |
|
33 | - 'FeaturedImage', |
|
34 | - ]; |
|
32 | + private static $owns = [ |
|
33 | + 'FeaturedImage', |
|
34 | + ]; |
|
35 | 35 | |
36 | - private static $table_name = 'NewsPage'; |
|
36 | + private static $table_name = 'NewsPage'; |
|
37 | 37 | |
38 | - public function fieldLabels($includerelations = true) |
|
39 | - { |
|
40 | - $labels = parent::fieldLabels($includerelations); |
|
41 | - $labels['Author'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.AuthorFieldLabel', 'Author'); |
|
42 | - $labels['FeaturedImageID'] = _t( |
|
43 | - 'CWP\\CWP\\PageTypes\\DateUpdatePage.FeaturedImageFieldLabel', |
|
44 | - 'Featured Image' |
|
45 | - ); |
|
38 | + public function fieldLabels($includerelations = true) |
|
39 | + { |
|
40 | + $labels = parent::fieldLabels($includerelations); |
|
41 | + $labels['Author'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.AuthorFieldLabel', 'Author'); |
|
42 | + $labels['FeaturedImageID'] = _t( |
|
43 | + 'CWP\\CWP\\PageTypes\\DateUpdatePage.FeaturedImageFieldLabel', |
|
44 | + 'Featured Image' |
|
45 | + ); |
|
46 | 46 | |
47 | - return $labels; |
|
48 | - } |
|
47 | + return $labels; |
|
48 | + } |
|
49 | 49 | |
50 | - public function getCMSFields() |
|
51 | - { |
|
52 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
53 | - $fields->addFieldToTab( |
|
54 | - 'Root.Main', |
|
55 | - TextField::create('Author', $this->fieldLabel('Author')), |
|
56 | - 'Abstract' |
|
57 | - ); |
|
50 | + public function getCMSFields() |
|
51 | + { |
|
52 | + $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
53 | + $fields->addFieldToTab( |
|
54 | + 'Root.Main', |
|
55 | + TextField::create('Author', $this->fieldLabel('Author')), |
|
56 | + 'Abstract' |
|
57 | + ); |
|
58 | 58 | |
59 | - $fields->addFieldToTab( |
|
60 | - 'Root.Main', |
|
61 | - UploadField::create('FeaturedImage', $this->fieldLabel('FeaturedImageID')), |
|
62 | - 'Abstract' |
|
63 | - ); |
|
64 | - }); |
|
65 | - return parent::getCMSFields(); |
|
66 | - } |
|
59 | + $fields->addFieldToTab( |
|
60 | + 'Root.Main', |
|
61 | + UploadField::create('FeaturedImage', $this->fieldLabel('FeaturedImageID')), |
|
62 | + 'Abstract' |
|
63 | + ); |
|
64 | + }); |
|
65 | + return parent::getCMSFields(); |
|
66 | + } |
|
67 | 67 | } |
@@ -11,42 +11,42 @@ |
||
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 | } |
@@ -14,20 +14,20 @@ |
||
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 | } |