@@ -10,50 +10,50 @@ |
||
| 10 | 10 | |
| 11 | 11 | class PopulateThemeSampleDataTaskTest extends SapphireTest |
| 12 | 12 | { |
| 13 | - protected $usesDatabase = true; |
|
| 14 | - |
|
| 15 | - /** |
|
| 16 | - * Ensure that the "contact" user form is only created once |
|
| 17 | - */ |
|
| 18 | - public function testOnlyCreateContactFormOnce() |
|
| 19 | - { |
|
| 20 | - if (!class_exists(UserDefinedForm::class)) { |
|
| 21 | - $this->markTestSkipped('This test requires the userforms module to be installed'); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - $createdMessage = 'Created "contact" UserDefinedForm'; |
|
| 25 | - |
|
| 26 | - $task = new PopulateThemeSampleDataTask; |
|
| 27 | - |
|
| 28 | - // Run the task |
|
| 29 | - $this->assertContains($createdMessage, $this->bufferedTask($task)); |
|
| 30 | - |
|
| 31 | - // Run a second time |
|
| 32 | - $this->assertNotContains($createdMessage, $this->bufferedTask($task)); |
|
| 33 | - |
|
| 34 | - // Change the page name |
|
| 35 | - $form = UserDefinedForm::get()->filter('URLSegment', 'contact')->first(); |
|
| 36 | - $form->URLSegment = 'testing'; |
|
| 37 | - $form->write(); |
|
| 38 | - |
|
| 39 | - // Ensure the old version is still detected in draft, so not recreated |
|
| 40 | - $this->assertNotContains($createdMessage, $this->bufferedTask($task)); |
|
| 41 | - |
|
| 42 | - // Delete the page, then ensure it's recreated again (DataObject::delete will remove staged versions) |
|
| 43 | - $form->delete(); |
|
| 44 | - $this->assertContains($createdMessage, $this->bufferedTask($task)); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Run a BuildTask while buffering its output, and return the result |
|
| 49 | - * |
|
| 50 | - * @param BuildTask $task |
|
| 51 | - * @return string |
|
| 52 | - */ |
|
| 53 | - protected function bufferedTask(BuildTask $task) |
|
| 54 | - { |
|
| 55 | - ob_start(); |
|
| 56 | - $task->run(new HTTPRequest('GET', '/')); |
|
| 57 | - return ob_get_clean(); |
|
| 58 | - } |
|
| 13 | + protected $usesDatabase = true; |
|
| 14 | + |
|
| 15 | + /** |
|
| 16 | + * Ensure that the "contact" user form is only created once |
|
| 17 | + */ |
|
| 18 | + public function testOnlyCreateContactFormOnce() |
|
| 19 | + { |
|
| 20 | + if (!class_exists(UserDefinedForm::class)) { |
|
| 21 | + $this->markTestSkipped('This test requires the userforms module to be installed'); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + $createdMessage = 'Created "contact" UserDefinedForm'; |
|
| 25 | + |
|
| 26 | + $task = new PopulateThemeSampleDataTask; |
|
| 27 | + |
|
| 28 | + // Run the task |
|
| 29 | + $this->assertContains($createdMessage, $this->bufferedTask($task)); |
|
| 30 | + |
|
| 31 | + // Run a second time |
|
| 32 | + $this->assertNotContains($createdMessage, $this->bufferedTask($task)); |
|
| 33 | + |
|
| 34 | + // Change the page name |
|
| 35 | + $form = UserDefinedForm::get()->filter('URLSegment', 'contact')->first(); |
|
| 36 | + $form->URLSegment = 'testing'; |
|
| 37 | + $form->write(); |
|
| 38 | + |
|
| 39 | + // Ensure the old version is still detected in draft, so not recreated |
|
| 40 | + $this->assertNotContains($createdMessage, $this->bufferedTask($task)); |
|
| 41 | + |
|
| 42 | + // Delete the page, then ensure it's recreated again (DataObject::delete will remove staged versions) |
|
| 43 | + $form->delete(); |
|
| 44 | + $this->assertContains($createdMessage, $this->bufferedTask($task)); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Run a BuildTask while buffering its output, and return the result |
|
| 49 | + * |
|
| 50 | + * @param BuildTask $task |
|
| 51 | + * @return string |
|
| 52 | + */ |
|
| 53 | + protected function bufferedTask(BuildTask $task) |
|
| 54 | + { |
|
| 55 | + ob_start(); |
|
| 56 | + $task->run(new HTTPRequest('GET', '/')); |
|
| 57 | + return ob_get_clean(); |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -17,136 +17,136 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class PopulateThemeSampleDataTask extends BuildTask |
| 19 | 19 | { |
| 20 | - protected $title = 'Populate sample data for theme demo'; |
|
| 21 | - |
|
| 22 | - protected $description = 'Populates some sample data for showcasing the functionality of the ' |
|
| 23 | - . 'starter and Wātea themes'; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * A series of method calls to create sample data |
|
| 27 | - * |
|
| 28 | - * @param HTTPRequest $request |
|
| 29 | - */ |
|
| 30 | - public function run($request) |
|
| 31 | - { |
|
| 32 | - if (!class_exists(UserDefinedForm::class)) { |
|
| 33 | - return; |
|
| 34 | - } |
|
| 35 | - $this->handleContactForm(); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Decide whether to create a contact user defined form, and call it to be be created if so |
|
| 40 | - * |
|
| 41 | - * @return $this |
|
| 42 | - */ |
|
| 43 | - protected function handleContactForm() |
|
| 44 | - { |
|
| 45 | - if (!$this->getContactFormExists()) { |
|
| 46 | - $this->createContactForm(); |
|
| 47 | - } |
|
| 48 | - return $this; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Determine whether a "contact us" userform exists yet |
|
| 53 | - * |
|
| 54 | - * @return bool |
|
| 55 | - */ |
|
| 56 | - protected function getContactFormExists() |
|
| 57 | - { |
|
| 58 | - $exists = false; |
|
| 59 | - foreach (UserDefinedForm::get()->column('ID') as $formId) { |
|
| 60 | - $count = Versioned::get_all_versions(UserDefinedForm::class, $formId) |
|
| 61 | - ->filter('URLSegment', 'contact') |
|
| 62 | - ->count(); |
|
| 63 | - |
|
| 64 | - if ($count >= 1) { |
|
| 65 | - $exists = true; |
|
| 66 | - break; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - return $exists; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Create a "contact us" userform. Please note that this form does not have any recipients by default, so |
|
| 74 | - * no emails will be sent. To add recipients - edit the page in the CMS and add a recipient via the "Recipients" |
|
| 75 | - * tab. |
|
| 76 | - * |
|
| 77 | - * @return $this |
|
| 78 | - */ |
|
| 79 | - protected function createContactForm() |
|
| 80 | - { |
|
| 81 | - $form = UserDefinedForm::create(array( |
|
| 82 | - 'Title' => 'Contact', |
|
| 83 | - 'URLSegment' => 'contact', |
|
| 84 | - 'Content' => '<p>$UserDefinedForm</p>', |
|
| 85 | - 'SubmitButtonText' => 'Submit', |
|
| 86 | - 'ClearButtonText' => 'Clear', |
|
| 87 | - 'OnCompleteMessage' => "<p>Thanks, we've received your submission and will be in touch shortly.</p>", |
|
| 88 | - 'EnableLiveValidation' => true |
|
| 89 | - )); |
|
| 90 | - |
|
| 91 | - $form->write(); |
|
| 92 | - |
|
| 93 | - // Add form fields |
|
| 94 | - $fields = array( |
|
| 95 | - EditableFormStep::create([ |
|
| 96 | - 'Title' => _t( |
|
| 97 | - 'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFormStep.TITLE_FIRST', |
|
| 98 | - 'First Page' |
|
| 99 | - ) |
|
| 100 | - ]), |
|
| 101 | - EditableTextField::create([ |
|
| 102 | - 'Title' => 'Name', |
|
| 103 | - 'Required' => true, |
|
| 104 | - 'RightTitle' => 'Please enter your first and last name' |
|
| 105 | - ]), |
|
| 106 | - EditableEmailField::create([ |
|
| 107 | - 'Title' => Email::class, |
|
| 108 | - 'Required' => true, |
|
| 109 | - 'Placeholder' => '[email protected]' |
|
| 110 | - ]), |
|
| 111 | - EditableTextField::create([ |
|
| 112 | - 'Title' => 'Subject' |
|
| 113 | - ]), |
|
| 114 | - EditableTextField::create([ |
|
| 115 | - 'Title' => 'Message', |
|
| 116 | - 'Required' => true, |
|
| 117 | - 'Rows' => 5 |
|
| 118 | - ]) |
|
| 119 | - ); |
|
| 120 | - |
|
| 121 | - foreach ($fields as $field) { |
|
| 122 | - $field->write(); |
|
| 123 | - $form->Fields()->add($field); |
|
| 124 | - $field->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $form->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); |
|
| 128 | - $form->flushCache(); |
|
| 129 | - |
|
| 130 | - $this->output(' + Created "contact" UserDefinedForm page'); |
|
| 131 | - |
|
| 132 | - return $this; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Output a message either to the console or browser |
|
| 137 | - * |
|
| 138 | - * @param string $message |
|
| 139 | - * @return $this |
|
| 140 | - */ |
|
| 141 | - protected function output($message) |
|
| 142 | - { |
|
| 143 | - if (Director::is_cli()) { |
|
| 144 | - $message .= PHP_EOL; |
|
| 145 | - } else { |
|
| 146 | - $message = sprintf('<p>%s</p>', $message); |
|
| 147 | - } |
|
| 148 | - echo $message; |
|
| 149 | - |
|
| 150 | - return $this; |
|
| 151 | - } |
|
| 20 | + protected $title = 'Populate sample data for theme demo'; |
|
| 21 | + |
|
| 22 | + protected $description = 'Populates some sample data for showcasing the functionality of the ' |
|
| 23 | + . 'starter and Wātea themes'; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * A series of method calls to create sample data |
|
| 27 | + * |
|
| 28 | + * @param HTTPRequest $request |
|
| 29 | + */ |
|
| 30 | + public function run($request) |
|
| 31 | + { |
|
| 32 | + if (!class_exists(UserDefinedForm::class)) { |
|
| 33 | + return; |
|
| 34 | + } |
|
| 35 | + $this->handleContactForm(); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Decide whether to create a contact user defined form, and call it to be be created if so |
|
| 40 | + * |
|
| 41 | + * @return $this |
|
| 42 | + */ |
|
| 43 | + protected function handleContactForm() |
|
| 44 | + { |
|
| 45 | + if (!$this->getContactFormExists()) { |
|
| 46 | + $this->createContactForm(); |
|
| 47 | + } |
|
| 48 | + return $this; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Determine whether a "contact us" userform exists yet |
|
| 53 | + * |
|
| 54 | + * @return bool |
|
| 55 | + */ |
|
| 56 | + protected function getContactFormExists() |
|
| 57 | + { |
|
| 58 | + $exists = false; |
|
| 59 | + foreach (UserDefinedForm::get()->column('ID') as $formId) { |
|
| 60 | + $count = Versioned::get_all_versions(UserDefinedForm::class, $formId) |
|
| 61 | + ->filter('URLSegment', 'contact') |
|
| 62 | + ->count(); |
|
| 63 | + |
|
| 64 | + if ($count >= 1) { |
|
| 65 | + $exists = true; |
|
| 66 | + break; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + return $exists; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Create a "contact us" userform. Please note that this form does not have any recipients by default, so |
|
| 74 | + * no emails will be sent. To add recipients - edit the page in the CMS and add a recipient via the "Recipients" |
|
| 75 | + * tab. |
|
| 76 | + * |
|
| 77 | + * @return $this |
|
| 78 | + */ |
|
| 79 | + protected function createContactForm() |
|
| 80 | + { |
|
| 81 | + $form = UserDefinedForm::create(array( |
|
| 82 | + 'Title' => 'Contact', |
|
| 83 | + 'URLSegment' => 'contact', |
|
| 84 | + 'Content' => '<p>$UserDefinedForm</p>', |
|
| 85 | + 'SubmitButtonText' => 'Submit', |
|
| 86 | + 'ClearButtonText' => 'Clear', |
|
| 87 | + 'OnCompleteMessage' => "<p>Thanks, we've received your submission and will be in touch shortly.</p>", |
|
| 88 | + 'EnableLiveValidation' => true |
|
| 89 | + )); |
|
| 90 | + |
|
| 91 | + $form->write(); |
|
| 92 | + |
|
| 93 | + // Add form fields |
|
| 94 | + $fields = array( |
|
| 95 | + EditableFormStep::create([ |
|
| 96 | + 'Title' => _t( |
|
| 97 | + 'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFormStep.TITLE_FIRST', |
|
| 98 | + 'First Page' |
|
| 99 | + ) |
|
| 100 | + ]), |
|
| 101 | + EditableTextField::create([ |
|
| 102 | + 'Title' => 'Name', |
|
| 103 | + 'Required' => true, |
|
| 104 | + 'RightTitle' => 'Please enter your first and last name' |
|
| 105 | + ]), |
|
| 106 | + EditableEmailField::create([ |
|
| 107 | + 'Title' => Email::class, |
|
| 108 | + 'Required' => true, |
|
| 109 | + 'Placeholder' => '[email protected]' |
|
| 110 | + ]), |
|
| 111 | + EditableTextField::create([ |
|
| 112 | + 'Title' => 'Subject' |
|
| 113 | + ]), |
|
| 114 | + EditableTextField::create([ |
|
| 115 | + 'Title' => 'Message', |
|
| 116 | + 'Required' => true, |
|
| 117 | + 'Rows' => 5 |
|
| 118 | + ]) |
|
| 119 | + ); |
|
| 120 | + |
|
| 121 | + foreach ($fields as $field) { |
|
| 122 | + $field->write(); |
|
| 123 | + $form->Fields()->add($field); |
|
| 124 | + $field->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $form->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); |
|
| 128 | + $form->flushCache(); |
|
| 129 | + |
|
| 130 | + $this->output(' + Created "contact" UserDefinedForm page'); |
|
| 131 | + |
|
| 132 | + return $this; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Output a message either to the console or browser |
|
| 137 | + * |
|
| 138 | + * @param string $message |
|
| 139 | + * @return $this |
|
| 140 | + */ |
|
| 141 | + protected function output($message) |
|
| 142 | + { |
|
| 143 | + if (Director::is_cli()) { |
|
| 144 | + $message .= PHP_EOL; |
|
| 145 | + } else { |
|
| 146 | + $message = sprintf('<p>%s</p>', $message); |
|
| 147 | + } |
|
| 148 | + echo $message; |
|
| 149 | + |
|
| 150 | + return $this; |
|
| 151 | + } |
|
| 152 | 152 | } |
@@ -7,45 +7,45 @@ |
||
| 7 | 7 | |
| 8 | 8 | class SitemapPageController extends PageController |
| 9 | 9 | { |
| 10 | - private static $allowed_actions = [ |
|
| 11 | - 'showpage', |
|
| 12 | - ]; |
|
| 13 | - |
|
| 14 | - private static $url_handlers = [ |
|
| 15 | - 'page/$ID' => 'showpage', |
|
| 16 | - ]; |
|
| 17 | - |
|
| 18 | - public function showpage($request) |
|
| 19 | - { |
|
| 20 | - $id = (int) $request->param('ID'); |
|
| 21 | - if (!$id) { |
|
| 22 | - return false; |
|
| 23 | - } |
|
| 24 | - $page = SiteTree::get()->byId($id); |
|
| 25 | - |
|
| 26 | - // does the page exist? |
|
| 27 | - if (!($page && $page->exists())) { |
|
| 28 | - return $this->httpError(404); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - // can the page be viewed? |
|
| 32 | - if (!$page->canView()) { |
|
| 33 | - return $this->httpError(403); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - $viewer = $this->customise([ |
|
| 37 | - 'IsAjax' => $request->isAjax(), |
|
| 38 | - 'SelectedPage' => $page, |
|
| 39 | - 'Children' => $page->Children(), |
|
| 40 | - ]); |
|
| 41 | - |
|
| 42 | - if ($request->isAjax()) { |
|
| 43 | - return $viewer->renderWith([ |
|
| 44 | - 'type' => 'Includes', |
|
| 45 | - 'SitemapNodeChildren' |
|
| 46 | - ]); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - return $viewer; |
|
| 50 | - } |
|
| 10 | + private static $allowed_actions = [ |
|
| 11 | + 'showpage', |
|
| 12 | + ]; |
|
| 13 | + |
|
| 14 | + private static $url_handlers = [ |
|
| 15 | + 'page/$ID' => 'showpage', |
|
| 16 | + ]; |
|
| 17 | + |
|
| 18 | + public function showpage($request) |
|
| 19 | + { |
|
| 20 | + $id = (int) $request->param('ID'); |
|
| 21 | + if (!$id) { |
|
| 22 | + return false; |
|
| 23 | + } |
|
| 24 | + $page = SiteTree::get()->byId($id); |
|
| 25 | + |
|
| 26 | + // does the page exist? |
|
| 27 | + if (!($page && $page->exists())) { |
|
| 28 | + return $this->httpError(404); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + // can the page be viewed? |
|
| 32 | + if (!$page->canView()) { |
|
| 33 | + return $this->httpError(403); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + $viewer = $this->customise([ |
|
| 37 | + 'IsAjax' => $request->isAjax(), |
|
| 38 | + 'SelectedPage' => $page, |
|
| 39 | + 'Children' => $page->Children(), |
|
| 40 | + ]); |
|
| 41 | + |
|
| 42 | + if ($request->isAjax()) { |
|
| 43 | + return $viewer->renderWith([ |
|
| 44 | + 'type' => 'Includes', |
|
| 45 | + 'SitemapNodeChildren' |
|
| 46 | + ]); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + return $viewer; |
|
| 50 | + } |
|
| 51 | 51 | } |
@@ -27,147 +27,147 @@ |
||
| 27 | 27 | |
| 28 | 28 | class BasePage extends SiteTree |
| 29 | 29 | { |
| 30 | - private static $icon = 'cwp/cwp:images/icons/sitetree_images/page.png'; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide" |
|
| 34 | - * |
|
| 35 | - * {@inheritDoc} |
|
| 36 | - */ |
|
| 37 | - private static $hide_ancestor = BasePage::class; |
|
| 38 | - |
|
| 39 | - private static $api_access = [ |
|
| 40 | - 'view' => [ |
|
| 41 | - 'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription', |
|
| 42 | - 'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID' |
|
| 43 | - ], |
|
| 44 | - 'edit' => [ |
|
| 45 | - 'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription', |
|
| 46 | - 'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID' |
|
| 47 | - ], |
|
| 48 | - ]; |
|
| 49 | - |
|
| 50 | - private static $table_name = 'BasePage'; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @config |
|
| 54 | - * @var string |
|
| 55 | - */ |
|
| 56 | - private static $related_pages_title = 'Related pages'; |
|
| 57 | - |
|
| 58 | - private static $many_many = [ |
|
| 59 | - 'Terms' => TaxonomyTerm::class, |
|
| 60 | - 'RelatedPages' => BasePage::class, |
|
| 61 | - ]; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @var array |
|
| 65 | - * @config |
|
| 66 | - */ |
|
| 67 | - private static $many_many_extraFields = [ |
|
| 68 | - 'RelatedPages' => [ |
|
| 69 | - 'SortOrder' => DBInt::class, |
|
| 70 | - ], |
|
| 71 | - ]; |
|
| 72 | - |
|
| 73 | - private static $plural_name = 'Base Pages'; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Get the footer holder. |
|
| 77 | - */ |
|
| 78 | - public function getFooter() |
|
| 79 | - { |
|
| 80 | - return FooterHolder::get_one(FooterHolder::class); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - public function RelatedPages() |
|
| 84 | - { |
|
| 85 | - return $this->getManyManyComponents('RelatedPages')->sort('SortOrder'); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - public function RelatedPagesTitle() |
|
| 89 | - { |
|
| 90 | - return $this->config()->get('related_pages_title'); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - public function getCMSFields() |
|
| 94 | - { |
|
| 95 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 96 | - // Related Pages |
|
| 97 | - $components = GridFieldConfig_RelationEditor::create(); |
|
| 98 | - $components->removeComponentsByType(GridFieldAddNewButton::class); |
|
| 99 | - $components->removeComponentsByType(GridFieldEditButton::class); |
|
| 100 | - $components->removeComponentsByType(GridFieldFilterHeader::class); |
|
| 101 | - $components->addComponent(new GridFieldOrderableRows('SortOrder')); |
|
| 102 | - |
|
| 103 | - /** @var GridFieldDataColumns $dataColumns */ |
|
| 104 | - $dataColumns = $components->getComponentByType(GridFieldDataColumns::class); |
|
| 105 | - $dataColumns->setDisplayFields([ |
|
| 106 | - 'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'), |
|
| 107 | - 'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type') |
|
| 108 | - ]); |
|
| 109 | - |
|
| 110 | - $fields->findOrMakeTab( |
|
| 111 | - 'Root.RelatedPages', |
|
| 112 | - _t(__CLASS__ . '.RelatedPages', 'Related pages') |
|
| 113 | - ); |
|
| 114 | - $fields->addFieldToTab( |
|
| 115 | - 'Root.RelatedPages', |
|
| 116 | - GridField::create( |
|
| 117 | - 'RelatedPages', |
|
| 118 | - _t(__CLASS__ . '.RelatedPages', 'Related pages'), |
|
| 119 | - $this->RelatedPages(), |
|
| 120 | - $components |
|
| 121 | - ) |
|
| 122 | - ); |
|
| 123 | - |
|
| 124 | - // Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc) |
|
| 125 | - $hasMany = $this->hasMany(); |
|
| 126 | - $manyMany = $this->manyMany(); |
|
| 127 | - if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) { |
|
| 128 | - $components = GridFieldConfig_RelationEditor::create(); |
|
| 129 | - $components->removeComponentsByType(GridFieldAddNewButton::class); |
|
| 130 | - $components->removeComponentsByType(GridFieldEditButton::class); |
|
| 131 | - |
|
| 132 | - /** @var GridFieldAddExistingAutocompleter $autoCompleter */ |
|
| 133 | - $autoCompleter = $components->getComponentByType(GridFieldAddExistingAutocompleter::class); |
|
| 134 | - $autoCompleter->setResultsFormat('$Name ($TaxonomyName)'); |
|
| 135 | - |
|
| 136 | - /** @var GridFieldDataColumns $dataColumns */ |
|
| 137 | - $dataColumns = $components->getComponentByType(GridFieldDataColumns::class); |
|
| 138 | - $dataColumns->setDisplayFields([ |
|
| 139 | - 'Name' => _t(__CLASS__ . '.Term', 'Term'), |
|
| 140 | - 'TaxonomyName' => _t(__CLASS__ . '.Taxonomy', 'Taxonomy') |
|
| 141 | - ]); |
|
| 142 | - |
|
| 143 | - $fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags')); |
|
| 144 | - $fields->addFieldToTab( |
|
| 145 | - 'Root.Tags', |
|
| 146 | - TreeMultiselectField::create( |
|
| 147 | - 'Terms', |
|
| 148 | - _t(__CLASS__ . '.Terms', 'Terms'), |
|
| 149 | - TaxonomyTerm::class |
|
| 150 | - )->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms')) |
|
| 151 | - ); |
|
| 152 | - } |
|
| 153 | - }); |
|
| 154 | - return parent::getCMSFields(); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Returns the native language name for the selected locale/language, empty string if Fluent is not available |
|
| 159 | - * |
|
| 160 | - * @return string |
|
| 161 | - */ |
|
| 162 | - public function getSelectedLanguage() |
|
| 163 | - { |
|
| 164 | - if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) { |
|
| 165 | - return ''; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** @var ArrayData $information */ |
|
| 169 | - $information = $this->LocaleInformation(FluentState::singleton()->getLocale()); |
|
| 170 | - |
|
| 171 | - return $information->LanguageNative; |
|
| 172 | - } |
|
| 30 | + private static $icon = 'cwp/cwp:images/icons/sitetree_images/page.png'; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide" |
|
| 34 | + * |
|
| 35 | + * {@inheritDoc} |
|
| 36 | + */ |
|
| 37 | + private static $hide_ancestor = BasePage::class; |
|
| 38 | + |
|
| 39 | + private static $api_access = [ |
|
| 40 | + 'view' => [ |
|
| 41 | + 'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription', |
|
| 42 | + 'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID' |
|
| 43 | + ], |
|
| 44 | + 'edit' => [ |
|
| 45 | + 'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription', |
|
| 46 | + 'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID' |
|
| 47 | + ], |
|
| 48 | + ]; |
|
| 49 | + |
|
| 50 | + private static $table_name = 'BasePage'; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @config |
|
| 54 | + * @var string |
|
| 55 | + */ |
|
| 56 | + private static $related_pages_title = 'Related pages'; |
|
| 57 | + |
|
| 58 | + private static $many_many = [ |
|
| 59 | + 'Terms' => TaxonomyTerm::class, |
|
| 60 | + 'RelatedPages' => BasePage::class, |
|
| 61 | + ]; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @var array |
|
| 65 | + * @config |
|
| 66 | + */ |
|
| 67 | + private static $many_many_extraFields = [ |
|
| 68 | + 'RelatedPages' => [ |
|
| 69 | + 'SortOrder' => DBInt::class, |
|
| 70 | + ], |
|
| 71 | + ]; |
|
| 72 | + |
|
| 73 | + private static $plural_name = 'Base Pages'; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Get the footer holder. |
|
| 77 | + */ |
|
| 78 | + public function getFooter() |
|
| 79 | + { |
|
| 80 | + return FooterHolder::get_one(FooterHolder::class); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + public function RelatedPages() |
|
| 84 | + { |
|
| 85 | + return $this->getManyManyComponents('RelatedPages')->sort('SortOrder'); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + public function RelatedPagesTitle() |
|
| 89 | + { |
|
| 90 | + return $this->config()->get('related_pages_title'); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + public function getCMSFields() |
|
| 94 | + { |
|
| 95 | + $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 96 | + // Related Pages |
|
| 97 | + $components = GridFieldConfig_RelationEditor::create(); |
|
| 98 | + $components->removeComponentsByType(GridFieldAddNewButton::class); |
|
| 99 | + $components->removeComponentsByType(GridFieldEditButton::class); |
|
| 100 | + $components->removeComponentsByType(GridFieldFilterHeader::class); |
|
| 101 | + $components->addComponent(new GridFieldOrderableRows('SortOrder')); |
|
| 102 | + |
|
| 103 | + /** @var GridFieldDataColumns $dataColumns */ |
|
| 104 | + $dataColumns = $components->getComponentByType(GridFieldDataColumns::class); |
|
| 105 | + $dataColumns->setDisplayFields([ |
|
| 106 | + 'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'), |
|
| 107 | + 'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type') |
|
| 108 | + ]); |
|
| 109 | + |
|
| 110 | + $fields->findOrMakeTab( |
|
| 111 | + 'Root.RelatedPages', |
|
| 112 | + _t(__CLASS__ . '.RelatedPages', 'Related pages') |
|
| 113 | + ); |
|
| 114 | + $fields->addFieldToTab( |
|
| 115 | + 'Root.RelatedPages', |
|
| 116 | + GridField::create( |
|
| 117 | + 'RelatedPages', |
|
| 118 | + _t(__CLASS__ . '.RelatedPages', 'Related pages'), |
|
| 119 | + $this->RelatedPages(), |
|
| 120 | + $components |
|
| 121 | + ) |
|
| 122 | + ); |
|
| 123 | + |
|
| 124 | + // Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc) |
|
| 125 | + $hasMany = $this->hasMany(); |
|
| 126 | + $manyMany = $this->manyMany(); |
|
| 127 | + if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) { |
|
| 128 | + $components = GridFieldConfig_RelationEditor::create(); |
|
| 129 | + $components->removeComponentsByType(GridFieldAddNewButton::class); |
|
| 130 | + $components->removeComponentsByType(GridFieldEditButton::class); |
|
| 131 | + |
|
| 132 | + /** @var GridFieldAddExistingAutocompleter $autoCompleter */ |
|
| 133 | + $autoCompleter = $components->getComponentByType(GridFieldAddExistingAutocompleter::class); |
|
| 134 | + $autoCompleter->setResultsFormat('$Name ($TaxonomyName)'); |
|
| 135 | + |
|
| 136 | + /** @var GridFieldDataColumns $dataColumns */ |
|
| 137 | + $dataColumns = $components->getComponentByType(GridFieldDataColumns::class); |
|
| 138 | + $dataColumns->setDisplayFields([ |
|
| 139 | + 'Name' => _t(__CLASS__ . '.Term', 'Term'), |
|
| 140 | + 'TaxonomyName' => _t(__CLASS__ . '.Taxonomy', 'Taxonomy') |
|
| 141 | + ]); |
|
| 142 | + |
|
| 143 | + $fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags')); |
|
| 144 | + $fields->addFieldToTab( |
|
| 145 | + 'Root.Tags', |
|
| 146 | + TreeMultiselectField::create( |
|
| 147 | + 'Terms', |
|
| 148 | + _t(__CLASS__ . '.Terms', 'Terms'), |
|
| 149 | + TaxonomyTerm::class |
|
| 150 | + )->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms')) |
|
| 151 | + ); |
|
| 152 | + } |
|
| 153 | + }); |
|
| 154 | + return parent::getCMSFields(); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * Returns the native language name for the selected locale/language, empty string if Fluent is not available |
|
| 159 | + * |
|
| 160 | + * @return string |
|
| 161 | + */ |
|
| 162 | + public function getSelectedLanguage() |
|
| 163 | + { |
|
| 164 | + if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) { |
|
| 165 | + return ''; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** @var ArrayData $information */ |
|
| 169 | + $information = $this->LocaleInformation(FluentState::singleton()->getLocale()); |
|
| 170 | + |
|
| 171 | + return $information->LanguageNative; |
|
| 172 | + } |
|
| 173 | 173 | } |
@@ -26,137 +26,137 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class BaseHomePage extends Page |
| 28 | 28 | { |
| 29 | - private static $icon = 'cwp/cwp:images/icons/sitetree_images/home.png'; |
|
| 30 | - |
|
| 31 | - private static $hide_ancestor = BaseHomePage::class; |
|
| 32 | - |
|
| 33 | - private static $singular_name = 'Home Page'; |
|
| 34 | - |
|
| 35 | - private static $plural_name = 'Home Pages'; |
|
| 36 | - |
|
| 37 | - private static $table_name = 'BaseHomePage'; |
|
| 38 | - |
|
| 39 | - private static $db = [ |
|
| 40 | - 'FeatureOneTitle' => 'Varchar(255)', |
|
| 41 | - 'FeatureOneCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')", |
|
| 42 | - 'FeatureOneContent' => 'HTMLText', |
|
| 43 | - 'FeatureOneButtonText' => 'Varchar(255)', |
|
| 44 | - 'FeatureTwoTitle' => 'Varchar(255)', |
|
| 45 | - 'FeatureTwoCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')", |
|
| 46 | - 'FeatureTwoContent' => 'HTMLText', |
|
| 47 | - 'FeatureTwoButtonText' => 'Varchar(255)' |
|
| 48 | - ]; |
|
| 49 | - |
|
| 50 | - private static $has_one = [ |
|
| 51 | - 'LearnMorePage' => SiteTree::class, |
|
| 52 | - 'FeatureOneLink' => SiteTree::class, |
|
| 53 | - 'FeatureTwoLink' => SiteTree::class, |
|
| 54 | - ]; |
|
| 55 | - |
|
| 56 | - private static $has_many = [ |
|
| 57 | - 'Quicklinks' => Quicklink::class . '.Parent', |
|
| 58 | - ]; |
|
| 59 | - |
|
| 60 | - public function Quicklinks() |
|
| 61 | - { |
|
| 62 | - return $this->getComponents('Quicklinks')->sort('SortOrder'); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - public function getCMSFields() |
|
| 66 | - { |
|
| 67 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 68 | - // Main Content tab |
|
| 69 | - $fields->addFieldToTab( |
|
| 70 | - 'Root.Main', |
|
| 71 | - TreeDropdownField::create( |
|
| 72 | - 'LearnMorePageID', |
|
| 73 | - _t(__CLASS__ . '.LearnMoreLink', 'Page to link the "Learn More" button to:'), |
|
| 74 | - SiteTree::class |
|
| 75 | - ), |
|
| 76 | - 'Metadata' |
|
| 77 | - ); |
|
| 78 | - |
|
| 79 | - $gridField = GridField::create( |
|
| 80 | - 'Quicklinks', |
|
| 81 | - 'Quicklinks', |
|
| 82 | - $this->Quicklinks(), |
|
| 83 | - GridFieldConfig_RelationEditor::create() |
|
| 84 | - ); |
|
| 85 | - $gridConfig = $gridField->getConfig(); |
|
| 86 | - $gridConfig->getComponentByType(GridFieldAddNewButton::class)->setButtonName( |
|
| 87 | - _t(__CLASS__ . '.AddNewButton', 'Add new') |
|
| 88 | - ); |
|
| 89 | - |
|
| 90 | - $injector = Injector::inst(); |
|
| 91 | - |
|
| 92 | - $gridConfig->removeComponentsByType(GridFieldAddExistingAutocompleter::class); |
|
| 93 | - $gridConfig->removeComponentsByType(GridFieldDeleteAction::class); |
|
| 94 | - $gridConfig->addComponent($injector->create(GridFieldDeleteAction::class)); |
|
| 95 | - $gridConfig->addComponent($injector->create(GridFieldOrderableRows::class, 'SortOrder')); |
|
| 96 | - $gridField->setModelClass(Quicklink::class); |
|
| 97 | - |
|
| 98 | - $fields->addFieldToTab('Root.Quicklinks', $gridField); |
|
| 99 | - |
|
| 100 | - $fields->removeByName('Import'); |
|
| 101 | - |
|
| 102 | - $fields->addFieldToTab( |
|
| 103 | - 'Root.Features', |
|
| 104 | - ToggleCompositeField::create( |
|
| 105 | - 'FeatureOne', |
|
| 106 | - _t(__CLASS__ . '.FeatureOne', 'Feature One'), |
|
| 107 | - array( |
|
| 108 | - TextField::create('FeatureOneTitle', _t(__CLASS__ . '.Title', 'Title')), |
|
| 109 | - $dropdownField = DropdownField::create( |
|
| 110 | - 'FeatureOneCategory', |
|
| 111 | - _t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'), |
|
| 112 | - singleton(BaseHomePage::class)->dbObject('FeatureOneCategory')->enumValues() |
|
| 113 | - ), |
|
| 114 | - HTMLEditorField::create( |
|
| 115 | - 'FeatureOneContent', |
|
| 116 | - _t(__CLASS__ . '.FeatureContentFieldLabel', 'Content') |
|
| 117 | - ), |
|
| 118 | - TextField::create( |
|
| 119 | - 'FeatureOneButtonText', |
|
| 120 | - _t(__CLASS__ . '.FeatureButtonText', 'Button text') |
|
| 121 | - ), |
|
| 122 | - TreeDropdownField::create( |
|
| 123 | - 'FeatureOneLinkID', |
|
| 124 | - _t(__CLASS__ . '.FeatureLink', 'Page to link to'), |
|
| 125 | - SiteTree::class |
|
| 126 | - )->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in')) |
|
| 127 | - ) |
|
| 128 | - )->setHeadingLevel(3) |
|
| 129 | - ); |
|
| 130 | - $dropdownField->setEmptyString('none'); |
|
| 131 | - |
|
| 132 | - $fields->addFieldToTab('Root.Features', ToggleCompositeField::create( |
|
| 133 | - 'FeatureTwo', |
|
| 134 | - _t(__CLASS__ . '.FeatureTwo', 'Feature Two'), |
|
| 135 | - array( |
|
| 136 | - TextField::create('FeatureTwoTitle', _t(__CLASS__ . '.Title', 'Title')), |
|
| 137 | - $dropdownField = DropdownField::create( |
|
| 138 | - 'FeatureTwoCategory', |
|
| 139 | - _t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'), |
|
| 140 | - singleton(BaseHomePage::class)->dbObject('FeatureTwoCategory')->enumValues() |
|
| 141 | - ), |
|
| 142 | - HTMLEditorField::create( |
|
| 143 | - 'FeatureTwoContent', |
|
| 144 | - _t(__CLASS__ . '.FeatureContentFieldLabel', 'Content') |
|
| 145 | - ), |
|
| 146 | - TextField::create( |
|
| 147 | - 'FeatureTwoButtonText', |
|
| 148 | - _t(__CLASS__ . '.FeatureButtonText', 'Button text') |
|
| 149 | - ), |
|
| 150 | - TreeDropdownField::create( |
|
| 151 | - 'FeatureTwoLinkID', |
|
| 152 | - _t(__CLASS__ . '.FeatureLink', 'Page to link to'), |
|
| 153 | - SiteTree::class |
|
| 154 | - )->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in')) |
|
| 155 | - ) |
|
| 156 | - )->setHeadingLevel(3)); |
|
| 157 | - $dropdownField->setEmptyString('none'); |
|
| 158 | - }); |
|
| 159 | - |
|
| 160 | - return parent::getCMSFields(); |
|
| 161 | - } |
|
| 29 | + private static $icon = 'cwp/cwp:images/icons/sitetree_images/home.png'; |
|
| 30 | + |
|
| 31 | + private static $hide_ancestor = BaseHomePage::class; |
|
| 32 | + |
|
| 33 | + private static $singular_name = 'Home Page'; |
|
| 34 | + |
|
| 35 | + private static $plural_name = 'Home Pages'; |
|
| 36 | + |
|
| 37 | + private static $table_name = 'BaseHomePage'; |
|
| 38 | + |
|
| 39 | + private static $db = [ |
|
| 40 | + 'FeatureOneTitle' => 'Varchar(255)', |
|
| 41 | + 'FeatureOneCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')", |
|
| 42 | + 'FeatureOneContent' => 'HTMLText', |
|
| 43 | + 'FeatureOneButtonText' => 'Varchar(255)', |
|
| 44 | + 'FeatureTwoTitle' => 'Varchar(255)', |
|
| 45 | + 'FeatureTwoCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')", |
|
| 46 | + 'FeatureTwoContent' => 'HTMLText', |
|
| 47 | + 'FeatureTwoButtonText' => 'Varchar(255)' |
|
| 48 | + ]; |
|
| 49 | + |
|
| 50 | + private static $has_one = [ |
|
| 51 | + 'LearnMorePage' => SiteTree::class, |
|
| 52 | + 'FeatureOneLink' => SiteTree::class, |
|
| 53 | + 'FeatureTwoLink' => SiteTree::class, |
|
| 54 | + ]; |
|
| 55 | + |
|
| 56 | + private static $has_many = [ |
|
| 57 | + 'Quicklinks' => Quicklink::class . '.Parent', |
|
| 58 | + ]; |
|
| 59 | + |
|
| 60 | + public function Quicklinks() |
|
| 61 | + { |
|
| 62 | + return $this->getComponents('Quicklinks')->sort('SortOrder'); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + public function getCMSFields() |
|
| 66 | + { |
|
| 67 | + $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 68 | + // Main Content tab |
|
| 69 | + $fields->addFieldToTab( |
|
| 70 | + 'Root.Main', |
|
| 71 | + TreeDropdownField::create( |
|
| 72 | + 'LearnMorePageID', |
|
| 73 | + _t(__CLASS__ . '.LearnMoreLink', 'Page to link the "Learn More" button to:'), |
|
| 74 | + SiteTree::class |
|
| 75 | + ), |
|
| 76 | + 'Metadata' |
|
| 77 | + ); |
|
| 78 | + |
|
| 79 | + $gridField = GridField::create( |
|
| 80 | + 'Quicklinks', |
|
| 81 | + 'Quicklinks', |
|
| 82 | + $this->Quicklinks(), |
|
| 83 | + GridFieldConfig_RelationEditor::create() |
|
| 84 | + ); |
|
| 85 | + $gridConfig = $gridField->getConfig(); |
|
| 86 | + $gridConfig->getComponentByType(GridFieldAddNewButton::class)->setButtonName( |
|
| 87 | + _t(__CLASS__ . '.AddNewButton', 'Add new') |
|
| 88 | + ); |
|
| 89 | + |
|
| 90 | + $injector = Injector::inst(); |
|
| 91 | + |
|
| 92 | + $gridConfig->removeComponentsByType(GridFieldAddExistingAutocompleter::class); |
|
| 93 | + $gridConfig->removeComponentsByType(GridFieldDeleteAction::class); |
|
| 94 | + $gridConfig->addComponent($injector->create(GridFieldDeleteAction::class)); |
|
| 95 | + $gridConfig->addComponent($injector->create(GridFieldOrderableRows::class, 'SortOrder')); |
|
| 96 | + $gridField->setModelClass(Quicklink::class); |
|
| 97 | + |
|
| 98 | + $fields->addFieldToTab('Root.Quicklinks', $gridField); |
|
| 99 | + |
|
| 100 | + $fields->removeByName('Import'); |
|
| 101 | + |
|
| 102 | + $fields->addFieldToTab( |
|
| 103 | + 'Root.Features', |
|
| 104 | + ToggleCompositeField::create( |
|
| 105 | + 'FeatureOne', |
|
| 106 | + _t(__CLASS__ . '.FeatureOne', 'Feature One'), |
|
| 107 | + array( |
|
| 108 | + TextField::create('FeatureOneTitle', _t(__CLASS__ . '.Title', 'Title')), |
|
| 109 | + $dropdownField = DropdownField::create( |
|
| 110 | + 'FeatureOneCategory', |
|
| 111 | + _t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'), |
|
| 112 | + singleton(BaseHomePage::class)->dbObject('FeatureOneCategory')->enumValues() |
|
| 113 | + ), |
|
| 114 | + HTMLEditorField::create( |
|
| 115 | + 'FeatureOneContent', |
|
| 116 | + _t(__CLASS__ . '.FeatureContentFieldLabel', 'Content') |
|
| 117 | + ), |
|
| 118 | + TextField::create( |
|
| 119 | + 'FeatureOneButtonText', |
|
| 120 | + _t(__CLASS__ . '.FeatureButtonText', 'Button text') |
|
| 121 | + ), |
|
| 122 | + TreeDropdownField::create( |
|
| 123 | + 'FeatureOneLinkID', |
|
| 124 | + _t(__CLASS__ . '.FeatureLink', 'Page to link to'), |
|
| 125 | + SiteTree::class |
|
| 126 | + )->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in')) |
|
| 127 | + ) |
|
| 128 | + )->setHeadingLevel(3) |
|
| 129 | + ); |
|
| 130 | + $dropdownField->setEmptyString('none'); |
|
| 131 | + |
|
| 132 | + $fields->addFieldToTab('Root.Features', ToggleCompositeField::create( |
|
| 133 | + 'FeatureTwo', |
|
| 134 | + _t(__CLASS__ . '.FeatureTwo', 'Feature Two'), |
|
| 135 | + array( |
|
| 136 | + TextField::create('FeatureTwoTitle', _t(__CLASS__ . '.Title', 'Title')), |
|
| 137 | + $dropdownField = DropdownField::create( |
|
| 138 | + 'FeatureTwoCategory', |
|
| 139 | + _t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'), |
|
| 140 | + singleton(BaseHomePage::class)->dbObject('FeatureTwoCategory')->enumValues() |
|
| 141 | + ), |
|
| 142 | + HTMLEditorField::create( |
|
| 143 | + 'FeatureTwoContent', |
|
| 144 | + _t(__CLASS__ . '.FeatureContentFieldLabel', 'Content') |
|
| 145 | + ), |
|
| 146 | + TextField::create( |
|
| 147 | + 'FeatureTwoButtonText', |
|
| 148 | + _t(__CLASS__ . '.FeatureButtonText', 'Button text') |
|
| 149 | + ), |
|
| 150 | + TreeDropdownField::create( |
|
| 151 | + 'FeatureTwoLinkID', |
|
| 152 | + _t(__CLASS__ . '.FeatureLink', 'Page to link to'), |
|
| 153 | + SiteTree::class |
|
| 154 | + )->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in')) |
|
| 155 | + ) |
|
| 156 | + )->setHeadingLevel(3)); |
|
| 157 | + $dropdownField->setEmptyString('none'); |
|
| 158 | + }); |
|
| 159 | + |
|
| 160 | + return parent::getCMSFields(); |
|
| 161 | + } |
|
| 162 | 162 | } |
@@ -12,81 +12,81 @@ |
||
| 12 | 12 | |
| 13 | 13 | class EventPage extends DatedUpdatePage |
| 14 | 14 | { |
| 15 | - private static $description = 'Describes an event occurring on a specific date.'; |
|
| 16 | - |
|
| 17 | - private static $default_parent = EventHolder::class; |
|
| 18 | - |
|
| 19 | - private static $can_be_root = false; |
|
| 20 | - |
|
| 21 | - private static $icon = 'cwp/cwp:images/icons/sitetree_images/event_page.png'; |
|
| 22 | - |
|
| 23 | - private static $singular_name = 'Event Page'; |
|
| 24 | - |
|
| 25 | - private static $plural_name = 'Event Pages'; |
|
| 26 | - |
|
| 27 | - private static $db = [ |
|
| 28 | - 'StartTime' => 'Time', |
|
| 29 | - 'EndTime' => 'Time', |
|
| 30 | - 'Location' => 'Text', |
|
| 31 | - ]; |
|
| 32 | - |
|
| 33 | - private static $table_name = 'EventPage'; |
|
| 34 | - |
|
| 35 | - public function fieldLabels($includerelations = true) |
|
| 36 | - { |
|
| 37 | - $labels = parent::fieldLabels($includerelations); |
|
| 38 | - $labels['StartTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.StartTimeFieldLabel', 'Start Time'); |
|
| 39 | - $labels['EndTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.EndTimeFieldLabel', 'End Time'); |
|
| 40 | - $labels['Location'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.LocationFieldLabel', 'Location'); |
|
| 41 | - |
|
| 42 | - return $labels; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Add the default for the Date being the current day. |
|
| 47 | - */ |
|
| 48 | - public function populateDefaults() |
|
| 49 | - { |
|
| 50 | - if (!isset($this->Date) || $this->Date === null) { |
|
| 51 | - $this->Date = DBDatetime::now()->Format('y-MM-dd'); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if (!isset($this->StartTime) || $this->StartTime === null) { |
|
| 55 | - $this->StartTime = '09:00:00'; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - if (!isset($this->EndTime) || $this->EndTime === null) { |
|
| 59 | - $this->EndTime = '17:00:00'; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - parent::populateDefaults(); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - public function getCMSFields() |
|
| 66 | - { |
|
| 67 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 68 | - $fields->removeByName('Date'); |
|
| 69 | - |
|
| 70 | - $dateTimeFields = array(); |
|
| 71 | - |
|
| 72 | - $dateTimeFields[] = $dateField = DateField::create('Date', 'Date'); |
|
| 73 | - $dateTimeFields[] = $startTimeField = TimeField::create( |
|
| 74 | - 'StartTime', |
|
| 75 | - $this->fieldLabel('StartTime') |
|
| 76 | - ); |
|
| 77 | - $dateTimeFields[] = $endTimeField = TimeField::create('EndTime', $this->fieldLabel('EndTime')); |
|
| 78 | - |
|
| 79 | - $fields->addFieldsToTab('Root.Main', [ |
|
| 80 | - $dateTimeField = FieldGroup::create('Date and time', $dateTimeFields), |
|
| 81 | - $locationField = TextareaField::create('Location', $this->fieldLabel('Location')) |
|
| 82 | - ], 'Abstract'); |
|
| 83 | - $locationField->setRows(4); |
|
| 84 | - }); |
|
| 85 | - return parent::getCMSFields(); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - public function NiceLocation() |
|
| 89 | - { |
|
| 90 | - return nl2br(Convert::raw2xml($this->Location), true); |
|
| 91 | - } |
|
| 15 | + private static $description = 'Describes an event occurring on a specific date.'; |
|
| 16 | + |
|
| 17 | + private static $default_parent = EventHolder::class; |
|
| 18 | + |
|
| 19 | + private static $can_be_root = false; |
|
| 20 | + |
|
| 21 | + private static $icon = 'cwp/cwp:images/icons/sitetree_images/event_page.png'; |
|
| 22 | + |
|
| 23 | + private static $singular_name = 'Event Page'; |
|
| 24 | + |
|
| 25 | + private static $plural_name = 'Event Pages'; |
|
| 26 | + |
|
| 27 | + private static $db = [ |
|
| 28 | + 'StartTime' => 'Time', |
|
| 29 | + 'EndTime' => 'Time', |
|
| 30 | + 'Location' => 'Text', |
|
| 31 | + ]; |
|
| 32 | + |
|
| 33 | + private static $table_name = 'EventPage'; |
|
| 34 | + |
|
| 35 | + public function fieldLabels($includerelations = true) |
|
| 36 | + { |
|
| 37 | + $labels = parent::fieldLabels($includerelations); |
|
| 38 | + $labels['StartTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.StartTimeFieldLabel', 'Start Time'); |
|
| 39 | + $labels['EndTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.EndTimeFieldLabel', 'End Time'); |
|
| 40 | + $labels['Location'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.LocationFieldLabel', 'Location'); |
|
| 41 | + |
|
| 42 | + return $labels; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Add the default for the Date being the current day. |
|
| 47 | + */ |
|
| 48 | + public function populateDefaults() |
|
| 49 | + { |
|
| 50 | + if (!isset($this->Date) || $this->Date === null) { |
|
| 51 | + $this->Date = DBDatetime::now()->Format('y-MM-dd'); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if (!isset($this->StartTime) || $this->StartTime === null) { |
|
| 55 | + $this->StartTime = '09:00:00'; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + if (!isset($this->EndTime) || $this->EndTime === null) { |
|
| 59 | + $this->EndTime = '17:00:00'; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + parent::populateDefaults(); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + public function getCMSFields() |
|
| 66 | + { |
|
| 67 | + $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 68 | + $fields->removeByName('Date'); |
|
| 69 | + |
|
| 70 | + $dateTimeFields = array(); |
|
| 71 | + |
|
| 72 | + $dateTimeFields[] = $dateField = DateField::create('Date', 'Date'); |
|
| 73 | + $dateTimeFields[] = $startTimeField = TimeField::create( |
|
| 74 | + 'StartTime', |
|
| 75 | + $this->fieldLabel('StartTime') |
|
| 76 | + ); |
|
| 77 | + $dateTimeFields[] = $endTimeField = TimeField::create('EndTime', $this->fieldLabel('EndTime')); |
|
| 78 | + |
|
| 79 | + $fields->addFieldsToTab('Root.Main', [ |
|
| 80 | + $dateTimeField = FieldGroup::create('Date and time', $dateTimeFields), |
|
| 81 | + $locationField = TextareaField::create('Location', $this->fieldLabel('Location')) |
|
| 82 | + ], 'Abstract'); |
|
| 83 | + $locationField->setRows(4); |
|
| 84 | + }); |
|
| 85 | + return parent::getCMSFields(); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + public function NiceLocation() |
|
| 89 | + { |
|
| 90 | + return nl2br(Convert::raw2xml($this->Location), true); |
|
| 91 | + } |
|
| 92 | 92 | } |
@@ -34,361 +34,361 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | class DatedUpdateHolderController extends PageController |
| 36 | 36 | { |
| 37 | - private static $allowed_actions = [ |
|
| 38 | - 'rss', |
|
| 39 | - 'atom', |
|
| 40 | - 'DateRangeForm', |
|
| 41 | - ]; |
|
| 42 | - |
|
| 43 | - private static $casting = [ |
|
| 44 | - 'MetaTitle' => 'Text', |
|
| 45 | - 'FilterDescription' => 'Text', |
|
| 46 | - ]; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * The session key for storing temporary form messages |
|
| 50 | - * |
|
| 51 | - * @var string |
|
| 52 | - */ |
|
| 53 | - const TEMP_FORM_MESSAGE = __CLASS__ . '.TempFormMessage'; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Get the meta title for the current action |
|
| 57 | - * |
|
| 58 | - * @return string |
|
| 59 | - */ |
|
| 60 | - public function getMetaTitle() |
|
| 61 | - { |
|
| 62 | - $title = $this->data()->getTitle(); |
|
| 63 | - $filter = $this->FilterDescription(); |
|
| 64 | - if ($filter) { |
|
| 65 | - $title = "{$title} - {$filter}"; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - $this->extend('updateMetaTitle', $title); |
|
| 69 | - return $title; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Returns a description of the current filter |
|
| 74 | - * |
|
| 75 | - * @return string |
|
| 76 | - */ |
|
| 77 | - public function FilterDescription() |
|
| 78 | - { |
|
| 79 | - $params = $this->parseParams(); |
|
| 80 | - |
|
| 81 | - $filters = array(); |
|
| 82 | - if ($params['tag']) { |
|
| 83 | - $term = TaxonomyTerm::get_by_id(TaxonomyTerm::class, $params['tag']); |
|
| 84 | - if ($term) { |
|
| 85 | - $filters[] = _t( |
|
| 86 | - 'CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_WITHIN', |
|
| 87 | - 'within' |
|
| 88 | - ) . ' "' . $term->Name . '"'; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - if ($params['from'] || $params['to']) { |
|
| 93 | - if ($params['from']) { |
|
| 94 | - $from = strtotime($params['from']); |
|
| 95 | - if ($params['to']) { |
|
| 96 | - $to = strtotime($params['to']); |
|
| 97 | - $filters[] = _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_BETWEEN', 'between') . ' ' |
|
| 98 | - . date('j/m/Y', $from) . ' and ' . date('j/m/Y', $to); |
|
| 99 | - } else { |
|
| 100 | - $filters[] = _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_ON', 'on') |
|
| 101 | - . ' ' . date('j/m/Y', $from); |
|
| 102 | - } |
|
| 103 | - } else { |
|
| 104 | - $to = strtotime($params['to']); |
|
| 105 | - $filters[] = _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_ON', 'on') |
|
| 106 | - . ' ' . date('j/m/Y', $to); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - if ($params['year'] && $params['month']) { |
|
| 111 | - $timestamp = mktime(1, 1, 1, $params['month'], 1, $params['year']); |
|
| 112 | - $filters[] = _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_IN', 'in') |
|
| 113 | - . ' ' . date('F', $timestamp) . ' ' . $params['year']; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - if ($filters) { |
|
| 117 | - return $this->getUpdateName() . ' ' . implode(' ', $filters); |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - public function getUpdateName() |
|
| 122 | - { |
|
| 123 | - return Config::inst()->get($this->data()->ClassName, 'update_name'); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - protected function init() |
|
| 127 | - { |
|
| 128 | - parent::init(); |
|
| 129 | - RSSFeed::linkToFeed($this->Link() . 'rss', $this->getSubscriptionTitle()); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Parse URL parameters. |
|
| 134 | - * |
|
| 135 | - * @param bool $produceErrorMessages Set to false to omit session messages. |
|
| 136 | - */ |
|
| 137 | - public function parseParams($produceErrorMessages = true) |
|
| 138 | - { |
|
| 139 | - $tag = $this->request->getVar('tag'); |
|
| 140 | - $from = $this->request->getVar('from'); |
|
| 141 | - $to = $this->request->getVar('to'); |
|
| 142 | - $year = $this->request->getVar('year'); |
|
| 143 | - $month = $this->request->getVar('month'); |
|
| 144 | - |
|
| 145 | - if ($tag == '') { |
|
| 146 | - $tag = null; |
|
| 147 | - } |
|
| 148 | - if ($from == '') { |
|
| 149 | - $from = null; |
|
| 150 | - } |
|
| 151 | - if ($to == '') { |
|
| 152 | - $to = null; |
|
| 153 | - } |
|
| 154 | - if ($year == '') { |
|
| 155 | - $year = null; |
|
| 156 | - } |
|
| 157 | - if ($month == '') { |
|
| 158 | - $month = null; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - if (isset($tag)) { |
|
| 162 | - $tag = (int)$tag; |
|
| 163 | - } |
|
| 164 | - if (isset($from)) { |
|
| 165 | - $from = urldecode($from); |
|
| 166 | - $parser = DBDatetime::create(); |
|
| 167 | - $parser->setValue($from); |
|
| 168 | - $from = $parser->Format('y-MM-dd'); |
|
| 169 | - } |
|
| 170 | - if (isset($to)) { |
|
| 171 | - $to = urldecode($to); |
|
| 172 | - $parser = DBDatetime::create(); |
|
| 173 | - $parser->setValue($to); |
|
| 174 | - $to = $parser->Format('y-MM-dd'); |
|
| 175 | - } |
|
| 176 | - if (isset($year)) { |
|
| 177 | - $year = (int)$year; |
|
| 178 | - } |
|
| 179 | - if (isset($month)) { |
|
| 180 | - $month = (int)$month; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - // If only "To" has been provided filter by single date. Normalise by swapping with "From". |
|
| 184 | - if (isset($to) && !isset($from)) { |
|
| 185 | - list($to, $from) = [$from, $to]; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - // Flip the dates if the order is wrong. |
|
| 189 | - if (isset($to) && isset($from) && strtotime($from) > strtotime($to)) { |
|
| 190 | - list($to, $from) = [$from, $to]; |
|
| 191 | - |
|
| 192 | - if ($produceErrorMessages) { |
|
| 193 | - $this->getRequest()->getSession()->set(self::TEMP_FORM_MESSAGE, _t( |
|
| 194 | - __CLASS__ . '.FilterAppliedMessage', |
|
| 195 | - 'Filter has been applied with the dates reversed.' |
|
| 196 | - )); |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - // Notify the user that filtering by single date is taking place. |
|
| 201 | - if (isset($from) && !isset($to)) { |
|
| 202 | - if ($produceErrorMessages) { |
|
| 203 | - $this->getRequest()->getSession()->set(self::TEMP_FORM_MESSAGE, _t( |
|
| 204 | - __CLASS__ . '.DateRangeFilterMessage', |
|
| 205 | - 'Filtered by a single date.' |
|
| 206 | - )); |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - return [ |
|
| 211 | - 'tag' => $tag, |
|
| 212 | - 'from' => $from, |
|
| 213 | - 'to' => $to, |
|
| 214 | - 'year' => $year, |
|
| 215 | - 'month' => $month, |
|
| 216 | - ]; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Build the link - keep the date range, reset the rest. |
|
| 221 | - */ |
|
| 222 | - public function AllTagsLink() |
|
| 223 | - { |
|
| 224 | - $link = HTTP::setGetVar('tag', null, null, '&'); |
|
| 225 | - $link = HTTP::setGetVar('month', null, $link, '&'); |
|
| 226 | - $link = HTTP::setGetVar('year', null, $link, '&'); |
|
| 227 | - $link = HTTP::setGetVar('start', null, $link, '&'); |
|
| 228 | - |
|
| 229 | - return $link; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * List tags and attach links. |
|
| 234 | - */ |
|
| 235 | - public function UpdateTagsWithLinks() |
|
| 236 | - { |
|
| 237 | - $tags = $this->UpdateTags(); |
|
| 238 | - |
|
| 239 | - $processed = ArrayList::create(); |
|
| 240 | - |
|
| 241 | - foreach ($tags as $tag) { |
|
| 242 | - // Build the link - keep the tag, and date range, but reset month, year and pagination. |
|
| 243 | - $link = HTTP::setGetVar('tag', $tag->ID, null, '&'); |
|
| 244 | - $link = HTTP::setGetVar('month', null, $link, '&'); |
|
| 245 | - $link = HTTP::setGetVar('year', null, $link, '&'); |
|
| 246 | - $link = HTTP::setGetVar('start', null, $link, '&'); |
|
| 247 | - |
|
| 248 | - $tag->Link = $link; |
|
| 249 | - $processed->push($tag); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - return $processed; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * Get the TaxonomyTerm related to the current tag GET parameter. |
|
| 257 | - */ |
|
| 258 | - public function CurrentTag() |
|
| 259 | - { |
|
| 260 | - $tagID = $this->request->getVar('tag'); |
|
| 261 | - |
|
| 262 | - if (isset($tagID)) { |
|
| 263 | - return TaxonomyTerm::get_by_id(TaxonomyTerm::class, (int)$tagID); |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * Extract the available months based on the current query. |
|
| 269 | - * Only tag is respected. Pagination and months are ignored. |
|
| 270 | - */ |
|
| 271 | - public function AvailableMonths() |
|
| 272 | - { |
|
| 273 | - $params = $this->parseParams(); |
|
| 274 | - |
|
| 275 | - return DatedUpdateHolder::ExtractMonths( |
|
| 276 | - $this->Updates($params['tag'], $params['from'], $params['to']), |
|
| 277 | - Director::makeRelative($_SERVER['REQUEST_URI']), |
|
| 278 | - $params['year'], |
|
| 279 | - $params['month'] |
|
| 280 | - ); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * Get the updates based on the current query. |
|
| 285 | - */ |
|
| 286 | - public function FilteredUpdates($pageSize = 20) |
|
| 287 | - { |
|
| 288 | - $params = $this->parseParams(); |
|
| 289 | - |
|
| 290 | - $items = $this->Updates( |
|
| 291 | - $params['tag'], |
|
| 292 | - $params['from'], |
|
| 293 | - $params['to'], |
|
| 294 | - $params['year'], |
|
| 295 | - $params['month'] |
|
| 296 | - ); |
|
| 297 | - |
|
| 298 | - // Apply pagination |
|
| 299 | - $list = PaginatedList::create($items, $this->getRequest()); |
|
| 300 | - $list->setPageLength($pageSize); |
|
| 301 | - return $list; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * @return Form |
|
| 306 | - */ |
|
| 307 | - public function DateRangeForm() |
|
| 308 | - { |
|
| 309 | - $dateFromTitle = DBField::create_field('HTMLText', sprintf( |
|
| 310 | - '%s <span class="field-note">%s</span>', |
|
| 311 | - _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FROM_DATE', 'From date'), |
|
| 312 | - _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.DATE_EXAMPLE', '(example: 30/12/2017)') |
|
| 313 | - )); |
|
| 314 | - $dateToTitle = DBField::create_field('HTMLText', sprintf( |
|
| 315 | - '%s <span class="field-note">%s</span>', |
|
| 316 | - _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.TO_DATE', 'To date'), |
|
| 317 | - _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.DATE_EXAMPLE', '(example: 30/12/2017)') |
|
| 318 | - )); |
|
| 319 | - |
|
| 320 | - $fields = FieldList::create( |
|
| 321 | - DateField::create('from', $dateFromTitle), |
|
| 322 | - DateField::create('to', $dateToTitle), |
|
| 323 | - HiddenField::create('tag') |
|
| 324 | - ); |
|
| 325 | - |
|
| 326 | - $actions = FieldList::create( |
|
| 327 | - FormAction::create("doDateFilter") |
|
| 328 | - ->setTitle(_t(__CLASS__ . '.Filter', 'Filter')) |
|
| 329 | - ->addExtraClass('btn btn-primary primary'), |
|
| 330 | - FormAction::create("doDateReset") |
|
| 331 | - ->setTitle(_t(__CLASS__ . '.Clear', 'Clear')) |
|
| 332 | - ->addExtraClass('btn') |
|
| 333 | - ); |
|
| 334 | - |
|
| 335 | - $form = Form::create($this, 'DateRangeForm', $fields, $actions); |
|
| 336 | - $form->loadDataFrom($this->request->getVars()); |
|
| 337 | - $form->setFormMethod('get'); |
|
| 338 | - |
|
| 339 | - // Add any locally stored form messages before returning |
|
| 340 | - if ($formMessage = $this->getRequest()->getSession()->get(self::TEMP_FORM_MESSAGE)) { |
|
| 341 | - $form->setMessage($formMessage, ValidationResult::TYPE_WARNING); |
|
| 342 | - $this->getRequest()->getSession()->clear(self::TEMP_FORM_MESSAGE); |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - return $form; |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - public function doDateFilter() |
|
| 349 | - { |
|
| 350 | - $params = $this->parseParams(); |
|
| 351 | - |
|
| 352 | - // Build the link - keep the tag, but reset month, year and pagination. |
|
| 353 | - $link = HTTP::setGetVar('from', $params['from'], $this->AbsoluteLink(), '&'); |
|
| 354 | - $link = HTTP::setGetVar('to', $params['to'], $link, '&'); |
|
| 355 | - if (isset($params['tag'])) { |
|
| 356 | - $link = HTTP::setGetVar('tag', $params['tag'], $link, '&'); |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - $this->redirect($link); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - public function doDateReset() |
|
| 363 | - { |
|
| 364 | - $params = $this->parseParams(false); |
|
| 365 | - |
|
| 366 | - // Reset the link - only include the tag. |
|
| 367 | - $link = $this->AbsoluteLink(); |
|
| 368 | - if (isset($params['tag'])) { |
|
| 369 | - $link = HTTP::setGetVar('tag', $params['tag'], $link, '&'); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - $this->redirect($link); |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - public function rss() |
|
| 376 | - { |
|
| 377 | - $rss = RSSFeed::create( |
|
| 378 | - $this->Updates()->sort('Created DESC')->limit(20), |
|
| 379 | - $this->Link('rss'), |
|
| 380 | - $this->getSubscriptionTitle() |
|
| 381 | - ); |
|
| 382 | - return $rss->outputToBrowser(); |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - public function atom() |
|
| 386 | - { |
|
| 387 | - $atom = CwpAtomFeed::create( |
|
| 388 | - $this->Updates()->sort('Created DESC')->limit(20), |
|
| 389 | - $this->Link('atom'), |
|
| 390 | - $this->getSubscriptionTitle() |
|
| 391 | - ); |
|
| 392 | - return $atom->outputToBrowser(); |
|
| 393 | - } |
|
| 37 | + private static $allowed_actions = [ |
|
| 38 | + 'rss', |
|
| 39 | + 'atom', |
|
| 40 | + 'DateRangeForm', |
|
| 41 | + ]; |
|
| 42 | + |
|
| 43 | + private static $casting = [ |
|
| 44 | + 'MetaTitle' => 'Text', |
|
| 45 | + 'FilterDescription' => 'Text', |
|
| 46 | + ]; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * The session key for storing temporary form messages |
|
| 50 | + * |
|
| 51 | + * @var string |
|
| 52 | + */ |
|
| 53 | + const TEMP_FORM_MESSAGE = __CLASS__ . '.TempFormMessage'; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Get the meta title for the current action |
|
| 57 | + * |
|
| 58 | + * @return string |
|
| 59 | + */ |
|
| 60 | + public function getMetaTitle() |
|
| 61 | + { |
|
| 62 | + $title = $this->data()->getTitle(); |
|
| 63 | + $filter = $this->FilterDescription(); |
|
| 64 | + if ($filter) { |
|
| 65 | + $title = "{$title} - {$filter}"; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + $this->extend('updateMetaTitle', $title); |
|
| 69 | + return $title; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Returns a description of the current filter |
|
| 74 | + * |
|
| 75 | + * @return string |
|
| 76 | + */ |
|
| 77 | + public function FilterDescription() |
|
| 78 | + { |
|
| 79 | + $params = $this->parseParams(); |
|
| 80 | + |
|
| 81 | + $filters = array(); |
|
| 82 | + if ($params['tag']) { |
|
| 83 | + $term = TaxonomyTerm::get_by_id(TaxonomyTerm::class, $params['tag']); |
|
| 84 | + if ($term) { |
|
| 85 | + $filters[] = _t( |
|
| 86 | + 'CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_WITHIN', |
|
| 87 | + 'within' |
|
| 88 | + ) . ' "' . $term->Name . '"'; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + if ($params['from'] || $params['to']) { |
|
| 93 | + if ($params['from']) { |
|
| 94 | + $from = strtotime($params['from']); |
|
| 95 | + if ($params['to']) { |
|
| 96 | + $to = strtotime($params['to']); |
|
| 97 | + $filters[] = _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_BETWEEN', 'between') . ' ' |
|
| 98 | + . date('j/m/Y', $from) . ' and ' . date('j/m/Y', $to); |
|
| 99 | + } else { |
|
| 100 | + $filters[] = _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_ON', 'on') |
|
| 101 | + . ' ' . date('j/m/Y', $from); |
|
| 102 | + } |
|
| 103 | + } else { |
|
| 104 | + $to = strtotime($params['to']); |
|
| 105 | + $filters[] = _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_ON', 'on') |
|
| 106 | + . ' ' . date('j/m/Y', $to); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + if ($params['year'] && $params['month']) { |
|
| 111 | + $timestamp = mktime(1, 1, 1, $params['month'], 1, $params['year']); |
|
| 112 | + $filters[] = _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_IN', 'in') |
|
| 113 | + . ' ' . date('F', $timestamp) . ' ' . $params['year']; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + if ($filters) { |
|
| 117 | + return $this->getUpdateName() . ' ' . implode(' ', $filters); |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + public function getUpdateName() |
|
| 122 | + { |
|
| 123 | + return Config::inst()->get($this->data()->ClassName, 'update_name'); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + protected function init() |
|
| 127 | + { |
|
| 128 | + parent::init(); |
|
| 129 | + RSSFeed::linkToFeed($this->Link() . 'rss', $this->getSubscriptionTitle()); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Parse URL parameters. |
|
| 134 | + * |
|
| 135 | + * @param bool $produceErrorMessages Set to false to omit session messages. |
|
| 136 | + */ |
|
| 137 | + public function parseParams($produceErrorMessages = true) |
|
| 138 | + { |
|
| 139 | + $tag = $this->request->getVar('tag'); |
|
| 140 | + $from = $this->request->getVar('from'); |
|
| 141 | + $to = $this->request->getVar('to'); |
|
| 142 | + $year = $this->request->getVar('year'); |
|
| 143 | + $month = $this->request->getVar('month'); |
|
| 144 | + |
|
| 145 | + if ($tag == '') { |
|
| 146 | + $tag = null; |
|
| 147 | + } |
|
| 148 | + if ($from == '') { |
|
| 149 | + $from = null; |
|
| 150 | + } |
|
| 151 | + if ($to == '') { |
|
| 152 | + $to = null; |
|
| 153 | + } |
|
| 154 | + if ($year == '') { |
|
| 155 | + $year = null; |
|
| 156 | + } |
|
| 157 | + if ($month == '') { |
|
| 158 | + $month = null; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + if (isset($tag)) { |
|
| 162 | + $tag = (int)$tag; |
|
| 163 | + } |
|
| 164 | + if (isset($from)) { |
|
| 165 | + $from = urldecode($from); |
|
| 166 | + $parser = DBDatetime::create(); |
|
| 167 | + $parser->setValue($from); |
|
| 168 | + $from = $parser->Format('y-MM-dd'); |
|
| 169 | + } |
|
| 170 | + if (isset($to)) { |
|
| 171 | + $to = urldecode($to); |
|
| 172 | + $parser = DBDatetime::create(); |
|
| 173 | + $parser->setValue($to); |
|
| 174 | + $to = $parser->Format('y-MM-dd'); |
|
| 175 | + } |
|
| 176 | + if (isset($year)) { |
|
| 177 | + $year = (int)$year; |
|
| 178 | + } |
|
| 179 | + if (isset($month)) { |
|
| 180 | + $month = (int)$month; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + // If only "To" has been provided filter by single date. Normalise by swapping with "From". |
|
| 184 | + if (isset($to) && !isset($from)) { |
|
| 185 | + list($to, $from) = [$from, $to]; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + // Flip the dates if the order is wrong. |
|
| 189 | + if (isset($to) && isset($from) && strtotime($from) > strtotime($to)) { |
|
| 190 | + list($to, $from) = [$from, $to]; |
|
| 191 | + |
|
| 192 | + if ($produceErrorMessages) { |
|
| 193 | + $this->getRequest()->getSession()->set(self::TEMP_FORM_MESSAGE, _t( |
|
| 194 | + __CLASS__ . '.FilterAppliedMessage', |
|
| 195 | + 'Filter has been applied with the dates reversed.' |
|
| 196 | + )); |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + // Notify the user that filtering by single date is taking place. |
|
| 201 | + if (isset($from) && !isset($to)) { |
|
| 202 | + if ($produceErrorMessages) { |
|
| 203 | + $this->getRequest()->getSession()->set(self::TEMP_FORM_MESSAGE, _t( |
|
| 204 | + __CLASS__ . '.DateRangeFilterMessage', |
|
| 205 | + 'Filtered by a single date.' |
|
| 206 | + )); |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + return [ |
|
| 211 | + 'tag' => $tag, |
|
| 212 | + 'from' => $from, |
|
| 213 | + 'to' => $to, |
|
| 214 | + 'year' => $year, |
|
| 215 | + 'month' => $month, |
|
| 216 | + ]; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Build the link - keep the date range, reset the rest. |
|
| 221 | + */ |
|
| 222 | + public function AllTagsLink() |
|
| 223 | + { |
|
| 224 | + $link = HTTP::setGetVar('tag', null, null, '&'); |
|
| 225 | + $link = HTTP::setGetVar('month', null, $link, '&'); |
|
| 226 | + $link = HTTP::setGetVar('year', null, $link, '&'); |
|
| 227 | + $link = HTTP::setGetVar('start', null, $link, '&'); |
|
| 228 | + |
|
| 229 | + return $link; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * List tags and attach links. |
|
| 234 | + */ |
|
| 235 | + public function UpdateTagsWithLinks() |
|
| 236 | + { |
|
| 237 | + $tags = $this->UpdateTags(); |
|
| 238 | + |
|
| 239 | + $processed = ArrayList::create(); |
|
| 240 | + |
|
| 241 | + foreach ($tags as $tag) { |
|
| 242 | + // Build the link - keep the tag, and date range, but reset month, year and pagination. |
|
| 243 | + $link = HTTP::setGetVar('tag', $tag->ID, null, '&'); |
|
| 244 | + $link = HTTP::setGetVar('month', null, $link, '&'); |
|
| 245 | + $link = HTTP::setGetVar('year', null, $link, '&'); |
|
| 246 | + $link = HTTP::setGetVar('start', null, $link, '&'); |
|
| 247 | + |
|
| 248 | + $tag->Link = $link; |
|
| 249 | + $processed->push($tag); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + return $processed; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * Get the TaxonomyTerm related to the current tag GET parameter. |
|
| 257 | + */ |
|
| 258 | + public function CurrentTag() |
|
| 259 | + { |
|
| 260 | + $tagID = $this->request->getVar('tag'); |
|
| 261 | + |
|
| 262 | + if (isset($tagID)) { |
|
| 263 | + return TaxonomyTerm::get_by_id(TaxonomyTerm::class, (int)$tagID); |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * Extract the available months based on the current query. |
|
| 269 | + * Only tag is respected. Pagination and months are ignored. |
|
| 270 | + */ |
|
| 271 | + public function AvailableMonths() |
|
| 272 | + { |
|
| 273 | + $params = $this->parseParams(); |
|
| 274 | + |
|
| 275 | + return DatedUpdateHolder::ExtractMonths( |
|
| 276 | + $this->Updates($params['tag'], $params['from'], $params['to']), |
|
| 277 | + Director::makeRelative($_SERVER['REQUEST_URI']), |
|
| 278 | + $params['year'], |
|
| 279 | + $params['month'] |
|
| 280 | + ); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * Get the updates based on the current query. |
|
| 285 | + */ |
|
| 286 | + public function FilteredUpdates($pageSize = 20) |
|
| 287 | + { |
|
| 288 | + $params = $this->parseParams(); |
|
| 289 | + |
|
| 290 | + $items = $this->Updates( |
|
| 291 | + $params['tag'], |
|
| 292 | + $params['from'], |
|
| 293 | + $params['to'], |
|
| 294 | + $params['year'], |
|
| 295 | + $params['month'] |
|
| 296 | + ); |
|
| 297 | + |
|
| 298 | + // Apply pagination |
|
| 299 | + $list = PaginatedList::create($items, $this->getRequest()); |
|
| 300 | + $list->setPageLength($pageSize); |
|
| 301 | + return $list; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * @return Form |
|
| 306 | + */ |
|
| 307 | + public function DateRangeForm() |
|
| 308 | + { |
|
| 309 | + $dateFromTitle = DBField::create_field('HTMLText', sprintf( |
|
| 310 | + '%s <span class="field-note">%s</span>', |
|
| 311 | + _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FROM_DATE', 'From date'), |
|
| 312 | + _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.DATE_EXAMPLE', '(example: 30/12/2017)') |
|
| 313 | + )); |
|
| 314 | + $dateToTitle = DBField::create_field('HTMLText', sprintf( |
|
| 315 | + '%s <span class="field-note">%s</span>', |
|
| 316 | + _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.TO_DATE', 'To date'), |
|
| 317 | + _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.DATE_EXAMPLE', '(example: 30/12/2017)') |
|
| 318 | + )); |
|
| 319 | + |
|
| 320 | + $fields = FieldList::create( |
|
| 321 | + DateField::create('from', $dateFromTitle), |
|
| 322 | + DateField::create('to', $dateToTitle), |
|
| 323 | + HiddenField::create('tag') |
|
| 324 | + ); |
|
| 325 | + |
|
| 326 | + $actions = FieldList::create( |
|
| 327 | + FormAction::create("doDateFilter") |
|
| 328 | + ->setTitle(_t(__CLASS__ . '.Filter', 'Filter')) |
|
| 329 | + ->addExtraClass('btn btn-primary primary'), |
|
| 330 | + FormAction::create("doDateReset") |
|
| 331 | + ->setTitle(_t(__CLASS__ . '.Clear', 'Clear')) |
|
| 332 | + ->addExtraClass('btn') |
|
| 333 | + ); |
|
| 334 | + |
|
| 335 | + $form = Form::create($this, 'DateRangeForm', $fields, $actions); |
|
| 336 | + $form->loadDataFrom($this->request->getVars()); |
|
| 337 | + $form->setFormMethod('get'); |
|
| 338 | + |
|
| 339 | + // Add any locally stored form messages before returning |
|
| 340 | + if ($formMessage = $this->getRequest()->getSession()->get(self::TEMP_FORM_MESSAGE)) { |
|
| 341 | + $form->setMessage($formMessage, ValidationResult::TYPE_WARNING); |
|
| 342 | + $this->getRequest()->getSession()->clear(self::TEMP_FORM_MESSAGE); |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + return $form; |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + public function doDateFilter() |
|
| 349 | + { |
|
| 350 | + $params = $this->parseParams(); |
|
| 351 | + |
|
| 352 | + // Build the link - keep the tag, but reset month, year and pagination. |
|
| 353 | + $link = HTTP::setGetVar('from', $params['from'], $this->AbsoluteLink(), '&'); |
|
| 354 | + $link = HTTP::setGetVar('to', $params['to'], $link, '&'); |
|
| 355 | + if (isset($params['tag'])) { |
|
| 356 | + $link = HTTP::setGetVar('tag', $params['tag'], $link, '&'); |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + $this->redirect($link); |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + public function doDateReset() |
|
| 363 | + { |
|
| 364 | + $params = $this->parseParams(false); |
|
| 365 | + |
|
| 366 | + // Reset the link - only include the tag. |
|
| 367 | + $link = $this->AbsoluteLink(); |
|
| 368 | + if (isset($params['tag'])) { |
|
| 369 | + $link = HTTP::setGetVar('tag', $params['tag'], $link, '&'); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + $this->redirect($link); |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + public function rss() |
|
| 376 | + { |
|
| 377 | + $rss = RSSFeed::create( |
|
| 378 | + $this->Updates()->sort('Created DESC')->limit(20), |
|
| 379 | + $this->Link('rss'), |
|
| 380 | + $this->getSubscriptionTitle() |
|
| 381 | + ); |
|
| 382 | + return $rss->outputToBrowser(); |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + public function atom() |
|
| 386 | + { |
|
| 387 | + $atom = CwpAtomFeed::create( |
|
| 388 | + $this->Updates()->sort('Created DESC')->limit(20), |
|
| 389 | + $this->Link('atom'), |
|
| 390 | + $this->getSubscriptionTitle() |
|
| 391 | + ); |
|
| 392 | + return $atom->outputToBrowser(); |
|
| 393 | + } |
|
| 394 | 394 | } |
@@ -10,17 +10,17 @@ |
||
| 10 | 10 | class TaxonomyTermExtension extends DataExtension |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - private static $api_access = true; |
|
| 13 | + private static $api_access = true; |
|
| 14 | 14 | |
| 15 | - private static $belongs_many_many = array( |
|
| 16 | - 'Pages' => BasePage::class |
|
| 17 | - ); |
|
| 15 | + private static $belongs_many_many = array( |
|
| 16 | + 'Pages' => BasePage::class |
|
| 17 | + ); |
|
| 18 | 18 | |
| 19 | - public function updateCMSFields(FieldList $fields) |
|
| 20 | - { |
|
| 21 | - $pagesGridField = $fields->dataFieldByName('Pages'); |
|
| 22 | - if ($pagesGridField) { |
|
| 23 | - $pagesGridField->getConfig()->removeComponentsByType(GridFieldAddNewButton::class); |
|
| 24 | - } |
|
| 25 | - } |
|
| 19 | + public function updateCMSFields(FieldList $fields) |
|
| 20 | + { |
|
| 21 | + $pagesGridField = $fields->dataFieldByName('Pages'); |
|
| 22 | + if ($pagesGridField) { |
|
| 23 | + $pagesGridField->getConfig()->removeComponentsByType(GridFieldAddNewButton::class); |
|
| 24 | + } |
|
| 25 | + } |
|
| 26 | 26 | } |
@@ -5,41 +5,41 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class CwpSiteSummaryExtension extends Extension |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Updates the modules used for the version label by: |
|
| 10 | - * - Removing SS Framework |
|
| 11 | - * - Adding CWP |
|
| 12 | - * - Relabelling SS CMS |
|
| 13 | - * |
|
| 14 | - * @param array $modules |
|
| 15 | - */ |
|
| 16 | - public function updateVersionModules(&$modules) |
|
| 17 | - { |
|
| 18 | - unset($modules['silverstripe/framework']); |
|
| 19 | - $modules = ['cwp/cwp' => 'CWP'] + $modules; |
|
| 20 | - $modules['silverstripe/cms'] = 'SilverStripe CMS'; |
|
| 21 | - } |
|
| 8 | + /** |
|
| 9 | + * Updates the modules used for the version label by: |
|
| 10 | + * - Removing SS Framework |
|
| 11 | + * - Adding CWP |
|
| 12 | + * - Relabelling SS CMS |
|
| 13 | + * |
|
| 14 | + * @param array $modules |
|
| 15 | + */ |
|
| 16 | + public function updateVersionModules(&$modules) |
|
| 17 | + { |
|
| 18 | + unset($modules['silverstripe/framework']); |
|
| 19 | + $modules = ['cwp/cwp' => 'CWP'] + $modules; |
|
| 20 | + $modules['silverstripe/cms'] = 'SilverStripe CMS'; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Updates the dropdown filter used to filter supported packages by renaming the labels (replaces the existing |
|
| 25 | - * filter options) |
|
| 26 | - * |
|
| 27 | - * @param GridFieldDropdownFilter $dropdownFilter |
|
| 28 | - */ |
|
| 29 | - public function updateDropdownFilterOptions($dropdownFilter) |
|
| 30 | - { |
|
| 31 | - $dropdownFilter->removeFilterOption('supported'); |
|
| 32 | - $dropdownFilter->removeFilterOption('unsupported'); |
|
| 23 | + /** |
|
| 24 | + * Updates the dropdown filter used to filter supported packages by renaming the labels (replaces the existing |
|
| 25 | + * filter options) |
|
| 26 | + * |
|
| 27 | + * @param GridFieldDropdownFilter $dropdownFilter |
|
| 28 | + */ |
|
| 29 | + public function updateDropdownFilterOptions($dropdownFilter) |
|
| 30 | + { |
|
| 31 | + $dropdownFilter->removeFilterOption('supported'); |
|
| 32 | + $dropdownFilter->removeFilterOption('unsupported'); |
|
| 33 | 33 | |
| 34 | - $dropdownFilter->addFilterOption( |
|
| 35 | - 'supported', |
|
| 36 | - _t(__CLASS__ . '.FilterSupported', 'CWP recipe modules'), |
|
| 37 | - ['Supported' => true] |
|
| 38 | - ); |
|
| 39 | - $dropdownFilter->addFilterOption( |
|
| 40 | - 'unsupported', |
|
| 41 | - _t(__CLASS__ . '.FilterUnsupported', 'Non CWP modules'), |
|
| 42 | - ['Supported' => false] |
|
| 43 | - ); |
|
| 44 | - } |
|
| 34 | + $dropdownFilter->addFilterOption( |
|
| 35 | + 'supported', |
|
| 36 | + _t(__CLASS__ . '.FilterSupported', 'CWP recipe modules'), |
|
| 37 | + ['Supported' => true] |
|
| 38 | + ); |
|
| 39 | + $dropdownFilter->addFilterOption( |
|
| 40 | + 'unsupported', |
|
| 41 | + _t(__CLASS__ . '.FilterUnsupported', 'Non CWP modules'), |
|
| 42 | + ['Supported' => false] |
|
| 43 | + ); |
|
| 44 | + } |
|
| 45 | 45 | } |