From: Steve Sutton Date: Mon, 16 May 2016 21:25:17 +0000 (-0400) Subject: Working on the ical feed for event profile X-Git-Tag: v1.0.0^2~34 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=914997441b8bb8be87f60bb120f760fa8afa5633;p=WP-Plugins%2Fglm-member-db-events.git Working on the ical feed for event profile Creating an ical feed for event profile. --- diff --git a/models/admin/ajax/icalFeed.php b/models/admin/ajax/icalFeed.php new file mode 100644 index 0000000..e7db76c --- /dev/null +++ b/models/admin/ajax/icalFeed.php @@ -0,0 +1,59 @@ + + * @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; + +} diff --git a/models/front/events/icalFeed.php b/models/front/events/icalFeed.php new file mode 100644 index 0000000..468b2b2 --- /dev/null +++ b/models/front/events/icalFeed.php @@ -0,0 +1,118 @@ + + * @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 '
$event: ' . print_r($event, true) . '
'; +$icalHeader = << 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'); + //header('Content-type: text/calendar; charset=utf-8'); + //header('Content-Disposition: inline; filename=event-' . $eventId . '.ics'); + $output .= '
';
+            $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 .= '
'; + echo $output; + exit; + break; + default: + die('should not reach this'); + break; + } + } + + function icalDateFormat($datetime) + { + return date('Ymd\THis', $datetime); + } +} diff --git a/setup/validActions.php b/setup/validActions.php index 9c4c97b..0a8f9c0 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -33,8 +33,9 @@ $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, @@ -55,7 +56,7 @@ $glmMembersEventsAddOnValidActions = array( '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, ) ) ); diff --git a/views/front/events/detail.html b/views/front/events/detail.html index 7a3cc5a..7c7426e 100644 --- a/views/front/events/detail.html +++ b/views/front/events/detail.html @@ -1,6 +1,7 @@
+ Ical Feed