static function get_api_params($all = false) { if (!class_exists('dsSearchAgent_Client')) { return false; } $apiParams = @dsSearchAgent_Client::GetApiParams(stripslashes_deep(@$_GET)); // dsIDXpress doesn't add a param when showing all listings if (isset($_GET['idx-q-DistressTypes'])) { $apiParams['query.DistressTypes'] = (int) $_GET['idx-q-DistressTypes']; } if (isset($_GET['idx-q-PhotoCountMin'])) { $apiParams['query.PhotoCountMin'] = (int) $_GET['idx-q-PhotoCountMin']; } if (isset($_GET['idx-q-ListingStatuses'])) { $apiParams['query.ListingStatuses'] = (int) $_GET['idx-q-ListingStatuses']; } # if($apiParams['query.DistressTypes'] === 'all') { # unset($apiParams['query.DistressTypes']); # } if (empty($apiParams) || !is_array($apiParams)) { return false; } foreach ($apiParams as $key => $value) { if (!$all && preg_match('/directive|ResultsPerPage/ism', $key)) { continue; } if (strpos($key, 'Cities') || strpos($key, 'Areas')) { $value = ucwords($value); } $params[str_replace('query.', '', $key)] = $value; } foreach (self::get_numeric_params() as $key) { if (!empty($params) && is_array($params) && array_key_exists($key, $params)) { $params[$key] = floatval(str_replace(",", "", $params[$key])); } } if (empty($params) || !is_array($params)) { return false; } foreach ($params as $key => $value) { // Process array of results if (preg_match('/(.*?)\\[([0-9]+)\\](?:\\.(.+))?/ism', $key, $matches)) { if (isset($matches[3])) { $params[$matches[1]][$matches[3]][$matches[2]] = $value; } else { $params[$matches[1]][$matches[2]] = $value; } unset($params[$key]); } else { $matches = explode('.', $key); if (!empty($matches[1])) { $params[$matches[0]][$matches[1]] = $value; unset($params[$key], $params[$matches[1]]); } } } ksort($params); return $params; }
/** * Get the MLS number of the current listing, if exists. * @global $wp_query * @uses dsSearchAgent_Client::GetApiParams() * @return mixed MLS number if exists; false if not. */ function get_mls() { global $wp_query; if (!class_exists('dsSearchAgent_Client')) { return false; } if (isset($wp_query->query_vars['idx-q-MlsNumber'])) { return $wp_query->query_vars['idx-q-MlsNumber']; } else { $apiParams = @dsSearchAgent_Client::GetApiParams(stripslashes_deep(@$_GET)); return isset($apiParams['query.MlsNumber']) ? $apiParams['query.MlsNumber'] : ''; } return false; }