Updates for the Select (rename to registration)
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 18 Aug 2017 12:59:10 +0000 (08:59 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 18 Aug 2017 12:59:10 +0000 (08:59 -0400)
Renaming the select model and view to registration. Setting up the list
view to list out the events. Then the registration page will show just
one event.

data/events.php [new file with mode: 0644]
models/front/registrations/index.php
models/front/registrations/list.php
models/front/registrations/registration.php [new file with mode: 0644]
models/front/registrations/select.php [deleted file]
views/front/registrations/list.html
views/front/registrations/registration.html [new file with mode: 0644]
views/front/registrations/select.html [deleted file]

diff --git a/data/events.php b/data/events.php
new file mode 100644 (file)
index 0000000..b99a76d
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+$eventData = array(
+    1 => array(
+        'id'         => 1,
+        'title'      => 'PHP Payment Gateways',
+        'short_desc' => 'Setting up your developer account and testing payment gateways',
+        'levels'     => array(
+            3 => array(
+                'id'          => 3,
+                'title'       => 'General Admittance',
+                'registrants' => array(
+                    1 => array(
+                        'id'    => 1,
+                        'fname' => 'Dan',
+                        'lname' => 'Smith',
+                        'email' => 'dan@smith.com',
+                    ),
+                    3 => array(
+                        'id'    => 3,
+                        'fname' => 'Tony',
+                        'lname' => 'Johnson',
+                        'email' => 'tj@website.com',
+                    ),
+                ),
+            ),
+        ),
+    ),
+    2 => array(
+        'id'         => 2,
+        'title'       => 'Mailchimp Newsletters',
+        'short_desc' => 'Learning how to setup test and use mailchimp to the fullest.',
+        'levels'     => array(
+            4 => array(
+                'id'    => 4,
+                'title' => 'General Admittance',
+                'registrants' => array(
+                    2 => array(
+                        'id'    => 2,
+                        'fname' => 'John',
+                        'lname' => 'Handler',
+                        'email' => 'johny@handler.com',
+                    ),
+                ),
+            ),
+        ),
+    )
+);
index 42179bf..7305a44 100644 (file)
@@ -1,10 +1,10 @@
 <?php
+
 /*
- * This class determines which registration page to run 
+ * This class determines which registration page to run
  * then calls it and returns the result back to the controller.
  *
- */  
+ */
 class GlmMembersFront_registrations_index
 {
     /**
@@ -21,11 +21,11 @@ class GlmMembersFront_registrations_index
     * @access public
     */
     public $config;
-    
+
     /*
      * Constructor
      *
-     * This contructor sets up this model. At this time that only includes
+     * This contractor sets up this model. At this time that only includes
      * storing away the WordPress data object and GLM associate plugin configuration array.
      *
      * @return object Class object
@@ -33,13 +33,13 @@ class GlmMembersFront_registrations_index
      */
     public function __construct ($wpdb, $config)
     {
-        
+
         // Save WordPress Database object
         $this->wpdb = $wpdb;
-        
+
         // Save plugin configuration object
         $this->config = $config;
-        
+
     }
 
     /*
@@ -83,11 +83,15 @@ class GlmMembersFront_registrations_index
         // Check for valid page - if not valid default to "list"
         $page = $actionData['request']['page'];
 
+        if ( isset( $_REQUEST['page'] ) && $request = filter_var( $_REQUEST['page'], FILTER_SANITIZE_STRING ) ) {
+            $page = $request;
+        }
+
         // Make sure the specified page is valid or default to "list"
-        if (!in_array($page, array('list', 'select', 'cart', 'checkout', 'summary', 'login', 'account'))) {
+        if (!in_array($page, array('list', 'registration', 'cart', 'checkout', 'summary', 'login', 'account'))) {
             $page = 'list';
         }
-        
+
         // Load the specified model
         $pageFile = GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH.'/models/front/registrations/'.$page.'.php';
         require_once($pageFile);
@@ -98,6 +102,6 @@ class GlmMembersFront_registrations_index
         $regResult = $regModel->modelAction($actionData);
 
         return $regResult;
-        
+
     }
  }
index bef41e1..6aa7bbd 100644 (file)
     * @access public
     */
     public $config;
+
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+    }
+
     /**
      * Constructor
      *
      *
      * 'status'
      *
-     * True if successfull and false if there was a fatal failure.
+     * True if successful and false if there was a fatal failure.
      *
      * 'view'
      *
-     * A suggested view name that the contoller should use instead of the
+     * A suggested view name that the controller should use instead of the
      * default view for this model or false to indicate that the default view
      * should be used.
      *
 
         }
 
+        // including test data for now
+        include GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH . '/data/events.php';
+
         // Compile template data
         $templateData = array(
-
+            'events' => $eventData,
         );
              // Return status, any suggested view, and any data to controller
         return array(
diff --git a/models/front/registrations/registration.php b/models/front/registrations/registration.php
new file mode 100644 (file)
index 0000000..99b3262
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+ require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegEvent.php';
+
+ class GlmMembersFront_registrations_registration extends GlmDataRegistrationsRegEvent {
+    /**
+    * WordPress Database Object
+    *
+    * @var $wpdb
+    * @access public
+    */
+    public $wpdb;
+    /**
+    * Plugin Configuration Data
+    *
+    * @var $config
+    * @access public
+    */
+    public $config;
+
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+    }
+
+    public function modelAction($actionData = false)
+    {
+        $regEvent = array();
+
+        // Get any provided option
+        if (isset($_REQUEST['option'])) {
+            $option = $_REQUEST['option'];
+        }
+
+        // Get account ID if supplied
+        if (isset($_REQUEST['account'])) {
+
+            // Make sure it's numeric
+            $this->accountID = ($_REQUEST['account'] - 0);
+
+            if ($this->accountID <= 0) {
+                $this->accountID = false;
+            }
+        }
+
+        // Get account ID if supplied
+        if (isset($_REQUEST['eventRegId'])) {
+
+            // Make sure it's numeric
+            $eventRegID = ($_REQUEST['eventRegId'] - 0);
+
+            if ($eventRegID <= 0) {
+                $eventRegID = false;
+            }
+        }
+        $view = 'registration';
+
+        switch ( $option ) {
+
+        }
+
+        // including test data for now
+        include GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH . '/data/events.php';
+
+        if ( isset( $eventData[$eventRegID] ) ) {
+            $regEvent[] = $eventData[$eventRegID];
+        } else {
+            $regEvent = array();
+        }
+        //echo '<pre>$events: ' . print_r( $events, true ) . '</pre>';
+
+        // Compile template data
+        $templateData = array(
+            'events' => $regEvent,
+        );
+             // Return status, any suggested view, and any data to controller
+        return array(
+            'status'        => true,
+            'modelRedirect' => false,
+            'view'          => 'front/registrations/' . $view . '.html',
+            'data'          => $templateData
+        );
+
+    }
+ }
diff --git a/models/front/registrations/select.php b/models/front/registrations/select.php
deleted file mode 100644 (file)
index 0b8abda..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-<?php
- require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegEvent.php';
-
- class GlmMembersFront_registrations_select extends GlmDataRegistrationsRegEvent {
-    /**
-    * WordPress Database Object
-    *
-    * @var $wpdb
-    * @access public
-    */
-    public $wpdb;
-    /**
-    * Plugin Configuration Data
-    *
-    * @var $config
-    * @access public
-    */
-    public $config;
-
-    public function __construct ($wpdb, $config)
-    {
-        
-        // Save WordPress Database object
-        $this->wpdb = $wpdb;
-        
-        // Save plugin configuration object
-        $this->config = $config;
-        
-    }
-    
-    public function modelAction($actionData = false)
-    {
-        $events = array();
-        
-        // Get any provided option
-        if (isset($_REQUEST['option'])) {
-            $option = $_REQUEST['option'];
-        }
-
-        // Get account ID if supplied
-        if (isset($_REQUEST['account'])) {
-
-            // Make sure it's numeric
-            $this->accountID = ($_REQUEST['account'] - 0);
-
-            if ($this->accountID <= 0) {
-                $this->accountID = false;
-            }
-        }
-
-        $view = 'select';
-
-        switch ( $option ) {
-
-        }
-
-        $events = array(
-            1 => array(
-                'id'         => 1,
-                'title'      => 'PHP Payment Gateways',
-                'short_desc' => 'Setting up your developer account and testing payment gateways',
-                'levels'     => array(
-                    3 => array(
-                        'id'          => 3,
-                        'title'       => 'General Admittance',
-                        'registrants' => array(
-                            1 => array(
-                                'id'    => 1,
-                                'fname' => 'Dan',
-                                'lname' => 'Smith',
-                                'email' => 'dan@smith.com',
-                            ),
-                            3 => array(
-                                'id'    => 3,
-                                'fname' => 'Tony',
-                                'lname' => 'Johnson',
-                                'email' => 'tj@website.com',
-                            ),
-                        ),
-                    ),
-                ),
-            ),
-            2 => array(
-                'id'         => 2,
-                'title'       => 'Mailchimp Newsletters',
-                'short_desc' => 'Learning how to setup test and use mailchimp to the fullest.',
-                'levels'     => array(
-                    4 => array(
-                        'id'    => 4,
-                        'title' => 'General Admittance',
-                        'registrants' => array(
-                            2 => array(
-                                'id'    => 2,
-                                'fname' => 'John',
-                                'lname' => 'Handler',
-                                'email' => 'johny@handler.com',
-                            ),
-                        ),
-                    ),
-                ),
-            )
-        );
-        //echo '<pre>$events: ' . print_r( $events, true ) . '</pre>';
-
-        // Compile template data
-        $templateData = array(
-            'events' => $events,
-        );
-             // Return status, any suggested view, and any data to controller
-        return array(
-            'status'        => true,
-            'modelRedirect' => false,
-            'view'          => 'front/registrations/' . $view . '.html',
-            'data'          => $templateData
-        );
-
-    }
- }
index 8eee247..ecc7bf6 100644 (file)
@@ -1 +1,10 @@
-This is a list
\ No newline at end of file
+<div class="glm-reg-event-list">
+    {foreach $events as $event}
+    <div class="glm-reg-event-item clearfix">
+        <h2><a href="{$thisUrl}?page=registration&eventRegId={$event.id}">{$event.title}</a></h2>
+        <p>{$event.short_desc}</p>
+
+    </div>
+    {/foreach}
+
+</div>
diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html
new file mode 100644 (file)
index 0000000..1f1f640
--- /dev/null
@@ -0,0 +1,31 @@
+<div class="glm-reg-event-list">
+    {foreach $events as $event}
+    <div class="glm-reg-event-item clearfix">
+        <h2>{$event.title}</h2>
+        <div class="glm-reg-compcode-entry">
+            <input type="text" placeholder="Enter Comp Code Here" />
+        </div>
+        <p>{$event.short_desc}</p>
+        <div class="glm-reg-entryforms clearfix">
+            <div class="glm-reg-dates">
+                <h4>Pick your registration dates</h4>
+                <input type="date" placeholder="Enter Date" />
+                <input type="text" placeholder="Enter Time" />
+            </div>
+            {foreach $event.levels as $level}
+            <div class="glm-reg-level">
+                <h3>{$level.title}</h3>
+                <span class="glm-reg-level-add-registrant">+</span>
+                {foreach $level.registrants as $reg}
+                <div class="glm-reg-level-registrant clearfix"><span class="glm-reg-level-registrant-name">{$reg.fname} {$reg.lname}</span> <span class="glm-reg-level-registrant-email">{$reg.email}</span></div>
+                {/foreach}
+            </div>
+            {/foreach}
+            <div class="glm-reg-submit">
+                <input type="submit" value="Continue to Cart" />
+            </div>
+        </div>
+    </div>
+    {/foreach}
+
+</div>
diff --git a/views/front/registrations/select.html b/views/front/registrations/select.html
deleted file mode 100644 (file)
index 1f1f640..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<div class="glm-reg-event-list">
-    {foreach $events as $event}
-    <div class="glm-reg-event-item clearfix">
-        <h2>{$event.title}</h2>
-        <div class="glm-reg-compcode-entry">
-            <input type="text" placeholder="Enter Comp Code Here" />
-        </div>
-        <p>{$event.short_desc}</p>
-        <div class="glm-reg-entryforms clearfix">
-            <div class="glm-reg-dates">
-                <h4>Pick your registration dates</h4>
-                <input type="date" placeholder="Enter Date" />
-                <input type="text" placeholder="Enter Time" />
-            </div>
-            {foreach $event.levels as $level}
-            <div class="glm-reg-level">
-                <h3>{$level.title}</h3>
-                <span class="glm-reg-level-add-registrant">+</span>
-                {foreach $level.registrants as $reg}
-                <div class="glm-reg-level-registrant clearfix"><span class="glm-reg-level-registrant-name">{$reg.fname} {$reg.lname}</span> <span class="glm-reg-level-registrant-email">{$reg.email}</span></div>
-                {/foreach}
-            </div>
-            {/foreach}
-            <div class="glm-reg-submit">
-                <input type="submit" value="Continue to Cart" />
-            </div>
-        </div>
-    </div>
-    {/foreach}
-
-</div>