From: Steve Sutton Date: Wed, 18 May 2016 20:40:42 +0000 (-0400) Subject: Event rss feed now working X-Git-Tag: v1.0.0^2~30 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=e86e7c70fab46d93b3305771c77687ffeec0c08e;p=WP-Plugins%2Fglm-member-db-events.git Event rss feed now working Using the smarty templates for the css feed --- diff --git a/models/admin/ajax/rssFeed.php b/models/admin/ajax/rssFeed.php new file mode 100644 index 0000000..ecb0c2a --- /dev/null +++ b/models/admin/ajax/rssFeed.php @@ -0,0 +1,59 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +require_once GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/models/front/events/rssFeed.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_rssFeed extends GlmMembersFront_events_rssFeed +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + +} diff --git a/models/front/events/rssFeed.php b/models/front/events/rssFeed.php new file mode 100644 index 0000000..4f287ff --- /dev/null +++ b/models/front/events/rssFeed.php @@ -0,0 +1,95 @@ + + * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt} + */ +class GlmMembersFront_events_rssFeed 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-rss'; + } + } + + if ( !isset($eventId) || !$eventId ) { + $action = 'event-list-rss'; + } + + if ( !$action) { + return ''; + } + + $output = ''; + //header("Content-Type: application/xml\n"); + + switch ($action) { + case 'event-rss': + $events = array($this->getModelEventData( $eventId )); + break; + case 'event-list-rss': + $events = $this->getModelEventsData(); + break; + } + + //echo '
$events: ' . print_r($events, true) . '
'; + //exit; + // Load Smarty Template support + $smarty = new smartyTemplateSupport(); + + $viewPath = GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/views'; + $smarty->template->setTemplateDir($viewPath); + + //echo '
$smarty: ' . print_r($smarty, true) . '
'; + //exit; + + $smarty->templateAssign('eventUrlBase', get_bloginfo('url') . '/event-detail/'); + $smarty->templateAssign('title', 'Events'); + $smarty->templateAssign('link', 'main_event_page_url'); + $smarty->templateAssign('description', 'Calendar of Events'); + $smarty->templateAssign('pubDate', date('r')); + $smarty->templateAssign('language', 'en-EN'); + $smarty->templateAssign('generator', 'Gaslight Media Event Feed Generator'); + + $smarty->templateAssign('items', $events); + + // Add standard parameters + require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php'; + + $viewFile = 'front/events/rssFeed.xml'; + + // Generate output from model data and view + $output = $smarty->template->fetch($viewFile); + echo $output; + } +} diff --git a/setup/validActions.php b/setup/validActions.php index 0a8f9c0..bae7db6 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -36,6 +36,7 @@ $glmMembersEventsAddOnValidActions = array( 'pdfOutput' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, 'nameSearch' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, 'icalFeed' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, + 'rssFeed' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, ), 'member' => array( 'events' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, diff --git a/views/front/events/rssFeed.xml b/views/front/events/rssFeed.xml new file mode 100644 index 0000000..c16fcb5 --- /dev/null +++ b/views/front/events/rssFeed.xml @@ -0,0 +1,50 @@ + + + + + <![CDATA[ {$title} ]]> + + + {$link} + + + + + {$pubDate} + {$generator} + {$language} + http://blogs.law.harvard.edu/tech/rss + {foreach $items as $item} + + + <![CDATA[ {$item.name} ]]> + + + {$eventUrlBase}{$item.name_slug}/ + + + {$eventUrlBase}{$item.name_slug}/ + + + + + {$item.starting_timestamp|date_format:"%m/%d/%Y"} + + {$item.starting_timestamp|date_format:"%D"} + + + {$item.ending_timestamp|date_format:"%D"} + + + {$item.starting_timestamp|date_format:"%H:%M:%S"} + + + {$item.ending_timestamp|date_format:"%H:%M:%S"} + + + {/foreach} + +