From: Anthony Talarico Date: Mon, 12 Nov 2018 14:18:26 +0000 (-0500) Subject: undoing ajax changes to adapt for the controller returning html X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=4431ae0d5513b8f16e22ae0f4fef51900c86ad58;p=WP-Plugins%2Fglm-member-db.git undoing ajax changes to adapt for the controller returning html --- diff --git a/controllers/admin.php b/controllers/admin.php index bafbdc57..1053cd87 100755 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -726,7 +726,7 @@ class glmMembersAdmin extends GlmPluginSupport * @return void * @access public */ - public function controller( $menuItem, $action = false, $actionData = false, $returnOutput = false, $forceAction = false ) + public function controller( $menuItem, $action = false, $actionData = false, $returnOutput = false, $forceAction = false) { if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { @@ -1040,11 +1040,11 @@ class glmMembersAdmin extends GlmPluginSupport $this->config['settings'][$key] = $val; } } - + /* * Merge data returned from the model with the selected view */ - + // Load Smarty Template support $smarty = new smartyTemplateSupport(); @@ -1073,9 +1073,12 @@ class glmMembersAdmin extends GlmPluginSupport // Update the Smarty view path $smarty->template->addTemplateDir($viewPath); - + if ( $returnOutput == 'getTemplateData') { + return $smarty->template->getTemplateVars(); + } // Generate output from model data and view if ( $returnOutput ) { + //echo '
', print_r($smarty->template->getTemplateVars()), '
'; $output = $output.$smarty->template->fetch( $viewFile ); } else { echo $output; @@ -1091,7 +1094,7 @@ class glmMembersAdmin extends GlmPluginSupport } if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { - $smarty->template->display( 'admin/smartyDebug.html'); + $smarty->template->display( 'admin/smartyDebug.html' ); } if ( $returnOutput ) { diff --git a/models/admin/ajax/adminSearch.php b/models/admin/ajax/adminSearch.php index a55c8a2d..2033f941 100644 --- a/models/admin/ajax/adminSearch.php +++ b/models/admin/ajax/adminSearch.php @@ -57,7 +57,15 @@ class GlmMembersAdmin_ajax_adminSearch //parent::__construct(false, false); } - + function write_log ( $log ) { + if ( true === WP_DEBUG ) { + if ( is_array( $log ) || is_object( $log ) ) { + error_log( print_r( $log, true ) ); + } else { + error_log( $log ); + } + } + } /** * Perform Model Action * @@ -90,27 +98,11 @@ class GlmMembersAdmin_ajax_adminSearch $limit = 20; $status = $this->config['status_numb']['Active']; - if( isset( $_REQUEST['table'] ) ){ - // echo "test123"; - } - - // // Check for a text search - if (isset($_REQUEST['text_search']) && trim($_REQUEST['text_search']) != '') { - - // $textSearch = addslashes(filter_input(INPUT_POST, 'text_search', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); - $textSearch = addslashes(filter_var($_REQUEST['text_search'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); - $where .= " AND T.id in ( - SELECT DISTINCT(id) - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members - WHERE name like '%$textSearch%' - )"; - - } - - $listResult = $Members->getSimpleMembersList(); + $list = apply_filters('glm-member-db-admin-search'); + $this->write_log($list); $return = array( - 'searchData' => $listResult + 'searchData' => $list // Where our events list will go ); header('Content-type:application/json;charset=utf-8', true); diff --git a/models/admin/members/list.php b/models/admin/members/list.php index 5ac55461..186b75bb 100755 --- a/models/admin/members/list.php +++ b/models/admin/members/list.php @@ -402,7 +402,7 @@ class GlmMembersAdmin_members_list extends GlmDataMembers 'status' => $success, 'menuItemRedirect' => false, 'modelRedirect' => false, - 'view' => 'admin/members/list.html', + 'view' => 'admin/common/manageDashboard/list.html', 'data' => $templateData ); diff --git a/models/admin/newDashboard/index.php b/models/admin/newDashboard/index.php index df1939bf..4036a5eb 100644 --- a/models/admin/newDashboard/index.php +++ b/models/admin/newDashboard/index.php @@ -148,7 +148,7 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers // echo "
" . $a['slug'] . " has no filter called " . $a['slug'] . "-dashboard-widget"; } } - + echo apply_filters('glm-member-db-admin-search', array('glm_action'=>'list')); // Compile template data. $templateData = array( 'lockedToMember' => $lockedToMember, diff --git a/setup/adminHooks.php b/setup/adminHooks.php index f53d57fe..4e080f54 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -574,3 +574,9 @@ add_filter( 13, 1 ); +add_filter( + 'glm-member-db-admin-search', + function ( $input = '' ) { + return $this->controller( 'members', 'list'); + } +); \ No newline at end of file diff --git a/views/admin/common/manageDashboard/index.html b/views/admin/common/manageDashboard/index.html index 2083a335..e048ec98 100644 --- a/views/admin/common/manageDashboard/index.html +++ b/views/admin/common/manageDashboard/index.html @@ -39,179 +39,125 @@ complete: $("#glm-admin-search-overlay").fadeOut('slow'), success: function(data) { - // Kept for reference - // data.searchData.forEach( function(value, index){ - // $("
", { - // text : value, - // class : "glm-list-result" - // }).appendTo( $("#glm-admin-member-list")); - // }) - - console.log(data.searchData[1]); - - // Created some columns based on the keys available in the first result - $.each(data.searchData[1], function(fieldKey, fieldVal) { - $("", { - text : fieldKey, - class : "header-item glm-list-header-column" - }).appendTo( $("#glm-admin-list-columns")); - }); - - // Loop through the search data, treat each as a record - $.each(data.searchData, function(recordNum, record) { - console.log(recordNum, record); - // Throwing all the records into the list - $("
", { - text : "ID: " + record.id + " | Name: " + record.name + " | Featured: " + record.featured.name + " | Created: " + record.created.date, - class : "glm-list-result", - recordID: record.id - }).appendTo( $("#glm-admin-member-list")); - - // Displaying all the data fields one by one - for(var fieldNum in record) { - // console.log(record[fieldNum]); - } - - // Displaying all the data fields one by one - $.each(record, function(fieldKey, fieldVal) { - // console.log(fieldKey, fieldVal) - }); - - - - }); - } }); } }; - /* - * Init Materialize collapsible - */ - jQuery(function($){ - $('.collapsible').collapsible(); - $('select').formSelect(); - $('.modal').modal(); - }) - - /* - * Text Search Autocomplete - */ - function textSearch(textSearchData){ - // Text Search Component + /* + * Init Materialize collapsible + */ jQuery(function($){ - let searchResults = {}; - let imageUrl = `{$glmPluginMediaUrl}/images` - let data = { - action : 'glm_members_admin_ajax', - glm_action : 'glmTextSearch', - table : textSearchData.table, - fields : textSearchData.fields, - where : textSearchData.where - } - $('input#'+textSearchData.slug+'-text').autoComplete({ - minChars: 1, - source: function( request, response ) { - data.query = request; - $.ajax({ - dataType: "json", - type : 'POST', - url: '{$ajaxUrl}', - data: data, - success: function(data) { - console.log(data.searchData); - if(data.searchData){ - let searchDropdown = []; - for(let i = 0;i < data.searchData.length;i++){ - let searchTitle = Object.keys(data.searchData[i])[0]; - let image = (data.searchData[i][searchTitle].image) ? data.searchData[i][searchTitle].image : null; - let memberID = data.searchData[i][searchTitle].memberID; - let entityID = data.searchData[i][searchTitle].entityID; - searchDropdown.push(searchTitle); - {literal} searchResults[searchTitle] = {image: image, memberID: memberID, entityID: entityID}; {/literal} - } - {literal} response(searchDropdown); {/literal} - }else{ - response(['No Results Found']) + $('.collapsible').collapsible(); + $('select').formSelect(); + $('.modal').modal(); + }) + + /* + * Text Search Autocomplete + */ + function textSearch(textSearchData){ + // Text Search Component + jQuery(function($){ + let searchResults = {}; + let imageUrl = `{$glmPluginMediaUrl}/images` + let data = { + action : 'glm_members_admin_ajax', + glm_action : 'glmTextSearch', + table : textSearchData.table, + fields : textSearchData.fields, + where : textSearchData.where + } + $('input#'+textSearchData.slug+'-text').autoComplete({ + minChars: 1, + source: function( request, response ) { + data.query = request; + $.ajax({ + dataType: "json", + type : 'POST', + url: '{$ajaxUrl}', + data: data, + success: function(data) { + console.log(data.searchData); + if(data.searchData){ + let searchDropdown = []; + for(let i = 0;i < data.searchData.length;i++){ + let searchTitle = Object.keys(data.searchData[i])[0]; + let image = (data.searchData[i][searchTitle].image) ? data.searchData[i][searchTitle].image : null; + let memberID = data.searchData[i][searchTitle].memberID; + let entityID = data.searchData[i][searchTitle].entityID; + searchDropdown.push(searchTitle); + {literal} searchResults[searchTitle] = {image: image, memberID: memberID, entityID: entityID}; {/literal} + } + {literal} response(searchDropdown); {/literal} + }else{ + response(['No Results Found']) + } } + }); + }, + renderItem: function (item, search){ + search = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi"); + return '
'+item.replace(re, "$1")+'
'; + + }, + onSelect: function(e, term, item){ + let search = $(item).text(); + console.log(search) + if(search !== "No Results Found"){ + window.location.replace(textSearchData.resultUrl+searchResults[search].entityID); } - }); - }, - renderItem: function (item, search){ - search = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); - var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi"); - return '
'+item.replace(re, "$1")+'
'; + }, + }); + }); + } - }, - onSelect: function(e, term, item){ - let search = $(item).text(); - console.log(search) - if(search !== "No Results Found"){ - window.location.replace(textSearchData.resultUrl+searchResults[search].entityID); + /* + * Date Search Widget + */ + function dateSearch(dateSearchData){ + jQuery(function($){ + + var date = new Date(); + var toDate = '', fromDate = (dateSearchData.defaultFromDate) ? '&' + dateSearchData.fromDate + '=' + dateSearchData.defaultFromDate : ''; + $('.fromDate').datepicker({ + format : 'mm/dd/yyyy', + setDefaultDate : true, + defaultDate : date, + autoClose : true, + onClose : function(){ + fromDate = '&' + dateSearchData.fromDate + '=' + $(this)[0].el.value; } - }, + }); + $('.toDate').datepicker({ + format : 'mm/dd/yyyy', + autoClose : true, + onClose: function(){ + toDate = '&' + dateSearchData.toDate + '=' + $(this)[0].el.value; + } + }); + console.log( dateSearchData.resultUrl + fromDate + toDate) + $('#' + dateSearchData.searchBtn).on("click", function(){ + window.location = dateSearchData.resultUrl + fromDate + toDate; + }) }); - }); - } - - /* - * Date Search Widget - */ - function dateSearch(dateSearchData){ - jQuery(function($){ + } - var date = new Date(); - var toDate = '', fromDate = (dateSearchData.defaultFromDate) ? '&' + dateSearchData.fromDate + '=' + dateSearchData.defaultFromDate : ''; - $('.fromDate').datepicker({ - format : 'mm/dd/yyyy', - setDefaultDate : true, - defaultDate : date, - autoClose : true, - onClose : function(){ - fromDate = '&' + dateSearchData.fromDate + '=' + $(this)[0].el.value; - } - }); - $('.toDate').datepicker({ - format : 'mm/dd/yyyy', - autoClose : true, - onClose: function(){ - toDate = '&' + dateSearchData.toDate + '=' + $(this)[0].el.value; - } + /* + * List component tooltips + */ + function listComponent(listComponentData) { + jQuery(function($){ + $('.tooltipped').tooltip(); }); - console.log( dateSearchData.resultUrl + fromDate + toDate) - $('#' + dateSearchData.searchBtn).on("click", function(){ - window.location = dateSearchData.resultUrl + fromDate + toDate; - }) - }); - } - - /* - * Export Modal - */ - function exportData(exportData){ - jQuery(function($){ - - }); - } - - /* - * List component tooltips - */ - function listComponent(listComponentData) { - jQuery(function($){ - $('.tooltipped').tooltip(); - }); - } - - - - - + } + let data = { action : 'glm_members_admin_ajax', glm_action : 'adminSearch', + form_action : 'list' // table : textSearchData.table, // fields : textSearchData.fields, // where : textSearchData.where @@ -221,7 +167,7 @@ $(".glm-admin-search-field").on("change", function(){ console.log( $(this) ); window.Glma.adminSearch(data); - }) + }); }); diff --git a/views/admin/common/manageDashboard/list.html b/views/admin/common/manageDashboard/list.html new file mode 100644 index 00000000..6cb8e6ec --- /dev/null +++ b/views/admin/common/manageDashboard/list.html @@ -0,0 +1,384 @@ + +
+
+ + + + + + +

List of {$terms.term_member_plur_cap}

+ +
+ {$terms.term_member_cap} Types + +
+ +
+ Show Archived: + Featured Only: + Pending Only: +
+ + {apply_filters('glm-member-db-custom-filter-search', '', 'glm-member-db' )} + +

Total found: {$memberCount}  

+ +
+ +
{$terms.term_member_cap} Export/Reports
+ + {if $paging} + + + {/if} + + + + + + + + + + + + + + + + + {if $haveMembers} + {assign var="i" value="0"} + {foreach $members as $m} + {if $i++ is odd by 1} + + {else} + + {/if} + + + + + + + + + {/foreach} + {else} + + {/if} + +
ID{$terms.term_member_cap} NameFeaturedAccess
+ {$m.id} + + {$m.name} + + Edit Active Profile + + View Profile + + {$m.featured.name} + + {$m.access_short.name} +
(no {$terms.term_member_plur} listed)
+ + {if $paging} + + + {/if} + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + {* Custom Field Part *} + {if apply_filters( 'glm-members-customfields-active', false )} + + + + + {/if} + + + + + + + + +
Categories: + +
Member Types: + +
Show Archived:
Featured Only:
Pending Only:
Name Search:
+ Enter any portion of a {$terms.term_member_cap} name and press enter or select any specific {$terms.term_member_cap} found. +
Fields to export + + + + + + + + +
Check All / Uncheck All
+ {$terms.term_member_cap} ID
+ Old {$terms.term_member_cap} ID
+ {$terms.term_member_cap} Name
+ Profile Reference Name
+ Address Line #1
+ Address Line #2
+ City
+ State
+ ZIP/Postal Code
+ County
+ Region
+
+ Phone #
+ Toll Free
+ Main E-Mail
+ Primary Contact Name
+ Primary Contact E-Mail
+ Web Address (URL)
+ Categories
+ Mailing Address Line #1
+ Mailing Address Line #2
+ Mailing City
+ Mailing State
+ Mailing ZIP/Postal Code
+
+
Custom Fields + {$customFields = apply_filters('glm-member-db-fields-get-members-fields', false, 'glm-member-db')} + {if $customFields} + {foreach $customFields as $cf} + {$cf.field_name}
+ {/foreach} + {/if} +
Include Clicks & Views + + + + + + + +
+ Month: +
+ URL Click Counts
+ Detail Page View Counts +
+
Export to: + Export for Print
+ Export to Spreadsheet (CSV) +
+ Cancel + +
+
+
+ + + +