Completed initial front-end member list and added documentation and functionality...
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 13 Mar 2015 16:45:36 +0000 (12:45 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 13 Mar 2015 16:45:36 +0000 (12:45 -0400)
16 files changed:
classes/data/dataAccommodationTypes.php
classes/data/dataAmenities.php
classes/data/dataCategories.php
classes/data/dataCategoryMemberInfo.php
classes/data/dataCities.php
classes/data/dataMemberInfo.php
classes/data/dataMemberTypes.php
classes/data/dataMembers.php
classes/data/dataRegions.php
css/front.css
lib/GlmDataAbstract/.~lock.documentation.odt# [new file with mode: 0644]
lib/GlmDataAbstract/DataAbstract.php
lib/GlmDataAbstract/GlmDataAbstract_Programmers_Manual.pdf [new file with mode: 0644]
lib/GlmDataAbstract/documentation.odt [new file with mode: 0644]
models/front/members/list.php
views/front/members/list.html

index 9038339..38fd379 100644 (file)
@@ -87,7 +87,6 @@ class GlmDataAccommodationTypes extends GlmDataAbstract
      */
     function __construct ($wpdb, $config)
     {
-        parent::__construct($wpdb, $config);
 
         // Save WordPress Database object
         $this->wpdb = $wpdb;
index 25321dd..f427729 100644 (file)
@@ -87,7 +87,6 @@ class GlmDataAmenities extends GlmDataAbstract
      */
     function __construct ($wpdb, $config)
     {
-        parent::__construct($wpdb, $config);
 
         // Save WordPress Database object
         $this->wpdb = $wpdb;
index d9e6a72..3455e71 100644 (file)
@@ -87,7 +87,6 @@ class GlmDataCategories extends GlmDataAbstract
      */
     function __construct ($wpdb, $config)
     {
-        parent::__construct($wpdb, $config);
 
         // Save WordPress Database object
         $this->wpdb = $wpdb;
index ae3e4bc..5e64e7a 100644 (file)
@@ -87,7 +87,6 @@ class GlmDataCategoryMemberInfo extends GlmDataAbstract
      */
     function __construct ($wpdb, $config)
     {
-        parent::__construct($wpdb, $config);
 
         // Save WordPress Database object
         $this->wpdb = $wpdb;
index a4f4f01..ac3679e 100644 (file)
@@ -87,7 +87,6 @@ class GlmDataCities extends GlmDataAbstract
      */
     function __construct ($wpdb, $config)
     {
-        parent::__construct($wpdb, $config);
 
         // Save WordPress Database object
         $this->wpdb = $wpdb;
index 815bc15..e05a91c 100644 (file)
@@ -83,9 +83,8 @@ class GlmDataMemberInfo extends GlmDataAbstract {
         * @return void
         * @access public
         */
-       function __construct($wpdb, $config) {
-
-               parent::__construct ( $wpdb, $config );
+       function __construct($wpdb, $config)
+       {
 
                // Save WordPress Database object
                $this->wpdb = $wpdb;
@@ -307,9 +306,51 @@ class GlmDataMemberInfo extends GlmDataAbstract {
                    glmMembersAdmin::addNotice($this->fields, 'DataBlock', 'Table Fields: '.$this->table);
                }
 
+       }
 
-
+       /*
+        * Entry Post Processing Call-Back Method
+        *
+        * Perform post-processing for all result entries.
+        *
+        * In this case we're using it to append an array of category
+        * data to each member result.
+        *
+        * @param array $r Array of field result data for a single entry
+        * @param string $a Action being performed (l, i, g, ...)
+        *
+        * @return object Class object
+        *
+        */
+       public function entryPostProcessing($r, $a)
+       {
+
+           // Only run these tests for 'l' (getList)
+           if ($a != 'l') {
+               return $r;
+           }
+
+           // Get Member Category data for this entry
+           $sql = "
+            SELECT CMI.member_info AS member_info_id, C.id, C.name, C.descr, C.short_descr,
+                   COALESCE (
+                        (
+                        SELECT name
+                          FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "categories
+                         WHERE id = C.parent
+                        ), ''
+                   ) AS parent_name
+              FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "categories AS C,
+                   ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "category_member_info AS CMI
+             WHERE C.id = CMI.category
+               AND CMI.member_info = ".$r['id']."
+        ;";
+           $r['categories'] = $this->wpdb->get_results($sql, ARRAY_A);
+
+           // Required
+           return $r;
        }
+
 }
 
 ?>
\ No newline at end of file
index a593875..224e0ea 100644 (file)
@@ -87,7 +87,6 @@ class GlmDataMemberTypes extends GlmDataAbstract
      */
     function __construct ($wpdb, $config)
     {
-        parent::__construct($wpdb, $config);
 
         // Save WordPress Database object
         $this->wpdb = $wpdb;
index e45978e..04d97db 100644 (file)
@@ -83,9 +83,8 @@ class GlmDataMembers extends GlmDataAbstract {
         * @return void
         * @access public
         */
-       function __construct($wpdb, $config) {
-
-               parent::__construct ( $wpdb, $config );
+       function __construct($wpdb, $config)
+       {
 
                // Save WordPress Database object
                $this->wpdb = $wpdb;
index 5ed060f..92fc593 100644 (file)
@@ -87,7 +87,6 @@ class GlmDataRegions extends GlmDataAbstract
      */
     function __construct ($wpdb, $config)
     {
-        parent::__construct($wpdb, $config);
 
         // Save WordPress Database object
         $this->wpdb = $wpdb;
index 971dbc8..9f9f4ab 100644 (file)
     float: left;    
 }
 
-
-.glm-item-container {
+/* Member Containers */
+.glm-member-list-container {
     border: 1px #ccc solid;
     padding: .4em;
     background: #f8f8f8;
+    margin: .4em 0px .4em 0px;
+}
+.glm-member-list-image {
+    float: right;
+}
+.glm-member-list-nameAddress {
+    float: left;
+}
+.glm-member-list-info {
+    clear: both;
+}
+.glm-member-list-categories {
+    margin-top: .5em;
 }
 
 /* Map */
+
 .glm-map { 
-    width:90%; 
+    width: 100%; 
     height:400px; 
     border: 2px black solid;
 }
-
-
-.glm-copyright {
-    text-align: center;
-    margin: 2em;
+/* overrride whatever was causing the 100% width for images in Google Maps */
+.glm-map img {
+    max-width: none !important;
 }
diff --git a/lib/GlmDataAbstract/.~lock.documentation.odt# b/lib/GlmDataAbstract/.~lock.documentation.odt#
new file mode 100644 (file)
index 0000000..01daedf
--- /dev/null
@@ -0,0 +1 @@
+,cscott,Ubuntu-1404,13.03.2015 12:40,file:///home/cscott/.config/libreoffice/4;
\ No newline at end of file
index e7cf487..1e2422b 100755 (executable)
@@ -121,22 +121,6 @@ abstract class GlmDataAbstract
      */
     public $deleteRestrictions = false;
 
-    /**
-     * Constructor
-     *
-     * @param object $d database connection
-     *
-     * @return void
-     * @access public
-     */
-    public function __construct($wpdb, $config)
-    {
-
-        $this->wpdb = $wpdb;
-        $this->config = $config;
-
-    }
-
     /**
      * Field processing for various field types
      *
@@ -183,7 +167,7 @@ abstract class GlmDataAbstract
 
         if (trim($in) != '' && !is_numeric($in)) {
             $this->inputFieldStatus = false;
-            $this->inputErrorReason = 'Input is not numeric.';
+            $this->inputErrorReason = 'Input not numeric.';
             return $in;
         }
 
@@ -288,7 +272,7 @@ abstract class GlmDataAbstract
 
         if ($in != '' && !is_numeric($in)) {
             $this->inputFieldStatus = false;
-            $this->inputErrorReason = 'Input is not numeric.';
+            $this->inputErrorReason = 'Input not numeric.';
             return $in;
         }
 
@@ -390,7 +374,7 @@ abstract class GlmDataAbstract
 
         if (!is_numeric($in)) {
             $this->inputFieldStatus = false;
-            $this->inputErrorReason = 'Input is not numeric.';
+            $this->inputErrorReason = 'Input not numeric.';
             return $in;
         }
 
@@ -487,7 +471,7 @@ abstract class GlmDataAbstract
 
         if (!is_numeric($in)) {
             $this->inputFieldStatus = false;
-            $this->inputErrorReason = 'Input is not numeric.';
+            $this->inputErrorReason = 'Input not numeric.';
             return $in;
         }
 
@@ -765,7 +749,7 @@ abstract class GlmDataAbstract
 
             if ($in != '' && !is_numeric($in)) {
                 $this->inputFieldStatus = false;
-                $this->inputErrorReason = 'Selected item is not valid.';
+                $this->inputErrorReason = 'Selected item not valid.';
                 //                return $in;
                 }
 
@@ -774,7 +758,7 @@ abstract class GlmDataAbstract
 
             if (!is_int($in)) {
                 $this->inputFieldStatus = false;
-                $this->inputErrorReason = 'Selected item is not valid.';
+                $this->inputErrorReason = 'Selected item not valid.';
                 return $in;
             }
 
@@ -1006,13 +990,13 @@ abstract class GlmDataAbstract
             // Is it one of the available values
             if (isset($f['required']) && $f['required'] && trim($in) == '') {
                 $this->inputFieldStatus = false;
-                $this->inputErrorReason = 'Required input is not provded.';
+                $this->inputErrorReason = 'Required input not provded.';
             }
 
             // Is it a valid value
             if (trim($in) != '' && !isset($list[$in])) {
                 $this->inputFieldStatus = false;
-                $this->inputErrorReason = 'Value selected is not valid.';
+                $this->inputErrorReason = 'Value selected not valid.';
             }
 
         }
@@ -1202,7 +1186,7 @@ abstract class GlmDataAbstract
         $filter = FILTER_SANITIZE_STRING;
         if (isset($f['filter'])) {
             if (!is_numeric($f['filter'])) {
-                echo "<P>&nbsp;</p><strong>ERROR:</strong> Supplied value for option 'filter' in fields array is not a defined filter for PHP filter_input();";
+                echo "<P>&nbsp;</p><strong>ERROR:</strong> Supplied value for option 'filter' in fields array not a defined filter for PHP filter_input();";
                 exit;
             }
             $filter = $f['filter'];
@@ -2461,7 +2445,7 @@ abstract class GlmDataAbstract
             (trim($in['sec']) != '' && !is_numeric($in['sec']))
         ) {
             $this->inputFieldStatus = false;
-            $this->inputErrorReason = 'Latitude input is not entirely numeric.';
+            $this->inputErrorReason = 'Latitude input not entirely numeric.';
             return $in;
         }
 
@@ -2589,7 +2573,7 @@ abstract class GlmDataAbstract
             (trim($in['sec']) != '' && !is_numeric($in['sec']))
         ) {
             $this->inputFieldStatus = false;
-            $this->inputErrorReason = 'Longitude input is not entirely numeric.';
+            $this->inputErrorReason = 'Longitude input not entirely numeric.';
             return $in;
         }
 
@@ -2773,6 +2757,11 @@ abstract class GlmDataAbstract
             }
         }
 
+        //
+        // Check if there's a function to do other checks
+        $data = $this->entryPostProcessing($data, $op);
+
+
         if ($forEdit) {
             $r = array(
                 'status' => true,
@@ -2880,7 +2869,9 @@ abstract class GlmDataAbstract
     /**
      * Stats Method
      *
-     * @return void
+     * @param string $where Optional WHERE clause for selection of entries. Defaults to all.
+     *
+     * @return integer Count of records matching $where
      * @access public
      */
     public function getStats($where = 'true')
@@ -2902,13 +2893,19 @@ abstract class GlmDataAbstract
     }
 
     /**
-     * List Method
+     * List Entries Method
      *
-     * @return void
+     * @param string $where Optional WHERE clause for selection of entries. Defaults to all.
+     * @param string $order Optional ORDER BY clause for sorting of results.
+     * @param boolean $fieldVals Optional flag requesting fields contain array of all possible values.
+     * @param string $idField Optional name of ID field (primary index) to use for result array keys.
+     *
+     * @return array Array containing results
      * @access public
      */
-    public function getList($where = '', $order = '')
+    public function getList($where = '', $order = '', $fieldVals = true, $idField = 'id')
     {
+        // NOTE: $fieldVals not yet implemented
 
         // Get field specifications for this instance
         $this->buildFieldsList('l');
@@ -2931,23 +2928,23 @@ abstract class GlmDataAbstract
             glmMembersAdmin::addNotice($sql, 'DataBlock', "DataAbstract - getList() query");
         }
 
-        //echo "<pre>$sql</pre>";
         $list = $this->wpdb->get_results($sql, ARRAY_A);
 
         if (count($list) == 0) {
             return false;
         }
 
-        // Process individual fields
+        // Process field output data for each result - use ID field as key
+        $newList = array();
         while (list($k, $v) = each($list)) {
-            $list[$k] = $this->processOutputData($v, 'l');
+            $newList[$v['id']] = $this->processOutputData($v, 'l');
         }
 
         if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
-            glmMembersAdmin::addNotice($list, 'DataBlock', "getList() data");
+            glmMembersAdmin::addNotice($newList, 'DataBlock', "getList() data");
         }
 
-        return $list;
+        return $newList;
     }
 
     /**
@@ -2956,7 +2953,7 @@ abstract class GlmDataAbstract
      * @return void
      * @access public
      */
-    public function getEntry($id, $idfield = 'id', $where = '', $forEdit = false)
+    public function getEntry($id, $idfield = 'id', $where = '', $fieldVals = false)
     {
 
        if ($id-0 == 0) {
@@ -2979,7 +2976,7 @@ abstract class GlmDataAbstract
                }
 
         // Process individual fields
-        $detail = $this->processOutputData($detail, 'g', $forEdit);
+        $detail = $this->processOutputData($detail, 'g', $fieldVals);
 
 
         if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
@@ -3123,8 +3120,7 @@ abstract class GlmDataAbstract
     /**
      * Check Other fields (default function)
      * This is here so it doesn't have to be defined in data{xxx}.php file.
-     * if it is, be sure to use the following in that function.
-     *     parent::checkOther($r, $a);
+     * It will be overridden by any method of the same name in the extending code.
      *
      * @param array $r A result array from one of the other functions
      * @param string $a The action type being performed (single letter, i.e. l, g, ...)
@@ -3137,6 +3133,23 @@ abstract class GlmDataAbstract
         return $r;
     }
 
+    /**
+     * Post process an individual result entry.
+     *
+     * This is here so it doesn't have to be defined in data{xxx}.php file.
+     * It will be overridden by any method of the same name in the extending code.
+     *
+     * @param array $r A single result entry
+     * @param string $a The action type being performed (single letter, i.e. l, g, ...)
+     *
+     * @return array Returns supplied result entry as updated
+     * @access public
+     */
+    public function entryPostProcessing($r, $a)
+    {
+        return $r;
+    }
+
     /**
      * Store New Method
      *
@@ -3223,13 +3236,13 @@ abstract class GlmDataAbstract
      * @return void
      * @access public
      */
-    public function editEntry($id, $idfield = 'id')
+    public function editEntry($id, $idField = 'id')
     {
         $this->buildFieldsList('g');
 
         $sql = "SELECT $this->select
                 FROM $this->table T
-                WHERE $idfield = $id
+                WHERE $idField = $id
                 ;";
         $detail = $this->wpdb->get_row($sql, ARRAY_A);
 
@@ -3239,7 +3252,7 @@ abstract class GlmDataAbstract
         }
 
         // Process individual fields
-        $detail = $this->processOutputData($detail, 'e', true, $id, $idfield);
+        $detail = $this->processOutputData($detail, 'e', true, $id, $idField);
 
         if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
             glmMembersAdmin::addNotice($sql, 'DataBlock', "DataAbstract - editEntry() query");
diff --git a/lib/GlmDataAbstract/GlmDataAbstract_Programmers_Manual.pdf b/lib/GlmDataAbstract/GlmDataAbstract_Programmers_Manual.pdf
new file mode 100644 (file)
index 0000000..8cb9e4a
Binary files /dev/null and b/lib/GlmDataAbstract/GlmDataAbstract_Programmers_Manual.pdf differ
diff --git a/lib/GlmDataAbstract/documentation.odt b/lib/GlmDataAbstract/documentation.odt
new file mode 100644 (file)
index 0000000..b1a3519
Binary files /dev/null and b/lib/GlmDataAbstract/documentation.odt differ
index 557c48b..d542e79 100644 (file)
@@ -107,7 +107,10 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
 
         $where .= " T.status = ".$this->config['status_numb']['Active'];
 
-        // Get a current list of members
+        /*
+         *  Get a current list of members
+         */
+
         $list = $this->getList($where);
 
         if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
@@ -152,6 +155,51 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
 
     }
 
+    /*
+     * Entry Post Processing Call-Back Method
+     *
+     * Perform post-processing for all result entries.
+     *
+     * In this case we're using it to append an array of category
+     * data to each member result.
+     *
+     * @param array $r Array of field result data for a single entry
+     * @param string $a Action being performed (l, i, g, ...)
+     *
+     * @return object Class object
+     *
+     */
+    public function entryPostProcessing($r, $a)
+    {
+
+       // Only run these tests for 'l' (getList)
+       if ($a != 'l') {
+               return $r;
+       }
+
+       // Get Member Category data for this entry
+       $sql = "
+            SELECT CMI.member_info AS member_info_id, C.id, C.name, C.descr, C.short_descr,
+                   COALESCE (
+                        (
+                        SELECT name
+                          FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "categories
+                         WHERE id = C.parent
+                        ), ''
+                   ) AS parent_name
+              FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "categories AS C,
+                   ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "category_member_info AS CMI
+             WHERE C.id = CMI.category
+               AND CMI.member_info = ".$r['id']."
+        ;";
+       $r['categories'] = $this->wpdb->get_results($sql, ARRAY_A);
+
+       // Required
+       return $r;
+    }
+
+
+
 
 }
 
index b1cbd77..085f367 100644 (file)
     
 {if $haveMembers}
     {foreach $members as $m}
-        <div class="glm-item-container">
-            <div><img src="{$glmPluginMediaURL}/images/small/{$m.logo}"></div>
-            <div>
+        <div class="glm-member-list-container">
+            <div class="glm-member-list-image"><img src="{$glmPluginMediaURL}/images/small/{$m.logo}"></div>
+            <div class="glm-member-list-nameAddress">
                 <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}
+                    {if $m.region.value}<p>Region: {$m.region.name}</p>{/if}
                 </p>                
-                
-                
+            </div>
+            <div class="glm-member-list-info">
         {if $m.descr}
                 <p>{$m.descr}</p>
         {else if $m.short_descr}
                 <p>{$m.short_descr}</p>
+        {/if}
+                {if $m.phone}Phone: {$m.phone}<br>{/if}
+                {if $m.toll_free}Toll Free: {$m.toll_free}<br>{/if}
+                {if $m.url}Web site: <a href="{$m.url}">{$m.url}</a><br>{/if}
+        {if $m.categories}
+                <div class="glm-member-list-categories">           
+                    Member Categories
+                    <ul>
+            {foreach $m.categories as $c}
+                        <li>
+                            {if $c.parent_name}{$c.parent_name}: {/if}{$c.name}
+                        </li>
+            {/foreach}
+                    </ul>
+                </div>
         {/if}
             </div>
-            
         </div>
+            
     {/foreach}
 {else}
         <div>(no members listed)</div>
 {/if}
+                {if $m.toll_free}<p>{$m.toll_free}</p>{/if}
 
     <script type="text/javascript">
         jQuery(document).ready(function($) {
 
             /*
              * Google Maps
-             *  API reference: https://developers.google.com/maps/documentation/javascript/reference
+             *  API reference: https://develope                {if $m.toll_free}<p>{$m.toll_free}</p>{/if}
+rs.google.com/maps/documentation/javascript/reference
              */
             
             // Set default - Need to make this configurable
                 mapTypeId: google.maps.MapTypeId.MAP,  
             });  
             var geocoder = new google.maps.Geocoder();
-
             var bounds = new google.maps.LatLngBounds();
+            var infowindow = new google.maps.InfoWindow({
+               maxWidth: 300
+            });            
 
     {if $haveMembers}
         {foreach $members as $m}
                 position: new google.maps.LatLng({$m.lat}, {$m.lon}),
                 draggable: false,
                 animation: google.maps.Animation.DROP,  
-                title: "{$m.member}",
+                title: '{$m.member}',
+                descr: ' \
+                    <b>{$m.member}</b><hr> \
+                    <p>{$m.short_descr}<br> \
+                    <a href="{$m.url}" target="memberWebSite">{$m.url}</a><br> \
+                    <a href="{$thisURL}?action=detail&member={$m.id}">More Info</a> \
+                    </p>',
                 memberID: {$m.id}
             });
-            
+
             // Add a click listener for this marker
             marker.addListener('click', function() {
-               markerSelected(this);
+               infowindow.setOptions({
+                       content: this.descr
+               });
+                infowindow.open(map,this);
             });
             
             // Extend the map bounds to include this marker
         {/foreach}
     {/if}
 
-            // Marker click events - Send to detail page
-            function markerSelected(t) {
-                window.location.replace("{$thisURL}?action=detail&member=" + this.memberID);
-            }
-
             // Fit map to bounds of all markers
             map.fitBounds(bounds);
-        
-
+            
         });
     </script>