Will need work on main plugin to add counties into the cities table.
});
jQuery(".mapCity a").click(function (){
GlmMap._hideLocations();
- var params = "?city_id=" + jQuery(this).attr('rel');
- jQuery.get(glm_base_url + "member-city-google-map/" + params, GlmMap._centerCity, 'xml');
+ var params = "city_id=" + jQuery(this).data('id');
+
+ jQuery.ajax({
+ url: glm_ajax_url + '?action=glm_members_admin_ajax&glm_action=citiesMapData&' + params,
+ cache: false,
+ dataType: 'json',
+ success: function( mapData ){
+ console.log( 'mapData: ', mapData );
+ GlmMap._centerCity( mapData )
+ }
+ });
+
return false;
});
jQuery(".mapCounty a").click(function (){
GlmMap._hideLocations();
- var params = "?region=" + jQuery(this).attr('rel');
- jQuery.get(glm_base_url + "member-city-google-map/" + params, GlmMap._centerCounty, 'xml');
+ var params = "county_id=" + jQuery(this).data('id');
+ jQuery.ajax({
+ url: glm_ajax_url + '?action=glm_members_admin_ajax&glm_action=countiesMapData&' + params,
+ cache: false,
+ dataType: 'json',
+ success: function( mapData ){
+ console.log( 'mapData: ', mapData );
+ GlmMap._centerCounty( mapData )
+ }
+ });
+
return false;
});
},
_getCategoryValues: function(){
var values = jQuery("#category-form").serialize();
- // jQuery.get(glm_base_url + 'member-area-google-map/?' + values, GlmMap._loadData, 'xml');
jQuery.ajax({
url: glm_ajax_url + '?action=glm_members_admin_ajax&glm_action=membersMapData&' + values,
cache: false,
dataType: 'json',
success: function( mapData ){
- console.log( 'mapData: ', mapData );
GlmMap._loadData( mapData )
}
});
});
},
- _loadCityData: function(data)
+ _loadCityData: function( markers )
{
- var markers = data.documentElement.getElementsByTagName("marker");
for (i = 0; i < markers.length; i++) {
- var name = markers[i].getAttribute('city_name');
- var lat = markers[i].getAttribute('lat');
- var lng = markers[i].getAttribute('lng');
+ var name = markers[i].name;
+ var lat = markers[i].lat;
+ var lng = markers[i].lon;
var point = new google.maps.LatLng(
parseFloat(lat),
},
- _centerCity: function(data) {
+ _centerCity: function( markers ) {
GlmMap.markerAreaGroup.clearLayers();
- var markers = data.documentElement.getElementsByTagName("marker");
for (i = 0; i < markers.length; i++) {
- var lat = markers[i].getAttribute('lat');
- var lng = markers[i].getAttribute('lng');
- var leafletMarker = L.marker([lat, lng], { title: name })
+ var lat = markers[i].lat;
+ var lng = markers[i].lon;
+ var leafletMarker = L.marker([lat, lng])
.addTo(GlmMap.markerAreaGroup);
}
GlmMap.leafletMap.fitBounds(GlmMap.markerAreaGroup.getBounds());
GlmMap.leafletMap.setZoom(13);
},
- _centerCounty: function(data) {
+ _centerCounty: function( markers ) {
GlmMap.markerAreaGroup.clearLayers();
- var markers = data.documentElement.getElementsByTagName("marker");
for (i = 0; i < markers.length; i++) {
- var lat = markers[i].getAttribute('lat');
- var lng = markers[i].getAttribute('lng');
- var leafletMarker = L.marker([lat, lng], { title: name })
+ var lat = markers[i].lat;
+ var lng = markers[i].lon;
+ var leafletMarker = L.marker([lat, lng])
.addTo(GlmMap.markerAreaGroup);
}
GlmMap.leafletMap.fitBounds(GlmMap.markerAreaGroup.getBounds());
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * File Library - File Delete
+ *
+ * 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/dataCities.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_citiesMapData extends GlmDataCities
+{
+
+ /**
+ * 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(false, false);
+
+ }
+
+ /*
+ * Perform Model Action
+ *
+ * This modelAction takes an AJAX image upload and stores the image in the
+ * media/images directory of the plugin.
+ *
+ * This model action does not return, it simply does it's work then calls die();
+ *
+ * @param $_REQUEST['id'] File Library ID
+ */
+ public function modelAction ( $actionData = false )
+ {
+ $cityData = array();
+
+ trigger_error( print_r( $_REQUEST, true ), E_USER_NOTICE );
+
+ if ( isset( $_REQUEST['values'] ) ) {
+ trigger_error( print_r( $_REQUEST['values'], true ), E_USER_NOTICE );
+ }
+
+ $city_id = filter_var( $_REQUEST['city_id'], FILTER_VALIDATE_INT );
+
+ $where = "T.id = $city_id";
+
+ $cityData = $this->wpdb->get_results(
+ $this->wpdb->prepare(
+ "SELECT *
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "cities
+ WHERE id = %d",
+ $city_id
+ ),
+ ARRAY_A
+ );
+
+
+ header( 'Content-type: application/json' );
+ echo json_encode( $cityData );
+
+ exit;
+
+ }
+
+}
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * File Library - File Delete
+ *
+ * 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/dataCounties.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_countiesMapData extends GlmDataCounties
+{
+
+ /**
+ * 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(false, false);
+
+ }
+
+ /*
+ * Perform Model Action
+ *
+ * This modelAction takes an AJAX image upload and stores the image in the
+ * media/images directory of the plugin.
+ *
+ * This model action does not return, it simply does it's work then calls die();
+ *
+ * @param $_REQUEST['id'] File Library ID
+ */
+ public function modelAction ( $actionData = false )
+ {
+ $countyData = array();
+
+ trigger_error( print_r( $_REQUEST, true ), E_USER_NOTICE );
+
+ if ( isset( $_REQUEST['values'] ) ) {
+ trigger_error( print_r( $_REQUEST['values'], true ), E_USER_NOTICE );
+ }
+
+ $county_id = filter_var( $_REQUEST['county_id'], FILTER_VALIDATE_INT );
+
+ $where = "T.id = $county_id";
+
+ $countyData = $this->wpdb->get_results(
+ $this->wpdb->prepare(
+ "SELECT *
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "counties
+ WHERE id = %d",
+ $county_id
+ ),
+ ARRAY_A
+ );
+
+
+ header( 'Content-type: application/json' );
+ echo json_encode( $countyData );
+
+ exit;
+
+ }
+
+}
{
$settings = array();
$success = true;
+ $mainCats = array();
+
+ if ( $actionData['request']['main-level-cats'] ) {
+ // Setup the main level categories for the Map.
+ $mainCatsRequested = explode( ',', $actionData['request']['main-level-cats'] );
+
+ foreach ( $mainCatsRequested as $k => $v ) {
+ if ( preg_match( '%^[0-9]*$%', trim( $v ) && $v > 0 ) ) {
+ $mainCats[] = ( $v - 0 );
+ }
+ }
+ }
// Need Member Categories (with active members)
// Need Cities (with active members)
$templateData = array(
'jsUrl' => GLM_MEMBERS_PLUGIN_JS_URL,
- 'categories' => $this->getMemberCategories(),
-
+ 'categories' => $this->getMemberCategories( $mainCats ),
+ 'counties' => $this->getCounties(),
+ 'counties' => $this->getCounties(),
+ 'cities' => $this->getCities(),
);
// echo '<pre>$categories: ' . print_r( $this->getMemberCategories(), true ) . '</pre>';
'modelRedirect' => false,
'view' => "front/members/interactivemap.html",
'data' => $templateData,
- 'settings' => $settings
+ 'settings' => $settings,
);
}
- public function getMemberCategories()
+ public function getMemberCategories( $mainCats )
{
- $categories = array(
- 793 => array(
- 'name' => 'Places To Stay',
- 'subCats' => $this->getSubCategories( 793 ),
- ),
- 791 => array(
- 'name' => 'Attractions',
- 'subCats' => $this->getSubCategories( 791 ),
- ),
- 794 => array(
- 'name' => 'Recreation',
- 'subCats' => $this->getSubCategories( 794 ),
- ),
- 792 => array(
- 'name' => 'Dining',
- 'subCats' => $this->getSubCategories( 792 ),
- ),
- 796 => array(
- 'name' => 'Shopping',
- 'subCats' => $this->getSubCategories( 796 ),
- ),
- 795 => array(
- 'name' => 'Services',
- 'subCats' => $this->getSubCategories( 795 ),
- ),
- 797 => array(
- 'name' => 'Transportation',
- 'subCats' => $this->getSubCategories( 797 ),
- ),
- );
+ $categories = array();
+ foreach ( $mainCats as $cat ) {
+ $categories[$cat] = array(
+ 'name' => $this->getCategoryName( $cat ),
+ 'subCats' => $this->getSubCategories( $cat )
+ );
+ }
return $categories;
}
+ public function getCategoryName( $id )
+ {
+ return $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT name
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "categories
+ WHERE id = %d",
+ $id
+ )
+ );
+ }
+
public function getSubCategories( $id )
{
$categories = array();
return $categories;
}
- public function getRegions()
+ public function getCounties()
{
+ return $this->wpdb->get_results(
+ "SELECT *
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "counties",
+ ARRAY_A
+ );
}
public function getCities()
{
+ return $this->wpdb->get_results(
+ "SELECT *
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "cities",
+ ARRAY_A
+ );
}
'action' => 'interactivemap',
'table' => false,
'attributes' => array(
- 'client' => 'uptra',
+ 'client' => 'uptra',
+ 'main-level-cats' => false,
),
),
);
'fileLibraryUpdate' => 'glm-member-db',
'glmCron' => 'glm-member-db',
'membersMapData' => 'glm-member-db',
+ 'citiesMapData' => 'glm-member-db',
+ 'countiesMapData' => 'glm-member-db',
),
'dashboard' => array(
'index' => 'glm-member-db',
+<script>
+ glm_ajax_url = '{$ajaxUrl}';
+ glm_memberCats = [
+ {foreach $categories as $catId => $cat}
+ {$catId}{if !$cat@last},{/if}
+ {/foreach}
+ ];
+</script>
{literal}
<style>
#category {display: none;}
<div id="mapCounties">
<b>Counties:</b>
<ul>
- {* foreach regions region *}
+ {foreach $counties as $county}
<li class="mapCounty">
- <a href="#" rel="{* region[region_id] *}">{* region[region_name] *}</a>
+ <a href="#" data-id="{$county.id}">{$county.name}</a>
</li>
- {* /foreach *}
+ {/foreach}
</ul>
- </div><!-- /#mapCounties -->
+ </div>
<div id="mapCities">
<b>Cities:</b>
<ul>
- {* foreach cities city *}
+ {foreach $cities as $city}
<li class="mapCity">
- <a href="#" rel="{* city[city_id] *}">{* city[city_name] *}</a>
+ <a href="#" data-id="{$city.id}">{$city.name}</a>
</li>
- {* /foreach *}
+ {/foreach}
</ul>
</div>
</div>
</div>
-</div><!-- /#mapwrap -->
-<script>
- glm_ajax_url = '{$ajaxUrl}';
- glm_memberCats = [
- 793, // Places to Stay
- 791, // Attractions
- 794, // Recreation
- 792, // Dining
- 796, // Shopping
- 795, // Services
- 797 // Transportation
- ];
-</script>
+