From: Chuck Scott Date: Fri, 13 Mar 2015 16:45:36 +0000 (-0400) Subject: Completed initial front-end member list and added documentation and functionality... X-Git-Tag: v1.0.0~53 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=197f05dd7a48ea0e7dc245606f3cede45373b10f;p=WP-Plugins%2Fglm-member-db.git Completed initial front-end member list and added documentation and functionality to the data abstriact. --- diff --git a/classes/data/dataAccommodationTypes.php b/classes/data/dataAccommodationTypes.php index 9038339b..38fd3794 100644 --- a/classes/data/dataAccommodationTypes.php +++ b/classes/data/dataAccommodationTypes.php @@ -87,7 +87,6 @@ class GlmDataAccommodationTypes extends GlmDataAbstract */ function __construct ($wpdb, $config) { - parent::__construct($wpdb, $config); // Save WordPress Database object $this->wpdb = $wpdb; diff --git a/classes/data/dataAmenities.php b/classes/data/dataAmenities.php index 25321dd2..f4277295 100644 --- a/classes/data/dataAmenities.php +++ b/classes/data/dataAmenities.php @@ -87,7 +87,6 @@ class GlmDataAmenities extends GlmDataAbstract */ function __construct ($wpdb, $config) { - parent::__construct($wpdb, $config); // Save WordPress Database object $this->wpdb = $wpdb; diff --git a/classes/data/dataCategories.php b/classes/data/dataCategories.php index d9e6a72c..3455e715 100644 --- a/classes/data/dataCategories.php +++ b/classes/data/dataCategories.php @@ -87,7 +87,6 @@ class GlmDataCategories extends GlmDataAbstract */ function __construct ($wpdb, $config) { - parent::__construct($wpdb, $config); // Save WordPress Database object $this->wpdb = $wpdb; diff --git a/classes/data/dataCategoryMemberInfo.php b/classes/data/dataCategoryMemberInfo.php index ae3e4bcd..5e64e7a0 100644 --- a/classes/data/dataCategoryMemberInfo.php +++ b/classes/data/dataCategoryMemberInfo.php @@ -87,7 +87,6 @@ class GlmDataCategoryMemberInfo extends GlmDataAbstract */ function __construct ($wpdb, $config) { - parent::__construct($wpdb, $config); // Save WordPress Database object $this->wpdb = $wpdb; diff --git a/classes/data/dataCities.php b/classes/data/dataCities.php index a4f4f01e..ac3679ef 100644 --- a/classes/data/dataCities.php +++ b/classes/data/dataCities.php @@ -87,7 +87,6 @@ class GlmDataCities extends GlmDataAbstract */ function __construct ($wpdb, $config) { - parent::__construct($wpdb, $config); // Save WordPress Database object $this->wpdb = $wpdb; diff --git a/classes/data/dataMemberInfo.php b/classes/data/dataMemberInfo.php index 815bc156..e05a91c7 100644 --- a/classes/data/dataMemberInfo.php +++ b/classes/data/dataMemberInfo.php @@ -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 diff --git a/classes/data/dataMemberTypes.php b/classes/data/dataMemberTypes.php index a5938758..224e0ea1 100644 --- a/classes/data/dataMemberTypes.php +++ b/classes/data/dataMemberTypes.php @@ -87,7 +87,6 @@ class GlmDataMemberTypes extends GlmDataAbstract */ function __construct ($wpdb, $config) { - parent::__construct($wpdb, $config); // Save WordPress Database object $this->wpdb = $wpdb; diff --git a/classes/data/dataMembers.php b/classes/data/dataMembers.php index e45978e2..04d97dbb 100644 --- a/classes/data/dataMembers.php +++ b/classes/data/dataMembers.php @@ -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; diff --git a/classes/data/dataRegions.php b/classes/data/dataRegions.php index 5ed060f3..92fc5937 100644 --- a/classes/data/dataRegions.php +++ b/classes/data/dataRegions.php @@ -87,7 +87,6 @@ class GlmDataRegions extends GlmDataAbstract */ function __construct ($wpdb, $config) { - parent::__construct($wpdb, $config); // Save WordPress Database object $this->wpdb = $wpdb; diff --git a/css/front.css b/css/front.css index 971dbc8d..9f9f4ab7 100644 --- a/css/front.css +++ b/css/front.css @@ -11,22 +11,34 @@ 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 index 00000000..01daedf3 --- /dev/null +++ b/lib/GlmDataAbstract/.~lock.documentation.odt# @@ -0,0 +1 @@ +,cscott,Ubuntu-1404,13.03.2015 12:40,file:///home/cscott/.config/libreoffice/4; \ No newline at end of file diff --git a/lib/GlmDataAbstract/DataAbstract.php b/lib/GlmDataAbstract/DataAbstract.php index e7cf4870..1e2422bc 100755 --- a/lib/GlmDataAbstract/DataAbstract.php +++ b/lib/GlmDataAbstract/DataAbstract.php @@ -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 "

 

ERROR: Supplied value for option 'filter' in fields array is not a defined filter for PHP filter_input();"; + echo "

 

ERROR: 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 "
$sql
"; $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 index 00000000..8cb9e4ab 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 index 00000000..b1a35198 Binary files /dev/null and b/lib/GlmDataAbstract/documentation.odt differ diff --git a/models/front/members/list.php b/models/front/members/list.php index 557c48b8..d542e79c 100644 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -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; + } + + + } diff --git a/views/front/members/list.html b/views/front/members/list.html index b1cbd778..085f367e 100644 --- a/views/front/members/list.html +++ b/views/front/members/list.html @@ -10,37 +10,55 @@ {if $haveMembers} {foreach $members as $m} -
-
-
+
+
+

{$m.member}

{if $m.addr1}{$m.addr1}
{/if} {if $m.addr2}{$m.addr2}
{/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}
{$m.country.name}{/if} + {if $m.region.value}

Region: {$m.region.name}

{/if}

- - +
+
{if $m.descr}

{$m.descr}

{else if $m.short_descr}

{$m.short_descr}

+ {/if} + {if $m.phone}Phone: {$m.phone}
{/if} + {if $m.toll_free}Toll Free: {$m.toll_free}
{/if} + {if $m.url}Web site: {$m.url}
{/if} + {if $m.categories} +
+ Member Categories +
    + {foreach $m.categories as $c} +
  • + {if $c.parent_name}{$c.parent_name}: {/if}{$c.name} +
  • + {/foreach} +
+
{/if}
-
+ {/foreach} {else}
(no members listed)
{/if} + {if $m.toll_free}

{$m.toll_free}

{/if}