Start WIP for CSV Import
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 18 May 2017 17:57:12 +0000 (13:57 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 18 May 2017 17:57:12 +0000 (13:57 -0400)
Creating menu, model and view.
Adding to valid actions

models/admin/import/index.php [new file with mode: 0644]
setup/adminMenus.php
setup/validActions.php
views/admin/import/header.html [new file with mode: 0644]
views/admin/import/index.html [new file with mode: 0644]

diff --git a/models/admin/import/index.php b/models/admin/import/index.php
new file mode 100644 (file)
index 0000000..0eda98e
--- /dev/null
@@ -0,0 +1,127 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Data Import
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersAdmin_import_index
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /**
+     * Constructor
+     *
+     * This contractor sets up this model. At this time that only includes
+     * storing away the WordPress data object.
+     *
+     * @return object Class object
+     *
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+    }
+
+    /**
+     * Perform Model Action
+     *
+     * This method does the work for this model and returns any resulting data
+     *
+     * @return array Status and data array
+     *
+     * 'status'
+     *
+     * True if successful and false if there was a fatal failure.
+     *
+     * 'menuItemRedirect'
+     *
+     * If not false, provides a menu item the controller should
+     * execute after this one. Normally if this is used, there would also be a
+     * modelRedirect value supplied as well.
+     *
+     * 'modelRedirect'
+     *
+     * If not false, provides an action the controller should execute after
+     * this one.
+     *
+     * 'view'
+     *
+     * 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.
+     *
+     * 'data'
+     *
+     * Data that the model is returning for use in merging with the view to
+     * produce output.
+     *
+     */
+    public function modelAction ($actionData = false)
+    {
+
+
+        $view    = 'index.html';
+        $failure = false;
+        $option  = '';
+
+        if (isset($_REQUEST['option']) && $_REQUEST['option'] != '') {
+            $option = $_REQUEST['option'];
+        }
+
+        switch($option) {
+
+            default:
+
+                break;
+
+        }
+
+        $templateData = array(
+            'data'    => false,
+        );
+        // Return status, suggested view, and data to controller
+        return array(
+            'status'           => true,
+            'menuItemRedirect' => false,
+            'modelRedirect'    => false,
+            'view'             => 'admin/import/'.$view,
+            'data'             => $templateData
+        );
+
+    }
+
+}
index cd49d61..b005603 100644 (file)
@@ -147,6 +147,16 @@ add_submenu_page(
     function() {$this->controller('management');}
 );
 
+// Add a submenu for the "Import" section
+add_submenu_page(
+    'glm-members-admin-menu-members',
+    'Import',
+    'Import',
+    'glm_members_management',
+    'glm-members-admin-menu-import',
+    function() {$this->controller('import');}
+);
+
 // Add a submenu for the "Shortcode Reference" section
 add_submenu_page(
     'glm-members-admin-menu-members',
index eab646d..ff0a155 100644 (file)
@@ -88,6 +88,9 @@ $glmMembersValidActions = array(
         'pages' => array(
             'shortcode' => 'glm-member-db',
         ),
+        'import' => array(
+            'index' => 'glm-member-db',
+        ),
     ),
     'frontActions' => array(
         'members' => array(
diff --git a/views/admin/import/header.html b/views/admin/import/header.html
new file mode 100644 (file)
index 0000000..5d663c9
--- /dev/null
@@ -0,0 +1,9 @@
+<div class="wrap glm-associate-admin-wrap glm-associate-admin-management-wrap">
+
+    <h2>{$glmPluginName} CSV Import</h2>
+
+    <h2 class="nav-tab-wrapper">
+        <a href="{$thisUrl}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">Import CSV</a>
+    </h2>
+    <div id="glm-admin-content-container">
+
diff --git a/views/admin/import/index.html b/views/admin/import/index.html
new file mode 100644 (file)
index 0000000..2d9bb76
--- /dev/null
@@ -0,0 +1,27 @@
+{include file='admin/import/header.html'}
+
+    <h2>Data Import Step 1: Upload files</h2>
+
+    <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="glm_action" value="index" />
+
+        <table class="glm-admin-table">
+            <tr>
+                <th>City Data</th>
+                <td><input type="file" name="member_city_file" /></td>
+            </tr>
+            <tr>
+                <th>State Data</th>
+                <td><input type="file" name="member_state_file" /></td>
+            </tr>
+            <tr>
+                <th>Member Profile Data</th>
+                <td><input type="file" name="member_profile_file" /></td>
+            </tr>
+        </table>
+
+        <input type="submit" value="Continue" class="button button-primary submit-import">
+
+    </form>
+
+{include file='admin/footer.html'}