From cf7518d9e4924d25b7f41341c6b5c8eb9814887d Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 5 Apr 2018 11:47:59 -0400 Subject: [PATCH] Add city drop down for add event form. Use the city list to generate a select for cities. Too many cities end up getting created. --- models/front/events/frontAdd.php | 53 +++++++++++++++++++------------- views/front/events/frontAdd.html | 17 ++++++---- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/models/front/events/frontAdd.php b/models/front/events/frontAdd.php index a71d939..43a5614 100644 --- a/models/front/events/frontAdd.php +++ b/models/front/events/frontAdd.php @@ -12,6 +12,7 @@ require_once GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/models/front/events/baseAction.p require_once GLM_MEMBERS_PLUGIN_PATH.'/models/admin/ajax/imageUpload.php'; require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataRecurrences.php'; require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataManagement.php'; +require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php'; /** * GLmMembersFront_event_fontAdd @@ -194,24 +195,25 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents wp_enqueue_script('glm-members-front-maskedinput'); // Set initial values for variables. - $fromDate = ''; - $permalink = ''; - $title = ''; - $errorMsg = ''; - $days = - $lastDayOfMonth = - $startTime = - $endTime = 0; - $status = false; - $memberOnly = false; - $memberContact = false; - $memberManager = false; - $members = false; - $venues = false; - $eventAmenities = array(); - $venues = false; - $startTimeOnly = 0; + $fromDate = ''; + $permalink = ''; + $title = ''; + $errorMsg = ''; + $days = + $lastDayOfMonth = + $startTime = + $endTime = 0; + $status = false; + $memberOnly = false; + $memberContact = false; + $memberManager = false; + $members = false; + $venues = false; + $eventAmenities = array(); + $venues = false; + $startTimeOnly = 0; $eventCategories = []; + $cities = array(); if ( isset( $actionData['request']['member_only'] ) && $memberOnly = filter_var( $actionData['request']['member_only'], FILTER_VALIDATE_BOOLEAN ) ) { @@ -236,6 +238,12 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents // wp_enqueue_script('front-js', GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/js/front.js'); } $view = 'frontAdd'; + // populate cities dropdown + $cityData = new GlmDataCities( $this->wpdb, $this->config ); + $cityVals = $cityData->getList(); + foreach ( $cityVals as $city ) { + $cities[$city['id']] = $city['name']; + } // populate category dropdown $categories = new GlmDataEventsCategories( $this->wpdb, $this->config ); //$emailInfo = new GlmDataEventsManagement( $this->wpdb, $this->config ); @@ -339,7 +347,7 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents $admin_name = $this->filterInput( $_REQUEST['admin_name'] ); $admin_org = $this->filterInput( $_REQUEST['admin_org'] ); $adminPhone = $this->filterInput( $_REQUEST['admin_phone'] ); - $userEmail = $this->filterInput( $_REQUEST['admin_email'] ); + $userEmail = $this->filterInput( $_REQUEST['admin_email'] ); $contactFirst = $this->filterInput( $_REQUEST['contact_fname'] ); $contactLast = $this->filterInput( $_REQUEST['contact_lname'] ); $place = $this->filterInput( $_REQUEST['place'] ); @@ -352,7 +360,7 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents $fileDescr = $this->filterInput( $_REQUEST['fileDescription'] ); // get lat lon - $latLon = $this->getGeoLocation( array($address, $city, $state) ); + $latLon = $this->getGeoLocation( array($address, $cities[$city], $state) ); if ($latLon) { $lat = $latLon[0]; $lon = $latLon[1]; @@ -398,7 +406,7 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents } } - $city = $this->getCityId($city); + // $city = $this->getCityId($city); // image upload settings $image = $_FILES['image_new']; $imageName = $image['name']; @@ -729,7 +737,8 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents 'from_email' => $fromEmail, 'notification' => $emailNotification, 'confirmation_page' => $redirect_url, - 'mainImgUrl' => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/large/' + 'mainImgUrl' => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/large/', + 'cities' => $cities, ); //error_reporting(E_ALL ^ E_NOTICE); @@ -739,7 +748,7 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents 'modelRedirect' => false, 'view' => 'front/events/'.$view.'.html', 'data' => $templateData, - //'settings' => $settings + //'settings' => $settings ); } } diff --git a/views/front/events/frontAdd.html b/views/front/events/frontAdd.html index f60a4d7..f018adf 100644 --- a/views/front/events/frontAdd.html +++ b/views/front/events/frontAdd.html @@ -257,10 +257,10 @@
- +
- + {if $event.fieldData.image}
@@ -273,14 +273,14 @@ Delete Image
{$event.fieldData.image}
- + {/if}
New image:

Best image size to provide is between 800 and 1000 pixels wide and stored as a JPG or JPEG file. Also try to supply images that have a reasonable aspect ratio (not too tall, not too wide). Files provided like this should have a file size of 100 to 250 KB. Images will be automatically resized for use in the Web site. Images that are too large will be rejected

- +
{if $memberOnly}
@@ -334,7 +334,12 @@
- +
@@ -489,7 +494,7 @@ jQuery(document).ready(function($) { $('#' + msgArea).html('Characters remaining: ' + rem); } } - + // check image upload type $(".glm-event-front-end-image").change(function () { var ext = this.value.match(/\.(.+)$/)[1]; -- 2.17.1