From: Chuck Scott Date: Tue, 10 Mar 2015 19:38:45 +0000 (-0400) Subject: Started building front-end output X-Git-Tag: v1.0.0~56 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=3b0a45781bdf30703e133f58e083719b9db49d26;p=WP-Plugins%2Fglm-member-db.git Started building front-end output --- diff --git a/config/plugin.ini b/config/plugin.ini index 67480c5c..eaee2adb 100644 --- a/config/plugin.ini +++ b/config/plugin.ini @@ -245,6 +245,7 @@ phrase['phrase_test'] = 'test' [chuck:common] admin_debug = true +front_debug = true googleMapsApiKey = '' diff --git a/controllers/front.php b/controllers/front.php index 2b2c3271..2d737cba 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -28,10 +28,7 @@ $GLOBALS['glmMembersFrontValidActions'] = array( 'members' => array( - 'index', // member list - 'list', - 'reports', - 'other' + 'list' ) ); @@ -71,7 +68,7 @@ class glmMembersFront extends GlmPluginSupport $this->config = $config; // Add front-end scripts and css - add_action('front_enqueue_scripts', + add_action('wp_enqueue_scripts', array( $this, 'glmMembersFrontScripts' @@ -82,6 +79,7 @@ class glmMembersFront extends GlmPluginSupport $this, 'controller' )); + } /** @@ -97,26 +95,28 @@ class glmMembersFront extends GlmPluginSupport public function glmMembersFrontScripts () { - /* - * - * wp_enqueue_script('jquery'); - * wp_enqueue_script('jquery-style'); - * wp_enqueue_script('jquery-ui-core'); - * wp_enqueue_script('jquery-ui-dialog'); - * - * wp_register_script('glm-members-front-js', - * GLM_MEMBERS_PLUGIN_URL . 'js/front.js', - * array( - * 'jquery' - * )); - * wp_enqueue_script('glm-members-front-js'); - */ + wp_enqueue_script('jquery'); + wp_enqueue_script('jquery-style'); + wp_enqueue_script('jquery-ui-core'); + wp_enqueue_script('jquery-ui-dialog'); + wp_enqueue_style("wp-jquery-ui-dialog"); + + // Front end script + wp_register_script( + 'glm-members-front-js', + GLM_MEMBERS_PLUGIN_URL . 'js/front.js', + array( + 'jquery' + )); + wp_enqueue_script('glm-members-front-js'); // A simple set of styles for things I haven't found as a WordPress - // default yet - wp_register_style('glmMembersFrontStyle', - GLM_MEMBERS_PLUGIN_URL . 'css/front.css'); + wp_register_style( + 'glmMembersFrontStyle', + GLM_MEMBERS_PLUGIN_URL . 'css/front.css' + ); wp_enqueue_style('glmMembersFrontStyle'); + } /** @@ -173,12 +173,16 @@ class glmMembersFront extends GlmPluginSupport */ public function controller ($atts, $content = null) { + // Shortcode Attributes defaults $request = shortcode_atts( - array( - 'action' => 'list', - 'option' => false - ), $atts); + array( + 'action' => 'index', + 'option' => false + ), + $atts, + 'glm-members' + ); /* * Because WordPress insists on forcing the timezone to UTC @@ -191,11 +195,11 @@ class glmMembersFront extends GlmPluginSupport $errorMsg = ''; - if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { // Get all defiend constants then if not VERBOSE select out only user contstants $consts = get_defined_constants(true); - if (!GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + if (!GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) { $consts = $consts['user']; } @@ -208,10 +212,19 @@ class glmMembersFront extends GlmPluginSupport */ // Default action is "index" - $action = 'index'; + $menuItem = 'members'; + $action = 'list'; + $option = false; + + // First check shortcode attributes + if ($request['action']) { + $action = $request['action']; + } + if ($request['option']) { + $action = $request['option']; + } - // Get any requested "action" from a form submission modify path/name - // accordingly + // Get any requested "action" from a form submission - Overrides shortcode attributes if (isset($_REQUEST['glm_action']) && $_REQUEST['glm_action'] != '') { $a = sanitize_text_field($_REQUEST['glm_action']); if ($a != '') { @@ -225,8 +238,7 @@ class glmMembersFront extends GlmPluginSupport do { if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { - $this->addNotice( - "Requested Action: Menu item = $menuItem, Action = $action", 'Process'); + glmMembersFront::addNotice("Requested Action: Menu item = $menuItem, Action = $action", 'Process'); } $modelRedirect = false; @@ -360,19 +372,19 @@ class glmMembersFront extends GlmPluginSupport $smarty = new smartyTemplateSupport(); // Add standard parameters - $smarty->templateAssign ( 'adminDebug', GLM_MEMBERS_PLUGIN_ADMIN_DEBUG); + $smarty->templateAssign ( 'frontDebug', GLM_MEMBERS_PLUGIN_FRONT_DEBUG); $smarty->templateAssign ( 'baseURL', GLM_MEMBERS_PLUGIN_BASE_URL); $smarty->templateAssign ( 'thisURL', GLM_MEMBERS_PLUGIN_CURRENT_URL ); - $smarty->templateAssign ( 'thisPage', $_REQUEST['page']); $smarty->templateAssign ( 'glmPluginName', GLM_MEMBERS_PLUGIN_NAME ); $smarty->templateAssign ( 'glmPluginMediaURL', GLM_MEMBERS_PLUGIN_MEDIA_URL ); $smarty->templateAssign ( 'thisYear', date ( 'Y' ) ); $smarty->templateAssign ( $this->config['term']); $smarty->templateAssign ( $this->config['phrase']); + $smarty->templateAssign ( 'googleMapsBrowserApiKey', $this->config['googleMapsApiKey']); // Add all terms and phrases from the config/plugin.ini file - $smarty->templateAssign ( 'terms', $this->config->term); - $smarty->templateAssign ( 'phrase', $this->config->phrase); +// $smarty->templateAssign ( 'terms', $this->config->term); +// $smarty->templateAssign ( 'phrase', $this->config->phrase); // Add data from model to Smarty template if (is_array($results['data']) && count($results['data']) > 0) { diff --git a/css/front.css b/css/front.css index 7766c467..971dbc8d 100644 --- a/css/front.css +++ b/css/front.css @@ -3,3 +3,30 @@ Gaslight Media Members Database Front-End Styles */ + +.glm-right { + float: right; +} +.glm-left { + float: left; +} + + +.glm-item-container { + border: 1px #ccc solid; + padding: .4em; + background: #f8f8f8; +} + +/* Map */ +.glm-map { + width:90%; + height:400px; + border: 2px black solid; +} + + +.glm-copyright { + text-align: center; + margin: 2em; +} diff --git a/index.php b/index.php index 703c4875..ee289df4 100644 --- a/index.php +++ b/index.php @@ -59,7 +59,7 @@ if (isset($configData[$hostSection])) { ; } -// Add Debug defines +// Add Debug defines - These can't go into the defines.php file - Guess why. define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG', $config['admin_debug']); define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', $config['admin_debug_verbose']); define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG', $config['front_debug']); diff --git a/lib/GlmDataAbstract/DataAbstract.php b/lib/GlmDataAbstract/DataAbstract.php index 2f1daaf1..e7cf4870 100755 --- a/lib/GlmDataAbstract/DataAbstract.php +++ b/lib/GlmDataAbstract/DataAbstract.php @@ -716,7 +716,7 @@ abstract class GlmDataAbstract // Get pointer options from specified table $order_by = $f['p_field']; - if ($f['p_orderby']) { + if (isset($f['p_orderby']) && $f['p_orderby']) { $order_by = $f['p_orderby']; } diff --git a/misc/smarty/templates_c/081a36d97cdf30d438a1e104c26a275acc180da0.file.index.html.php b/misc/smarty/templates_c/081a36d97cdf30d438a1e104c26a275acc180da0.file.index.html.php index 238c2b9c..d206596e 100644 --- a/misc/smarty/templates_c/081a36d97cdf30d438a1e104c26a275acc180da0.file.index.html.php +++ b/misc/smarty/templates_c/081a36d97cdf30d438a1e104c26a275acc180da0.file.index.html.php @@ -1,4 +1,4 @@ - decodeProperties(array ( @@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array ( '081a36d97cdf30d438a1e104c26a275acc180da0' => array ( 0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/members/index.html', - 1 => 1426001070, + 1 => 1426001139, 2 => 'file', ), ), diff --git a/models/admin/member/memberInfo.php b/models/admin/member/memberInfo.php index 802a4df0..b78846c7 100644 --- a/models/admin/member/memberInfo.php +++ b/models/admin/member/memberInfo.php @@ -378,7 +378,8 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo $sql = " UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info SET status = ".$this->config['status_numb']['Inactive']." - WHERE status = ".$this->config['status_numb']['Active']." + WHERE member = $memberID + AND status = ".$this->config['status_numb']['Active']." AND id != $memberInfoID ;"; $this->wpdb->query($sql); diff --git a/models/front/members/list.php b/models/front/members/list.php new file mode 100644 index 00000000..557c48b8 --- /dev/null +++ b/models/front/members/list.php @@ -0,0 +1,158 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Members data abstract +require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersFront_members_list extends GlmDataMemberInfo +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor 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; + + // Run constructor for members data class + parent::__construct($this->wpdb, $this->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 successfull 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 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. + * + */ + public function modelAction ($redirectData = false) + { + + $where = ''; + $filterPending = false; + $filterArchived = false; + $filterName = false; + $haveFilter = false; + + $where .= " T.status = ".$this->config['status_numb']['Active']; + + // Get a current list of members + $list = $this->getList($where); + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + glmMembersFront::addNotice($list, 'DataBlock', 'Member Data'); + } + + // If we have list entries - even if it's an empty list + $success = true; + $haveMembers = false; + if ($list !== false) { + + $success = true; + + // If we have any entries + if (count($list) > 0) { + $haveMembers = true; + } + } + + // Determine if current user can add, edit, delete member data +// $canEdit = current_user_can('glm_members_edit'); + + // Compile template data + $templateData = array( + 'haveMembers' => $haveMembers, + 'members' => $list, + 'haveFilter' => $haveFilter, + 'filterArchived' => $filterArchived, + 'filterPending' => $filterPending, + 'filterName' => stripslashes($filterName) +// 'canEdit' => $canEdit + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'front/members/list.html', + 'data' => $templateData + ); + + } + + +} + +?> \ No newline at end of file diff --git a/views/front/error/badAction.html b/views/front/error/badAction.html new file mode 100644 index 00000000..7165a075 --- /dev/null +++ b/views/front/error/badAction.html @@ -0,0 +1,11 @@ +{include file='front/error/header.html'} + +

Sorry, we've had an error.

+ +

Error: : An invalid action has been specified.

+ + {if $errorMsg}

{$errorMsg}

{/if} + +

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

+ +{include file='front/footer.html'} diff --git a/views/front/error/header.html b/views/front/error/header.html new file mode 100644 index 00000000..f9fdb916 --- /dev/null +++ b/views/front/error/header.html @@ -0,0 +1,5 @@ +
+ +

{$glmPluginName}

+ + \ No newline at end of file diff --git a/views/front/error/index.html b/views/front/error/index.html new file mode 100644 index 00000000..ece4c866 --- /dev/null +++ b/views/front/error/index.html @@ -0,0 +1,12 @@ +{include file='front/error/header.html'} + +
+ +

Sorry, we've had some type of fatal error.

+ +

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

+ +
+ +{include file='front/footer.html'} + diff --git a/views/front/footer.html b/views/front/footer.html new file mode 100644 index 00000000..9782baf0 --- /dev/null +++ b/views/front/footer.html @@ -0,0 +1,16 @@ + +
+ + + {if $frontDebug} + + {/if} + + \ No newline at end of file diff --git a/views/front/members/header.html b/views/front/members/header.html new file mode 100644 index 00000000..4af7c4fc --- /dev/null +++ b/views/front/members/header.html @@ -0,0 +1,3 @@ +
+
+ \ No newline at end of file diff --git a/views/front/members/list.html b/views/front/members/list.html new file mode 100644 index 00000000..b9ca45a2 --- /dev/null +++ b/views/front/members/list.html @@ -0,0 +1,87 @@ +{include file='front/members/header.html'} + + + + +
(map loads here)
+ + +

List of Members

+ +{if $haveMembers} + {foreach $members as $m} +
+
+
+

{$m.member}

+

+ {if $m.addr1}{$m.addr1}
{/if} + {if $m.addr2}{$m.addr2}
{/if} + {if $m.city.name}{$m.city.name}{if $m.state.name}, {/if}{/if}{if $m.state.name}{$m.state.name}{/if}{if $m.zip} {$m.zip}{/if} + {if $m.country.name}
{$m.country.name}{/if} +

+ + + {if $m.descr} +

{$m.descr}

+ {else if $m.short_descr} +

{$m.short_descr}

+ {/if} +
+ +
+ {/foreach} +{else} +
(no members listed)
+{/if} + + + + + +{include file='front/footer.html'}