From 6252fecb6493c0f4b119b1b120df5456bf174f76 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 16 Mar 2017 10:44:08 -0400 Subject: [PATCH] Updating the management options Also working more on the drop down schedule. --- models/admin/ajax/schedule.php | 7 +- models/admin/management/apis.php | 15 +++- models/front/apis/schedule.php | 30 +++++-- views/admin/management/apis.html | 17 +++- views/front/apis/schedule.html | 142 +++++++++++++++++-------------- 5 files changed, 133 insertions(+), 78 deletions(-) diff --git a/models/admin/ajax/schedule.php b/models/admin/ajax/schedule.php index 47559fd..b91f625 100644 --- a/models/admin/ajax/schedule.php +++ b/models/admin/ajax/schedule.php @@ -84,7 +84,12 @@ class GlmMembersAdmin_ajax_schedule public function modelAction($actionData = false) { if ( isset( $_REQUEST['schedule_id'] ) && preg_match( '/sel([0-9]*)/', $_REQUEST['schedule_id'] ) ) { - $url = get_option( GLM_MEMBERS_APIS_STARLINE_OPTION_NAME ) . 'schedule-' . $_REQUEST['schedule_id'] . '.js'; + // Get the options for starline + $starlineOptions = unserialize( get_option( GLM_MEMBERS_APIS_STARLINE_OPTION_NAME ) ); + $starlineUrl = ( isset( $starlineOptions['ticketUrl'] ) ) ? $starlineOptions['ticketUrl'] : ''; + $starlinePageSlug = ( isset( $starlineOptions['pageSlug'] ) ) ? $starlineOptions['pageSlug'] : ''; + + $url = $starlineUrl . 'schedule-' . $_REQUEST['schedule_id'] . '.js'; $curl = curl_init( $url ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $curl, CURLOPT_USERPWD, 'dev55:Glm15Keep!' ); diff --git a/models/admin/management/apis.php b/models/admin/management/apis.php index 92ffd20..52d8918 100644 --- a/models/admin/management/apis.php +++ b/models/admin/management/apis.php @@ -92,6 +92,8 @@ class GlmMembersAdmin_management_apis $settings_update_error = false; $api_settings = false; $option2 = false; + $starlineUrl = false; + $starlinePageSlug = false; $starlineOptionName = GLM_MEMBERS_APIS_STARLINE_OPTION_NAME; if (isset($_REQUEST['option'])) { @@ -127,14 +129,18 @@ class GlmMembersAdmin_management_apis // Update the settings and redisplay the form case 'submit': $settings_updated = true; - update_option( $starlineOptionName, $_REQUEST[$starlineOptionName] ); - $starlineUrl = get_option( $starlineOptionName ); + update_option( $starlineOptionName, serialize( $_REQUEST[$starlineOptionName] ) ); + $starlineOptions = unserialize( get_option( $starlineOptionName ) ); + $starlineUrl = ( isset( $starlineOptions['ticketUrl'] ) ) ? $starlineOptions['ticketUrl'] : ''; + $starlinePageSlug = ( isset( $starlineOptions['pageSlug'] ) ) ? $starlineOptions['pageSlug'] : ''; break; // Default is to get the current settings and display the form default: - $starlineUrl = get_option( $starlineOptionName ); + $starlineOptions = unserialize( get_option( $starlineOptionName ) ); + $starlineUrl = ( isset( $starlineOptions['ticketUrl'] ) ) ? $starlineOptions['ticketUrl'] : ''; + $starlinePageSlug = ( isset( $starlineOptions['pageSlug'] ) ) ? $starlineOptions['pageSlug'] : ''; break; } @@ -144,7 +150,8 @@ class GlmMembersAdmin_management_apis // Compile template data $template_data = array( 'option' => $option, - 'starlineUrl' => $starlineUrl, + 'starlineUrl' => $starlineUrl, + 'starlinePageSlug' => $starlinePageSlug, 'starlineOptionName' => $starlineOptionName, 'settingsUpdated' => $settings_updated, 'settingsUpdateError' => $settings_update_error, diff --git a/models/front/apis/schedule.php b/models/front/apis/schedule.php index f5f838c..2c2ea87 100644 --- a/models/front/apis/schedule.php +++ b/models/front/apis/schedule.php @@ -49,15 +49,35 @@ class GlmMembersFront_apis_schedule */ public function modelAction($actionData = false) { + echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; //echo '
$actionData: ' . print_r( $actionData, true ) . '
'; $view = 'schedule'; $settings = array(); $content = ''; - // Get the schedule from starline - $url = get_option( GLM_MEMBERS_APIS_STARLINE_OPTION_NAME ) . 'ferrySchedule.php'; - if ( isset( $actionData['request']['in_dropdown'] ) && $inDropDown = filter_var( $actionData['request']['in_dropdown'], FILTER_VALIDATE_BOOLEAN) ) { - $url .= '?dropdown=1'; + // Get the options for starline + $starlineOptions = unserialize( get_option( GLM_MEMBERS_APIS_STARLINE_OPTION_NAME ) ); + $starlineUrl = ( isset( $starlineOptions['ticketUrl'] ) ) ? $starlineOptions['ticketUrl'] : ''; + $starlinePageSlug = ( isset( $starlineOptions['pageSlug'] ) ) ? $starlineOptions['pageSlug'] : ''; + + // Setup the url. + $url = $starlineUrl . 'ferrySchedule.php'; + $inDropDown = filter_var( $actionData['request']['in_dropdown'], FILTER_VALIDATE_BOOLEAN ); + $urlParams = array(); + if ( isset( $actionData['request']['in_dropdown'] ) && $inDropDown ) { + $urlParams[] = 'dropdown=1'; + } + if ( isset( $_REQUEST['mapLink'] ) && $inDropDown ) { + $urlParams[] = 'mapLink=' . $_REQUEST['mapLink']; + } + if ( isset( $_REQUEST['dockId'] ) && !$inDropDown ) { + $urlParams[] = 'dockId=' . $_REQUEST['dockId']; + } + if ( isset( $_REQUEST['scheduleId'] ) && !$inDropDown ) { + $urlParams[] = 'scheduleId=' . $_REQUEST['scheduleId']; + } + if ( !empty( $urlParams ) ) { + $url .= '?' . implode( '&', $urlParams ); } $curl = curl_init( $url ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); @@ -68,7 +88,7 @@ class GlmMembersFront_apis_schedule $templateData = array( 'content' => $content, 'inDropDown' => $inDropDown, - 'schedulePage' => 'schedule-test-page' + 'schedulePage' => get_home_url(null, '/' ) . $starlinePageSlug . '/', ); error_reporting(E_ALL ^ E_NOTICE); diff --git a/views/admin/management/apis.html b/views/admin/management/apis.html index 8fd4930..cc81a61 100644 --- a/views/admin/management/apis.html +++ b/views/admin/management/apis.html @@ -9,26 +9,37 @@ {if $settingsUpdated}

Settings Updated

{/if} {if $settingsUpdateError}Settings Update Error{/if} -

Management Settings

+

Starline API

- + + + +
URL for ticketing system (Starline) [include ending slash] URL for ticketing system (Starline) [include ending slash]
Page slug for the Schedule + +
diff --git a/views/front/apis/schedule.html b/views/front/apis/schedule.html index 09815ae..3c4e53b 100644 --- a/views/front/apis/schedule.html +++ b/views/front/apis/schedule.html @@ -1,71 +1,83 @@
+ {if $inDropDown} + + + +{/if} {$content} + {if $inDropDown} + + {/if}
-- 2.17.1