From: Chuck Scott Date: Wed, 18 Mar 2015 21:45:40 +0000 (-0400) Subject: Added more mapping features and started doing search form X-Git-Tag: v1.0.0~49 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=24be307e916aab365ec2553135451f855268e8f9;p=WP-Plugins%2Fglm-member-db.git Added more mapping features and started doing search form --- diff --git a/classes/data/dataCategories.php b/classes/data/dataCategories.php index 83629fa4..40db5136 100644 --- a/classes/data/dataCategories.php +++ b/classes/data/dataCategories.php @@ -303,10 +303,9 @@ class GlmDataCategories extends GlmDataAbstract public function getListSortedParentChild() { $categories = $this->getList(); + $categoriesSorted = $this->sortParentChild($categories); - $categories = glmMembersAdmin::sortParentChild($categories); - - return $categories; + return $categoriesSorted; } @@ -337,6 +336,56 @@ class GlmDataCategories extends GlmDataAbstract return $r; } + /* + * Sort a database result array (from DataAbstract.php) by parent, child relationships + * + * @param array $array Array to be sorted + * @param string $name Name of array element that represents the text to sort on + * @param string $parent Name of the array element that represents the parent ID to sort on + * + * @return array Sorted array + */ + public static function sortParentChild($array, $name = 'name', $parent = 'parent') + { + + if (!is_array($array) || count($array) == 0) { + return false; + } + + // Do a sort by custom function with it included in the call + // This lets me directly use $name and $parent in the sort function + uasort($array, function ($a, $b) use ($name, $parent) { + + // If there's a parent, append the name of this entry to the parent + // The '~~~' simply keeps appended strings from any chance of a match with something else + if ($a[$parent]['value']) { + $aVal = $a[$parent]['name'].'~~~'.$a['name']; + } else { + // Otheriwse just use the name. + $aVal = $a['name']; + } + + // Same for b value + if ($b[$parent]['value']) { + $bVal = $b[$parent]['name'].'~~~'.$b['name']; + } else { + $bVal = $b['name']; + } + + if ($aVal > $bVal) { + return 1; + } + + if ($aVal < $bVal) { + return -1; + } + + return 0; + + }); + + return $array; + } } diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index ec9c511a..7be41a55 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -113,58 +113,6 @@ class GlmPluginSupport } - /* - * Sort a database result array (from DataAbstract.php) by parent, child relationships - * - * @param array $array Array to be sorted - * @param string $name Name of array element that represents the text to sort on - * @param string $parent Name of the array element that represents the parent ID to sort on - * - * @return array Sorted array - */ - public static function sortParentChild($array, $name = 'name', $parent = 'parent') - { - - if (!is_array($array) || count($array) == 0) { - return false; - } - - // Do a sort by custom function with it included in the call - // This lets me directly use $name and $parent in the sort function - uasort($array, function ($a, $b) use ($name, $parent) { - - // If there's a parent, append the name of this entry to the parent - // The '~~~' simply keeps appended strings from any chance of a match with something else - if ($a[$parent]['value']) { - $aVal = $a[$parent]['name'].'~~~'.$a['name']; - } else { - // Otheriwse just use the name. - $aVal = $a['name']; - } - - // Same for b value - if ($b[$parent]['value']) { - $bVal = $b[$parent]['name'].'~~~'.$b['name']; - } else { - $bVal = $b['name']; - } - - if ($aVal > $bVal) { - return 1; - } - - if ($aVal < $bVal) { - return -1; - } - - return 0; - - }); - - return $array; - } - - } ?> \ No newline at end of file diff --git a/config/plugin.ini b/config/plugin.ini index eaee2adb..685cbac4 100644 --- a/config/plugin.ini +++ b/config/plugin.ini @@ -34,13 +34,16 @@ thumb['crop'] = false [common] +; +; Site Configuration Options +; + ; Debug Options admin_debug = false admin_debug_verbose = false front_debug = false front_debug_verbose = false -; ; Google Maps Browser API Key ; Account: cscott.glm@gmail.com ; Need to create a new key for each "Project", referrer @@ -49,12 +52,79 @@ front_debug_verbose = false ; googleMapsApiKey = 'AIzaSyDWgyf8MeYdxZRHaN73O37vFbkhvPjjNhU' -; General Settings +; Site Time Zone timezone = America/Detroit + ; Default map location is Gaslight Media office map_default_lat = 45.3749 map_default_lon = -84.9592 +; Front-end Member Listing - [glm-members-list] +front-config['list_show_map'] = true +front-config['list_show_list'] = true +front-config['list_show_search'] = true +front-config['list_search_text'] = true +front-config['list_search_category'] = true +front-config['list_search_amenities'] = false +front-config['list_search_alpha'] = false +; Front-end Member Listing Options +front-config['list_show_detaillink'] = true +front-config['list_show_logo'] = true +front-config['list_logo_size'] = small +front-config['list_show_address'] = true +front-config['list_show_street'] = true +front-config['list_show_citystatezip'] = true +front-config['list_show_country'] = false +front-config['list_show_region'] = true +front-config['list_show_description'] = true +front-config['list_show_short_descr'] = false +front-config['list_show_phone'] = true +front-config['list_show_tollfree'] = true +front-config['list_show_url'] = true +front-config['list_show_categories'] = false +front-config['list_show_creditcards'] = false +front-config['list_show_amenities'] = false +; Front-end Meber Listing Map Options +front-config['list_map_show_detaillink'] = true +front-config['list_map_show_logo'] = true +front-config['list_map_logo_size'] = thumb +front-config['list_map_show_description'] = true +front-config['list_map_show_short_descr'] = false +front-config['list_map_show_address'] = true +front-config['list_map_show_street'] = true +front-config['list_map_show_citystatezip'] = true +front-config['list_map_show_country'] = true +front-config['list_map_show_region'] = true +front-config['list_map_show_phone'] = true +front-config['list_map_show_tollfree'] = true +front-config['list_map_show_url'] = true +front-config['list_map_show_categories'] = true +front-config['list_map_show_creditcards'] = true +front-config['list_map_show_amenities'] = false +; Front-end Member Detail Options +front-config['detail_show_map'] = true +front-config['detail_show_directions'] = true +front-config['detail_show_detaillink'] = true +front-config['detail_show_logo'] = true +front-config['detail_logo_size'] = large +front-config['detail_show_address'] = true +front-config['detail_show_street'] = true +front-config['detail_show_citystatezip'] = true +front-config['detail_show_country'] = true +front-config['detail_show_region'] = true +front-config['detail_show_description'] = true +front-config['detail_show_short_descr'] = false +front-config['detail_show_phone'] = true +front-config['detail_show_tollfree'] = true +front-config['detail_show_url'] = true +front-config['detail_show_categories'] = true +front-config['detail_show_creditcards'] = true +front-config['detail_show_amenities'] = true + +; +; End of site configuration options +; + ; ; Entry Status Types ; diff --git a/controllers/front.php b/controllers/front.php index bffee328..50a0526f 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -404,6 +404,7 @@ class glmMembersFront extends GlmPluginSupport $smarty->templateAssign ( 'glmPluginName', GLM_MEMBERS_PLUGIN_NAME ); $smarty->templateAssign ( 'glmPluginMediaURL', GLM_MEMBERS_PLUGIN_MEDIA_URL ); $smarty->templateAssign ( 'thisYear', date ( 'Y' ) ); + $smarty->templateAssign ( $this->config['front-config']); $smarty->templateAssign ( $this->config['term']); $smarty->templateAssign ( $this->config['phrase']); $smarty->templateAssign ( 'googleMapsBrowserApiKey', $this->config['googleMapsApiKey']); diff --git a/css/front.css b/css/front.css index a57a51df..d0d92411 100644 --- a/css/front.css +++ b/css/front.css @@ -3,21 +3,52 @@ Gaslight Media Members Database Front-End Styles */ - .glm-right { float: right; } .glm-left { float: left; } +.glm-hidden { + display: none; +} +.glm-button { /* Requires default WordPress classes "button" and either "button-primary" or "button-secondary". */ + margin: 4px !important; + padding: .4em !important; + cursor: pointer; +} + +/* Input fields */ +.glm-form-bad-input { + background: #FFaBa9; + padding: .2em; +} +.glm-form-text-input { + width: 95%; +} +.glm-form-text-input-short { + width: 15em; +} +.glm-form-text-input-medium { + width: 30em; +} +.glm-form-textarea { + width: 90%; +} -/* Member Containers */ + +/* Member List */ .glm-member-list-container { border: 1px #ccc solid; padding: .4em; background: #f8f8f8; margin: .4em 0px .4em 0px; } +.glm-member-entry-container { + border: 1px #ccc solid; + padding: .4em; + margin: 1em 0px 1em 0px; +} .glm-member-list-image { float: right; } @@ -31,12 +62,28 @@ margin-top: .5em; } +/* Member Detail */ +.glm-member-detail-container { +} +.glm-member-detail-image { + margin-bottom: 1em; +} +.glm-member-detail-nameAddress { +} +.glm-member-detail-info { + clear: both; +} +.glm-member-detail-items { + margin-top: .5em; +} + /* Map */ .glm-map { width: 100%; height:400px; border: 2px black solid; + margin; 10px 0 10px 0; } /* overrride whatever was causing the 100% width for images in Google Maps */ .glm-map img { @@ -45,5 +92,10 @@ .glm-map-member-name { width: 100%; font-weight: bold; - border-bottom: 2px #ccc solid; + border-bottom: 2px #ccc solid; +} + +/* Specific Divs */ +#glm-directions { + padding: 1em; } \ No newline at end of file diff --git a/misc/notes.txt b/misc/notes.txt new file mode 100644 index 00000000..c030fe8a --- /dev/null +++ b/misc/notes.txt @@ -0,0 +1,26 @@ +Development Notes +----------------- + +ADMIN AREA + +* Consider paginating certain lists + +* On all admin lists - add sort order links to headers + +* Amenities setup + - On Add an Amenity pop-up, move type to top of form + - Add list filter for Facility Type + - Add text search filter + + +FRONT-END + +* Add amenities to member lists and maps, and member detail pages + + +DATA ABSTRACT + +* Add option to build alpha lists + +* Add pagenation, option to return total number of entries and number returned for display for getList() + diff --git a/models/front/members/list.php b/models/front/members/list.php index 3ae629db..0d0027fe 100644 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -99,15 +99,38 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo public function modelAction ($actionData = false) { - $where = ''; + $where = ' TRUE'; $filterPending = false; $filterArchived = false; $filterName = false; $haveFilter = false; + $textSearch = ''; + + // Apply any provided text search to name, description, short description, and street address + if (isset($_REQUEST['textSearch']) && $_REQUEST['textSearch'] != '') { + $textSearch = filter_input(INPUT_POST, 'textSearch', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES); + $where .= " AND ( + ( + SELECT true + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members + WHERE id = T.member + AND name LIKE '%$textSearch%' + ) OR + T.descr LIKE '%$textSearch%' OR + T.short_descr LIKE '%$textSearch%' OR + T.addr1 LIKE '%$textSearch%' OR + T.addr2 LIKE '%$textSearch%' + )"; + } // Apply any specified category filter + require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php'); + $Categories = new GlmDataCategories($this->wpdb, $this->config); + $categoryData = $Categories->getListSortedParentChild(); +//*** HERE complete category filter **** - $where .= " T.status = ".$this->config['status_numb']['Active']; + // Only look at active member information + $where .= " AND T.status = ".$this->config['status_numb']['Active']; /* * Get a current list of members @@ -139,7 +162,9 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo 'haveFilter' => $haveFilter, 'filterArchived' => $filterArchived, 'filterPending' => $filterPending, - 'filterName' => stripslashes($filterName) + 'filterName' => stripslashes($filterName), + 'textSearch' => $textSearch, + 'categories' => $categoryData // 'canEdit' => $canEdit ); diff --git a/views/admin/configure/amenities.html b/views/admin/configure/amenities.html index 7d893b5a..4e765618 100644 --- a/views/admin/configure/amenities.html +++ b/views/admin/configure/amenities.html @@ -1,7 +1,7 @@ {include file='admin/configure/header.html'} -
Add a Amenity
+
Add an Amenity
diff --git a/views/front/members/detail.html b/views/front/members/detail.html index ae632931..4e43aee4 100644 --- a/views/front/members/detail.html +++ b/views/front/members/detail.html @@ -4,34 +4,65 @@ -
(map loads here)
- + {if $detail_show_map} +
+
(map loads here)
+
+ {/if} + {if $detail_show_directions} +
+
(directions load here)
+
+ +
+
+
+ Enter address to show directions ...
+
+
+
+ + +
+
+ {/if}

Member Detail

-
-
-
-

{$member.member}

+
+ {if $detail_show_logo}
{/if} +
+

+ {if $detail_show_detaillink} + {$member.member} + {else} + {$member.member} + {/if} +

+ {if $detail_show_address}

+ {if $detail_show_street} {if $member.addr1}{$member.addr1}
{/if} {if $member.addr2}{$member.addr2}
{/if} - {if $member.city.name}{$member.city.name}{if $member.state.name}, {/if}{/if}{if $member.state.name}{$member.state.name}{/if}{if $member.zip} {$member.zip}{/if} - {if $member.country.name}
{$member.country.name}{/if} - {if $member.region.value}

Region: {$member.region.name}

{/if} -

+ {/if} + {if $detail_show_citystatezip} + {if $member.city.name}{$member.city.name}{if $member.state.name}, {/if}{/if}{if $member.state.name}{$member.state.name}{/if}{if $member.zip} {$member.zip}{/if} + {/if} + {if $member.country.name && $detail_show_country}
{$member.country.name}{/if} +

+ {/if} {*list_show_address*}
-
- {if $member.descr} -

{$member.descr}

- {else if $member.short_descr} -

{$member.short_descr}

- {/if} - {if $member.phone}Phone: {$member.phone}
{/if} - {if $member.toll_free}Toll Free: {$member.toll_free}
{/if} - {if $member.url}Web site: {$member.url}
{/if} - {if $member.categories} -
+
+

+ {if $member.phone && $detail_show_phone}Phone: {$member.phone}
{/if} + {if $member.toll_free && $detail_show_tollfree}Toll Free: {$member.toll_free}
{/if} + {if $member.url && $detail_show_url}Web site: {$member.url}
{/if} + {if $member.region.value && $detail_show_region}

Region: {$member.region.name}

{/if} +

+ {if $member.descr && $detail_show_description}

{$member.descr}

{/if} + {if $member.short_descr && $detail_show_short_descr}

{$member.short_descr}

{/if} + {if $member.categories && $detail_show_categories} +
Member Categories
    {foreach $member.categories as $c} @@ -42,8 +73,8 @@
{/if} - {if $member.cc_type} -
+ {if $member.cc_type && $detail_show_creditcards} +
Credit Cards Accepted:
    {foreach $member.cc_type.names as $c} @@ -51,6 +82,11 @@ {/foreach}
+ {/if} + {if $detail_show_amenities} +
+

Amenities go here

+
{/if}
@@ -58,18 +94,21 @@ diff --git a/views/front/members/list.html b/views/front/members/list.html index 420075c1..03874af9 100644 --- a/views/front/members/list.html +++ b/views/front/members/list.html @@ -3,35 +3,83 @@ +{if $list_show_map}
(map loads here)
- - +{/if} + +{if $list_show_search} + +
+


Search for a Member

+ {if $list_search_text} +
+ Text Search: +
+ {/if} + {if $list_search_category} +
+ Member Category: + +
+ {/if} + {if $list_search_amenities} +
Amenity search goes here
+ {/if} + {if $list_search_alpha} +
Alpha search goes here
+ {/if} + +
+ +{/if} {*list_show_search*} + +{if $list_show_list}

List of Members

-{if $haveMembers} + {if $haveMembers} + + {foreach $members as $m}
-
+ {if $list_show_logo}
{/if}
-

{$m.member}

+

+ {if $list_show_detaillink} + {$m.member} + {else} + {$m.member} + {/if} +

+ {if $list_show_address}

+ {if $list_show_street} {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} + {if $list_show_citystatezip} + {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} + {if $m.country.name && $list_show_country}
{$m.country.name}{/if} +

+ {/if} {*list_show_address*}
- {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} +

+ {if $m.phone && $list_show_phone}Phone: {$m.phone}
{/if} + {if $m.toll_free && $list_show_tollfree}Toll Free: {$m.toll_free}
{/if} + {if $m.url && $list_show_url}Web site: {$m.url}
{/if} + {if $m.region.value && $list_show_region}

Region: {$m.region.name}

{/if} +

+ {if $m.descr && $list_show_description}

{$m.descr}

{/if} + {if $m.short_descr && $list_show_short_descr}

{$m.short_descr}

{/if} + {if $m.categories && $list_show_categories}
Member Categories
    @@ -43,7 +91,7 @@
{/if} - {if $m.cc_type} + {if $m.cc_type && $list_show_creditcards}
Credit Cards Accepted:
    @@ -52,18 +100,85 @@ {/foreach}
+ {/if} + {if $list_show_amenities} +
+

Amenities go here

+
{/if}
- {/foreach} -{else} + +
+ {if $m.logo && $list_map_show_logo}
{/if} +
+ {if $list_map_show_detaillink} + {$m.member} + {else} + {$m.member} + {/if} +
+ {if $list_map_show_address} +

+ {if $list_map_show_street} + {if $m.addr1}{$m.addr1}
{/if} + {if $m.addr2}{$m.addr2}
{/if} + {/if} + {if $list_map_show_citystatezip} + {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} + {if $m.country.name && $list_map_show_country}
{$m.country.name}{/if} +

+ {/if} {*list_map_show_address*} +
+

+ {if $m.phone && $list_map_show_phone}Phone: {$m.phone}
{/if} + {if $m.toll_free && $list_map_show_tollfree}Toll Free: {$m.toll_free}
{/if} + {if $m.url && $list_map_show_url}Web site: {$m.url}
{/if} + {if $m.region.value && $list_map_show_region}

Region: {$m.region.name}

{/if} +

+ {if $m.descr && $list_map_show_description}{$m.descr}
{/if} + {if $m.short_descr && $list_map_show_short_descr}{$m.short_descr}
{/if} + {if $m.categories && $list_map_show_categories} +
+ Member Categories +
    + {foreach $m.categories as $c} +
  • + {if $c.parent_name}{$c.parent_name}: {/if}{$c.name} +
  • + {/foreach} +
+
+ {/if}1 + {if $m.cc_type && $list_map_show_creditcards} +
+ Credit Cards Accepted: +
    + {foreach $m.cc_type.names as $c} +
  • {$c}
  • + {/foreach} +
+
+ {/if} + {if $list_map_show_amenities} +
+

Amenities go here

+
+ {/if} +
+
+ + {/foreach} {*$members*} + {else}
(no members listed)
-{/if} - + {/if} +{/if} {*list_show_list*}