@@ -15,34 +15,34 @@ |
||
15 | 15 | class WorkflowDefinitionExtensionTest extends FunctionalTest |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var Boolean If set to TRUE, this will force a test database to be generated |
|
20 | - * in {@link setUp()}. Note that this flag is overruled by the presence of a |
|
21 | - * {@link $fixture_file}, which always forces a database build. |
|
22 | - */ |
|
23 | - protected $usesDatabase = true; |
|
18 | + /** |
|
19 | + * @var Boolean If set to TRUE, this will force a test database to be generated |
|
20 | + * in {@link setUp()}. Note that this flag is overruled by the presence of a |
|
21 | + * {@link $fixture_file}, which always forces a database build. |
|
22 | + */ |
|
23 | + protected $usesDatabase = true; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Tests the config option that controls the creation of a default workflow definition |
|
27 | - * |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function testCreateDefaultWorkflowTest() |
|
31 | - { |
|
32 | - DB::quiet(); |
|
25 | + /** |
|
26 | + * Tests the config option that controls the creation of a default workflow definition |
|
27 | + * |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function testCreateDefaultWorkflowTest() |
|
31 | + { |
|
32 | + DB::quiet(); |
|
33 | 33 | |
34 | - // test disabling the default workflow definition |
|
35 | - Config::modify()->set(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', false); |
|
36 | - $workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class); |
|
37 | - $workflowExtn->requireDefaultRecords(); |
|
38 | - $definition = WorkflowDefinition::get()->first(); |
|
39 | - $this->assertNull($definition); |
|
34 | + // test disabling the default workflow definition |
|
35 | + Config::modify()->set(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', false); |
|
36 | + $workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class); |
|
37 | + $workflowExtn->requireDefaultRecords(); |
|
38 | + $definition = WorkflowDefinition::get()->first(); |
|
39 | + $this->assertNull($definition); |
|
40 | 40 | |
41 | - // test enabling the default workflow definition |
|
42 | - Config::modify()->set(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', true); |
|
43 | - $workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class); |
|
44 | - $workflowExtn->requireDefaultRecords(); |
|
45 | - $definition = WorkflowDefinition::get()->first(); |
|
46 | - $this->assertNotNull($definition); |
|
47 | - } |
|
41 | + // test enabling the default workflow definition |
|
42 | + Config::modify()->set(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', true); |
|
43 | + $workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class); |
|
44 | + $workflowExtn->requireDefaultRecords(); |
|
45 | + $definition = WorkflowDefinition::get()->first(); |
|
46 | + $this->assertNotNull($definition); |
|
47 | + } |
|
48 | 48 | } |
@@ -7,51 +7,51 @@ discard block |
||
7 | 7 | |
8 | 8 | class SynonymValidatorTest extends SapphireTest |
9 | 9 | { |
10 | - /** |
|
11 | - * @var SynonymValidator |
|
12 | - */ |
|
13 | - protected $validator; |
|
10 | + /** |
|
11 | + * @var SynonymValidator |
|
12 | + */ |
|
13 | + protected $validator; |
|
14 | 14 | |
15 | - protected function setUp() |
|
16 | - { |
|
17 | - parent::setUp(); |
|
15 | + protected function setUp() |
|
16 | + { |
|
17 | + parent::setUp(); |
|
18 | 18 | |
19 | - $this->validator = new SynonymValidator([ |
|
20 | - 'Synonyms', |
|
21 | - ]); |
|
22 | - } |
|
19 | + $this->validator = new SynonymValidator([ |
|
20 | + 'Synonyms', |
|
21 | + ]); |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * @dataProvider validValuesProvider |
|
26 | - */ |
|
27 | - public function testItAllowsValidValues($value) |
|
28 | - { |
|
29 | - $this->validator->php([ |
|
30 | - 'Synonyms' => $value, |
|
31 | - ]); |
|
24 | + /** |
|
25 | + * @dataProvider validValuesProvider |
|
26 | + */ |
|
27 | + public function testItAllowsValidValues($value) |
|
28 | + { |
|
29 | + $this->validator->php([ |
|
30 | + 'Synonyms' => $value, |
|
31 | + ]); |
|
32 | 32 | |
33 | - $this->assertEmpty($this->validator->getErrors()); |
|
34 | - } |
|
33 | + $this->assertEmpty($this->validator->getErrors()); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function validValuesProvider() |
|
40 | - { |
|
41 | - return [ |
|
42 | - ['foo'], |
|
43 | - ['foo,bar,baz'], |
|
44 | - ['foo, bar, baz'], |
|
45 | - [ |
|
46 | - ' |
|
36 | + /** |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function validValuesProvider() |
|
40 | + { |
|
41 | + return [ |
|
42 | + ['foo'], |
|
43 | + ['foo,bar,baz'], |
|
44 | + ['foo, bar, baz'], |
|
45 | + [ |
|
46 | + ' |
|
47 | 47 | foo |
48 | 48 | bar |
49 | 49 | baz |
50 | 50 | ' |
51 | - ], |
|
52 | - ['foo => bar, baz'], |
|
53 | - [ |
|
54 | - ' |
|
51 | + ], |
|
52 | + ['foo => bar, baz'], |
|
53 | + [ |
|
54 | + ' |
|
55 | 55 | # this is a comment, it should be ignored! |
56 | 56 | |
57 | 57 | foo, bar, baz |
@@ -59,32 +59,32 @@ discard block |
||
59 | 59 | |
60 | 60 | # ...as should this. |
61 | 61 | ' |
62 | - ], |
|
63 | - ]; |
|
64 | - } |
|
62 | + ], |
|
63 | + ]; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @dataProvider invalidValuesProvider |
|
68 | - * |
|
69 | - * @param string $value |
|
70 | - */ |
|
71 | - public function testItDisallowsInvalidValues($value) |
|
72 | - { |
|
73 | - $this->validator->php([ |
|
74 | - 'Synonyms' => $value, |
|
75 | - ]); |
|
66 | + /** |
|
67 | + * @dataProvider invalidValuesProvider |
|
68 | + * |
|
69 | + * @param string $value |
|
70 | + */ |
|
71 | + public function testItDisallowsInvalidValues($value) |
|
72 | + { |
|
73 | + $this->validator->php([ |
|
74 | + 'Synonyms' => $value, |
|
75 | + ]); |
|
76 | 76 | |
77 | - $this->assertNotEmpty($this->validator->getErrors()); |
|
78 | - } |
|
77 | + $this->assertNotEmpty($this->validator->getErrors()); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return array |
|
82 | - */ |
|
83 | - public function invalidValuesProvider() |
|
84 | - { |
|
85 | - return [ |
|
86 | - ['foo, bar baz, qux'], |
|
87 | - ['foo => bar baz, qux'], |
|
88 | - ]; |
|
89 | - } |
|
80 | + /** |
|
81 | + * @return array |
|
82 | + */ |
|
83 | + public function invalidValuesProvider() |
|
84 | + { |
|
85 | + return [ |
|
86 | + ['foo, bar baz, qux'], |
|
87 | + ['foo => bar baz, qux'], |
|
88 | + ]; |
|
89 | + } |
|
90 | 90 | } |
@@ -7,30 +7,30 @@ |
||
7 | 7 | |
8 | 8 | class NewsHolderController extends DatedUpdateHolderController |
9 | 9 | { |
10 | - private static $allowed_actions = [ |
|
11 | - 'rss', |
|
12 | - 'atom', |
|
13 | - ]; |
|
10 | + private static $allowed_actions = [ |
|
11 | + 'rss', |
|
12 | + 'atom', |
|
13 | + ]; |
|
14 | 14 | |
15 | - public function rss() |
|
16 | - { |
|
17 | - $rss = RSSFeed::create( |
|
18 | - $this->Updates()->sort('Created DESC')->limit(20), |
|
19 | - $this->Link('rss'), |
|
20 | - $this->getSubscriptionTitle() |
|
21 | - ); |
|
22 | - $rss->setTemplate('CWP\\CWP\\PageTypes\\NewsHolder_rss'); |
|
23 | - return $rss->outputToBrowser(); |
|
24 | - } |
|
15 | + public function rss() |
|
16 | + { |
|
17 | + $rss = RSSFeed::create( |
|
18 | + $this->Updates()->sort('Created DESC')->limit(20), |
|
19 | + $this->Link('rss'), |
|
20 | + $this->getSubscriptionTitle() |
|
21 | + ); |
|
22 | + $rss->setTemplate('CWP\\CWP\\PageTypes\\NewsHolder_rss'); |
|
23 | + return $rss->outputToBrowser(); |
|
24 | + } |
|
25 | 25 | |
26 | - public function atom() |
|
27 | - { |
|
28 | - $atom = CwpAtomFeed::create( |
|
29 | - $this->Updates()->sort('Created DESC')->limit(20), |
|
30 | - $this->Link('atom'), |
|
31 | - $this->getSubscriptionTitle() |
|
32 | - ); |
|
33 | - $atom->setTemplate('CWP\\CWP\\PageTypes\\NewsHolder_atom'); |
|
34 | - return $atom->outputToBrowser(); |
|
35 | - } |
|
26 | + public function atom() |
|
27 | + { |
|
28 | + $atom = CwpAtomFeed::create( |
|
29 | + $this->Updates()->sort('Created DESC')->limit(20), |
|
30 | + $this->Link('atom'), |
|
31 | + $this->getSubscriptionTitle() |
|
32 | + ); |
|
33 | + $atom->setTemplate('CWP\\CWP\\PageTypes\\NewsHolder_atom'); |
|
34 | + return $atom->outputToBrowser(); |
|
35 | + } |
|
36 | 36 | } |
@@ -11,55 +11,55 @@ |
||
11 | 11 | */ |
12 | 12 | class CustomSiteConfig extends DataExtension |
13 | 13 | { |
14 | - private static $db = array( |
|
15 | - 'GACode' => 'Varchar(16)', |
|
16 | - 'FacebookURL' => 'Varchar(256)', // multitude of ways to link to Facebook accounts, best to leave it open. |
|
17 | - 'TwitterUsername' => 'Varchar(16)', // max length of Twitter username 15 |
|
18 | - ); |
|
14 | + private static $db = array( |
|
15 | + 'GACode' => 'Varchar(16)', |
|
16 | + 'FacebookURL' => 'Varchar(256)', // multitude of ways to link to Facebook accounts, best to leave it open. |
|
17 | + 'TwitterUsername' => 'Varchar(16)', // max length of Twitter username 15 |
|
18 | + ); |
|
19 | 19 | |
20 | - public function updateCMSFields(FieldList $fields) |
|
21 | - { |
|
22 | - $fields->addFieldToTab( |
|
23 | - 'Root.Main', |
|
24 | - $gaCode = TextField::create( |
|
25 | - 'GACode', |
|
26 | - _t(__CLASS__ . '.GaField', 'Google Analytics account') |
|
27 | - ) |
|
28 | - ); |
|
20 | + public function updateCMSFields(FieldList $fields) |
|
21 | + { |
|
22 | + $fields->addFieldToTab( |
|
23 | + 'Root.Main', |
|
24 | + $gaCode = TextField::create( |
|
25 | + 'GACode', |
|
26 | + _t(__CLASS__ . '.GaField', 'Google Analytics account') |
|
27 | + ) |
|
28 | + ); |
|
29 | 29 | |
30 | - $gaCode->setRightTitle( |
|
31 | - _t( |
|
32 | - __CLASS__ . '.GaFieldDesc', |
|
33 | - 'Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)' |
|
34 | - ) |
|
35 | - ); |
|
30 | + $gaCode->setRightTitle( |
|
31 | + _t( |
|
32 | + __CLASS__ . '.GaFieldDesc', |
|
33 | + 'Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)' |
|
34 | + ) |
|
35 | + ); |
|
36 | 36 | |
37 | - $fields->findOrMakeTab('Root.SocialMedia', _t(__CLASS__ . '.SocialMediaTab', 'Social Media')); |
|
37 | + $fields->findOrMakeTab('Root.SocialMedia', _t(__CLASS__ . '.SocialMediaTab', 'Social Media')); |
|
38 | 38 | |
39 | - $fields->addFieldToTab( |
|
40 | - 'Root.SocialMedia', |
|
41 | - $facebookURL = TextField::create( |
|
42 | - 'FacebookURL', |
|
43 | - _t(__CLASS__ . '.FbField', 'Facebook UID or username') |
|
44 | - ) |
|
45 | - ); |
|
46 | - $facebookURL->setRightTitle( |
|
47 | - _t( |
|
48 | - __CLASS__ . '.FbFieldDesc', |
|
49 | - 'Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/' |
|
50 | - . '<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)' |
|
51 | - ) |
|
52 | - ); |
|
39 | + $fields->addFieldToTab( |
|
40 | + 'Root.SocialMedia', |
|
41 | + $facebookURL = TextField::create( |
|
42 | + 'FacebookURL', |
|
43 | + _t(__CLASS__ . '.FbField', 'Facebook UID or username') |
|
44 | + ) |
|
45 | + ); |
|
46 | + $facebookURL->setRightTitle( |
|
47 | + _t( |
|
48 | + __CLASS__ . '.FbFieldDesc', |
|
49 | + 'Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/' |
|
50 | + . '<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)' |
|
51 | + ) |
|
52 | + ); |
|
53 | 53 | |
54 | - $fields->addFieldToTab( |
|
55 | - 'Root.SocialMedia', |
|
56 | - $twitterUsername = TextField::create( |
|
57 | - 'TwitterUsername', |
|
58 | - _t(__CLASS__ . '.TwitterField', 'Twitter username') |
|
59 | - ) |
|
60 | - ); |
|
61 | - $twitterUsername->setRightTitle( |
|
62 | - _t(__CLASS__ . '.TwitterFieldDesc', 'Twitter username (eg, http://twitter.com/<strong>username</strong>)') |
|
63 | - ); |
|
64 | - } |
|
54 | + $fields->addFieldToTab( |
|
55 | + 'Root.SocialMedia', |
|
56 | + $twitterUsername = TextField::create( |
|
57 | + 'TwitterUsername', |
|
58 | + _t(__CLASS__ . '.TwitterField', 'Twitter username') |
|
59 | + ) |
|
60 | + ); |
|
61 | + $twitterUsername->setRightTitle( |
|
62 | + _t(__CLASS__ . '.TwitterFieldDesc', 'Twitter username (eg, http://twitter.com/<strong>username</strong>)') |
|
63 | + ); |
|
64 | + } |
|
65 | 65 | } |
@@ -13,20 +13,20 @@ |
||
13 | 13 | */ |
14 | 14 | class CwpCommentingExtension extends Extension |
15 | 15 | { |
16 | - public function alterCommentForm(Form $form) |
|
17 | - { |
|
18 | - $fields = $form->Fields(); |
|
16 | + public function alterCommentForm(Form $form) |
|
17 | + { |
|
18 | + $fields = $form->Fields(); |
|
19 | 19 | |
20 | - if ($emailField = $fields->dataFieldByName(Email::class)) { |
|
21 | - $emailField |
|
22 | - ->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', Email::class)) |
|
23 | - ->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.')); |
|
24 | - } |
|
20 | + if ($emailField = $fields->dataFieldByName(Email::class)) { |
|
21 | + $emailField |
|
22 | + ->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', Email::class)) |
|
23 | + ->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.')); |
|
24 | + } |
|
25 | 25 | |
26 | - if ($urlField = $fields->dataFieldByName('URL')) { |
|
27 | - $urlField |
|
28 | - ->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)')) |
|
29 | - ->setAttribute('placeholder', 'http://'); |
|
30 | - } |
|
31 | - } |
|
26 | + if ($urlField = $fields->dataFieldByName('URL')) { |
|
27 | + $urlField |
|
28 | + ->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)')) |
|
29 | + ->setAttribute('placeholder', 'http://'); |
|
30 | + } |
|
31 | + } |
|
32 | 32 | } |
@@ -12,45 +12,45 @@ |
||
12 | 12 | class CwpSearchBoostExtension extends DataExtension |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Quality to boost the 'SearchBoost' field by. |
|
17 | - * Default boost is 2x |
|
18 | - * |
|
19 | - * @config |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - private static $search_boost = '2'; |
|
23 | - |
|
24 | - private static $db = array( |
|
25 | - 'SearchBoost' => 'Text' |
|
26 | - ); |
|
27 | - |
|
28 | - /** |
|
29 | - * Adds boost fields to this page |
|
30 | - * |
|
31 | - * @param FieldList $fields |
|
32 | - */ |
|
33 | - public function updateCMSFields(FieldList $fields) |
|
34 | - { |
|
35 | - parent::updateCMSFields($fields); |
|
36 | - |
|
37 | - // Rename metafield |
|
38 | - $meta = $fields->fieldByName('Root.Main.Metadata'); |
|
39 | - $meta->setTitle(_t(__CLASS__ . '.PAGEINFO', 'Page info and SEO')); |
|
40 | - |
|
41 | - $boostTitle = _t(__CLASS__ . '.SearchBoost', 'Boost Keywords'); |
|
42 | - $boostNote = _t( |
|
43 | - __CLASS__ . '.SearchBoostNote', |
|
44 | - '(Only applies to the search results on this site e.g. not on Google search)' |
|
45 | - ); |
|
46 | - $boostDescription = _t( |
|
47 | - __CLASS__ . '.SearchBoostDescription', |
|
48 | - 'Enter keywords separated by comma ( , ) for which to boost the ranking of this page ' |
|
49 | - . 'within the search results on this site.' |
|
50 | - ); |
|
51 | - $boostField = TextareaField::create('SearchBoost', $boostTitle) |
|
52 | - ->setRightTitle($boostNote) |
|
53 | - ->setDescription($boostDescription); |
|
54 | - $fields->insertBefore('MetaDescription', $boostField); |
|
55 | - } |
|
15 | + /** |
|
16 | + * Quality to boost the 'SearchBoost' field by. |
|
17 | + * Default boost is 2x |
|
18 | + * |
|
19 | + * @config |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + private static $search_boost = '2'; |
|
23 | + |
|
24 | + private static $db = array( |
|
25 | + 'SearchBoost' => 'Text' |
|
26 | + ); |
|
27 | + |
|
28 | + /** |
|
29 | + * Adds boost fields to this page |
|
30 | + * |
|
31 | + * @param FieldList $fields |
|
32 | + */ |
|
33 | + public function updateCMSFields(FieldList $fields) |
|
34 | + { |
|
35 | + parent::updateCMSFields($fields); |
|
36 | + |
|
37 | + // Rename metafield |
|
38 | + $meta = $fields->fieldByName('Root.Main.Metadata'); |
|
39 | + $meta->setTitle(_t(__CLASS__ . '.PAGEINFO', 'Page info and SEO')); |
|
40 | + |
|
41 | + $boostTitle = _t(__CLASS__ . '.SearchBoost', 'Boost Keywords'); |
|
42 | + $boostNote = _t( |
|
43 | + __CLASS__ . '.SearchBoostNote', |
|
44 | + '(Only applies to the search results on this site e.g. not on Google search)' |
|
45 | + ); |
|
46 | + $boostDescription = _t( |
|
47 | + __CLASS__ . '.SearchBoostDescription', |
|
48 | + 'Enter keywords separated by comma ( , ) for which to boost the ranking of this page ' |
|
49 | + . 'within the search results on this site.' |
|
50 | + ); |
|
51 | + $boostField = TextareaField::create('SearchBoost', $boostTitle) |
|
52 | + ->setRightTitle($boostNote) |
|
53 | + ->setDescription($boostDescription); |
|
54 | + $fields->insertBefore('MetaDescription', $boostField); |
|
55 | + } |
|
56 | 56 | } |
@@ -11,53 +11,53 @@ |
||
11 | 11 | class CwpSiteTreeFileExtension extends DataExtension |
12 | 12 | { |
13 | 13 | |
14 | - public function updateCMSFields(FieldList $fields) |
|
15 | - { |
|
16 | - Requirements::css('cwp/cwp:css/fieldDescriptionToggle.css'); |
|
17 | - Requirements::javascript('cwp/cwp:javascript/fieldDescriptionToggle.js'); |
|
18 | - |
|
19 | - $fields->insertAfter( |
|
20 | - 'LastEdited', |
|
21 | - ReadonlyField::create( |
|
22 | - 'BackLinkCount', |
|
23 | - _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.BACKLINKCOUNT', 'Used on:'), |
|
24 | - $this->owner->BackLinkTracking()->Count() . ' ' |
|
25 | - . _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.PAGES', 'page(s)') |
|
26 | - ) |
|
27 | - ->addExtraClass('cms-description-toggle') |
|
28 | - ->setDescription($this->BackLinkHTMLList()) |
|
29 | - ); |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * Generate an HTML list which provides links to where a file is used. |
|
34 | - * |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function BackLinkHTMLList() |
|
38 | - { |
|
39 | - $html = '<em>' . _t( |
|
40 | - __CLASS__ . '.BACKLINK_LIST_DESCRIPTION', |
|
41 | - 'This list shows all pages where the file has been added through a WYSIWYG editor.' |
|
42 | - ) . '</em>'; |
|
43 | - $html .= '<ul>'; |
|
44 | - |
|
45 | - foreach ($this->owner->BackLinkTracking() as $backLink) { |
|
46 | - $listItem = '<li>'; |
|
47 | - |
|
48 | - // Add the page link |
|
49 | - $listItem .= '<a href="' . $backLink->Link() . '" target="_blank">' |
|
50 | - . Convert::raw2xml($backLink->MenuTitle) . '</a> – '; |
|
51 | - |
|
52 | - // Add the CMS link |
|
53 | - $listItem .= '<a href="' . $backLink->CMSEditLink() . '">' |
|
54 | - . _t(__CLASS__ . '.EDIT', 'Edit') . '</a>'; |
|
55 | - |
|
56 | - $html .= $listItem . '</li>'; |
|
57 | - } |
|
58 | - |
|
59 | - $html .= '</ul>'; |
|
60 | - |
|
61 | - return $html; |
|
62 | - } |
|
14 | + public function updateCMSFields(FieldList $fields) |
|
15 | + { |
|
16 | + Requirements::css('cwp/cwp:css/fieldDescriptionToggle.css'); |
|
17 | + Requirements::javascript('cwp/cwp:javascript/fieldDescriptionToggle.js'); |
|
18 | + |
|
19 | + $fields->insertAfter( |
|
20 | + 'LastEdited', |
|
21 | + ReadonlyField::create( |
|
22 | + 'BackLinkCount', |
|
23 | + _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.BACKLINKCOUNT', 'Used on:'), |
|
24 | + $this->owner->BackLinkTracking()->Count() . ' ' |
|
25 | + . _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.PAGES', 'page(s)') |
|
26 | + ) |
|
27 | + ->addExtraClass('cms-description-toggle') |
|
28 | + ->setDescription($this->BackLinkHTMLList()) |
|
29 | + ); |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * Generate an HTML list which provides links to where a file is used. |
|
34 | + * |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function BackLinkHTMLList() |
|
38 | + { |
|
39 | + $html = '<em>' . _t( |
|
40 | + __CLASS__ . '.BACKLINK_LIST_DESCRIPTION', |
|
41 | + 'This list shows all pages where the file has been added through a WYSIWYG editor.' |
|
42 | + ) . '</em>'; |
|
43 | + $html .= '<ul>'; |
|
44 | + |
|
45 | + foreach ($this->owner->BackLinkTracking() as $backLink) { |
|
46 | + $listItem = '<li>'; |
|
47 | + |
|
48 | + // Add the page link |
|
49 | + $listItem .= '<a href="' . $backLink->Link() . '" target="_blank">' |
|
50 | + . Convert::raw2xml($backLink->MenuTitle) . '</a> – '; |
|
51 | + |
|
52 | + // Add the CMS link |
|
53 | + $listItem .= '<a href="' . $backLink->CMSEditLink() . '">' |
|
54 | + . _t(__CLASS__ . '.EDIT', 'Edit') . '</a>'; |
|
55 | + |
|
56 | + $html .= $listItem . '</li>'; |
|
57 | + } |
|
58 | + |
|
59 | + $html .= '</ul>'; |
|
60 | + |
|
61 | + return $html; |
|
62 | + } |
|
63 | 63 | } |
@@ -9,39 +9,39 @@ |
||
9 | 9 | |
10 | 10 | class CwpSiteTreeExtension extends DataExtension |
11 | 11 | { |
12 | - private static $db = array( |
|
13 | - 'ShowPageUtilities' => 'Boolean(1)' |
|
14 | - ); |
|
12 | + private static $db = array( |
|
13 | + 'ShowPageUtilities' => 'Boolean(1)' |
|
14 | + ); |
|
15 | 15 | |
16 | - private static $defaults = array( |
|
17 | - 'ShowPageUtilities' => true |
|
18 | - ); |
|
16 | + private static $defaults = array( |
|
17 | + 'ShowPageUtilities' => true |
|
18 | + ); |
|
19 | 19 | |
20 | - /** |
|
21 | - * Modify the settings for a SiteTree |
|
22 | - * |
|
23 | - * {@inheritDoc} |
|
24 | - * |
|
25 | - * @param FieldList $fields |
|
26 | - */ |
|
27 | - public function updateSettingsFields(FieldList $fields) |
|
28 | - { |
|
29 | - $helpText = _t( |
|
30 | - __CLASS__ . '.SHOW_PAGE_UTILITIES_HELP', |
|
31 | - 'You can disable page utilities (print, share, etc) for this page' |
|
32 | - ); |
|
20 | + /** |
|
21 | + * Modify the settings for a SiteTree |
|
22 | + * |
|
23 | + * {@inheritDoc} |
|
24 | + * |
|
25 | + * @param FieldList $fields |
|
26 | + */ |
|
27 | + public function updateSettingsFields(FieldList $fields) |
|
28 | + { |
|
29 | + $helpText = _t( |
|
30 | + __CLASS__ . '.SHOW_PAGE_UTILITIES_HELP', |
|
31 | + 'You can disable page utilities (print, share, etc) for this page' |
|
32 | + ); |
|
33 | 33 | |
34 | - $fields->addFieldsToTab( |
|
35 | - 'Root.Settings', |
|
36 | - array( |
|
37 | - LiteralField::create('PageUtilitiesHelp', $helpText), |
|
38 | - CheckboxField::create('ShowPageUtilities', $this->owner->fieldLabel('ShowPageUtilities')) |
|
39 | - ) |
|
40 | - ); |
|
41 | - } |
|
34 | + $fields->addFieldsToTab( |
|
35 | + 'Root.Settings', |
|
36 | + array( |
|
37 | + LiteralField::create('PageUtilitiesHelp', $helpText), |
|
38 | + CheckboxField::create('ShowPageUtilities', $this->owner->fieldLabel('ShowPageUtilities')) |
|
39 | + ) |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | - public function updateFieldLabels(&$labels) |
|
44 | - { |
|
45 | - $labels['ShowPageUtilities'] = _t(__CLASS__ . '.SHOW_PAGE_UTILITIES', 'Show page utilities?'); |
|
46 | - } |
|
43 | + public function updateFieldLabels(&$labels) |
|
44 | + { |
|
45 | + $labels['ShowPageUtilities'] = _t(__CLASS__ . '.SHOW_PAGE_UTILITIES', 'Show page utilities?'); |
|
46 | + } |
|
47 | 47 | } |
@@ -16,52 +16,52 @@ |
||
16 | 16 | class SynonymsSiteConfig extends DataExtension |
17 | 17 | { |
18 | 18 | |
19 | - private static $db = array( |
|
20 | - 'SearchSynonyms' => 'Text', // fulltextsearch synonyms.txt content |
|
21 | - ); |
|
19 | + private static $db = array( |
|
20 | + 'SearchSynonyms' => 'Text', // fulltextsearch synonyms.txt content |
|
21 | + ); |
|
22 | 22 | |
23 | - public function updateCMSFields(FieldList $fields) |
|
24 | - { |
|
25 | - // Don't show this field if you're not an admin |
|
26 | - if (!Permission::check('ADMIN')) { |
|
27 | - return; |
|
28 | - } |
|
23 | + public function updateCMSFields(FieldList $fields) |
|
24 | + { |
|
25 | + // Don't show this field if you're not an admin |
|
26 | + if (!Permission::check('ADMIN')) { |
|
27 | + return; |
|
28 | + } |
|
29 | 29 | |
30 | - // Search synonyms |
|
31 | - $fields->addFieldToTab( |
|
32 | - 'Root.FulltextSearch', |
|
33 | - TextareaField::create('SearchSynonyms', _t(__CLASS__ . '.SearchSynonyms', 'Search Synonyms')) |
|
34 | - ->setDescription(_t( |
|
35 | - __CLASS__ . '.SearchSynonyms_Description', |
|
36 | - 'Enter as many comma separated synonyms as you wish, where '. |
|
37 | - 'each line represents a group of synonyms.<br /> ' . |
|
38 | - 'You will need to run <a rel="external" target="_blank" href="dev/tasks/Solr_Configure">' |
|
39 | - . 'Solr_Configure</a> if you make any changes' |
|
40 | - )) |
|
41 | - ); |
|
42 | - } |
|
30 | + // Search synonyms |
|
31 | + $fields->addFieldToTab( |
|
32 | + 'Root.FulltextSearch', |
|
33 | + TextareaField::create('SearchSynonyms', _t(__CLASS__ . '.SearchSynonyms', 'Search Synonyms')) |
|
34 | + ->setDescription(_t( |
|
35 | + __CLASS__ . '.SearchSynonyms_Description', |
|
36 | + 'Enter as many comma separated synonyms as you wish, where '. |
|
37 | + 'each line represents a group of synonyms.<br /> ' . |
|
38 | + 'You will need to run <a rel="external" target="_blank" href="dev/tasks/Solr_Configure">' |
|
39 | + . 'Solr_Configure</a> if you make any changes' |
|
40 | + )) |
|
41 | + ); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @inheritdoc |
|
46 | - * |
|
47 | - * @param ValidationResult $validationResult |
|
48 | - */ |
|
49 | - public function validate(ValidationResult $validationResult) |
|
50 | - { |
|
51 | - $validator = new SynonymValidator(array( |
|
52 | - 'SearchSynonyms', |
|
53 | - )); |
|
44 | + /** |
|
45 | + * @inheritdoc |
|
46 | + * |
|
47 | + * @param ValidationResult $validationResult |
|
48 | + */ |
|
49 | + public function validate(ValidationResult $validationResult) |
|
50 | + { |
|
51 | + $validator = new SynonymValidator(array( |
|
52 | + 'SearchSynonyms', |
|
53 | + )); |
|
54 | 54 | |
55 | - $validator->php(array( |
|
56 | - 'SearchSynonyms' => $this->owner->SearchSynonyms |
|
57 | - )); |
|
55 | + $validator->php(array( |
|
56 | + 'SearchSynonyms' => $this->owner->SearchSynonyms |
|
57 | + )); |
|
58 | 58 | |
59 | - $errors = $validator->getErrors(); |
|
59 | + $errors = $validator->getErrors(); |
|
60 | 60 | |
61 | - if (is_array($errors) || $errors instanceof Traversable) { |
|
62 | - foreach ($errors as $error) { |
|
63 | - $validationResult->addError($error['message']); |
|
64 | - } |
|
65 | - } |
|
66 | - } |
|
61 | + if (is_array($errors) || $errors instanceof Traversable) { |
|
62 | + foreach ($errors as $error) { |
|
63 | + $validationResult->addError($error['message']); |
|
64 | + } |
|
65 | + } |
|
66 | + } |
|
67 | 67 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | TextareaField::create('SearchSynonyms', _t(__CLASS__ . '.SearchSynonyms', 'Search Synonyms')) |
34 | 34 | ->setDescription(_t( |
35 | 35 | __CLASS__ . '.SearchSynonyms_Description', |
36 | - 'Enter as many comma separated synonyms as you wish, where '. |
|
36 | + 'Enter as many comma separated synonyms as you wish, where ' . |
|
37 | 37 | 'each line represents a group of synonyms.<br /> ' . |
38 | 38 | 'You will need to run <a rel="external" target="_blank" href="dev/tasks/Solr_Configure">' |
39 | 39 | . 'Solr_Configure</a> if you make any changes' |