@@ -12,37 +12,37 @@ |
||
12 | 12 | */ |
13 | 13 | class CwpWorkflowDefinitionExtension extends DataExtension |
14 | 14 | { |
15 | - /** |
|
16 | - * Create the default 'Two-step Workflow' when this extension is loaded |
|
17 | - * |
|
18 | - * @config |
|
19 | - * @var boolean |
|
20 | - */ |
|
21 | - private static $create_default_workflow = true; |
|
15 | + /** |
|
16 | + * Create the default 'Two-step Workflow' when this extension is loaded |
|
17 | + * |
|
18 | + * @config |
|
19 | + * @var boolean |
|
20 | + */ |
|
21 | + private static $create_default_workflow = true; |
|
22 | 22 | |
23 | - public function requireDefaultRecords() |
|
24 | - { |
|
25 | - if (Config::inst()->get(CwpWorkflowDefinitionExtension::class, 'create_default_workflow')) { |
|
26 | - // Only proceed if a definition using this template has not been created yet |
|
27 | - $definition = WorkflowDefinition::get()->filter("Template", "Review and Approve")->First(); |
|
28 | - if ($definition && $definition->exists()) { |
|
29 | - return; |
|
30 | - } |
|
23 | + public function requireDefaultRecords() |
|
24 | + { |
|
25 | + if (Config::inst()->get(CwpWorkflowDefinitionExtension::class, 'create_default_workflow')) { |
|
26 | + // Only proceed if a definition using this template has not been created yet |
|
27 | + $definition = WorkflowDefinition::get()->filter("Template", "Review and Approve")->First(); |
|
28 | + if ($definition && $definition->exists()) { |
|
29 | + return; |
|
30 | + } |
|
31 | 31 | |
32 | - //generate from the template, which happens after we write the definition |
|
33 | - $definition = WorkflowDefinition::create(); |
|
34 | - $definition->Template = "Review and Approve"; |
|
35 | - $definition->write(); |
|
32 | + //generate from the template, which happens after we write the definition |
|
33 | + $definition = WorkflowDefinition::create(); |
|
34 | + $definition->Template = "Review and Approve"; |
|
35 | + $definition->write(); |
|
36 | 36 | |
37 | - //change the title, description, and reminder days |
|
38 | - $definition->update(array( |
|
39 | - 'Title' => "Two-step Workflow", |
|
40 | - 'Description' => "Content Authors can write content and Content Publishers can approve/reject.", |
|
41 | - 'RemindDays' => 3, |
|
42 | - )); |
|
43 | - $definition->write(); |
|
37 | + //change the title, description, and reminder days |
|
38 | + $definition->update(array( |
|
39 | + 'Title' => "Two-step Workflow", |
|
40 | + 'Description' => "Content Authors can write content and Content Publishers can approve/reject.", |
|
41 | + 'RemindDays' => 3, |
|
42 | + )); |
|
43 | + $definition->write(); |
|
44 | 44 | |
45 | - DB::alteration_message("Added default workflow definition to WorkflowDefinition table", "created"); |
|
46 | - } |
|
47 | - } |
|
45 | + DB::alteration_message("Added default workflow definition to WorkflowDefinition table", "created"); |
|
46 | + } |
|
47 | + } |
|
48 | 48 | } |
@@ -8,42 +8,42 @@ |
||
8 | 8 | |
9 | 9 | class BasePageTest extends SapphireTest |
10 | 10 | { |
11 | - protected static $fixture_file = 'BasePageTest.yml'; |
|
12 | - |
|
13 | - protected function setUp() |
|
14 | - { |
|
15 | - parent::setUp(); |
|
16 | - |
|
17 | - Config::modify()->set(BasePage::class, 'pdf_export', true); |
|
18 | - Config::modify()->set(BasePage::class, 'generated_pdf_path', 'assets/_generated_pdfs'); |
|
19 | - } |
|
20 | - |
|
21 | - public function testPdfFilename() |
|
22 | - { |
|
23 | - $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
24 | - $this->assertContains( |
|
25 | - 'assets/_generated_pdfs/test-page-one-1.pdf', |
|
26 | - $page->getPdfFilename(), |
|
27 | - 'Generated filename for PDF' |
|
28 | - ); |
|
29 | - } |
|
30 | - |
|
31 | - public function testPdfLink() |
|
32 | - { |
|
33 | - $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
34 | - $this->assertContains('test-page-one/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
35 | - } |
|
36 | - |
|
37 | - public function testHomePagePdfLink() |
|
38 | - { |
|
39 | - $page = $this->objFromFixture(BasePage::class, 'home-page'); |
|
40 | - $this->assertContains('home/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
41 | - } |
|
42 | - |
|
43 | - public function testPdfLinkDisabled() |
|
44 | - { |
|
45 | - Config::modify()->set(BasePage::class, 'pdf_export', false); |
|
46 | - $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
47 | - $this->assertFalse($page->PdfLink(), 'No PDF link as the functionality is disabled'); |
|
48 | - } |
|
11 | + protected static $fixture_file = 'BasePageTest.yml'; |
|
12 | + |
|
13 | + protected function setUp() |
|
14 | + { |
|
15 | + parent::setUp(); |
|
16 | + |
|
17 | + Config::modify()->set(BasePage::class, 'pdf_export', true); |
|
18 | + Config::modify()->set(BasePage::class, 'generated_pdf_path', 'assets/_generated_pdfs'); |
|
19 | + } |
|
20 | + |
|
21 | + public function testPdfFilename() |
|
22 | + { |
|
23 | + $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
24 | + $this->assertContains( |
|
25 | + 'assets/_generated_pdfs/test-page-one-1.pdf', |
|
26 | + $page->getPdfFilename(), |
|
27 | + 'Generated filename for PDF' |
|
28 | + ); |
|
29 | + } |
|
30 | + |
|
31 | + public function testPdfLink() |
|
32 | + { |
|
33 | + $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
34 | + $this->assertContains('test-page-one/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
35 | + } |
|
36 | + |
|
37 | + public function testHomePagePdfLink() |
|
38 | + { |
|
39 | + $page = $this->objFromFixture(BasePage::class, 'home-page'); |
|
40 | + $this->assertContains('home/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
41 | + } |
|
42 | + |
|
43 | + public function testPdfLinkDisabled() |
|
44 | + { |
|
45 | + Config::modify()->set(BasePage::class, 'pdf_export', false); |
|
46 | + $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
47 | + $this->assertFalse($page->PdfLink(), 'No PDF link as the functionality is disabled'); |
|
48 | + } |
|
49 | 49 | } |
@@ -8,94 +8,94 @@ |
||
8 | 8 | |
9 | 9 | class EventHolderTest extends SapphireTest |
10 | 10 | { |
11 | - protected static $fixture_file = 'EventHolderTest.yml'; |
|
11 | + protected static $fixture_file = 'EventHolderTest.yml'; |
|
12 | 12 | |
13 | - public function testEventTags() |
|
14 | - { |
|
15 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
13 | + public function testEventTags() |
|
14 | + { |
|
15 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
16 | 16 | |
17 | - $tags = $holder->UpdateTags(); |
|
18 | - $this->assertNotNull($tags->find('Name', 'Future'), 'Finds present terms.'); |
|
19 | - $this->assertNull($tags->find('Name', 'Event types', 'Does not find top level taxonomy.')); |
|
20 | - $this->assertNull($tags->find('Name', 'Carrot'), 'Does not find terms that are not applied.'); |
|
21 | - } |
|
17 | + $tags = $holder->UpdateTags(); |
|
18 | + $this->assertNotNull($tags->find('Name', 'Future'), 'Finds present terms.'); |
|
19 | + $this->assertNull($tags->find('Name', 'Event types', 'Does not find top level taxonomy.')); |
|
20 | + $this->assertNull($tags->find('Name', 'Carrot'), 'Does not find terms that are not applied.'); |
|
21 | + } |
|
22 | 22 | |
23 | - public function testEventWithParentFilter() |
|
24 | - { |
|
25 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder2'); |
|
23 | + public function testEventWithParentFilter() |
|
24 | + { |
|
25 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder2'); |
|
26 | 26 | |
27 | - $items = $holder->Updates(); |
|
27 | + $items = $holder->Updates(); |
|
28 | 28 | |
29 | - $this->assertNotNull($items->find('URLSegment', 'other-holder'), 'Event from the holder is shown.'); |
|
30 | - $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Events from other holders are not shown.'); |
|
31 | - } |
|
29 | + $this->assertNotNull($items->find('URLSegment', 'other-holder'), 'Event from the holder is shown.'); |
|
30 | + $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Events from other holders are not shown.'); |
|
31 | + } |
|
32 | 32 | |
33 | - public function testEventsWithTagFilter() |
|
34 | - { |
|
35 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
33 | + public function testEventsWithTagFilter() |
|
34 | + { |
|
35 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
36 | 36 | |
37 | - //Get the "Future" tag. |
|
38 | - $tag = $this->objFromFixture(TaxonomyTerm::class, 'TaxonomyTerm1'); |
|
37 | + //Get the "Future" tag. |
|
38 | + $tag = $this->objFromFixture(TaxonomyTerm::class, 'TaxonomyTerm1'); |
|
39 | 39 | |
40 | - $items = $holder->Updates($tag->ID); |
|
40 | + $items = $holder->Updates($tag->ID); |
|
41 | 41 | |
42 | - $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the tagged page.'); |
|
43 | - $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find pages that are not tagged.'); |
|
44 | - } |
|
42 | + $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the tagged page.'); |
|
43 | + $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find pages that are not tagged.'); |
|
44 | + } |
|
45 | 45 | |
46 | - public function testEventsWithMonthFilter() |
|
47 | - { |
|
48 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
46 | + public function testEventsWithMonthFilter() |
|
47 | + { |
|
48 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
49 | 49 | |
50 | - $items = $holder->Updates(null, null, null, 2013, 7); |
|
50 | + $items = $holder->Updates(null, null, null, 2013, 7); |
|
51 | 51 | |
52 | - $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the event in 2013-07.'); |
|
53 | - $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find events at other dates.'); |
|
54 | - } |
|
52 | + $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the event in 2013-07.'); |
|
53 | + $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find events at other dates.'); |
|
54 | + } |
|
55 | 55 | |
56 | - public function testEventsWithDateRangeFilter() |
|
57 | - { |
|
58 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
56 | + public function testEventsWithDateRangeFilter() |
|
57 | + { |
|
58 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
59 | 59 | |
60 | - $items = $holder->Updates(null, '2013-01-19', null); |
|
61 | - $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds the event at the date'); |
|
62 | - $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find the event at another date'); |
|
60 | + $items = $holder->Updates(null, '2013-01-19', null); |
|
61 | + $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds the event at the date'); |
|
62 | + $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find the event at another date'); |
|
63 | 63 | |
64 | - $items = $holder->Updates(null, '2013-01-01', '2013-01-19'); |
|
65 | - $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds events in the date range'); |
|
66 | - $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find event out of range'); |
|
67 | - } |
|
64 | + $items = $holder->Updates(null, '2013-01-01', '2013-01-19'); |
|
65 | + $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds events in the date range'); |
|
66 | + $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find event out of range'); |
|
67 | + } |
|
68 | 68 | |
69 | - public function testExtractMonths() |
|
70 | - { |
|
71 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
69 | + public function testExtractMonths() |
|
70 | + { |
|
71 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
72 | 72 | |
73 | - $months = EventHolder::ExtractMonths( |
|
74 | - $holder->Updates(), |
|
75 | - 'http://mybase.org/?tag=12&start=10&from=2010-10-10&to=2010-10-11', // Used for link generation |
|
76 | - 2013, // Currently selected |
|
77 | - 1 // Currently selected |
|
78 | - ); |
|
73 | + $months = EventHolder::ExtractMonths( |
|
74 | + $holder->Updates(), |
|
75 | + 'http://mybase.org/?tag=12&start=10&from=2010-10-10&to=2010-10-11', // Used for link generation |
|
76 | + 2013, // Currently selected |
|
77 | + 1 // Currently selected |
|
78 | + ); |
|
79 | 79 | |
80 | - // Check which years are generated. |
|
81 | - $this->assertNotNull($months->find('YearName', 2013), 'Generates existing year'); |
|
82 | - $this->assertNull($months->find('YearName', 1990), 'Does not generate non-present year'); |
|
80 | + // Check which years are generated. |
|
81 | + $this->assertNotNull($months->find('YearName', 2013), 'Generates existing year'); |
|
82 | + $this->assertNull($months->find('YearName', 1990), 'Does not generate non-present year'); |
|
83 | 83 | |
84 | - $year = $months->find('YearName', 2013); |
|
84 | + $year = $months->find('YearName', 2013); |
|
85 | 85 | |
86 | - // Check which months come up in 2013 |
|
87 | - $this->assertNotNull($year['Months']->find('MonthNumber', 7), 'Generates existing month'); |
|
88 | - $this->assertNull($year['Months']->find('MonthNumber', 12), 'Does not generate non-present month'); |
|
86 | + // Check which months come up in 2013 |
|
87 | + $this->assertNotNull($year['Months']->find('MonthNumber', 7), 'Generates existing month'); |
|
88 | + $this->assertNull($year['Months']->find('MonthNumber', 12), 'Does not generate non-present month'); |
|
89 | 89 | |
90 | - $month = $year['Months']->find('MonthNumber', 7); |
|
91 | - $this->assertEquals( |
|
92 | - $month['MonthLink'], |
|
93 | - 'http://mybase.org/?tag=12&from=2010-10-10&to=2010-10-11&month=7&year=2013', |
|
94 | - 'Selection link is built properly - start is removed, and tag, from and to retained.' |
|
95 | - ); |
|
90 | + $month = $year['Months']->find('MonthNumber', 7); |
|
91 | + $this->assertEquals( |
|
92 | + $month['MonthLink'], |
|
93 | + 'http://mybase.org/?tag=12&from=2010-10-10&to=2010-10-11&month=7&year=2013', |
|
94 | + 'Selection link is built properly - start is removed, and tag, from and to retained.' |
|
95 | + ); |
|
96 | 96 | |
97 | - // Check if these months are marked properly. |
|
98 | - $month = $year['Months']->find('MonthNumber', 1); |
|
99 | - $this->assertEquals($month['Active'], true, 'Correctly marks active link'); |
|
100 | - } |
|
97 | + // Check if these months are marked properly. |
|
98 | + $month = $year['Months']->find('MonthNumber', 1); |
|
99 | + $this->assertEquals($month['Active'], true, 'Correctly marks active link'); |
|
100 | + } |
|
101 | 101 | } |
@@ -9,26 +9,26 @@ |
||
9 | 9 | |
10 | 10 | class SitemapPageTest extends FunctionalTest |
11 | 11 | { |
12 | - protected static $fixture_file = 'SitemapPageTest.yml'; |
|
12 | + protected static $fixture_file = 'SitemapPageTest.yml'; |
|
13 | 13 | |
14 | - protected static $use_draft_site = true; |
|
14 | + protected static $use_draft_site = true; |
|
15 | 15 | |
16 | - protected function setUp() |
|
17 | - { |
|
18 | - parent::setUp(); |
|
16 | + protected function setUp() |
|
17 | + { |
|
18 | + parent::setUp(); |
|
19 | 19 | |
20 | - Config::inst()->update(SSViewer::class, 'theme', 'starter'); |
|
21 | - } |
|
20 | + Config::inst()->update(SSViewer::class, 'theme', 'starter'); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Note: this test depends on the "starter" theme being installed and configured as default |
|
25 | - */ |
|
26 | - public function testSitemapShowsNavigationTitleNotNormalTitle() |
|
27 | - { |
|
28 | - $response = $this->get('sitemap'); |
|
29 | - $parser = new CSSContentParser($response->getBody()); |
|
30 | - $elements = $parser->getBySelector('.sitemap li.first .sitemap-link'); |
|
31 | - $this->assertNotEmpty($elements); |
|
32 | - $this->assertEquals('Top page nav 1', (string) $elements[0]); |
|
33 | - } |
|
23 | + /** |
|
24 | + * Note: this test depends on the "starter" theme being installed and configured as default |
|
25 | + */ |
|
26 | + public function testSitemapShowsNavigationTitleNotNormalTitle() |
|
27 | + { |
|
28 | + $response = $this->get('sitemap'); |
|
29 | + $parser = new CSSContentParser($response->getBody()); |
|
30 | + $elements = $parser->getBySelector('.sitemap li.first .sitemap-link'); |
|
31 | + $this->assertNotEmpty($elements); |
|
32 | + $this->assertEquals('Top page nav 1', (string) $elements[0]); |
|
33 | + } |
|
34 | 34 | } |
@@ -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,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,120 +11,120 @@ |
||
11 | 11 | |
12 | 12 | class Quicklink extends DataObject |
13 | 13 | { |
14 | - private static $db = [ |
|
15 | - 'Name' => 'Varchar(255)', |
|
16 | - 'ExternalLink' => 'Varchar(255)', |
|
17 | - 'SortOrder' => 'Int', |
|
18 | - ]; |
|
19 | - |
|
20 | - private static $has_one = [ |
|
21 | - 'Parent' => BaseHomePage::class, |
|
22 | - 'InternalLink' => SiteTree::class, |
|
23 | - ]; |
|
24 | - |
|
25 | - private static $summary_fields = [ |
|
26 | - 'Name' => 'Name', |
|
27 | - 'InternalLink.Title' => 'Internal Link', |
|
28 | - 'ExternalLink' => 'External Link', |
|
29 | - ]; |
|
30 | - |
|
31 | - private static $table_name = 'Quicklink'; |
|
32 | - |
|
33 | - public function fieldLabels($includerelations = true) |
|
34 | - { |
|
35 | - $labels = parent::fieldLabels($includerelations); |
|
36 | - $labels['Name'] = _t(__CLASS__ . '.NameLabel', 'Name'); |
|
37 | - $labels['ExternalLink'] = _t(__CLASS__ . '.ExternalLinkLabel', 'External Link'); |
|
38 | - $labels['SortOrder'] = _t(__CLASS__ . '.SortOrderLabel', 'Sort Order'); |
|
39 | - $labels['ParentID'] = _t(__CLASS__ . '.ParentRelationLabel', 'Parent'); |
|
40 | - $labels['InternalLinkID'] = _t(__CLASS__ . '.InternalLinkLabel', 'Internal Link'); |
|
41 | - |
|
42 | - return $labels; |
|
43 | - } |
|
44 | - |
|
45 | - public function getLink() |
|
46 | - { |
|
47 | - if ($this->ExternalLink) { |
|
48 | - $url = parse_url($this->ExternalLink); |
|
49 | - |
|
50 | - // if no scheme set in the link, default to http |
|
51 | - if (!isset($url['scheme'])) { |
|
52 | - return 'http://' . $this->ExternalLink; |
|
53 | - } |
|
54 | - |
|
55 | - return $this->ExternalLink; |
|
56 | - } elseif ($this->InternalLinkID) { |
|
57 | - return $this->InternalLink()->Link(); |
|
58 | - } |
|
59 | - } |
|
60 | - |
|
61 | - public function canCreate($member = null, $context = []) |
|
62 | - { |
|
63 | - return $this->Parent()->canCreate($member, $context); |
|
64 | - } |
|
65 | - |
|
66 | - public function canEdit($member = null) |
|
67 | - { |
|
68 | - return $this->Parent()->canEdit($member); |
|
69 | - } |
|
70 | - |
|
71 | - public function canDelete($member = null) |
|
72 | - { |
|
73 | - return $this->Parent()->canDelete($member); |
|
74 | - } |
|
75 | - |
|
76 | - public function canView($member = null) |
|
77 | - { |
|
78 | - return $this->Parent()->canView($member); |
|
79 | - } |
|
80 | - |
|
81 | - public function getCMSFields() |
|
82 | - { |
|
83 | - $fields = parent::getCMSFields(); |
|
84 | - |
|
85 | - $fields->removeByName('ParentID'); |
|
86 | - |
|
87 | - $externalLinkField = $fields->fieldByName('Root.Main.ExternalLink'); |
|
88 | - |
|
89 | - $fields->removeByName('ExternalLink'); |
|
90 | - $fields->removeByName('InternalLinkID'); |
|
91 | - $fields->removeByName('SortOrder'); |
|
92 | - $externalLinkField->addExtraClass('noBorder'); |
|
93 | - |
|
94 | - $fields->addFieldToTab('Root.Main', CompositeField::create( |
|
95 | - array( |
|
96 | - TreeDropdownField::create( |
|
97 | - 'InternalLinkID', |
|
98 | - $this->fieldLabel('InternalLinkID'), |
|
99 | - SiteTree::class |
|
100 | - ), |
|
101 | - $externalLinkField, |
|
102 | - $wrap = CompositeField::create( |
|
103 | - $extraLabel = LiteralField::create( |
|
104 | - 'NoteOverride', |
|
105 | - _t( |
|
106 | - __CLASS__ . '.Note', |
|
107 | - // @todo remove the HTML from this translation |
|
108 | - '<div class="message good notice">Note: If you specify an External Link, ' |
|
109 | - . 'the Internal Link will be ignored.</div>' |
|
110 | - ) |
|
111 | - ) |
|
112 | - ) |
|
113 | - ) |
|
114 | - )); |
|
115 | - $fields->insertBefore( |
|
116 | - 'Name', |
|
117 | - LiteralField::create( |
|
118 | - 'Note', |
|
119 | - _t( |
|
120 | - __CLASS__ . '.Note2', |
|
121 | - // @todo remove the HTML from this translation |
|
122 | - '<p>Use this to specify a link to a page either on this site ' |
|
123 | - . '(Internal Link) or another site (External Link).</p>' |
|
124 | - ) |
|
125 | - ) |
|
126 | - ); |
|
127 | - |
|
128 | - return $fields; |
|
129 | - } |
|
14 | + private static $db = [ |
|
15 | + 'Name' => 'Varchar(255)', |
|
16 | + 'ExternalLink' => 'Varchar(255)', |
|
17 | + 'SortOrder' => 'Int', |
|
18 | + ]; |
|
19 | + |
|
20 | + private static $has_one = [ |
|
21 | + 'Parent' => BaseHomePage::class, |
|
22 | + 'InternalLink' => SiteTree::class, |
|
23 | + ]; |
|
24 | + |
|
25 | + private static $summary_fields = [ |
|
26 | + 'Name' => 'Name', |
|
27 | + 'InternalLink.Title' => 'Internal Link', |
|
28 | + 'ExternalLink' => 'External Link', |
|
29 | + ]; |
|
30 | + |
|
31 | + private static $table_name = 'Quicklink'; |
|
32 | + |
|
33 | + public function fieldLabels($includerelations = true) |
|
34 | + { |
|
35 | + $labels = parent::fieldLabels($includerelations); |
|
36 | + $labels['Name'] = _t(__CLASS__ . '.NameLabel', 'Name'); |
|
37 | + $labels['ExternalLink'] = _t(__CLASS__ . '.ExternalLinkLabel', 'External Link'); |
|
38 | + $labels['SortOrder'] = _t(__CLASS__ . '.SortOrderLabel', 'Sort Order'); |
|
39 | + $labels['ParentID'] = _t(__CLASS__ . '.ParentRelationLabel', 'Parent'); |
|
40 | + $labels['InternalLinkID'] = _t(__CLASS__ . '.InternalLinkLabel', 'Internal Link'); |
|
41 | + |
|
42 | + return $labels; |
|
43 | + } |
|
44 | + |
|
45 | + public function getLink() |
|
46 | + { |
|
47 | + if ($this->ExternalLink) { |
|
48 | + $url = parse_url($this->ExternalLink); |
|
49 | + |
|
50 | + // if no scheme set in the link, default to http |
|
51 | + if (!isset($url['scheme'])) { |
|
52 | + return 'http://' . $this->ExternalLink; |
|
53 | + } |
|
54 | + |
|
55 | + return $this->ExternalLink; |
|
56 | + } elseif ($this->InternalLinkID) { |
|
57 | + return $this->InternalLink()->Link(); |
|
58 | + } |
|
59 | + } |
|
60 | + |
|
61 | + public function canCreate($member = null, $context = []) |
|
62 | + { |
|
63 | + return $this->Parent()->canCreate($member, $context); |
|
64 | + } |
|
65 | + |
|
66 | + public function canEdit($member = null) |
|
67 | + { |
|
68 | + return $this->Parent()->canEdit($member); |
|
69 | + } |
|
70 | + |
|
71 | + public function canDelete($member = null) |
|
72 | + { |
|
73 | + return $this->Parent()->canDelete($member); |
|
74 | + } |
|
75 | + |
|
76 | + public function canView($member = null) |
|
77 | + { |
|
78 | + return $this->Parent()->canView($member); |
|
79 | + } |
|
80 | + |
|
81 | + public function getCMSFields() |
|
82 | + { |
|
83 | + $fields = parent::getCMSFields(); |
|
84 | + |
|
85 | + $fields->removeByName('ParentID'); |
|
86 | + |
|
87 | + $externalLinkField = $fields->fieldByName('Root.Main.ExternalLink'); |
|
88 | + |
|
89 | + $fields->removeByName('ExternalLink'); |
|
90 | + $fields->removeByName('InternalLinkID'); |
|
91 | + $fields->removeByName('SortOrder'); |
|
92 | + $externalLinkField->addExtraClass('noBorder'); |
|
93 | + |
|
94 | + $fields->addFieldToTab('Root.Main', CompositeField::create( |
|
95 | + array( |
|
96 | + TreeDropdownField::create( |
|
97 | + 'InternalLinkID', |
|
98 | + $this->fieldLabel('InternalLinkID'), |
|
99 | + SiteTree::class |
|
100 | + ), |
|
101 | + $externalLinkField, |
|
102 | + $wrap = CompositeField::create( |
|
103 | + $extraLabel = LiteralField::create( |
|
104 | + 'NoteOverride', |
|
105 | + _t( |
|
106 | + __CLASS__ . '.Note', |
|
107 | + // @todo remove the HTML from this translation |
|
108 | + '<div class="message good notice">Note: If you specify an External Link, ' |
|
109 | + . 'the Internal Link will be ignored.</div>' |
|
110 | + ) |
|
111 | + ) |
|
112 | + ) |
|
113 | + ) |
|
114 | + )); |
|
115 | + $fields->insertBefore( |
|
116 | + 'Name', |
|
117 | + LiteralField::create( |
|
118 | + 'Note', |
|
119 | + _t( |
|
120 | + __CLASS__ . '.Note2', |
|
121 | + // @todo remove the HTML from this translation |
|
122 | + '<p>Use this to specify a link to a page either on this site ' |
|
123 | + . '(Internal Link) or another site (External Link).</p>' |
|
124 | + ) |
|
125 | + ) |
|
126 | + ); |
|
127 | + |
|
128 | + return $fields; |
|
129 | + } |
|
130 | 130 | } |
@@ -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 | } |