From 954439b07de9422f404f7895fda183195ee3746c Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Fri, 12 Feb 2016 14:05:24 -0500 Subject: [PATCH] Added live sample menus and tabs and a few other minor things. --- assets/readme.txt | 2 + models/admin/info/index.php | 125 ++++++++++++++++++++++++++++++++ models/admin/members/sample.php | 125 ++++++++++++++++++++++++++++++++ models/admin/sample/index.php | 125 ++++++++++++++++++++++++++++++++ models/admin/sample/more.php | 125 ++++++++++++++++++++++++++++++++ setup/adminMenus.php | 51 ++++++++++++- setup/adminTabs.php | 13 ++++ setup/validActions.php | 13 ++-- views/admin/info/index.html | 6 ++ views/admin/members/sample.html | 6 ++ views/admin/sample/index.html | 7 ++ views/admin/sample/more.html | 6 ++ 12 files changed, 596 insertions(+), 8 deletions(-) create mode 100644 assets/readme.txt create mode 100644 models/admin/info/index.php create mode 100644 models/admin/members/sample.php create mode 100644 models/admin/sample/index.php create mode 100644 models/admin/sample/more.php create mode 100644 views/admin/info/index.html create mode 100644 views/admin/members/sample.html create mode 100644 views/admin/sample/index.html create mode 100644 views/admin/sample/more.html diff --git a/assets/readme.txt b/assets/readme.txt new file mode 100644 index 0000000..34a6135 --- /dev/null +++ b/assets/readme.txt @@ -0,0 +1,2 @@ +Assets folder for things like images and other +files that might need to be read directly. \ No newline at end of file diff --git a/models/admin/info/index.php b/models/admin/info/index.php new file mode 100644 index 0000000..4c61edb --- /dev/null +++ b/models/admin/info/index.php @@ -0,0 +1,125 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Contacts data abstract +//require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); + +class GlmMembersAdmin_info_index // extends GlmDataContacts +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Contact Info + * + * @var $contactInfo + * @access public + */ + public $contactInfo = false; + /** + * Member ID + * + * @var $memberID + * @access public + */ + public $memberID = false; + /** + * Contact ID + * + * @var $contactID + * @access public + */ + public $contactID = false; + + + /* + * Constructor + * + * This contructor performs the work for this model. This model returns + * an array containing the following. + * + * 'status' + * + * True if successfull 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 the Contacts data class + * + * Note, the third parameter is a flag that indicates to the Contacts + * data class that it should flag a group of fields as 'view_only'. + */ +// parent::__construct(false, false, true); + + + } + + public function modelAction($actionData = false) + { + + $displayData = 'This is the Sample Add-On "Info" model talking to you from inside WordPress.'; + + // Compile template data + $templateData = array( + 'displayData' => $displayData + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/info/index.html', + 'data' => $templateData + ); + + } + + +} diff --git a/models/admin/members/sample.php b/models/admin/members/sample.php new file mode 100644 index 0000000..ed2fac9 --- /dev/null +++ b/models/admin/members/sample.php @@ -0,0 +1,125 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Contacts data abstract +//require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); + +class GlmMembersAdmin_members_sample // extends GlmDataContacts +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Contact Info + * + * @var $contactInfo + * @access public + */ + public $contactInfo = false; + /** + * Member ID + * + * @var $memberID + * @access public + */ + public $memberID = false; + /** + * Contact ID + * + * @var $contactID + * @access public + */ + public $contactID = false; + + + /* + * Constructor + * + * This contructor performs the work for this model. This model returns + * an array containing the following. + * + * 'status' + * + * True if successfull 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 the Contacts data class + * + * Note, the third parameter is a flag that indicates to the Contacts + * data class that it should flag a group of fields as 'view_only'. + */ +// parent::__construct(false, false, true); + + + } + + public function modelAction($actionData = false) + { + + $displayData = 'This is the Sample "Members" "Sample" model talking to you from inside WordPress.'; + + // Compile template data + $templateData = array( + 'displayData' => $displayData + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/members/sample.html', + 'data' => $templateData + ); + + } + + +} diff --git a/models/admin/sample/index.php b/models/admin/sample/index.php new file mode 100644 index 0000000..5c321df --- /dev/null +++ b/models/admin/sample/index.php @@ -0,0 +1,125 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Contacts data abstract +//require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); + +class GlmMembersAdmin_sample_index // extends GlmDataContacts +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Contact Info + * + * @var $contactInfo + * @access public + */ + public $contactInfo = false; + /** + * Member ID + * + * @var $memberID + * @access public + */ + public $memberID = false; + /** + * Contact ID + * + * @var $contactID + * @access public + */ + public $contactID = false; + + + /* + * Constructor + * + * This contructor performs the work for this model. This model returns + * an array containing the following. + * + * 'status' + * + * True if successfull 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 the Contacts data class + * + * Note, the third parameter is a flag that indicates to the Contacts + * data class that it should flag a group of fields as 'view_only'. + */ +// parent::__construct(false, false, true); + + + } + + public function modelAction($actionData = false) + { + + $displayData = 'Hello, World! This is the Sample Add-On "sample" model talking to you from inside WordPress.'; + + // Compile template data + $templateData = array( + 'displayData' => $displayData + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/sample/index.html', + 'data' => $templateData + ); + + } + + +} diff --git a/models/admin/sample/more.php b/models/admin/sample/more.php new file mode 100644 index 0000000..b814759 --- /dev/null +++ b/models/admin/sample/more.php @@ -0,0 +1,125 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Contacts data abstract +//require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); + +class GlmMembersAdmin_sample_more // extends GlmDataContacts +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Contact Info + * + * @var $contactInfo + * @access public + */ + public $contactInfo = false; + /** + * Member ID + * + * @var $memberID + * @access public + */ + public $memberID = false; + /** + * Contact ID + * + * @var $contactID + * @access public + */ + public $contactID = false; + + + /* + * Constructor + * + * This contructor performs the work for this model. This model returns + * an array containing the following. + * + * 'status' + * + * True if successfull 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 the Contacts data class + * + * Note, the third parameter is a flag that indicates to the Contacts + * data class that it should flag a group of fields as 'view_only'. + */ +// parent::__construct(false, false, true); + + + } + + public function modelAction($actionData = false) + { + + $displayData = 'Welcome to more information!
This is the Sample Add-On "sample" model with action "more" talking to you from inside WordPress.'; + + // Compile template data + $templateData = array( + 'displayData' => $displayData + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/sample/more.html', + 'data' => $templateData + ); + + } + + +} diff --git a/setup/adminMenus.php b/setup/adminMenus.php index 0853084..6a1932a 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -36,8 +36,20 @@ /* * Added menus or sub-menus examples * + * // Add a main menu item + * add_menu_page( + * 'GLM Sample', // Page Title + * 'GLM Sample', // Menu Title + * 'glm-members-members', // Capability + * 'glm-members-admin-menu-glm-sample', // Menu Slug + * function() {$this->controller('sample');}, // Called function + * false, // Icon URL + * '92' // Menu Position + * ); + * + * // Add a sub-menu item * add_submenu_page( - * 'glm-members-admin-menu-members', // Parent slug + * 'glm-members-admin-menu-sample', // Parent slug * 'Sample', // Page title * 'Sample', // Menu Title * 'glm_members_edit', // Capability required @@ -48,4 +60,41 @@ * If creating a main menu item with add_menu_page(), please document * that structure here. * + * NOTE: The menu slug is the link for the page. It is also parsed by + * the controller and used to find the model to load. The + * "glm-members-admin-menu-" portion should not change, the last + * segment is the model directory name. By default the "index.php" file + * in that directory is executed. If the URL includes a "glm_action" + * parameter, then the model file called is in the same directory but + * is named the same as the "glm_action" parameter. + * */ + +// Add a main menu item +add_menu_page( + 'GLM Sample', // Page Title + 'GLM Sample', // Menu Title + 'glm-members-members', // Capability + 'glm-members-admin-menu-sample', // Menu Slug + function() {$this->controller('sample');}, // Called function + false, // Icon URL + '92' // Menu Position +); + +add_submenu_page( + 'glm-members-admin-menu-sample', // Parent slug + 'Sample', // Page title + 'Sample', // Menu Title + 'glm_members_members', // Capability required + 'glm-members-admin-menu-sample-sample', // Menu slug + function() {$this->controller('sample');} +); + +add_submenu_page( + 'glm-members-admin-menu-sample', // Parent slug + 'Info', // Page title + 'Info', // Menu Title + 'glm_members_members', // Capability required + 'glm-members-admin-menu-sample-info', // Menu slug + function() {$this->controller('info');} +); diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 850f8fd..9f22164 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -46,4 +46,17 @@ * */ +add_filter('glm-member-db-add-tab-for-members', + function($addOnTabs) { + $newTabs = array( + array( + 'text' => 'Sample', + 'menu' => 'members', + 'action' => 'sample' + ) + ); + $addOnTabs = array_merge($addOnTabs, $newTabs); + return $addOnTabs; + } +); diff --git a/setup/validActions.php b/setup/validActions.php index 5f5b3a2..658d1d6 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -46,17 +46,16 @@ $glmMembersSampleAddOnValidActions = array( 'adminActions' => array( -/* 'members' => array( - 'sample' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG + 'sample' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG, ), - 'member' => array( - 'sample' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG + 'sample' => array( + 'index' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG, + 'more' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG, ), - 'management' => array( - 'sample' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG + 'info' => array( + 'index' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG ) -*/ ), 'frontActions' => array( /* diff --git a/views/admin/info/index.html b/views/admin/info/index.html new file mode 100644 index 0000000..eab9b97 --- /dev/null +++ b/views/admin/info/index.html @@ -0,0 +1,6 @@ +
+
+

Info Sub-menu Model

+

{$displayData}

+
+
\ No newline at end of file diff --git a/views/admin/members/sample.html b/views/admin/members/sample.html new file mode 100644 index 0000000..22f4d71 --- /dev/null +++ b/views/admin/members/sample.html @@ -0,0 +1,6 @@ +{include file='admin/members/header.html'} + +

Members Sample Tab

+

{$displayData}

+ +{include file='admin/footer.html'} \ No newline at end of file diff --git a/views/admin/sample/index.html b/views/admin/sample/index.html new file mode 100644 index 0000000..4588ef0 --- /dev/null +++ b/views/admin/sample/index.html @@ -0,0 +1,7 @@ +
+
+

Sample Model

+

{$displayData}

+ Click me to see more! +
+
\ No newline at end of file diff --git a/views/admin/sample/more.html b/views/admin/sample/more.html new file mode 100644 index 0000000..5e1c19a --- /dev/null +++ b/views/admin/sample/more.html @@ -0,0 +1,6 @@ +
+
+

Sample Model - More Information

+

{$displayData}

+
+
\ No newline at end of file -- 2.17.1