From 6834bea31f45801368d0d6ed7f4f17f75730fbb6 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Thu, 5 Mar 2020 22:12:06 +0000 Subject: [PATCH] Split event list page from ical/rss feeds --- CRM/Event/{Page => }/ICalendar.php | 62 ++++++++++++-------------- CRM/Event/Page/List.php | 36 +++++++++++++++ CRM/Event/xml/Menu/Event.xml | 10 ++++- templates/CRM/Event/Page/ICalendar.tpl | 44 ------------------ templates/CRM/Event/Page/List.tpl | 51 +++++++++++++++++++++ 5 files changed, 124 insertions(+), 79 deletions(-) rename CRM/Event/{Page => }/ICalendar.php (59%) create mode 100644 CRM/Event/Page/List.php delete mode 100644 templates/CRM/Event/Page/ICalendar.tpl create mode 100644 templates/CRM/Event/Page/List.tpl diff --git a/CRM/Event/Page/ICalendar.php b/CRM/Event/ICalendar.php similarity index 59% rename from CRM/Event/Page/ICalendar.php rename to CRM/Event/ICalendar.php index 9936f6549b..8a1fb937df 100644 --- a/CRM/Event/Page/ICalendar.php +++ b/CRM/Event/ICalendar.php @@ -10,18 +10,9 @@ */ /** - * - * @package CRM - * @copyright CiviCRM LLC https://civicrm.org/licensing - * $Id$ - * + * Class to generate various "icalendar" type event feeds */ - -/** - * ICalendar class - * - */ -class CRM_Event_Page_ICalendar extends CRM_Core_Page { +class CRM_Event_ICalendar extends CRM_Core_Page { /** * Heart of the iCalendar data assignment process. The runner gets all the meta @@ -29,42 +20,45 @@ class CRM_Event_Page_ICalendar extends CRM_Core_Page { * to the user. If gData param is passed on the URL, outputs gData XML format. * Else outputs iCalendar format per IETF RFC2445. Page param true means send * to browser as inline content. Else, we send .ics file as attachment. - * - * @return void */ public function run() { - $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, NULL, 'GET'); - $type = CRM_Utils_Request::retrieve('type', 'Positive', $this, FALSE, 0); - $start = CRM_Utils_Request::retrieve('start', 'Positive', $this, FALSE, 0); - $end = CRM_Utils_Request::retrieve('end', 'Positive', $this, FALSE, 0); - $iCalPage = CRM_Utils_Request::retrieve('list', 'Positive', $this, FALSE, 0); - $gData = CRM_Utils_Request::retrieve('gData', 'Positive', $this, FALSE, 0); - $html = CRM_Utils_Request::retrieve('html', 'Positive', $this, FALSE, 0); - $rss = CRM_Utils_Request::retrieve('rss', 'Positive', $this, FALSE, 0); + $id = CRM_Utils_Request::retrieveValue('id', 'Positive', NULL, FALSE, 'GET'); + $type = CRM_Utils_Request::retrieveValue('type', 'Positive', 0); + $start = CRM_Utils_Request::retrieveValue('start', 'Positive', 0); + $end = CRM_Utils_Request::retrieveValue('end', 'Positive', 0); - $info = CRM_Event_BAO_Event::getCompleteInfo($start, $type, $id, $end); - $this->assign('events', $info); - $this->assign('timezone', @date_default_timezone_get()); + // We used to handle the event list as a html page at civicrm/event/ical - redirect to the new URL if that was what we requested. + if (CRM_Utils_Request::retrieveValue('html', 'Positive', 0)) { + $urlParams = [ + 'reset' => 1, + ]; + $id ? $urlParams['id'] = $id : NULL; + $type ? $urlParams['type'] = $type : NULL; + $start ? $urlParams['start'] = $start : NULL; + $end ? $urlParams['end'] = $end : NULL; + CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/list', $urlParams, FALSE, NULL, FALSE, TRUE)); + } + + $iCalPage = CRM_Utils_Request::retrieveValue('list', 'Positive', 0); + $gData = CRM_Utils_Request::retrieveValue('gData', 'Positive', 0); + $rss = CRM_Utils_Request::retrieveValue('rss', 'Positive', 0); - // Send data to the correct template for formatting (iCal vs. gData) $template = CRM_Core_Smarty::singleton(); $config = CRM_Core_Config::singleton(); + + $info = CRM_Event_BAO_Event::getCompleteInfo($start, $type, $id, $end); + $template->assign('events', $info); + $template->assign('timezone', @date_default_timezone_get()); + + // Send data to the correct template for formatting (iCal vs. gData) if ($rss) { // rss 2.0 requires lower case dash delimited locale - $this->assign('rssLang', str_replace('_', '-', strtolower($config->lcMessages))); + $template->assign('rssLang', str_replace('_', '-', strtolower($config->lcMessages))); $calendar = $template->fetch('CRM/Core/Calendar/Rss.tpl'); } elseif ($gData) { $calendar = $template->fetch('CRM/Core/Calendar/GData.tpl'); } - elseif ($html) { - // check if we're in shopping cart mode for events - $enable_cart = Civi::settings()->get('enable_cart'); - if ($enable_cart) { - $this->assign('registration_links', TRUE); - } - return parent::run(); - } else { $calendar = $template->fetch('CRM/Core/Calendar/ICal.tpl'); $calendar = preg_replace('/(?assign('events', $info); + + // check if we're in shopping cart mode for events + $enable_cart = (boolean) Civi::settings()->get('enable_cart'); + $this->assign('eventCartEnabled', $enable_cart); + + if ($enable_cart) { + $this->assign('registration_links', TRUE); + } + return parent::run(); + } + +} diff --git a/CRM/Event/xml/Menu/Event.xml b/CRM/Event/xml/Menu/Event.xml index c9cc607287..aaf33b861c 100644 --- a/CRM/Event/xml/Menu/Event.xml +++ b/CRM/Event/xml/Menu/Event.xml @@ -44,11 +44,19 @@ civicrm/event/ical Current and Upcoming Events - CRM_Event_Page_ICalendar + CRM_Event_ICalendar::run view event info true 0 + + civicrm/event/list + Current and Upcoming Events + CRM_Event_Page_List + view event info + true + 0 + civicrm/event/participant Event Participants List diff --git a/templates/CRM/Event/Page/ICalendar.tpl b/templates/CRM/Event/Page/ICalendar.tpl deleted file mode 100644 index 684cc1c8ca..0000000000 --- a/templates/CRM/Event/Page/ICalendar.tpl +++ /dev/null @@ -1,44 +0,0 @@ -{* - +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC. All rights reserved. | - | | - | This work is published under the GNU AGPLv3 license with some | - | permitted exceptions and without any warranty. For full license | - | and copyright information, see https://civicrm.org/licensing | - +--------------------------------------------------------------------+ -*} -{* Displays current and upcoming public Events Listing as an HTML page. *} -{include file="CRM/common/jsortable.tpl"} - - - - - - - - - - {if $registration_links}{/if} - - -{foreach from=$events key=uid item=event} - - - - - - - - {if $registration_links}{/if} - -{/foreach} -
{ts}Event{/ts}{ts}When{/ts}{ts}Location{/ts}{ts}Category{/ts}{ts}Email{/ts}{ts}Register{/ts}
{$event.title}{if $event.summary}{$event.summary} ({ts}read more{/ts}...){else} {/if} - {if $event.start_date}{$event.start_date|crmDate}{if $event.end_date}
{ts}through{/ts}
{strip} - {* Only show end time if end date = start date *} - {if $event.end_date|date_format:"%Y%m%d" == $event.start_date|date_format:"%Y%m%d"} - {$event.end_date|crmDate:0:1} - {else} - {$event.end_date|crmDate} - {/if}{/strip}{/if} - {else}{ts}(not available){/ts}{/if} -
{if $event.is_show_location EQ 1 AND $event.location}{$event.location}{else}{ts}(not available){/ts}{/if}{if $event.event_type}{$event.event_type}{else} {/if}{if $event.contact_email}{$event.contact_email}{else} {/if}{$event.registration_link_text}
diff --git a/templates/CRM/Event/Page/List.tpl b/templates/CRM/Event/Page/List.tpl new file mode 100644 index 0000000000..94a2b12913 --- /dev/null +++ b/templates/CRM/Event/Page/List.tpl @@ -0,0 +1,51 @@ +{* + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC. All rights reserved. | + | | + | This work is published under the GNU AGPLv3 license with some | + | permitted exceptions and without any warranty. For full license | + | and copyright information, see https://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} +{* Displays current and upcoming public Events Listing as an HTML page. *} +{include file="CRM/common/jsortable.tpl"} +
+ {if $eventCartEnabled} + {ts}View Cart{/ts} + {ts}Checkout{/ts} + {/if} + + + + + + + + + + + {if $registration_links}{/if} + + + {foreach from=$events key=uid item=event} + + + + + + + + {if $registration_links}{/if} + + {/foreach} +
{ts}Event{/ts}{ts}When{/ts}{ts}Location{/ts}{ts}Category{/ts}{ts}Email{/ts}{ts}Register{/ts}
{$event.title}{if $event.summary}{$event.summary} ({ts}read more{/ts}...){else} {/if} + {if $event.start_date}{$event.start_date|crmDate}{if $event.end_date}
{ts}through{/ts}
{strip} + {* Only show end time if end date = start date *} + {if $event.end_date|date_format:"%Y%m%d" == $event.start_date|date_format:"%Y%m%d"} + {$event.end_date|crmDate:0:1} + {else} + {$event.end_date|crmDate} + {/if}{/strip}{/if} + {else}{ts}(not available){/ts}{/if} +
{if $event.is_show_location EQ 1 AND $event.location}{$event.location}{else}{ts}(not available){/ts}{/if}{if $event.event_type}{$event.event_type}{else} {/if}{if $event.contact_email}{$event.contact_email}{else} {/if}{$event.registration_link_text}
+
-- 2.25.1