Event rss feed now working
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 18 May 2016 20:40:42 +0000 (16:40 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 18 May 2016 20:40:42 +0000 (16:40 -0400)
Using the smarty templates for the css feed

models/admin/ajax/rssFeed.php [new file with mode: 0644]
models/front/events/rssFeed.php [new file with mode: 0644]
setup/validActions.php
views/front/events/rssFeed.xml [new file with mode: 0644]

diff --git a/models/admin/ajax/rssFeed.php b/models/admin/ajax/rssFeed.php
new file mode 100644 (file)
index 0000000..ecb0c2a
--- /dev/null
@@ -0,0 +1,59 @@
+<?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/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 (file)
index 0000000..4f287ff
--- /dev/null
@@ -0,0 +1,95 @@
+<?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_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 '<pre>$events: ' . print_r($events, true) . '</pre>';
+        //exit;
+        // Load Smarty Template support
+        $smarty = new smartyTemplateSupport();
+
+        $viewPath = GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/views';
+        $smarty->template->setTemplateDir($viewPath);
+
+        //echo '<pre>$smarty: ' . print_r($smarty, true) . '</pre>';
+        //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;
+    }
+}
index 0a8f9c0..bae7db6 100644 (file)
@@ -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 (file)
index 0000000..c16fcb5
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss 
+    xmlns:content="http://purl.org/rss/1.0/modules/content/"
+    xmlns:glmEvent="http://www.gaslightmedia.com/rss"
+    version="2.0">
+    <channel>
+        <title>
+            <![CDATA[ {$title} ]]>
+        </title>
+        <link>
+            {$link}
+        </link>
+        <description>
+            <![CDATA[ {$description} ]]>
+        </description>
+        <pubDate>{$pubDate}</pubDate>
+        <generator>{$generator}</generator>
+        <language>{$language}</language>
+        <docs>http://blogs.law.harvard.edu/tech/rss</docs>
+        {foreach $items as $item}
+        <item>
+            <title>
+                <![CDATA[ {$item.name} ]]>
+            </title>
+            <link>
+                {$eventUrlBase}{$item.name_slug}/
+            </link>
+            <guid>
+                {$eventUrlBase}{$item.name_slug}/
+            </guid>
+            <description>
+                <![CDATA[ {$item.descr} ]]>
+            </description>
+            <pubDate>{$item.starting_timestamp|date_format:"%m/%d/%Y"}</pubDate>
+            <glmEvent:startDay>
+                {$item.starting_timestamp|date_format:"%D"}
+            </glmEvent:startDay>
+             <glmEvent:endDay>
+                {$item.ending_timestamp|date_format:"%D"}
+            </glmEvent:endDay>
+            <glmEvent:startTime>
+                {$item.starting_timestamp|date_format:"%H:%M:%S"}
+            </glmEvent:startTime>
+            <glmEvent:endTime>
+                {$item.ending_timestamp|date_format:"%H:%M:%S"}
+            </glmEvent:endTime>
+        </item>
+        {/foreach}
+    </channel>
+</rss>