From 6057c1fd935e441a229a688db138e9852988c51d Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 18 May 2017 13:57:12 -0400 Subject: [PATCH] Start WIP for CSV Import Creating menu, model and view. Adding to valid actions --- models/admin/import/index.php | 127 +++++++++++++++++++++++++++++++++ setup/adminMenus.php | 10 +++ setup/validActions.php | 3 + views/admin/import/header.html | 9 +++ views/admin/import/index.html | 27 +++++++ 5 files changed, 176 insertions(+) create mode 100644 models/admin/import/index.php create mode 100644 views/admin/import/header.html create mode 100644 views/admin/import/index.html diff --git a/models/admin/import/index.php b/models/admin/import/index.php new file mode 100644 index 00000000..0eda98e7 --- /dev/null +++ b/models/admin/import/index.php @@ -0,0 +1,127 @@ + + * @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 + ); + + } + +} diff --git a/setup/adminMenus.php b/setup/adminMenus.php index cd49d611..b0056033 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -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', diff --git a/setup/validActions.php b/setup/validActions.php index eab646d4..ff0a1552 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -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 index 00000000..5d663c9f --- /dev/null +++ b/views/admin/import/header.html @@ -0,0 +1,9 @@ +
+ +

{$glmPluginName} CSV Import

+ + +
+ diff --git a/views/admin/import/index.html b/views/admin/import/index.html new file mode 100644 index 00000000..2d9bb763 --- /dev/null +++ b/views/admin/import/index.html @@ -0,0 +1,27 @@ +{include file='admin/import/header.html'} + +

Data Import Step 1: Upload files

+ +
+ + + + + + + + + + + + + + + +
City Data
State Data
Member Profile Data
+ + + +
+ +{include file='admin/footer.html'} -- 2.17.1