--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * PDF Output by admin-ajax
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+require_once GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/models/front/events/icalFeed.php';
+/**
+ * Steve Note...
+ *
+ * You can get to this using the following URL.
+ *
+ * {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=pdfOutput&mystuff=THIS
+ *
+ * You should be able to do this as POST or GET and should be able to add and read additional parameters.
+ * I added a "mystuff" parameter to the URL above and it does output from the code in the
+ * modelAction() function below.
+ *
+ * To add another model under models/admin/ajax all you need to do is create it and add it to the
+ * setup/validActions.php file.
+ *
+ */
+
+// Load Members data abstract
+// require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php');
+
+/**
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_icalFeed extends GlmMembersFront_events_icalFeed
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+}
--- /dev/null
+<?php
+/**
+ * detail.php
+ *
+ * This is the Member Event Plugin model for the front detail shortcode.
+ * Handles the view of the detail pages.
+ */
+
+require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/data/dataEvents.php';
+require_once GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/models/front/events/baseAction.php';
+
+/**
+ * GLmMembersFront_event_detail
+ *
+ * @uses GlmDataEvents
+ * @package GlmMemberEvents
+ * @version 0.0.1
+ * @copyright Copyright (c) 2010 All rights reserved.
+ * @author Steve Sutton <steve@gaslightmedia.com>
+ * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
+ */
+class GLmMembersFront_events_icalFeed extends GlmMembersFront_events_baseAction
+{
+ /**
+ * modelAction
+ *
+ * @param bool $actionData Action Data passed to the modelAction
+ *
+ * @access public
+ * @return void
+ */
+ public function modelAction($actionData = false)
+ {
+ $action = '';
+ $fromDate = date('m/d/Y');
+ $this->dateRange = "start_time >= '{$fromDate}'";
+
+ if ( isset($_REQUEST['eventId']) && $eventId = filter_var($_REQUEST['eventId'], FILTER_VALIDATE_INT)) {
+ $search = true;
+ if ($ical = filter_var($_REQUEST['ical'], FILTER_VALIDATE_BOOLEAN)) {
+ $action = 'event-ical';
+ }
+ }
+
+ switch ($action) {
+ case 'event-ical':
+ $event = $this->getModelEventData($eventId);
+ echo '<pre>$event: ' . print_r($event, true) . '</pre>';
+$icalHeader = <<<EOD
+BEGIN:VCALENDAR
+PRODID:-//Gaslight Media Inc//Gaslight Events Calendar v2.0/EN
+VERSION:2.0
+CALSCALE:GREGORIAN
+METHOD:PUBLISH
+EOD;
+
+$icalFooter = <<<EOD
+\nEND:VCALENDAR
+EOD;
+
+$eventTemplateStart = <<<EOD
+\nBEGIN:VEVENT
+UID:%d@%s
+CREATED:%s
+DTSTAMP:%s
+DTSTART:%s
+DTEND:%s
+%s
+SUMMARY:%s
+STATUS:CONFIRMED
+EOD;
+$eventTemplateEnd = <<<EOD
+\nEND:VEVENT
+EOD;
+ $dateTimeFormat = '%s %s:%s %s';
+ $dateFormat = '%s';
+ $timeStampFormat = 'Ymd\THis';
+ $weekdays =
+ array(1 => 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
+ //header('Content-type: text/calendar; charset=utf-8');
+ //header('Content-Disposition: inline; filename=event-' . $eventId . '.ics');
+ $output .= '<pre>';
+ $output .= $icalHeader;
+ // clean description
+ $description = 'DESCRIPTION:' . str_replace("\n", "\\n", strip_tags($event['descr']));
+ $description = str_replace("\r", '', $description);
+ $urlParts = parse_url(get_bloginfo('url'), PHP_URL_HOST);
+ $urlHost = str_replace('www.', '', $urlParts);
+ $eventDataStart = sprintf($eventTemplateStart,
+ $event['id'],
+ $urlHost,
+ $this->icalDateFormat($event['starting_timestamp']),
+ $this->icalDateFormat($event['starting_timestamp']),
+ $this->icalDateFormat($event['starting_timestamp']),
+ ($event['reacur'])
+ ? $this->icalDateFormat($event['starting_timestamp'])
+ : $this->icalDateFormat($event['ending_timestamp']),
+ $description,
+ $event['name']
+ );
+ $output .= $eventDataStart;
+ $output .= $eventTemplateEnd;
+ $output .= $icalFooter;
+ $output .= '</pre>';
+ echo $output;
+ exit;
+ break;
+ default:
+ die('should not reach this');
+ break;
+ }
+ }
+
+ function icalDateFormat($datetime)
+ {
+ return date('Ymd\THis', $datetime);
+ }
+}
$glmMembersEventsAddOnValidActions = array(
'adminActions' => array(
'ajax' => array(
- 'pdfOutput' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
- 'nameSearch' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG
+ 'pdfOutput' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
+ 'nameSearch' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
+ 'icalFeed' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
),
'member' => array(
'events' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
'list' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
'detail' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
'frontAdd' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
- 'pdf' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG
+ 'pdf' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
)
)
);