Add shortcode for getting a member trip planner button develop
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 10 Oct 2019 17:02:20 +0000 (13:02 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 10 Oct 2019 17:02:20 +0000 (13:02 -0400)
Create it to add to a page.

models/front/itinerary/button.php [new file with mode: 0755]
setup/shortcodes.php
setup/validActions.php
views/front/itinerary/button.html [new file with mode: 0644]

diff --git a/models/front/itinerary/button.php b/models/front/itinerary/button.php
new file mode 100755 (executable)
index 0000000..737abf4
--- /dev/null
@@ -0,0 +1,102 @@
+<?php
+/**
+ * list.php
+ *
+ */
+
+/**
+ * GlmMembersFront_itinerary_list
+ *
+ * @uses      GlmDataItinerary
+ * @package   GlmMemberItinerary
+ * @version   0.0.1
+ * @copyright Copyright (c) 2010 All rights reserved.
+ * @author    Steve Sutton <steve@gaslightmedia.com>
+ * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
+ */
+class GlmMembersFront_itinerary_button // extends GlmMembersFront_events_baseAction
+{
+    /**
+     * Constructor
+     *
+     * This constructor performs the work for this model. This model returns
+     * an array containing the following.
+     *
+     * 'status'
+     *
+     * True if successful and false if there was a fatal failure.
+     *
+     * 'view'
+     *
+     * A suggested view name that the contoller should use instead of the
+     * default view for this model or false to indicate that the default view
+     * should be used.
+     *
+     * 'data'
+     *
+     * Data that the model is returning for use in merging with the view to
+     * produce output.
+     *
+     * @wpdb object WordPress database object
+     *
+     * @return array Array containing status, suggested view, and any data
+     */
+    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);
+
+    }
+
+    /**
+     * modelAction
+     *
+     * @param bool $actionData Action Data passed to the modelAction
+     *
+     * @access public
+     * @return void
+     */
+    public function modelAction( $actionData = false )
+    {
+        $status = true;
+        $option = false;
+        $view   = 'button.html';
+        $member = false;
+
+
+        if ( isset( $_REQUEST['option'] ) ) {
+            $option = filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING );
+        }
+
+        switch ( $option ) {
+
+        default:
+            if ( isset( $actionData['request']['member'] ) && $member = filter_var( $actionData['request']['member'], FILTER_VALIDATE_INT ) ) {
+                $button = glm_member_itinerary_trip_planner_link( '', $member );
+            } else {
+                $button = false;
+            }
+            break;
+        }
+
+        $templateData = array(
+            'button' => $button,
+        );
+
+        return array(
+            'status'           => $status,
+            'menuItemRedirect' => false,
+            'modelRedirect'    => false,
+            'view'             => 'front/itinerary/' . $view,
+            'data'             => $templateData,
+        );
+    }
+
+}
index 5b32e24..9bba43e 100644 (file)
@@ -95,7 +95,16 @@ $glmMembersItineraryShortcodes = array(
         'table'      => false,
         'attributes' => array(
         ),
-    )
+    ),
+    'glm-itinerary-button' => array(
+        'plugin'     => 'glm-member-db-itinerary',
+        'menu'       => 'itinerary',
+        'action'     => 'button',
+        'table'      => false,
+        'attributes' => array(
+            'member' => false,
+        ),
+    ),
 );
 
 $glmMembersItineraryShortcodesDescription = '
@@ -106,5 +115,11 @@ $glmMembersItineraryShortcodesDescription = '
         Displays the trip planner list.
     </td>
 </tr>
+<tr>
+    <th>[glm-itinerary-button]</th>
+    <td width="50%">
+        Display button with a member
+    </td>
+</tr>
 ';
 
index a091937..d00a980 100644 (file)
@@ -68,7 +68,8 @@ $glmMembersItineraryAddOnValidActions = array(
     ),
     'frontActions' => array(
         'itinerary' => array(
-            'list' => GLM_MEMBERS_ITINERARY_PLUGIN_SLUG,
+            'list'   => GLM_MEMBERS_ITINERARY_PLUGIN_SLUG,
+            'button' => GLM_MEMBERS_ITINERARY_PLUGIN_SLUG,
         )
     )
 );
diff --git a/views/front/itinerary/button.html b/views/front/itinerary/button.html
new file mode 100644 (file)
index 0000000..01f89d0
--- /dev/null
@@ -0,0 +1,5 @@
+<div class="glm-row">
+    <div id="glm-member-detail-map-wrapper">
+        {$button}
+    </div>
+</div>