@@ -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 | } |
@@ -8,30 +8,30 @@ |
||
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 | } |
@@ -12,58 +12,58 @@ |
||
12 | 12 | */ |
13 | 13 | class CustomSiteConfig extends DataExtension |
14 | 14 | { |
15 | - private static $db = array( |
|
16 | - 'GACode' => 'Varchar(16)', |
|
17 | - 'FacebookURL' => 'Varchar(256)', // multitude of ways to link to Facebook accounts, best to leave it open. |
|
18 | - 'TwitterUsername' => 'Varchar(16)', // max length of Twitter username 15 |
|
19 | - ); |
|
15 | + private static $db = array( |
|
16 | + 'GACode' => 'Varchar(16)', |
|
17 | + 'FacebookURL' => 'Varchar(256)', // multitude of ways to link to Facebook accounts, best to leave it open. |
|
18 | + 'TwitterUsername' => 'Varchar(16)', // max length of Twitter username 15 |
|
19 | + ); |
|
20 | 20 | |
21 | - public function updateCMSFields(FieldList $fields) |
|
22 | - { |
|
23 | - $fields->addFieldToTab( |
|
24 | - 'Root.Main', |
|
25 | - $gaCode = TextField::create( |
|
26 | - 'GACode', |
|
27 | - _t(__CLASS__ . '.GaField', 'Google Analytics account') |
|
28 | - ) |
|
29 | - ); |
|
21 | + public function updateCMSFields(FieldList $fields) |
|
22 | + { |
|
23 | + $fields->addFieldToTab( |
|
24 | + 'Root.Main', |
|
25 | + $gaCode = TextField::create( |
|
26 | + 'GACode', |
|
27 | + _t(__CLASS__ . '.GaField', 'Google Analytics account') |
|
28 | + ) |
|
29 | + ); |
|
30 | 30 | |
31 | - $gaCode->setDescription( |
|
32 | - DBField::create_field('HTMLFragment', _t( |
|
33 | - __CLASS__ . '.GaFieldDesc', |
|
34 | - 'Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)' |
|
35 | - )) |
|
36 | - ); |
|
31 | + $gaCode->setDescription( |
|
32 | + DBField::create_field('HTMLFragment', _t( |
|
33 | + __CLASS__ . '.GaFieldDesc', |
|
34 | + 'Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)' |
|
35 | + )) |
|
36 | + ); |
|
37 | 37 | |
38 | - $fields->findOrMakeTab('Root.SocialMedia', _t(__CLASS__ . '.SocialMediaTab', 'Social Media')); |
|
38 | + $fields->findOrMakeTab('Root.SocialMedia', _t(__CLASS__ . '.SocialMediaTab', 'Social Media')); |
|
39 | 39 | |
40 | - $fields->addFieldToTab( |
|
41 | - 'Root.SocialMedia', |
|
42 | - $facebookURL = TextField::create( |
|
43 | - 'FacebookURL', |
|
44 | - _t(__CLASS__ . '.FbField', 'Facebook UID or username') |
|
45 | - ) |
|
46 | - ); |
|
47 | - $facebookURL->setDescription( |
|
48 | - DBField::create_field('HTMLFragment', _t( |
|
49 | - __CLASS__ . '.FbFieldDesc', |
|
50 | - 'Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/' |
|
51 | - . '<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)' |
|
52 | - )) |
|
53 | - ); |
|
40 | + $fields->addFieldToTab( |
|
41 | + 'Root.SocialMedia', |
|
42 | + $facebookURL = TextField::create( |
|
43 | + 'FacebookURL', |
|
44 | + _t(__CLASS__ . '.FbField', 'Facebook UID or username') |
|
45 | + ) |
|
46 | + ); |
|
47 | + $facebookURL->setDescription( |
|
48 | + DBField::create_field('HTMLFragment', _t( |
|
49 | + __CLASS__ . '.FbFieldDesc', |
|
50 | + 'Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/' |
|
51 | + . '<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)' |
|
52 | + )) |
|
53 | + ); |
|
54 | 54 | |
55 | - $fields->addFieldToTab( |
|
56 | - 'Root.SocialMedia', |
|
57 | - $twitterUsername = TextField::create( |
|
58 | - 'TwitterUsername', |
|
59 | - _t(__CLASS__ . '.TwitterField', 'Twitter username') |
|
60 | - ) |
|
61 | - ); |
|
62 | - $twitterUsername->setDescription( |
|
63 | - DBField::create_field('HTMLFragment', _t( |
|
64 | - __CLASS__ . '.TwitterFieldDesc', |
|
65 | - 'Twitter username (eg, http://twitter.com/<strong>username</strong>)' |
|
66 | - )) |
|
67 | - ); |
|
68 | - } |
|
55 | + $fields->addFieldToTab( |
|
56 | + 'Root.SocialMedia', |
|
57 | + $twitterUsername = TextField::create( |
|
58 | + 'TwitterUsername', |
|
59 | + _t(__CLASS__ . '.TwitterField', 'Twitter username') |
|
60 | + ) |
|
61 | + ); |
|
62 | + $twitterUsername->setDescription( |
|
63 | + DBField::create_field('HTMLFragment', _t( |
|
64 | + __CLASS__ . '.TwitterFieldDesc', |
|
65 | + 'Twitter username (eg, http://twitter.com/<strong>username</strong>)' |
|
66 | + )) |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | } |