@@ -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 | } |
@@ -11,53 +11,53 @@ |
||
11 | 11 | class CwpSiteTreeFileExtension extends DataExtension |
12 | 12 | { |
13 | 13 | |
14 | - public function updateCMSFields(FieldList $fields) |
|
15 | - { |
|
16 | - Requirements::css('cwp/cwp:css/fieldDescriptionToggle.css'); |
|
17 | - Requirements::javascript('cwp/cwp:javascript/fieldDescriptionToggle.js'); |
|
18 | - |
|
19 | - $fields->insertAfter( |
|
20 | - 'LastEdited', |
|
21 | - ReadonlyField::create( |
|
22 | - 'BackLinkCount', |
|
23 | - _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.BACKLINKCOUNT', 'Used on:'), |
|
24 | - $this->owner->BackLinkTracking()->Count() . ' ' |
|
25 | - . _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.PAGES', 'page(s)') |
|
26 | - ) |
|
27 | - ->addExtraClass('cms-description-toggle') |
|
28 | - ->setDescription($this->BackLinkHTMLList()) |
|
29 | - ); |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * Generate an HTML list which provides links to where a file is used. |
|
34 | - * |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function BackLinkHTMLList() |
|
38 | - { |
|
39 | - $html = '<em>' . _t( |
|
40 | - __CLASS__ . '.BACKLINK_LIST_DESCRIPTION', |
|
41 | - 'This list shows all pages where the file has been added through a WYSIWYG editor.' |
|
42 | - ) . '</em>'; |
|
43 | - $html .= '<ul>'; |
|
44 | - |
|
45 | - foreach ($this->owner->BackLinkTracking() as $backLink) { |
|
46 | - $listItem = '<li>'; |
|
47 | - |
|
48 | - // Add the page link |
|
49 | - $listItem .= '<a href="' . $backLink->Link() . '" target="_blank">' |
|
50 | - . Convert::raw2xml($backLink->MenuTitle) . '</a> – '; |
|
51 | - |
|
52 | - // Add the CMS link |
|
53 | - $listItem .= '<a href="' . $backLink->CMSEditLink() . '">' |
|
54 | - . _t(__CLASS__ . '.EDIT', 'Edit') . '</a>'; |
|
55 | - |
|
56 | - $html .= $listItem . '</li>'; |
|
57 | - } |
|
58 | - |
|
59 | - $html .= '</ul>'; |
|
60 | - |
|
61 | - return $html; |
|
62 | - } |
|
14 | + public function updateCMSFields(FieldList $fields) |
|
15 | + { |
|
16 | + Requirements::css('cwp/cwp:css/fieldDescriptionToggle.css'); |
|
17 | + Requirements::javascript('cwp/cwp:javascript/fieldDescriptionToggle.js'); |
|
18 | + |
|
19 | + $fields->insertAfter( |
|
20 | + 'LastEdited', |
|
21 | + ReadonlyField::create( |
|
22 | + 'BackLinkCount', |
|
23 | + _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.BACKLINKCOUNT', 'Used on:'), |
|
24 | + $this->owner->BackLinkTracking()->Count() . ' ' |
|
25 | + . _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.PAGES', 'page(s)') |
|
26 | + ) |
|
27 | + ->addExtraClass('cms-description-toggle') |
|
28 | + ->setDescription($this->BackLinkHTMLList()) |
|
29 | + ); |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * Generate an HTML list which provides links to where a file is used. |
|
34 | + * |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function BackLinkHTMLList() |
|
38 | + { |
|
39 | + $html = '<em>' . _t( |
|
40 | + __CLASS__ . '.BACKLINK_LIST_DESCRIPTION', |
|
41 | + 'This list shows all pages where the file has been added through a WYSIWYG editor.' |
|
42 | + ) . '</em>'; |
|
43 | + $html .= '<ul>'; |
|
44 | + |
|
45 | + foreach ($this->owner->BackLinkTracking() as $backLink) { |
|
46 | + $listItem = '<li>'; |
|
47 | + |
|
48 | + // Add the page link |
|
49 | + $listItem .= '<a href="' . $backLink->Link() . '" target="_blank">' |
|
50 | + . Convert::raw2xml($backLink->MenuTitle) . '</a> – '; |
|
51 | + |
|
52 | + // Add the CMS link |
|
53 | + $listItem .= '<a href="' . $backLink->CMSEditLink() . '">' |
|
54 | + . _t(__CLASS__ . '.EDIT', 'Edit') . '</a>'; |
|
55 | + |
|
56 | + $html .= $listItem . '</li>'; |
|
57 | + } |
|
58 | + |
|
59 | + $html .= '</ul>'; |
|
60 | + |
|
61 | + return $html; |
|
62 | + } |
|
63 | 63 | } |
@@ -9,39 +9,39 @@ |
||
9 | 9 | |
10 | 10 | class CwpSiteTreeExtension extends DataExtension |
11 | 11 | { |
12 | - private static $db = array( |
|
13 | - 'ShowPageUtilities' => 'Boolean(1)' |
|
14 | - ); |
|
12 | + private static $db = array( |
|
13 | + 'ShowPageUtilities' => 'Boolean(1)' |
|
14 | + ); |
|
15 | 15 | |
16 | - private static $defaults = array( |
|
17 | - 'ShowPageUtilities' => true |
|
18 | - ); |
|
16 | + private static $defaults = array( |
|
17 | + 'ShowPageUtilities' => true |
|
18 | + ); |
|
19 | 19 | |
20 | - /** |
|
21 | - * Modify the settings for a SiteTree |
|
22 | - * |
|
23 | - * {@inheritDoc} |
|
24 | - * |
|
25 | - * @param FieldList $fields |
|
26 | - */ |
|
27 | - public function updateSettingsFields(FieldList $fields) |
|
28 | - { |
|
29 | - $helpText = _t( |
|
30 | - __CLASS__ . '.SHOW_PAGE_UTILITIES_HELP', |
|
31 | - 'You can disable page utilities (print, share, etc) for this page' |
|
32 | - ); |
|
20 | + /** |
|
21 | + * Modify the settings for a SiteTree |
|
22 | + * |
|
23 | + * {@inheritDoc} |
|
24 | + * |
|
25 | + * @param FieldList $fields |
|
26 | + */ |
|
27 | + public function updateSettingsFields(FieldList $fields) |
|
28 | + { |
|
29 | + $helpText = _t( |
|
30 | + __CLASS__ . '.SHOW_PAGE_UTILITIES_HELP', |
|
31 | + 'You can disable page utilities (print, share, etc) for this page' |
|
32 | + ); |
|
33 | 33 | |
34 | - $fields->addFieldsToTab( |
|
35 | - 'Root.Settings', |
|
36 | - array( |
|
37 | - LiteralField::create('PageUtilitiesHelp', $helpText), |
|
38 | - CheckboxField::create('ShowPageUtilities', $this->owner->fieldLabel('ShowPageUtilities')) |
|
39 | - ) |
|
40 | - ); |
|
41 | - } |
|
34 | + $fields->addFieldsToTab( |
|
35 | + 'Root.Settings', |
|
36 | + array( |
|
37 | + LiteralField::create('PageUtilitiesHelp', $helpText), |
|
38 | + CheckboxField::create('ShowPageUtilities', $this->owner->fieldLabel('ShowPageUtilities')) |
|
39 | + ) |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | - public function updateFieldLabels(&$labels) |
|
44 | - { |
|
45 | - $labels['ShowPageUtilities'] = _t(__CLASS__ . '.SHOW_PAGE_UTILITIES', 'Show page utilities?'); |
|
46 | - } |
|
43 | + public function updateFieldLabels(&$labels) |
|
44 | + { |
|
45 | + $labels['ShowPageUtilities'] = _t(__CLASS__ . '.SHOW_PAGE_UTILITIES', 'Show page utilities?'); |
|
46 | + } |
|
47 | 47 | } |
@@ -7,57 +7,57 @@ |
||
7 | 7 | |
8 | 8 | class EventHolder extends DatedUpdateHolder |
9 | 9 | { |
10 | - private static $description = 'Container page for Event Pages, provides event filtering and pagination'; |
|
11 | - |
|
12 | - private static $allowed_children = [ |
|
13 | - EventPage::class, |
|
14 | - ]; |
|
15 | - |
|
16 | - private static $default_child = EventPage::class; |
|
17 | - |
|
18 | - private static $update_name = 'Events'; |
|
19 | - |
|
20 | - private static $update_class = EventPage::class; |
|
21 | - |
|
22 | - private static $icon = 'cwp/cwp:images/icons/sitetree_images/event_holder.png'; |
|
23 | - |
|
24 | - private static $singular_name = 'Event Holder'; |
|
25 | - |
|
26 | - private static $plural_name = 'Event Holders'; |
|
27 | - |
|
28 | - private static $table_name = 'EventHolder'; |
|
29 | - |
|
30 | - /** |
|
31 | - * Find all site's news items, based on some filters. |
|
32 | - * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together. |
|
33 | - * |
|
34 | - * @param string $className The name of the class to fetch. |
|
35 | - * @param int $parentID The ID of the holder to extract the news items from. |
|
36 | - * @param int $tagID The ID of the tag to filter the news items by. |
|
37 | - * @param string $dateFrom The beginning of a date filter range. |
|
38 | - * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for. |
|
39 | - * @param int $year Numeric value of the year to show. |
|
40 | - * @param int $monthNumber Numeric value of the month to show. |
|
41 | - * |
|
42 | - * @returns DataList|PaginatedList |
|
43 | - */ |
|
44 | - public static function AllUpdates( |
|
45 | - $className = 'Events', |
|
46 | - $parentID = null, |
|
47 | - $tagID = null, |
|
48 | - $dateFrom = null, |
|
49 | - $dateTo = null, |
|
50 | - $year = null, |
|
51 | - $monthNumber = null |
|
52 | - ) { |
|
53 | - return parent::AllUpdates( |
|
54 | - $className, |
|
55 | - $parentID, |
|
56 | - $tagID, |
|
57 | - $dateFrom, |
|
58 | - $dateTo, |
|
59 | - $year, |
|
60 | - $monthNumber |
|
61 | - )->Sort('Date', 'ASC'); |
|
62 | - } |
|
10 | + private static $description = 'Container page for Event Pages, provides event filtering and pagination'; |
|
11 | + |
|
12 | + private static $allowed_children = [ |
|
13 | + EventPage::class, |
|
14 | + ]; |
|
15 | + |
|
16 | + private static $default_child = EventPage::class; |
|
17 | + |
|
18 | + private static $update_name = 'Events'; |
|
19 | + |
|
20 | + private static $update_class = EventPage::class; |
|
21 | + |
|
22 | + private static $icon = 'cwp/cwp:images/icons/sitetree_images/event_holder.png'; |
|
23 | + |
|
24 | + private static $singular_name = 'Event Holder'; |
|
25 | + |
|
26 | + private static $plural_name = 'Event Holders'; |
|
27 | + |
|
28 | + private static $table_name = 'EventHolder'; |
|
29 | + |
|
30 | + /** |
|
31 | + * Find all site's news items, based on some filters. |
|
32 | + * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together. |
|
33 | + * |
|
34 | + * @param string $className The name of the class to fetch. |
|
35 | + * @param int $parentID The ID of the holder to extract the news items from. |
|
36 | + * @param int $tagID The ID of the tag to filter the news items by. |
|
37 | + * @param string $dateFrom The beginning of a date filter range. |
|
38 | + * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for. |
|
39 | + * @param int $year Numeric value of the year to show. |
|
40 | + * @param int $monthNumber Numeric value of the month to show. |
|
41 | + * |
|
42 | + * @returns DataList|PaginatedList |
|
43 | + */ |
|
44 | + public static function AllUpdates( |
|
45 | + $className = 'Events', |
|
46 | + $parentID = null, |
|
47 | + $tagID = null, |
|
48 | + $dateFrom = null, |
|
49 | + $dateTo = null, |
|
50 | + $year = null, |
|
51 | + $monthNumber = null |
|
52 | + ) { |
|
53 | + return parent::AllUpdates( |
|
54 | + $className, |
|
55 | + $parentID, |
|
56 | + $tagID, |
|
57 | + $dateFrom, |
|
58 | + $dateTo, |
|
59 | + $year, |
|
60 | + $monthNumber |
|
61 | + )->Sort('Date', 'ASC'); |
|
62 | + } |
|
63 | 63 | } |
@@ -7,50 +7,50 @@ |
||
7 | 7 | |
8 | 8 | class NewsHolder extends DatedUpdateHolder |
9 | 9 | { |
10 | - private static $description = 'Container page for News Pages, provides news filtering and pagination'; |
|
11 | - |
|
12 | - private static $allowed_children = [ |
|
13 | - NewsPage::class, |
|
14 | - ]; |
|
15 | - |
|
16 | - private static $default_child = NewsPage::class; |
|
17 | - |
|
18 | - private static $update_name = 'News'; |
|
19 | - |
|
20 | - private static $update_class = NewsPage::class; |
|
21 | - |
|
22 | - private static $icon = 'cwp/cwp:images/icons/sitetree_images/news_listing.png'; |
|
23 | - |
|
24 | - private static $singular_name = 'News Holder'; |
|
25 | - |
|
26 | - private static $plural_name = 'News Holders'; |
|
27 | - |
|
28 | - private static $table_name = 'NewsHolder'; |
|
29 | - |
|
30 | - /** |
|
31 | - * Find all site's news items, based on some filters. |
|
32 | - * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together. |
|
33 | - * |
|
34 | - * @param string $className The name of the class to fetch. |
|
35 | - * @param int $parentID The ID of the holder to extract the news items from. |
|
36 | - * @param int $tagID The ID of the tag to filter the news items by. |
|
37 | - * @param string $dateFrom The beginning of a date filter range. |
|
38 | - * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for. |
|
39 | - * @param int $year Numeric value of the year to show. |
|
40 | - * @param int $monthNumber Numeric value of the month to show. |
|
41 | - * |
|
42 | - * @returns DataList|PaginatedList |
|
43 | - */ |
|
44 | - public static function AllUpdates( |
|
45 | - $className = NewsPage::class, |
|
46 | - $parentID = null, |
|
47 | - $tagID = null, |
|
48 | - $dateFrom = null, |
|
49 | - $dateTo = null, |
|
50 | - $year = null, |
|
51 | - $monthNumber = null |
|
52 | - ) { |
|
53 | - return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber) |
|
54 | - ->Sort('Date', 'DESC'); |
|
55 | - } |
|
10 | + private static $description = 'Container page for News Pages, provides news filtering and pagination'; |
|
11 | + |
|
12 | + private static $allowed_children = [ |
|
13 | + NewsPage::class, |
|
14 | + ]; |
|
15 | + |
|
16 | + private static $default_child = NewsPage::class; |
|
17 | + |
|
18 | + private static $update_name = 'News'; |
|
19 | + |
|
20 | + private static $update_class = NewsPage::class; |
|
21 | + |
|
22 | + private static $icon = 'cwp/cwp:images/icons/sitetree_images/news_listing.png'; |
|
23 | + |
|
24 | + private static $singular_name = 'News Holder'; |
|
25 | + |
|
26 | + private static $plural_name = 'News Holders'; |
|
27 | + |
|
28 | + private static $table_name = 'NewsHolder'; |
|
29 | + |
|
30 | + /** |
|
31 | + * Find all site's news items, based on some filters. |
|
32 | + * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together. |
|
33 | + * |
|
34 | + * @param string $className The name of the class to fetch. |
|
35 | + * @param int $parentID The ID of the holder to extract the news items from. |
|
36 | + * @param int $tagID The ID of the tag to filter the news items by. |
|
37 | + * @param string $dateFrom The beginning of a date filter range. |
|
38 | + * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for. |
|
39 | + * @param int $year Numeric value of the year to show. |
|
40 | + * @param int $monthNumber Numeric value of the month to show. |
|
41 | + * |
|
42 | + * @returns DataList|PaginatedList |
|
43 | + */ |
|
44 | + public static function AllUpdates( |
|
45 | + $className = NewsPage::class, |
|
46 | + $parentID = null, |
|
47 | + $tagID = null, |
|
48 | + $dateFrom = null, |
|
49 | + $dateTo = null, |
|
50 | + $year = null, |
|
51 | + $monthNumber = null |
|
52 | + ) { |
|
53 | + return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber) |
|
54 | + ->Sort('Date', 'DESC'); |
|
55 | + } |
|
56 | 56 | } |
@@ -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 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | |
65 | 65 | public function getCMSFields() |
66 | 66 | { |
67 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
67 | + $this->beforeUpdateCMSFields(function(FieldList $fields) { |
|
68 | 68 | $fields->removeByName('Date'); |
69 | 69 | |
70 | 70 | $dateTimeFields = array(); |
@@ -9,55 +9,55 @@ |
||
9 | 9 | |
10 | 10 | class NewsPage extends DatedUpdatePage |
11 | 11 | { |
12 | - private static $description = 'Describes an item of news'; |
|
12 | + private static $description = 'Describes an item of news'; |
|
13 | 13 | |
14 | - private static $default_parent = 'NewsHolderPage'; |
|
14 | + private static $default_parent = 'NewsHolderPage'; |
|
15 | 15 | |
16 | - private static $can_be_root = false; |
|
16 | + private static $can_be_root = false; |
|
17 | 17 | |
18 | - private static $icon = 'cwp/cwp:images/icons/sitetree_images/news.png'; |
|
18 | + private static $icon = 'cwp/cwp:images/icons/sitetree_images/news.png'; |
|
19 | 19 | |
20 | - private static $singular_name = 'News Page'; |
|
20 | + private static $singular_name = 'News Page'; |
|
21 | 21 | |
22 | - private static $plural_name = 'News Pages'; |
|
22 | + private static $plural_name = 'News Pages'; |
|
23 | 23 | |
24 | - private static $db = [ |
|
25 | - 'Author' => 'Varchar(255)', |
|
26 | - ]; |
|
24 | + private static $db = [ |
|
25 | + 'Author' => 'Varchar(255)', |
|
26 | + ]; |
|
27 | 27 | |
28 | - private static $has_one = [ |
|
29 | - 'FeaturedImage' => Image::class, |
|
30 | - ]; |
|
28 | + private static $has_one = [ |
|
29 | + 'FeaturedImage' => Image::class, |
|
30 | + ]; |
|
31 | 31 | |
32 | - private static $table_name = 'NewsPage'; |
|
32 | + private static $table_name = 'NewsPage'; |
|
33 | 33 | |
34 | - public function fieldLabels($includerelations = true) |
|
35 | - { |
|
36 | - $labels = parent::fieldLabels($includerelations); |
|
37 | - $labels['Author'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.AuthorFieldLabel', 'Author'); |
|
38 | - $labels['FeaturedImageID'] = _t( |
|
39 | - 'CWP\\CWP\\PageTypes\\DateUpdatePage.FeaturedImageFieldLabel', |
|
40 | - 'Featured Image' |
|
41 | - ); |
|
34 | + public function fieldLabels($includerelations = true) |
|
35 | + { |
|
36 | + $labels = parent::fieldLabels($includerelations); |
|
37 | + $labels['Author'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.AuthorFieldLabel', 'Author'); |
|
38 | + $labels['FeaturedImageID'] = _t( |
|
39 | + 'CWP\\CWP\\PageTypes\\DateUpdatePage.FeaturedImageFieldLabel', |
|
40 | + 'Featured Image' |
|
41 | + ); |
|
42 | 42 | |
43 | - return $labels; |
|
44 | - } |
|
43 | + return $labels; |
|
44 | + } |
|
45 | 45 | |
46 | - public function getCMSFields() |
|
47 | - { |
|
48 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
49 | - $fields->addFieldToTab( |
|
50 | - 'Root.Main', |
|
51 | - TextField::create('Author', $this->fieldLabel('Author')), |
|
52 | - 'Abstract' |
|
53 | - ); |
|
46 | + public function getCMSFields() |
|
47 | + { |
|
48 | + $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
49 | + $fields->addFieldToTab( |
|
50 | + 'Root.Main', |
|
51 | + TextField::create('Author', $this->fieldLabel('Author')), |
|
52 | + 'Abstract' |
|
53 | + ); |
|
54 | 54 | |
55 | - $fields->addFieldToTab( |
|
56 | - 'Root.Main', |
|
57 | - UploadField::create('FeaturedImage', $this->fieldLabel('FeaturedImageID')), |
|
58 | - 'Abstract' |
|
59 | - ); |
|
60 | - }); |
|
61 | - return parent::getCMSFields(); |
|
62 | - } |
|
55 | + $fields->addFieldToTab( |
|
56 | + 'Root.Main', |
|
57 | + UploadField::create('FeaturedImage', $this->fieldLabel('FeaturedImageID')), |
|
58 | + 'Abstract' |
|
59 | + ); |
|
60 | + }); |
|
61 | + return parent::getCMSFields(); |
|
62 | + } |
|
63 | 63 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | |
46 | 46 | public function getCMSFields() |
47 | 47 | { |
48 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
48 | + $this->beforeUpdateCMSFields(function(FieldList $fields) { |
|
49 | 49 | $fields->addFieldToTab( |
50 | 50 | 'Root.Main', |
51 | 51 | TextField::create('Author', $this->fieldLabel('Author')), |
@@ -7,42 +7,42 @@ |
||
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('SitemapNodeChildren'); |
|
44 | - } |
|
45 | - |
|
46 | - return $viewer; |
|
47 | - } |
|
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('SitemapNodeChildren'); |
|
44 | + } |
|
45 | + |
|
46 | + return $viewer; |
|
47 | + } |
|
48 | 48 | } |
@@ -19,53 +19,53 @@ |
||
19 | 19 | */ |
20 | 20 | class EventHolderController extends DatedUpdateHolderController |
21 | 21 | { |
22 | - public function getUpdateName() |
|
23 | - { |
|
24 | - $params = $this->parseParams(); |
|
25 | - if ($params['upcomingOnly']) { |
|
26 | - return _t(__CLASS__ . '.Upcoming', 'Upcoming events'); |
|
27 | - } |
|
22 | + public function getUpdateName() |
|
23 | + { |
|
24 | + $params = $this->parseParams(); |
|
25 | + if ($params['upcomingOnly']) { |
|
26 | + return _t(__CLASS__ . '.Upcoming', 'Upcoming events'); |
|
27 | + } |
|
28 | 28 | |
29 | - return _t(__CLASS__ . '.Events', 'Events'); |
|
30 | - } |
|
29 | + return _t(__CLASS__ . '.Events', 'Events'); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Parse URL parameters. |
|
34 | - * |
|
35 | - * @param boolean $produceErrorMessages Set to false to omit session messages. |
|
36 | - */ |
|
37 | - public function parseParams($produceErrorMessages = true) |
|
38 | - { |
|
39 | - $params = parent::parseParams($produceErrorMessages); |
|
32 | + /** |
|
33 | + * Parse URL parameters. |
|
34 | + * |
|
35 | + * @param boolean $produceErrorMessages Set to false to omit session messages. |
|
36 | + */ |
|
37 | + public function parseParams($produceErrorMessages = true) |
|
38 | + { |
|
39 | + $params = parent::parseParams($produceErrorMessages); |
|
40 | 40 | |
41 | - // We need to set whether or not we're supposed to be displaying only upcoming events or all events. |
|
42 | - $params['upcomingOnly'] = !($params['from'] || $params['to'] || $params['year'] || $params['month']); |
|
41 | + // We need to set whether or not we're supposed to be displaying only upcoming events or all events. |
|
42 | + $params['upcomingOnly'] = !($params['from'] || $params['to'] || $params['year'] || $params['month']); |
|
43 | 43 | |
44 | - return $params; |
|
45 | - } |
|
44 | + return $params; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Get the events based on the current query. |
|
49 | - */ |
|
50 | - public function FilteredUpdates($pageSize = 20) |
|
51 | - { |
|
52 | - $params = $this->parseParams(); |
|
47 | + /** |
|
48 | + * Get the events based on the current query. |
|
49 | + */ |
|
50 | + public function FilteredUpdates($pageSize = 20) |
|
51 | + { |
|
52 | + $params = $this->parseParams(); |
|
53 | 53 | |
54 | - $items = $this->Updates( |
|
55 | - $params['tag'], |
|
56 | - $params['from'], |
|
57 | - $params['to'], |
|
58 | - $params['year'], |
|
59 | - $params['month'] |
|
60 | - ); |
|
54 | + $items = $this->Updates( |
|
55 | + $params['tag'], |
|
56 | + $params['from'], |
|
57 | + $params['to'], |
|
58 | + $params['year'], |
|
59 | + $params['month'] |
|
60 | + ); |
|
61 | 61 | |
62 | - if ($params['upcomingOnly']) { |
|
63 | - $items = $items->filter(['Date:LessThan:Not' => DBDatetime::now()->Format('y-MM-dd')]); |
|
64 | - } |
|
62 | + if ($params['upcomingOnly']) { |
|
63 | + $items = $items->filter(['Date:LessThan:Not' => DBDatetime::now()->Format('y-MM-dd')]); |
|
64 | + } |
|
65 | 65 | |
66 | - // Apply pagination |
|
67 | - $list = PaginatedList::create($items, $this->getRequest()); |
|
68 | - $list->setPageLength($pageSize); |
|
69 | - return $list; |
|
70 | - } |
|
66 | + // Apply pagination |
|
67 | + $list = PaginatedList::create($items, $this->getRequest()); |
|
68 | + $list->setPageLength($pageSize); |
|
69 | + return $list; |
|
70 | + } |
|
71 | 71 | } |