From: Chuck Scott Date: Thu, 24 Jan 2019 20:53:06 +0000 (-0500) Subject: Merge branch 'feature/ajaxSearch' into develop X-Git-Tag: v2.11.0^2~8 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=8d35f170cdc99f1403a123804683c5a4497cb609;p=WP-Plugins%2Fglm-member-db.git Merge branch 'feature/ajaxSearch' into develop --- 8d35f170cdc99f1403a123804683c5a4497cb609 diff --cc models/front/members/list.php index 845f6b6c,a25611e6..3c6176f5 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@@ -297,146 -368,153 +368,151 @@@ class GlmMembersFront_members_list exte } } - - // Apply any provided text search to name, description, short description, and street address - if (trim($actionData['request']['text-search']) != '') { - $textSearch = addslashes(stripslashes(filter_var($actionData['request']['text-search'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES))); - $where .= $whereSep." ( - ( match(member_name) against('$textSearch') ) - OR - ( T.descr SOUNDS LIKE '$textSearch' OR T.descr LIKE '%$textSearch%' ) - OR - T.short_descr LIKE '%$textSearch%' - OR - T.addr1 LIKE '%$textSearch%' - OR - T.addr2 LIKE '%$textSearch%' - )"; - // City part (on hold) - // OR T.city IN ( - // SELECT id FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "cities - // WHERE name SOUNDS LIKE '%$textSearch%' OR name LIKE '%$textSearch%' - // ) - $appendSelect = " match(member_name) against('$textSearch') as rel_name "; - $whereSep = ' AND '; - $textSearch = stripslashes($textSearch); - $fullTextSearch = true; + // echo "
Settings Before Button Checks".print_r($settings,1)."
"; + + // Handle what to show when only certain things are included + $settings['list_map_show_button'] = true; + $settings['list_map_show_container'] = true; + $settings['list_search_show_button'] = true; + $settings['list_show_outer_container'] = true; + if ($settings['list_show_map'] && (!isset($settings['list_show_search']) || !$settings['list_show_search'])) { + $settings['list_map_show_opened'] = true; + $settings['list_map_show_button'] = false; + $settings['list_map_show_container'] = false; + $settings['list_show_outer_container'] = false; + } + if ($settings['list_show_search'] && (!isset($settings['list_show_map']) || !$settings['list_show_map'])) { + $settings['list_search_show_button'] = false; + $settings['list_show_search_filters_opened'] = true; + $settings['list_show_outer_container'] = false; } - // Get regions for possible use in search pick list for regions used in active member info records. - require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataRegions.php'; - $Regions = new GlmDataRegions($this->wpdb, $this->config); - $regionData = $Regions->getListForSearch(true, $actionData); + // If we don't already have a completed list query + if (!$thisInstance['listQuery']) { + + $thisInstance['listQuery'] = true; + -echo "

RUNNING QUERY

"; - + // Apply any provided text search to name, description, short description, and street address + if ( isset($actionData['request']['text-search']) && trim($actionData['request']['text-search']) != '') { + $textSearch = addslashes(stripslashes(filter_var($actionData['request']['text-search'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES))); + $where .= $whereSep." ( + ( match(member_name) against('$textSearch') ) + OR + ( T.descr SOUNDS LIKE '$textSearch' OR T.descr LIKE '%$textSearch%' ) + OR + T.short_descr LIKE '%$textSearch%' + OR + T.addr1 LIKE '%$textSearch%' + OR + T.addr2 LIKE '%$textSearch%' + )"; + // City part (on hold) + // OR T.city IN ( + // SELECT id FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "cities + // WHERE name SOUNDS LIKE '%$textSearch%' OR name LIKE '%$textSearch%' + // ) + $appendSelect = " match(member_name) against('$textSearch') as rel_name "; + $whereSep = ' AND '; + $textSearch = stripslashes($textSearch); + $fullTextSearch = true; + } - // Get cities for possible use in search pick list for cities used in active member info records. - require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php'; - $cities = new GlmDataCities($this->wpdb, $this->config); - $cityData = $cities->getListForSearch(true, $actionData); // Get only categories that are used in active member data + // Get regions for possible use in search pick list for regions used in active member info records. + require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataRegions.php'; + $Regions = new GlmDataRegions($this->wpdb, $this->config); + $regionData = $Regions->getListForSearch(true, $actionData); + // Get cities for possible use in search pick list for cities used in active member info records. + require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php'; + $cities = new GlmDataCities($this->wpdb, $this->config); + $cityData = $cities->getListForSearch(true, $actionData); // Get only categories that are used in active member data - // If we have a region set in shortcode or via URL. - $regions = array(); - if ($actionData['request']['region-search']) { + // If we have a region set in shortcode or via URL. + $regions = array(); + if ( isset( $actionData['request']['region-search'] ) && $actionData['request']['region-search']) { - // Convert comma separated list to an array - $regionsRequested = explode( ',', $actionData['request']['region-search'] ); + // Convert comma separated list to an array + $regionsRequested = explode( ',', $actionData['request']['region-search'] ); - // Check for numeric ID's only - foreach ( $regionsRequested as $k => $v ) { - if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) { - $regions[] = ( $v - 0 ); + // Check for numeric ID's only + while ( list( $k, $v ) = each( $regionsRequested ) ) { + if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) { + $regions[] = ( $v - 0 ); + } } - } - if ( isset( $regions ) && !empty( $regions ) ) { - $where .= $whereSep." T.region IN (" . implode( ',', $regions ) . ")"; - $whereSep = ' AND '; + if ( isset( $regions ) && !empty( $regions ) ) { + $where .= $whereSep." T.region IN (" . implode( ',', $regions ) . ")"; + $whereSep = ' AND '; + } } - } - $counties = array(); - $countyList = ''; - if ($actionData['request']['county-search']) { + $counties = array(); + // If we have a county set in shortcode or via URL. + if ( isset( $actionData['request']['county-search'] ) && $actionData['request']['county-search']) { - // Convert comma separated list to an array - $regionsRequested = explode( ',', $actionData['request']['county-search'] ); + // Convert comma separated list to an array + $regionsRequested = explode( ',', $actionData['request']['county-search'] ); - // Check for numeric ID's only - foreach ( $regionsRequested as $k => $v ) { - if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) { - $counties[] = ( $v - 0 ); + // Check for numeric ID's only + while ( list( $k, $v ) = each( $regionsRequested ) ) { + if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) { + $counties[] = ( $v - 0 ); + } } - } - if ( isset( $counties ) && !empty( $counties ) ) { - $where .= $whereSep." T.county IN (" . implode( ',', $counties ) . ")"; - $whereSep = ' AND '; - $countyList = implode( ',', $counties ); + if ( isset( $counties ) && !empty( $counties ) ) { + $where .= $whereSep." T.county IN (" . implode( ',', $counties ) . ")"; + $whereSep = ' AND '; + } } - } - // If there's regions shortcode or url options to restrict this page to certain regions - if (count($regions) > 0) { + // If there's regions shortcode or url options to restrict this page to certain regions + if (count($regions) > 0) { - while ( list($k,$v) = each ($regionData) ) { - if (!in_array($v['id'], $regions)) { - unset ($regionData[$k]); + while ( list($k,$v) = each ($regionData) ) { + if (!in_array($v['id'], $regions)) { + unset ($regionData[$k]); + } } - } - } + } - // If we have a city set in shortcode or via URL. - $cities = array(); - if ( isset( $actionData['request']['city-search'] ) - && $actionData['request']['city-search'] - ) { + // If we have a city set in shortcode or via URL. + $cities = array(); + if ( isset( $actionData['request']['city-search'] ) + && $actionData['request']['city-search'] + ) { - // Convert comma separated list to an array - $citiesRequested = explode( ',', $actionData['request']['city-search'] ); + // Convert comma separated list to an array + $citiesRequested = explode( ',', $actionData['request']['city-search'] ); - // Check for numeric ID's only - foreach ( $citiesRequested as $k => $v ) { - if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) { - $cities[] = ( $v - 0 ); + // Check for numeric ID's only + while ( list( $k, $v ) = each( $citiesRequested ) ) { + if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) { + $cities[] = ( $v - 0 ); + } } - } - if ( isset( $cities ) && !empty( $cities ) ) { - $where .= $whereSep." T.city IN (" . implode( ',', $cities ) . ")"; - $whereSep = ' AND '; + if ( isset( $cities ) && !empty( $cities ) ) { + $where .= $whereSep." T.city IN (" . implode( ',', $cities ) . ")"; + $whereSep = ' AND '; + } } - } - // If there's city's shortcode or url options to restrict this page to certain cities - if (count($cities) > 0) { + // If there's city's shortcode or url options to restrict this page to certain cities + if (count($cities) > 0) { - while ( list($k,$v) = each ($cityData) ) { - if (!in_array($v['id'], $cities)) { - unset ($cityData[$k]); - } - } - } - // Check for user region selection - $categoryRegionList = ''; - $categoryRegionSep = ''; - if (isset($_REQUEST) && is_array($regionData) && (isset($_REQUEST['regionUserSearch']) && count($_REQUEST['regionUserSearch']) > 0) || (isset($_REQUEST['regionSearch']) && $_REQUEST['regionSearch'] != "")) { - foreach ($regionData as $r) { - $id = $r['id']; - $regionData[$id]['default'] = false; - if ( (isset($_REQUEST['regionUserSearch']) && in_array($id, $_REQUEST['regionUserSearch'])) || (isset($_REQUEST['regionSearch']) && $id == $_REQUEST['regionSearch']) ) { - $regionData[$id]['default'] = true; - $regionSearchSelected = $id; - $where .= $whereSep." T.region = $id"; - $whereSep = ' AND '; - $categoryRegionList .= $categoryRegionSep."$id"; - $categoryRegionSep = ', '; + while ( list($k,$v) = each ($cityData) ) { + if (!in_array($v['id'], $cities)) { + unset ($cityData[$k]); + } } } - } else { - // Double check that we have an array from $regionData - if ( isset( $regionData ) && is_array( $regionData ) ) { - reset($regionData); + // Check for user region selection + $categoryRegionList = ''; + $categoryRegionSep = ''; + if (isset($_REQUEST) && is_array($regionData) && (isset($_REQUEST['regionUserSearch']) && count($_REQUEST['regionUserSearch']) > 0) || (isset($_REQUEST['regionSearch']) && $_REQUEST['regionSearch'] != "")) { foreach ($regionData as $r) { $id = $r['id']; $regionData[$id]['default'] = false;