Started building front-end output
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 10 Mar 2015 19:38:45 +0000 (15:38 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 10 Mar 2015 19:38:45 +0000 (15:38 -0400)
14 files changed:
config/plugin.ini
controllers/front.php
css/front.css
index.php
lib/GlmDataAbstract/DataAbstract.php
misc/smarty/templates_c/081a36d97cdf30d438a1e104c26a275acc180da0.file.index.html.php
models/admin/member/memberInfo.php
models/front/members/list.php [new file with mode: 0644]
views/front/error/badAction.html [new file with mode: 0644]
views/front/error/header.html [new file with mode: 0644]
views/front/error/index.html [new file with mode: 0644]
views/front/footer.html [new file with mode: 0644]
views/front/members/header.html [new file with mode: 0644]
views/front/members/list.html [new file with mode: 0644]

index 67480c5..eaee2ad 100644 (file)
@@ -245,6 +245,7 @@ phrase['phrase_test'] = 'test'
 
 [chuck:common]
 admin_debug = true
+front_debug = true
 googleMapsApiKey = ''
 
 
index 2b2c327..2d737cb 100644 (file)
 $GLOBALS['glmMembersFrontValidActions'] = array(
 
         'members' => array(
-                'index', // member list
-                'list',
-                'reports',
-                'other'
+                'list'
         )
 );
 
@@ -71,7 +68,7 @@ class glmMembersFront extends GlmPluginSupport
         $this->config = $config;
 
         // Add front-end scripts and css
-        add_action('front_enqueue_scripts',
+        add_action('wp_enqueue_scripts',
                 array(
                         $this,
                         'glmMembersFrontScripts'
@@ -82,6 +79,7 @@ class glmMembersFront extends GlmPluginSupport
                         $this,
                         'controller'
                 ));
+
     }
 
     /**
@@ -97,26 +95,28 @@ class glmMembersFront extends GlmPluginSupport
     public function glmMembersFrontScripts ()
     {
 
-        /*
-         *
-         * wp_enqueue_script('jquery');
-         * wp_enqueue_script('jquery-style');
-         * wp_enqueue_script('jquery-ui-core');
-         * wp_enqueue_script('jquery-ui-dialog');
-         *
-         * wp_register_script('glm-members-front-js',
-         * GLM_MEMBERS_PLUGIN_URL . 'js/front.js',
-         * array(
-         * 'jquery'
-         * ));
-         * wp_enqueue_script('glm-members-front-js');
-         */
+        wp_enqueue_script('jquery');
+        wp_enqueue_script('jquery-style');
+        wp_enqueue_script('jquery-ui-core');
+        wp_enqueue_script('jquery-ui-dialog');
+        wp_enqueue_style("wp-jquery-ui-dialog");
+
+        // Front end script
+        wp_register_script(
+            'glm-members-front-js',
+            GLM_MEMBERS_PLUGIN_URL . 'js/front.js',
+            array(
+                'jquery'
+            ));
+        wp_enqueue_script('glm-members-front-js');
 
         // A simple set of styles for things I haven't found as a WordPress
-        // default yet
-        wp_register_style('glmMembersFrontStyle',
-                GLM_MEMBERS_PLUGIN_URL . 'css/front.css');
+        wp_register_style(
+            'glmMembersFrontStyle',
+            GLM_MEMBERS_PLUGIN_URL . 'css/front.css'
+        );
         wp_enqueue_style('glmMembersFrontStyle');
+
     }
 
     /**
@@ -173,12 +173,16 @@ class glmMembersFront extends GlmPluginSupport
      */
     public function controller ($atts, $content = null)
     {
+
         // Shortcode Attributes defaults
         $request = shortcode_atts(
-                array(
-                        'action' => 'list',
-                        'option' => false
-                ), $atts);
+            array(
+                'action' => 'index',
+                'option' => false
+            ),
+            $atts,
+            'glm-members'
+        );
 
         /*
          * Because WordPress insists on forcing the timezone to UTC
@@ -191,11 +195,11 @@ class glmMembersFront extends GlmPluginSupport
 
         $errorMsg = '';
 
-        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+        if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
 
             // Get all defiend constants then if not VERBOSE select out only user contstants
             $consts = get_defined_constants(true);
-            if (!GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+            if (!GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) {
                 $consts = $consts['user'];
             }
 
@@ -208,10 +212,19 @@ class glmMembersFront extends GlmPluginSupport
          */
 
         // Default action is "index"
-        $action = 'index';
+        $menuItem = 'members';
+        $action = 'list';
+        $option = false;
+
+        // First check shortcode attributes
+        if  ($request['action']) {
+            $action = $request['action'];
+        }
+        if  ($request['option']) {
+            $action = $request['option'];
+        }
 
-        // Get any requested "action" from a form submission modify path/name
-        // accordingly
+        // Get any requested "action" from a form submission - Overrides shortcode attributes
         if (isset($_REQUEST['glm_action']) && $_REQUEST['glm_action'] != '') {
             $a = sanitize_text_field($_REQUEST['glm_action']);
             if ($a != '') {
@@ -225,8 +238,7 @@ class glmMembersFront extends GlmPluginSupport
         do {
 
             if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
-                $this->addNotice(
-                        "<b>Requested Action:</b> Menu item = $menuItem, Action = $action", 'Process');
+                glmMembersFront::addNotice("<b>Requested Action:</b> Menu item = $menuItem, Action = $action", 'Process');
             }
 
             $modelRedirect = false;
@@ -360,19 +372,19 @@ class glmMembersFront extends GlmPluginSupport
         $smarty = new smartyTemplateSupport();
 
         // Add standard parameters
-        $smarty->templateAssign ( 'adminDebug', GLM_MEMBERS_PLUGIN_ADMIN_DEBUG);
+        $smarty->templateAssign ( 'frontDebug', GLM_MEMBERS_PLUGIN_FRONT_DEBUG);
         $smarty->templateAssign ( 'baseURL', GLM_MEMBERS_PLUGIN_BASE_URL);
         $smarty->templateAssign ( 'thisURL', GLM_MEMBERS_PLUGIN_CURRENT_URL );
-        $smarty->templateAssign ( 'thisPage', $_REQUEST['page']);
         $smarty->templateAssign ( 'glmPluginName', GLM_MEMBERS_PLUGIN_NAME );
         $smarty->templateAssign ( 'glmPluginMediaURL', GLM_MEMBERS_PLUGIN_MEDIA_URL );
         $smarty->templateAssign ( 'thisYear', date ( 'Y' ) );
         $smarty->templateAssign ( $this->config['term']);
         $smarty->templateAssign ( $this->config['phrase']);
+        $smarty->templateAssign ( 'googleMapsBrowserApiKey', $this->config['googleMapsApiKey']);
 
         // Add all terms and phrases from the config/plugin.ini file
-        $smarty->templateAssign ( 'terms', $this->config->term);
-        $smarty->templateAssign ( 'phrase', $this->config->phrase);
+//        $smarty->templateAssign ( 'terms', $this->config->term);
+//        $smarty->templateAssign ( 'phrase', $this->config->phrase);
 
         // Add data from model to Smarty template
         if (is_array($results['data']) && count($results['data']) > 0) {
index 7766c46..971dbc8 100644 (file)
@@ -3,3 +3,30 @@
     Gaslight Media Members Database Front-End Styles
 
 */
+
+.glm-right {
+    float: right;    
+}
+.glm-left {
+    float: left;    
+}
+
+
+.glm-item-container {
+    border: 1px #ccc solid;
+    padding: .4em;
+    background: #f8f8f8;
+}
+
+/* Map */
+.glm-map { 
+    width:90%; 
+    height:400px; 
+    border: 2px black solid;
+}
+
+
+.glm-copyright {
+    text-align: center;
+    margin: 2em;
+}
index 703c487..ee289df 100644 (file)
--- a/index.php
+++ b/index.php
@@ -59,7 +59,7 @@ if (isset($configData[$hostSection])) {
     ;
 }
 
-// Add Debug defines
+// Add Debug defines - These can't go into the defines.php file - Guess why.
 define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG', $config['admin_debug']);
 define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', $config['admin_debug_verbose']);
 define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG', $config['front_debug']);
index 2f1daaf..e7cf487 100755 (executable)
@@ -716,7 +716,7 @@ abstract class GlmDataAbstract
 
         // Get pointer options from specified table
         $order_by = $f['p_field'];
-        if ($f['p_orderby']) {
+        if (isset($f['p_orderby']) && $f['p_orderby']) {
             $order_by = $f['p_orderby'];
         }
 
index 238c2b9..d206596 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-03-10 11:24:34
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-03-10 12:28:06
          compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/members/index.html" */ ?>
 <?php /*%%SmartyHeaderCode:43313958054c05ab60b0587-71987387%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
 $_valid = $_smarty_tpl->decodeProperties(array (
@@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array (
     '081a36d97cdf30d438a1e104c26a275acc180da0' => 
     array (
       0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/members/index.html',
-      1 => 1426001070,
+      1 => 1426001139,
       2 => 'file',
     ),
   ),
index 802a4df..b78846c 100644 (file)
@@ -378,7 +378,8 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo
                 $sql = "
                     UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info
                        SET status = ".$this->config['status_numb']['Inactive']."
-                     WHERE status = ".$this->config['status_numb']['Active']."
+                     WHERE member = $memberID
+                       AND status = ".$this->config['status_numb']['Active']."
                        AND id != $memberInfoID
                 ;";
                 $this->wpdb->query($sql);
diff --git a/models/front/members/list.php b/models/front/members/list.php
new file mode 100644 (file)
index 0000000..557c48b
--- /dev/null
@@ -0,0 +1,158 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Front List Members
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+// Load Members data abstract
+require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php');
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersFront_members_list extends GlmDataMemberInfo
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /*
+     * Constructor
+     *
+     * This contructor sets up this model. At this time that only includes
+     * storing away the WordPress data object.
+     *
+     * @return object Class object
+     *
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        // Run constructor for members data class
+        parent::__construct($this->wpdb, $this->config);
+
+    }
+
+    /*
+     * Perform Model Action
+     *
+     * This method does the work for this model and returns any resulting data
+     *
+     * @return array Status and data array
+     *
+     * 'status'
+     *
+     * True if successfull and false if there was a fatal failure.
+     *
+     * 'menuItemRedirect'
+     *
+     * If not false, provides a menu item the controller should
+     * execute after this one. Normally if this is used, there would also be a
+     * modelRedirect value supplied as well.
+     *
+     * 'modelRedirect'
+     *
+     * If not false, provides an action the controller should execute after
+     * this one.
+     *
+     * 'view'
+     *
+     * A suggested view name that the contoller should use instead of the
+     * default view for this model or false to indicate that the default view
+     * should be used.
+     *
+     * 'data'
+     *
+     * Data that the model is returning for use in merging with the view to
+     * produce output.
+     *
+     */
+    public function modelAction ($redirectData = false)
+    {
+
+        $where = '';
+        $filterPending = false;
+        $filterArchived = false;
+        $filterName = false;
+        $haveFilter = false;
+
+        $where .= " T.status = ".$this->config['status_numb']['Active'];
+
+        // Get a current list of members
+        $list = $this->getList($where);
+
+        if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+            glmMembersFront::addNotice($list, 'DataBlock', 'Member Data');
+        }
+
+        // If we have list entries - even if it's an empty list
+        $success = true;
+        $haveMembers = false;
+        if ($list !== false) {
+
+            $success = true;
+
+            // If we have any entries
+            if (count($list) > 0) {
+                $haveMembers = true;
+            }
+        }
+
+        // Determine if current user can add, edit, delete member data
+//        $canEdit = current_user_can('glm_members_edit');
+
+        // Compile template data
+        $templateData = array(
+            'haveMembers' => $haveMembers,
+            'members' => $list,
+            'haveFilter' => $haveFilter,
+            'filterArchived' => $filterArchived,
+            'filterPending' => $filterPending,
+            'filterName' => stripslashes($filterName)
+//            'canEdit' => $canEdit
+        );
+
+        // Return status, suggested view, and data to controller
+        return array(
+            'status' => $success,
+            'menuItemRedirect' => false,
+            'modelRedirect' => false,
+            'view' => 'front/members/list.html',
+            'data' => $templateData
+        );
+
+    }
+
+
+}
+
+?>
\ No newline at end of file
diff --git a/views/front/error/badAction.html b/views/front/error/badAction.html
new file mode 100644 (file)
index 0000000..7165a07
--- /dev/null
@@ -0,0 +1,11 @@
+{include file='front/error/header.html'}
+    
+    <h2>Sorry, we've had an error.</h2>
+    
+    <p><b>Error: </b>: An invalid action has been specified.</p>
+    
+    {if $errorMsg}<p>{$errorMsg}</p>{/if}
+
+    <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
+      
+{include file='front/footer.html'}
diff --git a/views/front/error/header.html b/views/front/error/header.html
new file mode 100644 (file)
index 0000000..f9fdb91
--- /dev/null
@@ -0,0 +1,5 @@
+<div class="wrap">
+       
+    <h2>{$glmPluginName}</h2>
+    
+  
\ No newline at end of file
diff --git a/views/front/error/index.html b/views/front/error/index.html
new file mode 100644 (file)
index 0000000..ece4c86
--- /dev/null
@@ -0,0 +1,12 @@
+{include file='front/error/header.html'}
+    
+    <center>
+    
+        <h3>Sorry, we've had some type of fatal error.</h3>
+        
+        <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
+          
+    </center>
+    
+{include file='front/footer.html'}
+
diff --git a/views/front/footer.html b/views/front/footer.html
new file mode 100644 (file)
index 0000000..9782baf
--- /dev/null
@@ -0,0 +1,16 @@
+
+    </div> <!-- / admin content area -->
+    <div class="glm-copyright">
+        {$glmPluginName}<br>
+        Copyright &copy; 2014-{$thisYear} Gaslight Media - All Rights Reserved<br>
+        Phone: 231-487-0692 - E-Mail: info@gaslightmedia.com<br>
+        <a href="http://www.gaslightmedia.com">http://www.gaslightmedia.com</a>
+    </div>
+         
+  {if $frontDebug}
+    <script>
+        window.open('{$thisURL}?glmDebugWindow=true','GLM_Plugin_Debug','width=800,height=800,left=50,top=50,resizable=yes,scrollbars=yes');
+    </script>
+  {/if}
+  
+</div> <!-- / wrap -->
\ No newline at end of file
diff --git a/views/front/members/header.html b/views/front/members/header.html
new file mode 100644 (file)
index 0000000..4af7c4f
--- /dev/null
@@ -0,0 +1,3 @@
+<div class="wrap">
+    <div id="glm-front-content-container">
+    
\ No newline at end of file
diff --git a/views/front/members/list.html b/views/front/members/list.html
new file mode 100644 (file)
index 0000000..b9ca45a
--- /dev/null
@@ -0,0 +1,87 @@
+{include file='front/members/header.html'}
+
+
+        <script src="http://maps.googleapis.com/maps/api/js?sensor=true&key={$googleMapsBrowserApiKey}"></script>
+
+        <div id="locationMap" class="glm-map">(map loads here)</div>     
+                    
+    
+    <h3>List of Members</h3>
+    
+{if $haveMembers}
+    {foreach $members as $m}
+        <div class="glm-item-container">
+            <div><img src="{$glmPluginMediaURL}/images/small/{$m.logo}"></div>
+            <div>
+                <h2><a href=""{$thisURL}?action=detail&member={$m.id}">{$m.member}</a></h2>
+                <p>
+                    {if $m.addr1}{$m.addr1}<br>{/if}
+                    {if $m.addr2}{$m.addr2}<br>{/if}
+                    {if $m.city.name}{$m.city.name}{if $m.state.name}, {/if}{/if}{if $m.state.name}{$m.state.name}{/if}{if $m.zip} {$m.zip}{/if} 
+                    {if $m.country.name}<br>{$m.country.name}{/if}
+                </p>                
+                
+                
+        {if $m.descr}
+                <p>{$m.descr}</p>
+        {else if $m.short_descr}
+                <p>{$m.short_descr}</p>
+        {/if}
+            </div>
+            
+        </div>
+    {/foreach}
+{else}
+        <div>(no members listed)</div>
+{/if}
+
+    <script type="text/javascript">
+        jQuery(document).ready(function($) {
+
+            /*
+             * Google Maps
+             *  API reference: https://developers.google.com/maps/documentation/javascript/reference
+             */
+            
+            // Set default - Need to make this configurable
+            var startLat = 45;
+            var startLon = -84;
+            var location = new google.maps.LatLng(startLat, startLon);
+            var map = new google.maps.Map(document.getElementById('locationMap'), {  
+                maxZoom: 12,  
+                disableDefaultUI: false,   
+                mapTypeId: google.maps.MapTypeId.MAP,  
+            });  
+            var geocoder = new google.maps.Geocoder();
+
+            var bounds = new google.maps.LatLngBounds();
+
+    {if $haveMembers}
+        {foreach $members as $m}
+
+            var marker = new google.maps.Marker({  
+                map: map,  
+                position: new google.maps.LatLng({$m.lat}, {$m.lon}),
+                draggable: true,
+                animation: google.maps.Animation.DROP,  
+                title: "{$m.member}",
+                memberID: {$m.id}
+            });
+            
+            bounds.extend(marker.position);
+        {/foreach}
+    {/if}
+
+            map.fitBounds(bounds);
+        
+            google.maps.event.addListener(marker, 'click', function() {
+                window.location.replace("{$thisURL}?action=detail&member=" + this.memberID);
+            });
+
+
+        });
+    </script>
+  
+
+
+{include file='front/footer.html'}