*/
/**
- *
- * @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
* 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('/(?<!\r)\n/', "\r\n", $calendar);
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | 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 |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Display a list of events on a page
+ */
+class CRM_Event_Page_List extends CRM_Core_Page {
+
+ public function run() {
+ $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);
+
+ // 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();
+ }
+
+}
<item>
<path>civicrm/event/ical</path>
<title>Current and Upcoming Events</title>
- <page_callback>CRM_Event_Page_ICalendar</page_callback>
+ <page_callback>CRM_Event_ICalendar::run</page_callback>
<access_arguments>view event info</access_arguments>
<is_public>true</is_public>
<weight>0</weight>
</item>
+ <item>
+ <path>civicrm/event/list</path>
+ <title>Current and Upcoming Events</title>
+ <page_callback>CRM_Event_Page_List</page_callback>
+ <access_arguments>view event info</access_arguments>
+ <is_public>true</is_public>
+ <weight>0</weight>
+ </item>
<item>
<path>civicrm/event/participant</path>
<title>Event Participants List</title>
+++ /dev/null
-{*
- +--------------------------------------------------------------------+
- | 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"}
-<table id="options" class="display">
-<thead>
-<tr>
- <th>{ts}Event{/ts}</th>
- <th></th>
- <th>{ts}When{/ts}</th>
- <th>{ts}Location{/ts}</th>
- <th>{ts}Category{/ts}</th>
- <th>{ts}Email{/ts}</th>
- {if $registration_links}<th>{ts}Register{/ts}</th>{/if}
-</tr>
-</thead>
-{foreach from=$events key=uid item=event}
-<tr class="{cycle values="odd-row,even-row"} {$row.class}">
- <td><a href="{crmURL p='civicrm/event/info' q="reset=1&id=`$event.event_id`"}" title="{ts}read more{/ts}"><strong>{$event.title}</strong></a></td>
- <td>{if $event.summary}{$event.summary} (<a href="{crmURL p='civicrm/event/info' q="reset=1&id=`$event.event_id`"}" title="{ts}details...{/ts}">{ts}read more{/ts}...</a>){else} {/if}</td>
- <td class="nowrap" data-order="{$event.start_date|crmDate:'%Y-%m-%d'}">
- {if $event.start_date}{$event.start_date|crmDate}{if $event.end_date}<br /><em>{ts}through{/ts}</em><br />{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}
- </td>
- <td>{if $event.is_show_location EQ 1 AND $event.location}{$event.location}{else}{ts}(not available){/ts}{/if}</td>
- <td>{if $event.event_type}{$event.event_type}{else} {/if}</td>
- <td>{if $event.contact_email}<a href="mailto:{$event.contact_email}">{$event.contact_email}</a>{else} {/if}</td>
- {if $registration_links}<td><a href="{$event.registration_link}">{$event.registration_link_text}</a></td>{/if}
-</tr>
-{/foreach}
-</table>
--- /dev/null
+{*
+ +--------------------------------------------------------------------+
+ | 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"}
+<div class="crm-section crm-event-list">
+ {if $eventCartEnabled}
+ <a href="{crmURL p='civicrm/event/view_cart' }" class="button crm-shoppingcart-button"><i class="crm-i fa-shopping-cart"></i> {ts}View Cart{/ts}</a>
+ <a href="{crmURL p='civicrm/event/cart_checkout'}" class="button crm-check-out-button"><i class="crm-i fa-credit-card"></i> {ts}Checkout{/ts}</a>
+ {/if}
+
+ <table id="options" class="display">
+ <thead>
+ <tr>
+ <th>{ts}Event{/ts}</th>
+ <th></th>
+ <th>{ts}When{/ts}</th>
+ <th>{ts}Location{/ts}</th>
+ <th>{ts}Category{/ts}</th>
+ <th>{ts}Email{/ts}</th>
+ {if $registration_links}<th>{ts}Register{/ts}</th>{/if}
+ </tr>
+ </thead>
+ {foreach from=$events key=uid item=event}
+ <tr class="{cycle values="odd-row,even-row"} {$row.class}">
+ <td><a href="{crmURL p='civicrm/event/info' q="reset=1&id=`$event.event_id`"}" title="{ts}read more{/ts}"><strong>{$event.title}</strong></a></td>
+ <td>{if $event.summary}{$event.summary} (<a href="{crmURL p='civicrm/event/info' q="reset=1&id=`$event.event_id`"}" title="{ts}details...{/ts}">{ts}read more{/ts}...</a>){else} {/if}</td>
+ <td class="nowrap" data-order="{$event.start_date|crmDate:'%Y-%m-%d'}">
+ {if $event.start_date}{$event.start_date|crmDate}{if $event.end_date}<br /><em>{ts}through{/ts}</em><br />{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}
+ </td>
+ <td>{if $event.is_show_location EQ 1 AND $event.location}{$event.location}{else}{ts}(not available){/ts}{/if}</td>
+ <td>{if $event.event_type}{$event.event_type}{else} {/if}</td>
+ <td>{if $event.contact_email}<a href="mailto:{$event.contact_email}">{$event.contact_email}</a>{else} {/if}</td>
+ {if $registration_links}<td><a href="{$event.registration_link}">{$event.registration_link_text}</a></td>{/if}
+ </tr>
+ {/foreach}
+ </table>
+</div>