Adding api for shortcode of the bibco search.
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 3 May 2017 17:35:12 +0000 (13:35 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 3 May 2017 17:35:12 +0000 (13:35 -0400)
Adding the bibco search to the api plugin.
Adds shorcode to bring in their old search form for dock schedules.

js/dummy.js [new file with mode: 0644]
models/front/apis/bibcoCalendar.php
models/front/apis/bibcoSearch.php
setup/shortcodes.php
setup/validActions.php
views/front/apis/bibcoSearch.html [new file with mode: 0644]

diff --git a/js/dummy.js b/js/dummy.js
new file mode 100644 (file)
index 0000000..e69de29
index 21d318f..a611d69 100644 (file)
@@ -54,6 +54,17 @@ class GlmMembersFront_apis_bibcoCalendar
 
         // Setup the url.
         $url = $calendarUrl . 'schedule.php';
+
+        // Check for $_REQUEST array and put into url
+        if ( isset( $_REQUEST['dock'] ) ) {
+            $urlParams[] = 'dock=' . $_REQUEST['dock'];
+        }
+        if ( isset( $_REQUEST['departDate'] ) ) {
+            $urlParams[] = 'departDate=' . $_REQUEST['departDate'];
+        }
+        if ( !empty( $urlParams ) ) {
+            $url .= '?' . implode( '&', $urlParams );
+        }
         $curl = curl_init( $url );
         curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
         curl_setopt( $curl, CURLOPT_USERPWD, 'dev55:Glm15Keep!' );
index c87c57b..1550f46 100644 (file)
@@ -32,12 +32,6 @@ class GlmMembersFront_apis_bibcoSearch
         $this->wpdb   = $wpdb;
         $this->config = $config;
 
-        //parent::__construct(false, false);
-
-        if ( $this->config['settings']['use_venue_locations'] ) {
-            $this->getMemberList();
-        }
-
     }
     /**
      * modelAction
@@ -52,14 +46,32 @@ class GlmMembersFront_apis_bibcoSearch
         $view        = 'bibcoSearch';
         $settings    = array();
         $content     = '';
-        $mainSchedId = false;
 
         // Get the options for bibco
         $bibcoOptions = unserialize( get_option( GLM_MEMBERS_APIS_BIBCO_OPTION_NAME ) );
         $calendarUrl  = ( isset( $bibcoOptions['calendarUrl'] ) ) ? $bibcoOptions['calendarUrl'] : '';
 
+        // enqueue styles and scripts for the schedule form.
+        wp_enqueue_style('jquery-ui');
+        wp_enqueue_style('plugin_name-admin-ui-css',
+            'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/cupertino/jquery-ui.css',
+            false,
+            '1.0',
+            false
+        );
+        wp_register_script(
+            'glm_api_dummy_script',
+            GLM_MEMBERS_APIS_PLUGIN_BASE_URL . '/js/dummy.js',
+            array('jquery-ui-datepicker'),
+            '1.0',
+            true
+        );
+
+        wp_enqueue_script('glm_api_dummy_script');
+
         // Setup the url.
         $url = $calendarUrl . 'scheduleSearch.php';
+
         $curl = curl_init( $url );
         curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
         curl_setopt( $curl, CURLOPT_USERPWD, 'dev55:Glm15Keep!' );
@@ -67,6 +79,9 @@ class GlmMembersFront_apis_bibcoSearch
         $content = curl_exec( $curl );
         curl_close( $curl );
 
+        // Once you get the content replace ACTION_URL
+        $content = str_replace( 'ACTION_URL', get_permalink(), $content );
+
         $templateData = array(
             'content'      => $content,
         );
index 63676aa..e7c05dc 100644 (file)
@@ -120,8 +120,8 @@ $glmMembersApisShortcodes = array(
         'menu'       => 'apis',
         'action'     => 'bibcoSearch',
         'table'      => false,
-        'attribute'  => array(
-            'template' => false
+        'attributes'  => array(
+            //'template' => false
         )
     ),
 );
@@ -143,17 +143,17 @@ $glmMembersApisShortcodesDescription = '
         </td>
     </tr>
      <tr>
-        <th>[glm-members-api-golf-directory]</th>
+        <th>[glm-members-api-bibco-search]</th>
         <td>&nbsp;</td>
         <td width="50%">
-            Pulls in the Directory for Harbor Point Golf Club
+            Pulls in the Search for Bibco
         </td>
     </tr>
      <tr>
-        <th>[glm-members-api-bibco-search]</th>
+        <th>[glm-members-api-golf-directory]</th>
         <td>&nbsp;</td>
         <td width="50%">
-            Pulls in the Search for Bibco
+            Pulls in the Directory for Harbor Point Golf Club
         </td>
     </tr>
     ';
index ad1fd63..8be2c3b 100644 (file)
@@ -73,6 +73,7 @@ $glmMembersApisAddOnValidActions = array(
         'apis' => array(
             'schedule'          => GLM_MEMBERS_APIS_PLUGIN_SLUG,
             'bibcoCalendar'     => GLM_MEMBERS_APIS_PLUGIN_SLUG,
+            'bibcoSearch'       => GLM_MEMBERS_APIS_PLUGIN_SLUG,
             'golfclubDirectory' => GLM_MEMBERS_APIS_PLUGIN_SLUG,
         ),
     )
diff --git a/views/front/apis/bibcoSearch.html b/views/front/apis/bibcoSearch.html
new file mode 100644 (file)
index 0000000..d9f1e44
--- /dev/null
@@ -0,0 +1 @@
+{$content}