function widget($args, $instance) { extract($args); extract($instance); $options = get_option(DSIDXWIDGETS_OPTION_NAME); $randString = dsWidgets_Service_Base::get_random_string('abcdefghijklmnopqrstuvwxyz1234567890', 5); $widgetType = htmlspecialchars($instance["widgetType"]); $imagesStub = dsWidgets_Service_Base::$widgets_images_stub; $apiStub = dsWidgets_Service_Base::$widgets_api_stub; $curURL = get_home_url(); $idxpress_options = get_option(DSIDXPRESS_OPTION_NAME); if (!empty($idxpress_options["AccountID"])) { $aid = $idxpress_options["AccountID"]; } else { $aid = $options["AccountID"]; } if (!empty($idxpress_options["SearchSetupID"])) { $ssid = $idxpress_options["SearchSetupID"]; } else { $ssid = $options["SearchSetupID"]; } echo $before_widget; if (defined('ZPRESS_API') && ZPRESS_API != '') { $widget_header = call_user_func('\\zpress\\themes\\Options::GetOption', 'theme_widgets_require_header'); if (!empty($widget_header->meta) && $widget_header->meta == 'true') { echo $before_title; echo 'Quick Search'; echo $after_title; } } echo <<<HTML <script type="text/javascript" id="divLocal{$randString}_"> LaunchBase{$randString} = function(){ \t\t\t\twindow.quickSearchHasDependency = true; var quickSearchScript, _ds_midx; CreateObject{$randString} = function () { _ds_midx = { currentURL: '{$curURL}', widgetType: '{$widgetType}', curAPIStub: '{$apiStub}', curImageStub: '{$imagesStub}', targetDomain: window["zpress_widget_domain_token"], accountId: '{$aid}',searchSetupId: '{$ssid}',muteStyles: true,location: 0,fields: '0123',city: '', community: '', curDivID: 'divLocal{$randString}_',product: '0' }; } AddJavaScriptToDOM{$randString}=function(c,d,e){if(1!=d){var a=document.createElement("script"),b=document.getElementsByTagName("script")[0];a.async=!0;a.src=c;a.onload=function(){ window[e] = 1;};b.parentNode.insertBefore(a,b)}return 1}; CreateWidget{$randString} = function () { (window.quickSearchFinished == 1) ? (window["ds.widget.view.quicksearch"].isProcessing = true, CreateObject{$randString}(), new window["ds.widget.view.quicksearch"](_ds_midx), window["ds.widget.view.quicksearch"].isProcessing = false, window.quickSearchHasDependency = false) : window.setTimeout("CreateWidget{$randString}(false)", 20); } if (quickSearchScript != 1) { quickSearchScript = AddJavaScriptToDOM{$randString}("{$this->widgetsCdn}/Scripts/PostCompile/QuickSearch_v1_1.js", quickSearchScript, 'quickSearchFinished') }; CreateWidget{$randString}(); } GetToken{$randString}=function(){if(!window.zpress_widget_domain_token&&1!=window.zpress_widget_domain_token_progress){window.zpress_widget_domain_token_progress=1;var c=-1<navigator.userAgent.indexOf("MSIE 7.0")?!0:!1,d=-1<navigator.userAgent.indexOf("MSIE 8.0")||-1<navigator.userAgent.indexOf("MSIE 9.0")?!0:!1;if(c)rr=document.createElement("script"),rr.async=!0,rr.id="domainScript",rr.type="text/javascript",rr.src="{$apiStub}Encrypt/?targetString="+window.location.hostname+"&targetObject=domain&authType=Basic&curDomain="+ window.location.hostname+"&objectName_=error",rr.onload=rr.onreadystatechange=function(){"undefined"!=typeof window.error?alert("We had a problem authenticating this domain"):(window.zpress_widget_domain_token=window.encrypted_domain,LaunchBase{$randString}())},document.getElementsByTagName("head")[0].appendChild(rr);else if(c="{$apiStub}Encrypt/?targetString="+window.location.hostname+"&targetObject=domain&authType=CORS&objectName_=error",d){var a=new XDomainRequest;a.onload=function(){window.zpress_widget_domain_token= eval(a.responseText);LaunchBase{$randString}()};a.onerror=function(){};a.onprogress=function(){};a.open("GET",c,!0);a.send(null)}else{var b;if(b=new XMLHttpRequest)b.onreadystatechange=function(){if(4==b.readyState)if(200==b.status){var a=eval(b.responseText);"undefined"!=typeof a.listingsError?alert(a.listingsError[0].Message):(window.zpress_widget_domain_token=a,LaunchBase{$randString}())}},b.open("GET",c,!0),b.send()}}else window.zpress_widget_domain_token?LaunchBase{$randString}(): window.setTimeout("GetToken{$randString}()",20)};GetToken{$randString}(); </script> HTML; echo $after_widget; dsidx_footer::ensure_disclaimer_exists("search"); }
function widget($args, $instance) { extract($args); extract($instance); $title = apply_filters("widget_title", $title); $options = get_option(DSIDXPRESS_OPTION_NAME); if (!$options["Activated"]) { return; } $pluginUrl = plugins_url() . '/dsidxpress/'; wp_enqueue_script('dsidxpress_widget_search_view', $pluginUrl . 'js/widget-client.js', array('jquery'), DSIDXPRESS_PLUGIN_VERSION, true); $formAction = get_home_url() . "/idx/"; $capabilities = dsSearchAgent_ApiRequest::FetchData('MlsCapabilities'); $capabilities = json_decode($capabilities['body'], true); $defaultSearchPanels = dsSearchAgent_ApiRequest::FetchData("AccountSearchPanelsDefault", array(), false, 60 * 60 * 24); $defaultSearchPanels = $defaultSearchPanels["response"]["code"] == "200" ? json_decode($defaultSearchPanels["body"]) : null; $propertyTypes = dsSearchAgent_ApiRequest::FetchData("AccountSearchSetupFilteredPropertyTypes", array(), false, 60 * 60 * 24); $propertyTypes = $propertyTypes["response"]["code"] == "200" ? json_decode($propertyTypes["body"]) : null; $account_options = dsSearchAgent_ApiRequest::FetchData("AccountOptions", array(), false); $account_options = $account_options["response"]["code"] == "200" ? json_decode($account_options["body"]) : null; $values = array(); $values['idx-q-Locations'] = isset($_GET['idx-q-Locations']) ? $_GET['idx-q-Locations'] : null; $values['idx-q-PropertyTypes'] = isset($_GET['idx-q-PropertyTypes']) ? $_GET['idx-q-PropertyTypes'] : null; $values['idx-q-Cities'] = isset($_GET['idx-q-Cities']) ? $_GET['idx-q-Cities'] : null; $values['idx-q-Communities'] = isset($_GET['idx-q-Communities']) ? $_GET['idx-q-Communities'] : null; $values['idx-q-TractIdentifiers'] = isset($_GET['idx-q-TractIdentifiers']) ? $_GET['idx-q-TractIdentifiers'] : null; $values['idx-q-ZipCodes'] = isset($_GET['idx-q-ZipCodes']) ? $_GET['idx-q-ZipCodes'] : null; $values['idx-q-PriceMin'] = isset($_GET['idx-q-PriceMin']) ? $_GET['idx-q-PriceMin'] : null; $values['idx-q-PriceMax'] = isset($_GET['idx-q-PriceMax']) ? $_GET['idx-q-PriceMax'] : null; $values['idx-q-BedsMin'] = isset($_GET['idx-q-BedsMin']) ? $_GET['idx-q-BedsMin'] : null; $values['idx-q-BathsMin'] = isset($_GET['idx-q-BathsMin']) ? $_GET['idx-q-BathsMin'] : null; $values['idx-q-ImprovedSqFtMin'] = isset($_GET['idx-q-ImprovedSqFtMin']) ? $_GET['idx-q-ImprovedSqFtMin'] : null; $values['idx-q-MlsNumbers'] = isset($_GET['idx-q-MlsNumbers']) ? $_GET['idx-q-MlsNumbers'] : null; $specialSlugs = array('city' => 'idx-q-Cities', 'community' => 'idx-q-Communities', 'tract' => 'idx-q-TractIdentifiers', 'zip' => 'idx-q-ZipCodes'); $urlParts = explode('/', $_SERVER['REQUEST_URI']); $count = 0; foreach ($urlParts as $p) { if (array_key_exists($p, $specialSlugs) && isset($urlParts[$count + 1])) { $values[$specialSlugs[$p]] = $urlParts[$count + 1]; } $count++; } echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo <<<HTML \t\t\t<div class="dsidx-resp-search-box dsidx-widget dsidx-resp-vertical"> \t\t\t<label id="idx-search-invalid-msg" style="color:red"></label> \t\t\t<form class="dsidx-resp-search-form" action="{$formAction}" method="get" onsubmit="return dsidx_w.searchWidget.validate();" > \t\t\t\t<fieldset> \t\t\t\t<div class="dsidx-resp-area"> \t\t\t\t<label>Property Type</label> \t\t\t\t<select name="idx-q-PropertyTypes" class="dsidx-search-widget-propertyTypes"> \t\t\t\t\t<option value="">Any</option> HTML; if (is_array($propertyTypes)) { foreach ($propertyTypes as $propertyType) { $name = htmlentities($propertyType->DisplayName); $selected = $propertyType->SearchSetupPropertyTypeID == $values['idx-q-PropertyTypes'] ? ' selected="selected"' : ''; echo "<option value=\"{$propertyType->SearchSetupPropertyTypeID}\"{$selected}>{$name}</option>"; } } echo <<<HTML \t\t\t\t</select> \t\t\t\t</div> \t\t\t\t<div class="dsidx-resp-area"> HTML; if ($searchOptions['show_cities'] == 'yes' && !empty($searchOptions['cities'])) { echo <<<HTML \t\t\t\t<label>City</label> \t\t\t\t<select id="idx-q-Cities" name="idx-q-Cities" class="idx-q-Location-Filter"> \t\t\t\t\t<option value="">Any</option> HTML; foreach ($searchOptions["cities"] as $city) { // there's an extra trim here in case the data was corrupted before the trim was added in the update code below $city = htmlentities(trim($city)); $selected = strtolower($city) == strtolower($values['idx-q-Cities']) ? ' selected="selected"' : ''; echo "<option value=\"{$city}\"{$selected}>{$city}</option>"; } echo '</select>'; echo '</div>'; } if ($searchOptions['show_communities'] == 'yes' && !empty($searchOptions['communities'])) { echo <<<HTML \t\t\t\t<div class="dsidx-resp-area"> \t\t\t\t<label>Community</label> \t\t\t\t<select id="idx-q-Communities" name="idx-q-Communities" class="idx-q-Location-Filter"> \t\t\t\t\t<option value="">Any</option> HTML; foreach ($searchOptions['communities'] as $community) { // there's an extra trim here in case the data was corrupted before the trim was added in the update code below $community = htmlentities(trim($community)); $selected = strtolower($community) == strtolower($values['idx-q-Communities']) ? ' selected="selected"' : ''; echo "<option value=\"{$community}\"{$selected}>{$community}</option>"; } echo '</select>'; echo '</div>'; } if ($searchOptions['show_tracts'] == 'yes' && !empty($searchOptions['tracts'])) { echo <<<HTML \t\t\t\t<div class="dsidx-resp-area"> \t\t\t\t<label>Tract</label> \t\t\t\t<select id="idx-q-TractIdentifiers" name="idx-q-TractIdentifiers" class="idx-q-Location-Filter"> \t\t\t\t\t<option value="">Any</option> HTML; foreach ($searchOptions["tracts"] as $tract) { // there's an extra trim here in case the data was corrupted before the trim was added in the update code below $tract = htmlentities(trim($tract)); $selected = strtolower($tract) == strtolower($values['idx-q-TractIdentifiers']) ? ' selected="selected"' : ''; echo "<option value=\"{$tract}\"{$selected}>{$tract}</option>"; } echo '</select>'; echo '</div>'; } if ($searchOptions['show_zips'] == 'yes' && !empty($searchOptions['zips'])) { echo <<<HTML \t\t\t\t<div class="dsidx-resp-area"> \t\t\t\t<label>Zip</label> \t\t\t\t<select id="idx-q-ZipCodes" name="idx-q-ZipCodes" class="idx-q-Location-Filter"> \t\t\t\t\t<option value="">Any</option> HTML; foreach ($searchOptions["zips"] as $zip) { // there's an extra trim here in case the data was corrupted before the trim was added in the update code below $zip = htmlentities(trim($zip)); $selected = strtolower($zip) == strtolower($values['idx-q-ZipCodes']) ? ' selected="selected"' : ''; echo "<option value=\"{$zip}\"{$selected}>{$zip}</option>"; } echo '</select>'; echo '</div>'; } if ($searchOptions["show_mlsnumber"] == "yes") { echo <<<HTML \t\t\t\t<div class="dsidx-resp-area"> \t\t\t\t<label for="idx-q-MlsNumbers">MLS #</label> \t\t\t\t<input id="idx-q-MlsNumbers" name="idx-q-MlsNumbers" type="text" class="dsidx-mlsnumber" value="{$values['idx-q-MlsNumbers']}" /> \t\t\t\t</div> HTML; } echo <<<HTML \t\t\t\t<div class="dsidx-resp-area dsidx-resp-area-half dsidx-resp-area-half dsidx-resp-area-left"> \t\t\t\t<label for="idx-q-PriceMin">Price From</label> \t\t\t\t<input id="idx-q-PriceMin" name="idx-q-PriceMin" type="text" class="dsidx-price" placeholder="Any" value="{$values['idx-q-PriceMin']}" /> </div> \t\t\t\t<div class="dsidx-resp-area dsidx-resp-area-half dsidx-resp-area-half dsidx-resp-area-right"> \t\t\t\t<label for="idx-q-PriceMin">To</label> \t\t\t\t<input id="idx-q-PriceMax" name="idx-q-PriceMax" type="text" class="dsidx-price" placeholder="Any" value="{$values['idx-q-PriceMax']}" /> \t\t\t\t</div> HTML; echo <<<HTML \t\t\t\t<div class="dsidx-resp-area dsidx-resp-min-baths-area dsidx-resp-area-half dsidx-resp-area-left"> \t\t\t\t<label for="idx-q-BedsMin">Beds</label> \t\t\t\t<select id="idx-q-BedsMin" name="idx-q-BedsMin" class="dsidx-beds"> \t\t\t\t\t<option value="">Any</option> HTML; for ($i = 1; $i <= 9; $i++) { $selected = $i == $values['idx-q-BedsMin'] ? ' selected="selected"' : ''; echo '<option value="' . $i . '"' . $selected . '>' . $i . '+</option>'; } echo <<<HTML \t\t\t\t</select> \t\t\t\t</div> \t\t\t\t<div class="dsidx-resp-area dsidx-resp-min-baths-area dsidx-resp-area-half dsidx-resp-area-right"> \t\t\t\t<label for="idx-q-BathsMin">Baths</label> \t\t\t\t<select id="idx-q-BathsMin" name="idx-q-BathsMin" class="dsidx-baths"> \t\t\t\t\t<option value="">Any</option> HTML; for ($i = 1; $i <= 9; $i++) { $selected = $i == $values['idx-q-BathsMin'] ? ' selected="selected"' : ''; echo '<option value="' . $i . '"' . $selected . '>' . $i . '+</option>'; } echo <<<HTML \t\t\t\t</select> \t\t\t\t</div> HTML; if (isset($defaultSearchPanels)) { foreach ($defaultSearchPanels as $key => $value) { if ($value->DomIdentifier == "search-input-home-size" && isset($capabilities['MinImprovedSqFt']) && $capabilities['MinImprovedSqFt'] > 0) { echo <<<HTML \t\t\t\t\t\t<div class="dsidx-resp-area"> \t\t\t\t\t\t<label for="idx-q-ImprovedSqFtMin">Min Sqft</label> \t\t\t\t\t\t<input id="idx-q-ImprovedSqFtMin" name="idx-q-ImprovedSqFtMin" type="text" class="dsidx-improvedsqft" placeholder="Any" value="{$values['idx-q-ImprovedSqFtMin']}" /> \t\t\t\t\t\t</div> HTML; break; } } } echo <<<HTML \t\t\t\t<div class="dsidx-resp-area dsidx-resp-area-submit"> \t\t\t\t\t<label for="idx-q-PriceMin"> </label> \t\t\t\t\t<input type="submit" class="submit" value="Search for properties" /> \t\t\t\t</div> HTML; if ($options["HasSearchAgentPro"] == "yes" && $searchOptions["show_advanced"] == "yes") { echo <<<HTML \t\t\t\t\t<div style="float: right;"> \t\t\t\t\ttry our <a href="{$formAction}advanced/"><img src="{$pluginUrl}assets/adv_search-16.png" /> Advanced Search</a> \t\t\t\t\t</div> HTML; } if ($account_options->EulaLink) { $eula_url = $account_options->EulaLink; echo <<<HTML \t\t\t\t\t<p>By searching, you agree to the <a href="{$eula_url}" target="_blank">EULA</a></p> HTML; } echo <<<HTML \t\t\t</fieldset> \t\t\t</form> \t\t\t</div> HTML; echo $after_widget; dsidx_footer::ensure_disclaimer_exists("search"); }
function widget($args, $instance) { extract($args); extract($instance); $title = apply_filters("widget_title", $title); $sort = isset($instance['areaSourceConfig']['sort']) ? $instance['areaSourceConfig']['sort'] : ''; $options = get_option(DSIDXPRESS_OPTION_NAME); if (!isset($options["Activated"]) || !$options["Activated"]) { return; } wp_enqueue_script('jquery', false, array(), false, true); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } $apiRequestParams = array(); $apiRequestParams["directive.ResultsPerPage"] = $listingsToShow; $apiRequestParams["responseDirective.ViewNameSuffix"] = "widget"; $apiRequestParams["responseDirective.DefaultDisplayType"] = $defaultDisplay; $apiRequestParams['responseDirective.IncludeDisclaimer'] = 'true'; $sort = explode('|', $sort); $apiRequestParams["directive.SortOrders[0].Column"] = $sort[0]; $apiRequestParams["directive.SortOrders[0].Direction"] = isset($sort[1]) ? $sort[1] : ''; if ($querySource == "area") { switch ($areaSourceConfig["type"]) { case "city": $typeKey = "query.Cities"; break; case "community": $typeKey = "query.Communities"; break; case "tract": $typeKey = "query.TractIdentifiers"; break; case "zip": $typeKey = "query.ZipCodes"; break; } $apiRequestParams[$typeKey] = $areaSourceConfig["name"]; } else { if ($querySource == "link") { $apiRequestParams["query.ForceUsePropertySearchConstraints"] = "true"; $apiRequestParams["query.LinkID"] = $linkSourceConfig["linkId"]; } else { if ($querySource == "agentlistings") { if (isset($options['AgentID']) && !empty($options['AgentID'])) { $apiRequestParams["query.ListingAgentID"] = $options['AgentID']; } } else { if ($querySource == "officelistings") { if (isset($options['OfficeID']) && !empty($options['OfficeID'])) { $apiRequestParams["query.ListingOfficeID"] = $options['OfficeID']; } } } } } $apiHttpResponse = dsSearchAgent_ApiRequest::FetchData("Results", $apiRequestParams); if (empty($apiHttpResponse["errors"]) && $apiHttpResponse["response"]["code"] == "200") { $data = $apiHttpResponse["body"]; } else { switch ($apiHttpResponse["response"]["code"]) { case 403: $data = '<p class="dsidx-error">' . DSIDXPRESS_INACTIVE_ACCOUNT_MESSAGE . '</p>'; break; default: $data = '<p class="dsidx-error">' . DSIDXPRESS_IDX_ERROR_MESSAGE . '</p>'; } } $data = str_replace('{$pluginUrlPath}', dsSearchAgent_ApiRequest::MakePluginsUrlRelative(plugin_dir_url(__FILE__)), $data); echo $data; echo $after_widget; dsidx_footer::ensure_disclaimer_exists(); }
static function ApiAction($action, $get, $idx_page_id = null) { global $wp_query; $options = get_option(DSIDXPRESS_OPTION_NAME); $post_id = !$idx_page_id ? time() : $idx_page_id; wp_enqueue_script("jquery-ui-dialog", false, array(), false, true); add_action("wp_head", array("dsSearchAgent_Client", "Header")); // allow wordpress to consume the page template option the user choose in the dsIDXpress settings if ($action == "results" && !empty($options["ResultsTemplate"])) { wp_cache_set($post_id, array("_wp_page_template" => array($options["ResultsTemplate"])), "post_meta"); } else { if ($action == "details" && !empty($options["DetailsTemplate"])) { wp_cache_set($post_id, array("_wp_page_template" => array($options["DetailsTemplate"])), "post_meta"); } } $apiParams = self::GetApiParams($get); // pull account options $apiHttpResponse = dsSearchAgent_ApiRequest::FetchData("AccountOptions"); if (!empty($apiHttpResponse["errors"]) || $apiHttpResponse["response"]["code"] != "200") { switch ($apiHttpResponse["response"]["code"]) { case 403: wp_die("We're sorry, but there’s nothing to display here; MLS data service is not activated for this account."); break; default: wp_die("We're sorry, but we ran into a temporary problem while trying to load the account data. Please check back soon.", "Account data load error"); } } else { $account_options = json_decode($apiHttpResponse["body"]); } if ($action == "results" || $action == "search") { dsidxpress_autocomplete::AddScripts(false); } if ($action == "results") { // save search if (!empty($get["idx-save"]) && $get["idx-save"] == "true") { $apiParams["name"] = $get["idx-save-name"]; $apiParams["updates"] = $get["idx-save-updates"] == "on" ? "true" : "false"; $apiHttpResponse = dsSearchAgent_ApiRequest::FetchData("SaveSearch", $apiParams, false, 0); $response = json_decode($apiHttpResponse["body"]); header('Content-Type: application/json'); echo $apiHttpResponse["body"]; die; } // check allowed searched before registration $allow_results_view = 1; if (!empty($account_options->AllowedSearchesBeforeRegistration) && isset($_COOKIE['dsidx-visitor-results-views'])) { if ((int) $account_options->AllowedSearchesBeforeRegistration <= (int) $_COOKIE['dsidx-visitor-results-views']) { $allow_results_view = 0; } } $apiParams["requester.AllowVisitorResultsView"] = $allow_results_view; if (isset($apiParams["query.LinkID"])) { $apiParams["query.ForceUsePropertySearchConstraints"] = "true"; } if (isset($apiParams["query.PropertySearchID"])) { $apiParams["query.ForceUsePropertySearchConstraints"] = "true"; } $apiParams["directive.ResultsPerPage"] = 25; if (isset($apiParams["directive.ResultPage"])) { $apiParams["directive.ResultPage"] = $apiParams["directive.ResultPage"] - 1; } $apiParams["responseDirective.IncludeMetadata"] = "true"; $apiParams["responseDirective.IncludeLinkMetadata"] = "true"; } else { if ($action == "details") { // check allowed searched before registration $allow_details_view = 1; if (!empty($account_options->AllowedDetailViewsBeforeRegistration) && isset($_COOKIE['dsidx-visitor-details-views'])) { if ((int) $account_options->AllowedDetailViewsBeforeRegistration <= (int) $_COOKIE['dsidx-visitor-details-views']) { $allow_details_view = 0; } } $useJuiceBox = 'true'; if (isset($options['ImageDisplay'])) { $useJuiceBox = $options['ImageDisplay'] == "slideshow" ? 'true' : 'false'; } // echo $useJuiceBox; $apiParams["requester.AllowVisitorDetailView"] = $allow_details_view; $apiParams["responseDirective.UseJuiceBoxSlideShow"] = $useJuiceBox; // if we have an auth cookie then record a property visit if (@$_COOKIE['dsidx-visitor-auth']) { $visitParams = array("mlsNumber" => $apiParams["query.MlsNumber"]); $apiVisitResponse = dsSearchAgent_ApiRequest::FetchData("RecordVisit", $visitParams, false, 0); } $screen_name = get_option('zillow_screen_name'); if (!empty($screen_name)) { $apiParams["responseDirective.ZillowScreenName"] = $screen_name; } } } $apiParams["responseDirective.IncludeDisclaimer"] = "true"; $apiParams["responseDirective.IncludeDsDisclaimer"] = defined('ZPRESS_API') && ZPRESS_API != '' ? "false" : "true"; $apiParams["responseDirective.RemoveDsDisclaimerLinks"] = isset($options['RemoveDsDisclaimerLinks']) && $options['RemoveDsDisclaimerLinks'] == 'Y' ? "true" : "false"; $apiHttpResponse = dsSearchAgent_ApiRequest::FetchData($wp_query->query["idx-action"], $apiParams, false); if (!isset($apiHttpResponse["body"]) || !isset($apiHttpResponse["response"])) { wp_die("We're sorry, but we ran into a temporary problem while trying to load the real estate data. Please check back soon.", "Real estate data load error"); } $apiData = $apiHttpResponse["body"]; $apiData = str_replace('{$contentDomId}', $post_id, $apiData); if ($action == 'details' && defined('ZPRESS_API') && ZPRESS_API != '') { if (!isset($personal_info)) { $personal_info = stripslashes_deep(get_option('personal_info')); } if (!empty($personal_info['google_authorship']) && !empty($personal_info['googleplus'])) { $apiData .= '<p>By <a href="' . esc_url($personal_info['googleplus']) . '?rel=author" target="_blank">' . $personal_info['first_name'] . ' ' . $personal_info['last_name'] . '</a></p>'; } } if (in_array($_SERVER["REMOTE_ADDR"], self::$DebugAllowedFrom)) { if (isset($get["debug-api-response"])) { print_r($apiHttpResponse); exit; } } if ($apiHttpResponse["response"]["code"] == "404") { $error_template = isset($options["404Template"]) ? $options["404Template"] : ''; if ($error_template == '') { } elseif (strpos($error_template, '.php')) { $error_404 = locate_template('404.php'); if (!empty($error_404)) { wp_cache_set($post_id, array("_wp_page_template" => array($error_template)), "post_meta"); } } elseif (is_numeric($error_template)) { $post_id = $error_template; } $wp_query->set('is_404', true); add_action('get_header', array("dsSearchAgent_Client", "Return404")); } else { if ($apiHttpResponse["response"]["code"] == "302") { $redirect = dsSearchAgent_Client::GetBasePath() . self::ExtractValueFromApiData($apiData, "redirect"); header("Location: {$redirect}", true, 302); exit; } else { if (empty($apiHttpResponse["body"]) || !empty($apiHttpResponse["errors"]) || substr($apiHttpResponse["response"]["code"], 0, 1) == "5") { wp_die("We're sorry, but we ran into a temporary problem while trying to load the real estate data. Please check back soon.", "Real estate data load error"); } } } /*if ($options['ResultsTitle'] != '') $title = $options['ResultsTitle']; else */ $seo_title = self::ExtractValueFromApiData($apiData, "seo_title"); $seo_description = self::ExtractValueFromApiData($apiData, "seo_description"); $seo_keywords = self::ExtractValueFromApiData($apiData, "seo_keywords"); $title = self::ExtractValueFromApiData($apiData, "title"); $dateaddedgmt = self::ExtractValueFromApiData($apiData, "dateaddedgmt"); $description = self::ExtractValueFromApiData($apiData, "description"); $firstimage = self::ExtractValueFromApiData($apiData, "firstimage"); self::$meta_tag_data = array('firstimage' => $firstimage, 'title' => $title, 'description' => $description); self::$CanonicalUri = self::ExtractValueFromApiData($apiData, "canonical"); self::$TriggeredAlternateUrlStructure = self::ExtractValueFromApiData($apiData, "alternate-urls"); if (!isset($wp_query->query['ds-idx-listings-page'])) { if ($apiHttpResponse["response"]["code"] != "404") { self::EnsureBaseUri(); } } set_query_var("name", "dsidxpress-{$action}"); // at least a few themes require _something_ to be set here to display a good <title> tag set_query_var("pagename", "dsidxpress-{$action}"); // setting pagename in case someone wants to do a custom theme file for this "page" if (isset($options["404Template"]) && !empty($options["404Template"]) && $post_id == $options["404Template"]) { $post_id = $options["404Template"]; $post = get_post($post_id); } else { $post = (object) array("ID" => $post_id, "comment_count" => 0, "comment_status" => "closed", "ping_status" => "closed", "post_author" => 1, "post_content" => $apiData, "post_date" => $dateaddedgmt ? $dateaddedgmt : date("c"), "post_date_gmt" => $dateaddedgmt ? $dateaddedgmt : gmdate("c"), "post_excerpt" => $description, "post_name" => "dsidxpress-data", "post_parent" => 0, "post_status" => "publish", "post_title" => $title, "post_type" => "page"); } if (!$idx_page_id) { wp_cache_set($post_id, $post, 'posts'); } $posts = array($post); // track the detail & result views, do this at the end in case something errors or w/e $views = intval(@$_COOKIE["dsidx-visitor-{$action}-views"]); setcookie("dsidx-visitor-{$action}-views", $views + 1, time() + 60 * 60 * 24 * 30, '/'); $dsidxpress_seo = new dsidxpress_seo($seo_title, $seo_description, $seo_keywords); if (!$idx_page_id && isset($seo_title)) { add_filter('wp_title', array($dsidxpress_seo, 'dsidxpress_title_filter')); } if (isset($seo_keywords) || isset($seo_description)) { add_action('wp_head', array($dsidxpress_seo, 'dsidxpress_head_action')); } add_action('wp_head', array("dsSearchAgent_Client", 'SocialMetaTags')); if ($action == "search") { dsidx_footer::ensure_disclaimer_exists("search"); } return $posts; }
function widget($args, $instance) { extract($args); extract($instance); $title = apply_filters("widget_title", $title); $options = get_option(DSIDXPRESS_OPTION_NAME); if (!$options["Activated"]) { return; } $pluginUrl = plugins_url() . '/dsidxpress/'; wp_enqueue_script('dsidxpress_widget_search_view', $pluginUrl . 'js/widget-client.js', array('jquery'), DSIDXPRESS_PLUGIN_VERSION, true); $formAction = get_home_url() . "/idx/"; $defaultSearchPanels = dsSearchAgent_ApiRequest::FetchData("AccountSearchPanelsDefault", array(), false, 60 * 60 * 24); $defaultSearchPanels = $defaultSearchPanels["response"]["code"] == "200" ? json_decode($defaultSearchPanels["body"]) : null; $propertyTypes = dsSearchAgent_ApiRequest::FetchData("AccountSearchSetupFilteredPropertyTypes", array(), false, 60 * 60 * 24); $propertyTypes = $propertyTypes["response"]["code"] == "200" ? json_decode($propertyTypes["body"]) : null; $account_options = dsSearchAgent_ApiRequest::FetchData("AccountOptions", array(), false); $account_options = $account_options["response"]["code"] == "200" ? json_decode($account_options["body"]) : null; $num_location_dropdowns = 0; $autoload_options = bon_get_option('idx_enable_search_autoload', 'yes'); if ($searchOptions["show_cities"] == "yes" || !isset($instance["searchOptions"]["show_cities"])) { $num_location_dropdowns++; } if ($searchOptions["show_cities"] == "yes") { if ($autoload_options == 'no') { $manual_city = explode("\n", trim(bon_get_option('idx_manual_city'))); sort($manual_city); $searchOptions['cities'] = $manual_city; } else { $searchOptions['cities'] = shandora_get_idx_options('City', true); } } if ($searchOptions["show_communities"] == "yes") { $num_location_dropdowns++; if ($autoload_options == 'no') { $manual_community = explode("\n", trim(bon_get_option('idx_manual_community'))); sort($manual_community); $searchOptions['communities'] = $manual_community; } else { $searchOptions['communities'] = shandora_get_idx_options('Community', true); } } if ($searchOptions["show_tracts"] == "yes") { $num_location_dropdowns++; if ($autoload_options == 'no') { $manual_tract = explode("\n", trim(bon_get_option('idx_manual_tract'))); sort($manual_tract); $searchOptions['tracts'] = $manual_tract; } else { $searchOptions['tracts'] = shandora_get_idx_options('Tract', true); } } if ($searchOptions["show_zips"] == "yes") { $num_location_dropdowns++; if ($autoload_options == 'no') { $manual_zip = explode("\n", trim(bon_get_option('idx_manual_zip'))); sort($manual_zip); $searchOptions['zips'] = $manual_zip; } else { $searchOptions['zips'] = shandora_get_idx_options('Zip', true); } } if ($searchOptions["show_mlsnumber"] == "yes") { $num_location_dropdowns++; } echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <div class="dsidx-search-widget dsidx-widget search-listing"> <form action="<?php echo $formAction; ?> " method="get" class="custom" onsubmit="return dsidx_w.searchWidget.validate();" > <div class="fieldset"> <label for="idx-q-PropertyTypes"><?php _e('Property Type', 'bon'); ?> </label> <select name="idx-q-PropertyTypes" class="dsidx-search-widget-propertyTypes"> <option value=""><?php _e('All Property Types', 'bon'); ?> </option> <?php if (is_array($propertyTypes)) { foreach ($propertyTypes as $propertyType) { $name = htmlentities($propertyType->DisplayName); ?> <option value="<?php echo $propertyType->SearchSetupPropertyTypeID; ?> "><?php echo $name; ?> </option> <?php } } ?> </select> <label id="idx-search-invalid-msg" style="color:red"></label> </div> <?php if ($searchOptions["show_cities"] == "yes" || !isset($instance["searchOptions"]["show_cities"])) { ?> <div class="fieldset"> <label for="idx-q-Cities"><?php _e('City', 'bon'); ?> </label> <select id="idx-q-Cities" name="idx-q-Cities" class="idx-q-Location-Filter"> <?php if ($num_location_dropdowns > 1) { ?> <option value=""><?php _e('Any', 'bon'); ?> </option> <?php } if (!empty($searchOptions['cities'])) { foreach ($searchOptions["cities"] as $city) { $city = htmlentities(trim($city)); ?> <option value="<?php echo $city; ?> "><?php echo $city; ?> </option> <?php } } ?> </select> </div> <?php } // end show_citites if ($searchOptions["show_communities"] == "yes") { ?> <div class="fieldset"> <label for="idx-q-Communities"><?php _e('Community', 'bon'); ?> </label> <select id="idx-q-Communities" name="idx-q-Communities" class="idx-q-Location-Filter"> <?php if ($num_location_dropdowns > 1) { ?> <option value=""><?php _e('Any', 'bon'); ?> </option> <?php } foreach ($searchOptions["communities"] as $community) { // there's an extra trim here in case the data was corrupted before the trim was added in the update code below $community = htmlentities(trim($community)); ?> <option value="<?php echo $community; ?> "><?php echo $community; ?> </option> <?php } ?> </select> </div> <?php } // end show_communtities ?> <?php if ($searchOptions["show_tracts"] == "yes") { ?> <div class="fieldset"> <label for="idx-q-TractIdentifiers"><?php _e('Tract', 'bon'); ?> </label> <select id="idx-q-TractIdentifiers" name="idx-q-TractIdentifiers" class="idx-q-Location-Filter"> <?php if ($num_location_dropdowns > 1) { ?> <option value=""><?php _e('Any', 'bon'); ?> </option> <?php } foreach ($searchOptions["tracts"] as $tract) { // there's an extra trim here in case the data was corrupted before the trim was added in the update code below $tract = htmlentities(trim($tract)); ?> <option value="<?php echo $tract; ?> "><?php echo $tract; ?> </option> <?php } ?> </select> </div> <?php } // end show_tracts ?> <?php if ($searchOptions["show_zips"] == "yes") { ?> <div class="fieldset"> <label for="idx-q-ZipCodes"><?php _e('Zip', 'bon'); ?> </label> <select id="idx-q-ZipCodes" name="idx-q-ZipCodes" class="idx-q-Location-Filter"> <?php if ($num_location_dropdowns > 1) { ?> <option value=""><?php _e('Any', 'bon'); ?> </option> <?php } foreach ($searchOptions["zips"] as $zip) { // there's an extra trim here in case the data was corrupted before the trim was added in the update code below $zip = htmlentities(trim($zip)); ?> <option value="<?php echo $zip; ?> "><?php echo $zip; ?> </option> <?php } ?> </select> </div> <?php } // end show_zips ?> <?php if ($searchOptions["show_mlsnumber"] == "yes") { ?> <div class="fieldset"> <label for="idx-q-MlsNumbers"><?php _e('MLS #', 'bon'); ?> </label> <input id="idx-q-MlsNumbers" name="idx-q-MlsNumbers" type="text" class="dsidx-mlsnumber" /> </div> <?php } if ($searchOptions["show_pricerange"] == "yes") { ?> <div class="fieldset"> <label for="idx-q-PriceMin"><?php _e('Price Range', 'bon'); ?> <span class="price-text text-min" id="idx-min-price-text-widget"></span> <span class="price-text text-max" id="idx-max-price-text-widget"></span> </label> <div class="price-slider-wrapper ui-slider-wrapper-custom"> <div id="idx-slider-range-widget"></div> </div> <input id="idx-q-PriceMin-widget" name="idx-q-PriceMin" type="hidden" class="dsidx-price" placeholder="min price" /> <input id="idx-q-PriceMax-widget" name="idx-q-PriceMax" type="hidden" class="dsidx-price" placeholder="max price" /> </div> <?php } if ($searchOptions["show_size"] == "yes") { ?> <?php if (isset($defaultSearchPanels)) { foreach ($defaultSearchPanels as $key => $value) { if ($value->DomIdentifier == "search-input-home-size") { ?> <div class="fieldset"> <label for="idx-q-ImprovedSqFtMin"><?php _e('Size', 'bon'); ?> </label> <input id="idx-q-ImprovedSqFtMin" name="idx-q-ImprovedSqFtMin" type="text" class="dsidx-improvedsqft" placeholder="min sqft" /> </div> <?php break; } } } ?> <?php } if ($searchOptions["show_beds"] == "yes") { ?> <div class="fieldset"> <label for="idx-q-BedsMin-widget"><?php _e('Beds', 'bon'); ?> </label> <div class="ui-slider-wrapper-custom beds-wrapper"> <select name="idx-q-BedsMin" id="idx-q-BedsMin-widget" class="bon-dsidx-beds dsidx-beds no-custom select-slider"> <option value=""><?php _e('Any', 'bon'); ?> </option> <?php for ($i = 1; $i <= 10; $i++) { ?> <option value="<?php echo $i; ?> "><?php echo $i; ?> </option> <?php } ?> </select> </div> </div> <?php } if ($searchOptions["show_bath"] == "yes") { ?> <div class="fieldset"> <label for="idx-q-BathsMin-widget"><?php _e('Baths', 'bon'); ?> </label> <div class="ui-slider-wrapper-custom baths-wrapper"> <select name="idx-q-BathsMin" id="idx-q-BathsMin-widget" class="bon-dsidx-baths dsidx-baths no-custom select-slider"> <option value=""><?php _e('Any', 'bon'); ?> </option> <?php for ($i = 1; $i <= 10; $i++) { ?> <option value="<?php echo $i; ?> "><?php echo $i; ?> </option> <?php } ?> </select> </div> </div> <?php } ?> <?php $button_color = bon_get_option('search_button_color', 'red'); ?> <input type="submit" class="button flat blue <?php echo $button_color; ?> radius submit" value="<?php _e('Search for Properties', 'bon'); ?> " /> <?php if ($options["HasSearchAgentPro"] == "yes" && $searchOptions["show_advanced"] == "yes") { ?> <?php _e('try our ', 'bon'); ?> <a href="<?php echo $formAction; ?> advanced/"><img src="<?php echo $pluginUrl; ?> assets/adv_search-16.png" /><?php _e('Advanced Search', 'bon'); ?> </a> <?php } ?> <?php if ($account_options->EulaLink) { $eula_url = $account_options->EulaLink; ?> <p><?php _e('By searching, you agree to the', 'bon'); ?> <a href="<?php echo $eula_url; ?> " target="_blank"><?php _e('EULA', 'bon'); ?> </a></p> <?php } ?> </form> </div> <?php echo $after_widget; dsidx_footer::ensure_disclaimer_exists("search"); }
function widget($args, $instance) { if (!$this->instance) { $this->instance = true; } else { return; } extract($args); extract($instance); $error_message = dsWidgets_Service_Base::getWidgetErrorMsg($before_widget, $after_widget); if ($error_message) { echo $error_message; return; } $capabilities = dsWidgets_Service_Base::getCapabilities(); $randString = dsWidgets_Service_Base::get_random_string('abcdefghijklmnopqrstuvwxyz1234567890', 5); wp_enqueue_script('googlemaps3', 'http://maps.googleapis.com/maps/api/js?sensor=false', array('jquery'), false, true); $options = get_option(DSIDXWIDGETS_OPTION_NAME); $state = htmlspecialchars($instance["state"]); $city = str_replace(" \r\n ", ",", htmlspecialchars($instance["city"])); $city = str_replace(" \r\n", ",", $city); $city = str_replace("\r\n ", ",", $city); $city = str_replace("\r\n", ",", $city); if (empty($capabilities->MinPrice)) { $instance['priceMin'] = ''; } if (empty($capabilities->MaxPrice)) { $instance['priceMax'] = ''; } if (empty($capabilities->MinImprovedSqFt)) { $instance['sqftMin'] = ''; } $instance = wp_parse_args($instance, array("state" => $state, "city" => $city, "zip" => "", "priceMin" => "250000", "priceMax" => "550000", "priceFloor" => "100000", "priceCeiling" => "1000000", "bedsMin" => "2", "bathsMin" => "2", "sqftMin" => "1500", "statusType" => "1", "rowCountType" => "25", "sortType" => "0", "eDomain" => "", "height" => "494", "width" => "548")); $zip = htmlspecialchars($instance["zip"]); $priceMin = htmlspecialchars($instance["priceMin"]); $priceMax = htmlspecialchars($instance["priceMax"]); $priceFloor = htmlspecialchars($instance["priceFloor"]); $priceCeiling = htmlspecialchars($instance["priceCeiling"]); $bedsMin = htmlspecialchars($instance["bedsMin"]); $bathsMin = htmlspecialchars($instance["bathsMin"]); $sqftMin = htmlspecialchars($instance["sqftMin"]); $statusType = htmlspecialchars($instance["statusType"]); $rowCountType = htmlspecialchars($instance["rowCountType"]); $sortType = htmlspecialchars($instance["sortType"]); $imagesStub = dsWidgets_Service_Base::$widgets_images_stub; $apiStub = dsWidgets_Service_Base::$widgets_api_stub; $height = htmlspecialchars($instance["height"]); $width = htmlspecialchars($instance["width"]); $curURL = get_home_url(); $idxpress_options = get_option(DSIDXPRESS_OPTION_NAME); if (!empty($idxpress_options["AccountID"])) { $aid = $idxpress_options["AccountID"]; } else { $aid = $options["AccountID"]; } if (!empty($idxpress_options["SearchSetupID"])) { $ssid = $idxpress_options["SearchSetupID"]; } else { $ssid = $options["SearchSetupID"]; } echo $before_widget; if (defined('ZPRESS_API') && ZPRESS_API != '') { $widget_header = call_user_func('\\zpress\\themes\\Options::GetOption', 'theme_widgets_require_header'); if (!empty($widget_header->meta) && $widget_header->meta == 'true') { echo $before_title; echo 'Map Search'; echo $after_title; } } echo <<<HTML <script type="text/javascript" id="divLocal{$randString}_"> \t\t\twindow.mapSearchHasDependency = true; var launchBaseCalled = false; var mapSearchDep1Finished = 1; LaunchBase{$randString} = function(){ var mapSearchScript,mapSearchDep1RevScript, _ds_midx, mapSearchProgress; CreateObject{$randString} = function () { _ds_midx = { currentURL: '{$curURL}', curHeight: '{$height}', curWidth: '{$width}', productType: '0', curAPIStub: '{$apiStub}', curImageStub: '{$imagesStub}', targetDomain: window["zpress_widget_domain_token"],accountId: '{$aid}',searchSetupId: '{$ssid}',muteStyles: true,state: '{$state}',city: '{$city}',zip: '{$zip}',priceMin: '{$priceMin}',priceMax: '{$priceMax}',priceFloor: '{$priceFloor}',priceCeiling: '{$priceCeiling}',bedsMin: '{$bedsMin}',bathsMin: '{$bathsMin}',sqftMin: '{$sqftMin}',curDivID: 'divLocal{$randString}_',querySchema: 'HNIPilgrh/9PwdKmimpgPE05NfSeqIkyvHeXiSh+gUIUzKp3KXDCFoWJ/DzaOsYlntCSXtSk36hbB76URZk1Sirc9iLz3tiLPAN0SK/EbNCrr6XWxD7hAYVJcDwXtpN4',status: '{$statusType}',rowCount: '{$rowCountType}',sort: '{$sortType}' }; } AddJavaScriptToDOM{$randString}=function(c,d,e){ if(d!=1){var a=document.createElement("script"),b=document.getElementsByTagName("script")[0];a.id=e;a.type='text/javascript';a.async=true;a.src=c;a.onload=a.onreadystatechange=function(){ if(a.readyState){ if (a.readyState == "loaded" || a.readyState == "complete") {window[e] = 1;}}else{window[e] = 1;}};b.parentNode.insertBefore(a,b)}return 1}; CreateWidget{$randString} = function () { (window.mapSearchFinished == 1 && mapSearchDep1Finished == 1) ? (window["ds.widget.view.mapsearch"].isProcessing = true, CreateObject{$randString}(), new window["ds.widget.view.mapsearch"](_ds_midx), window["ds.widget.view.mapsearch"].isProcessing = false, window.mapSearchHasDependency = false, DetectMapScripts{$randString}()) : window.setTimeout("CreateWidget{$randString}(false)", 20); } if (mapSearchScript != 1 && mapSearchProgress != 1) {mapSearchProgress=1, mapSearchScript = AddJavaScriptToDOM{$randString}("{$this->widgetsCdn}/Scripts/PostCompile/MapSearch_v1_1.js", mapSearchScript, 'mapSearchFinished') }; CreateWidget{$randString}(); } \t\t\tDetectMapScripts{$randString} = function(){ \t\t\t\tif (typeof google === 'object' && typeof google.maps === 'object') { \t\t\t\t\tMapSearchMapCallback(); \t\t\t\t} \t\t\t\telse{ \t\t\t\t\twindow.setTimeout("DetectMapScripts{$randString}()", 20) \t\t\t\t} \t\t\t} GetToken{$randString}=function(){ if(!window.zpress_widget_domain_token && window.zpress_widget_domain_token_progress!=1){ window.zpress_widget_domain_token_progress=1;var c=-1<navigator.userAgent.indexOf("MSIE 7.0")?!0:!1,d=-1<navigator.userAgent.indexOf("MSIE 8.0")||-1<navigator.userAgent.indexOf("MSIE 9.0")?!0:!1; if(c){ rr=document.createElement("script"); rr.async=1; rr.id="domainScript"; rr.type="text/javascript"; rr.src="{$apiStub}Encrypt/?targetString="+window.location.hostname+"&targetObject=domain&authType=Basic&curDomain=" + window.location.hostname+"&objectName_=error"; rr.onload=rr.onreadystatechange=function(){ if("undefined"!=typeof window.error){ alert("We had a problem authenticating this domain"); } else{ window.zpress_widget_domain_token=window.encrypted_domain; if(rr.readyState && (rr.readyState == "loaded" || rr.readyState == "complete")){ if(launchBaseCalled != true){ LaunchBase{$randString}(); } launchBaseCalled = true; } else{ window.setTimeout("GetToken{$randString}()",20); } } }; document.getElementsByTagName("head")[0].appendChild(rr); } else if(c="{$apiStub}Encrypt/?targetString="+window.location.hostname+"&targetObject=domain&authType=CORS&objectName_=error",d){var a=new XDomainRequest;a.onload=function(){window.zpress_widget_domain_token= eval(a.responseText);LaunchBase{$randString}()};a.onerror=function(){};a.onprogress=function(){};a.open("GET",c,!0);a.send(null)}else{var b;if(b=new XMLHttpRequest)b.onreadystatechange=function(){if(4==b.readyState)if(200==b.status){var a=eval(b.responseText);"undefined"!=typeof a.listingsError?alert(a.listingsError[0].Message):(window.zpress_widget_domain_token=a,LaunchBase{$randString}())}},b.open("GET",c,!0),b.send()} } else{ if(window.zpress_widget_domain_token && launchBaseCalled != true) { LaunchBase{$randString}(); launchBaseCalled = true; } else{ if(launchBaseCalled != true){ window.setTimeout("GetToken{$randString}()",20); } } } } GetToken{$randString}(); </script> HTML; echo $after_widget; dsidx_footer::ensure_disclaimer_exists("search"); }
function widget($args, $instance) { extract($args); extract($instance); $title = apply_filters("widget_title", $title); $options = get_option(DSIDXPRESS_OPTION_NAME); if (!$options["Activated"]) { return; } $pluginUrl = plugins_url() . '/dsidxpress/'; wp_enqueue_script('dsidxpress_widget_search_view', $pluginUrl . 'js/widget-client.js', array('jquery'), DSIDXPRESS_PLUGIN_VERSION, true); $formAction = get_home_url() . "/idx/"; $capabilities = dsSearchAgent_ApiRequest::FetchData('MlsCapabilities'); $capabilities = json_decode($capabilities['body'], true); $defaultSearchPanels = dsSearchAgent_ApiRequest::FetchData("AccountSearchPanelsDefault", array(), false, 60 * 60 * 24); $defaultSearchPanels = $defaultSearchPanels["response"]["code"] == "200" ? json_decode($defaultSearchPanels["body"]) : null; $propertyTypes = dsSearchAgent_ApiRequest::FetchData("AccountSearchSetupFilteredPropertyTypes", array(), false, 60 * 60 * 24); $propertyTypes = $propertyTypes["response"]["code"] == "200" ? json_decode($propertyTypes["body"]) : null; $account_options = dsSearchAgent_ApiRequest::FetchData("AccountOptions", array(), false); $account_options = $account_options["response"]["code"] == "200" ? json_decode($account_options["body"]) : null; echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo <<<HTML \t\t\t<div class="dsidx-search-widget dsidx-widget"> \t\t\t<form action="{$formAction}" method="get" onsubmit="return dsidx_w.searchWidget.validate();" > \t\t\t\t<select name="idx-q-PropertyTypes" class="dsidx-search-widget-propertyTypes"> \t\t\t\t\t<option value="">- All property types -</option> HTML; if (is_array($propertyTypes)) { foreach ($propertyTypes as $propertyType) { $name = htmlentities($propertyType->DisplayName); echo "<option value=\"{$propertyType->SearchSetupPropertyTypeID}\">{$name}</option>"; } } echo <<<HTML \t\t\t\t</select> \t\t\t\t<label id="idx-search-invalid-msg" style="color:red"></label> HTML; if ($searchOptions['show_cities'] == 'yes' && !empty($searchOptions['cities'])) { echo <<<HTML \t\t\t\t<select id="idx-q-Cities" name="idx-q-Cities" class="idx-q-Location-Filter"> \t\t\t\t\t<option value="">- City -</option> HTML; foreach ($searchOptions["cities"] as $city) { // there's an extra trim here in case the data was corrupted before the trim was added in the update code below $city = htmlentities(trim($city)); echo "<option value=\"{$city}\">{$city}</option>"; } echo '</select>'; } if ($searchOptions['show_communities'] == 'yes' && !empty($searchOptions['communities'])) { echo <<<HTML \t\t\t\t<select id="idx-q-Communities" name="idx-q-Communities" class="idx-q-Location-Filter"> \t\t\t\t\t<option value="">- Community -</option> HTML; foreach ($searchOptions['communities'] as $community) { // there's an extra trim here in case the data was corrupted before the trim was added in the update code below $community = htmlentities(trim($community)); echo "<option value=\"{$community}\">{$community}</option>"; } echo '</select>'; } if ($searchOptions['show_tracts'] == 'yes' && !empty($searchOptions['tracts'])) { echo <<<HTML \t\t\t\t<select id="idx-q-TractIdentifiers" name="idx-q-TractIdentifiers" class="idx-q-Location-Filter"> \t\t\t\t\t<option value="">- Tract -</option> HTML; foreach ($searchOptions["tracts"] as $tract) { // there's an extra trim here in case the data was corrupted before the trim was added in the update code below $tract = htmlentities(trim($tract)); echo "<option value=\"{$tract}\">{$tract}</option>"; } echo '</select>'; } if ($searchOptions['show_zips'] == 'yes' && !empty($searchOptions['zips'])) { echo <<<HTML \t\t\t\t<select id="idx-q-ZipCodes" name="idx-q-ZipCodes" class="idx-q-Location-Filter"> \t\t\t\t\t<option value="">- Zip -</option> HTML; foreach ($searchOptions["zips"] as $zip) { // there's an extra trim here in case the data was corrupted before the trim was added in the update code below $zip = htmlentities(trim($zip)); echo "<option value=\"{$zip}\">{$zip}</option>"; } echo '</select>'; } if ($searchOptions["show_mlsnumber"] == "yes") { echo <<<HTML \t\t\t\t<label for="idx-q-MlsNumbers">MLS #</label> \t\t\t\t<input id="idx-q-MlsNumbers" name="idx-q-MlsNumbers" type="text" class="dsidx-mlsnumber" /> HTML; } echo <<<HTML \t\t\t\t<label for="idx-q-PriceMin">Price</label> \t\t\t\t<input id="idx-q-PriceMin" name="idx-q-PriceMin" type="text" class="dsidx-price" placeholder="min price" /> \t\t\t\t<input id="idx-q-PriceMax" name="idx-q-PriceMax" type="text" class="dsidx-price" placeholder="max price" /> HTML; if (isset($defaultSearchPanels)) { foreach ($defaultSearchPanels as $key => $value) { if ($value->DomIdentifier == "search-input-home-size" && isset($capabilities['MinImprovedSqFt']) && $capabilities['MinImprovedSqFt'] > 0) { echo <<<HTML \t\t\t\t\t\t<label for="idx-q-ImprovedSqFtMin">Size</label> \t\t\t\t\t\t<input id="idx-q-ImprovedSqFtMin" name="idx-q-ImprovedSqFtMin" type="text" class="dsidx-improvedsqft" placeholder="min sqft" /> HTML; break; } } } echo <<<HTML \t\t\t\t<label for="idx-q-BedsMin">Beds</label> \t\t\t\t<input id="idx-q-BedsMin" name="idx-q-BedsMin" type="text" class="dsidx-beds" placeholder="min bedrooms" /> \t\t\t\t<label for="idx-q-BathsMin">Baths</label> \t\t\t\t<input id="idx-q-BathsMin" name="idx-q-BathsMin" type="text" class="dsidx-baths" placeholder="min bathrooms" /> \t\t\t\t<div class="dsidx-search-button search-form"> \t\t\t\t\t<input type="submit" class="submit" value="Search for properties" /> HTML; if ($options["HasSearchAgentPro"] == "yes" && $searchOptions["show_advanced"] == "yes") { echo <<<HTML \t\t\t\t\ttry our <a href="{$formAction}advanced/"><img src="{$pluginUrl}assets/adv_search-16.png" /> Advanced Search</a> HTML; } if ($account_options->EulaLink) { $eula_url = $account_options->EulaLink; echo <<<HTML \t\t\t\t\t<p>By searching, you agree to the <a href="{$eula_url}" target="_blank">EULA</a></p> HTML; } echo <<<HTML \t\t\t\t</div> \t\t\t</form> \t\t\t</div> HTML; echo $after_widget; dsidx_footer::ensure_disclaimer_exists("search"); }
public static function renderWidget($args, $instance) { extract($args); extract($instance); $title = apply_filters("widget_title", $title); $options = get_option(DSIDXPRESS_OPTION_NAME); if (!isset($options["Activated"]) || !$options["Activated"]) { return; } $pluginUrl = get_home_url() . '/wp-content/plugins/dsidxpress/'; $formAction = get_home_url() . "/idx/"; $defaultSearchPanels = \dsSearchAgent_ApiRequest::FetchData("AccountSearchPanelsDefault", array(), false, 60 * 60 * 24); $defaultSearchPanels = $defaultSearchPanels["response"]["code"] == "200" ? json_decode($defaultSearchPanels["body"]) : null; $propertyTypes = \dsSearchAgent_ApiRequest::FetchData("AccountSearchSetupFilteredPropertyTypes", array(), false, 60 * 60 * 24); $propertyTypes = $propertyTypes["response"]["code"] == "200" ? json_decode($propertyTypes["body"]) : null; $account_options = \dsSearchAgent_ApiRequest::FetchData("AccountOptions"); $account_options = $account_options["response"]["code"] == "200" ? json_decode($account_options["body"]) : null; $widgetType = htmlspecialchars($instance["widgetType"]); $values = array(); $values['idx-q-Locations'] = isset($_GET['idx-q-Locations']) ? stripslashes($_GET['idx-q-Locations']) : null; $values['idx-q-PropertyTypes'] = isset($_GET['idx-q-PropertyTypes']) ? $_GET['idx-q-PropertyTypes'] : null; $values['idx-q-PriceMin'] = isset($_GET['idx-q-PriceMin']) ? $_GET['idx-q-PriceMin'] : null; $values['idx-q-PriceMax'] = isset($_GET['idx-q-PriceMax']) ? $_GET['idx-q-PriceMax'] : null; $specialSlugs = array('city' => 'idx-q-Cities', 'community' => 'idx-q-Communities', 'tract' => 'idx-q-TractIdentifiers', 'zip' => 'idx-q-ZipCodes'); $urlParts = explode('/', $_SERVER['REQUEST_URI']); $count = 0; foreach ($urlParts as $p) { if (array_key_exists($p, $specialSlugs) && isset($urlParts[$count + 1])) { $values['idx-q-Locations'] = ucwords($urlParts[$count + 1]); } $count++; } echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } $widgetClass = $widgetType == 1 || $widgetType == 'vertical' ? 'dsidx-resp-vertical' : 'dsidx-resp-horizontal'; if (isset($instance['class'])) { //Allows us to add custim class for shortcode etc. $widgetClass .= ' ' . $instance['class']; } echo <<<HTML <div class="dsidx-resp-search-box {$widgetClass}"> <form class="dsidx-resp-search-form" action="{$formAction}" method="GET"> <fieldset> <div class="dsidx-resp-area dsidx-resp-location-area"> <label for="dsidx-resp-location" class="dsidx-resp-location">Location</label> <input placeholder="Search Term" name="idx-q-Locations" type="text" class="text dsidx-search-omnibox-autocomplete" id="dsidx-resp-location" value="{$values['idx-q-Locations']}" /> </div> <div class="dsidx-resp-area dsidx-resp-type-area"> <label for="dsidx-resp-area-type" class="dsidx-resp-type">Type</label> <select id="dsidx-resp-area-type" class="dsidx-resp-select" name="idx-q-PropertyTypes"> <option value="">Any</option> HTML; if (is_array($propertyTypes)) { foreach ($propertyTypes as $propertyType) { $name = htmlentities($propertyType->DisplayName); $selected = $propertyType->SearchSetupPropertyTypeID == $values['idx-q-PropertyTypes'] ? ' selected="selected"' : ''; echo "<option value=\"{$propertyType->SearchSetupPropertyTypeID}\"{$selected}>{$name}</option>"; } } echo <<<HTML </select> </div> <div class="dsidx-resp-area dsidx-quick-resp-min-baths-area dsidx-resp-area-half dsidx-resp-area-left"> <label for="idx-q-BedsMin">Beds</label> <select id="idx-q-BedsMin" name="idx-q-BedsMin" class="dsidx-beds"> <option value="">Any</option> HTML; for ($i = 1; $i <= 9; $i++) { $selected = $i == $values['idx-q-BedsMin'] ? ' selected="selected"' : ''; echo '<option value="' . $i . '"' . $selected . '>' . $i . '+</option>'; } echo <<<HTML </select> </div> <div class="dsidx-resp-area dsidx-quick-resp-min-baths-area dsidx-resp-area-half dsidx-resp-area-right"> <label for="idx-q-BathsMin">Baths</label> <select id="idx-q-BathsMin" name="idx-q-BathsMin" class="dsidx-baths"> <option value="">Any</option> HTML; for ($i = 1; $i <= 9; $i++) { $selected = $i == $values['idx-q-BathsMin'] ? ' selected="selected"' : ''; echo '<option value="' . $i . '"' . $selected . '>' . $i . '+</option>'; } echo <<<HTML </select> </div> <div class="dsidx-resp-area dsidx-quick-resp-price-area dsidx-resp-price-area-min dsidx-resp-area-half dsidx-resp-area-left"> <label for="dsidx-resp-price-min" class="dsidx-resp-price">Price</label> <input id="idx-q-PriceMin" name="idx-q-PriceMin" type="text" class="dsidx-price" placeholder="Any" value="{$values['idx-q-PriceMin']}" /> </div> <div class="dsidx-resp-area dsidx-quick-resp-price-area dsidx-resp-price-area-max dsidx-resp-area-half dsidx-resp-area-right"> <label for="dsidx-resp-price-max" class="dsidx-resp-price">To</label> <input id="idx-q-PriceMax" name="idx-q-PriceMax" type="text" class="dsidx-price" placeholder="Any" value="{$values['idx-q-PriceMax']}" /> </div> <div class="dsidx-resp-area dsidx-resp-area-submit"> <label for="dsidx-resp-submit" class="dsidx-resp-submit"> </label> <input type="submit" class="dsidx-resp-submit" value="Search" /> </div> </fieldset> </form> </div> HTML; \dsidx_footer::ensure_disclaimer_exists("search"); echo $after_widget; }
static function Listings($atts, $content = null, $code = "") { $options = get_option(DSIDXPRESS_OPTION_NAME); if (!$options["Activated"]) { return ""; } $atts = shortcode_atts(array("city" => "", "community" => "", "county" => "", "tract" => "", "zip" => "", "minprice" => "", "maxprice" => "", "minbeds" => "", "maxbeds" => "", "minbaths" => "", "maxbaths" => "", "mindom" => "", "maxdom" => "", "minyear" => "", "maxyear" => "", "minimpsqft" => "", "maximpsqft" => "", "minlotsqft" => "", "maxlotsqft" => "", "statuses" => "", "propertytypes" => "", "linkid" => "", "count" => "5", "orderby" => "DateAdded", "orderdir" => "DESC", "showlargerphotos" => "false"), $atts); $apiRequestParams = array(); $apiRequestParams["responseDirective.ViewNameSuffix"] = "shortcode"; $apiRequestParams["responseDirective.IncludeMetadata"] = "true"; $apiRequestParams["responseDirective.IncludeLinkMetadata"] = "true"; $apiRequestParams["responseDirective.ShowLargerPhotos"] = $atts["showlargerphotos"]; $apiRequestParams["query.Cities"] = htmlspecialchars_decode($atts["city"]); $apiRequestParams["query.Communities"] = htmlspecialchars_decode($atts["community"]); $apiRequestParams["query.Counties"] = htmlspecialchars_decode($atts["county"]); $apiRequestParams["query.TractIdentifiers"] = htmlspecialchars_decode($atts["tract"]); $apiRequestParams["query.ZipCodes"] = $atts["zip"]; $apiRequestParams["query.PriceMin"] = $atts["minprice"]; $apiRequestParams["query.PriceMax"] = $atts["maxprice"]; $apiRequestParams["query.BedsMin"] = $atts["minbeds"]; $apiRequestParams["query.BedsMax"] = $atts["maxbeds"]; $apiRequestParams["query.BathsMin"] = $atts["minbaths"]; $apiRequestParams["query.BathsMax"] = $atts["maxbaths"]; $apiRequestParams["query.DaysOnMarketMin"] = $atts["mindom"]; $apiRequestParams["query.DaysOnMarketMax"] = $atts["maxdom"]; $apiRequestParams["query.YearBuiltMin"] = $atts["minyear"]; $apiRequestParams["query.YearBuiltMax"] = $atts["maxyear"]; $apiRequestParams["query.ImprovedSqFtMin"] = $atts["minimpsqft"]; $apiRequestParams["query.ImprovedSqFtMax"] = $atts["maximpsqft"]; $apiRequestParams["query.LotSqFtMin"] = $atts["minlotsqft"]; $apiRequestParams["query.LotSqFtMax"] = $atts["maxlotsqft"]; if (self::TranslateStatuses($atts["statuses"])) { $apiRequestParams["query.ListingStatuses"] = self::TranslateStatuses($atts["statuses"]); } else { $apiRequestParams["query.ListingStatuses"] = 3; } if ($atts["propertytypes"]) { $propertyTypes = explode(",", str_replace(" ", "", $atts["propertytypes"])); $propertyTypes = array_combine(range(0, count($propertyTypes) - 1), $propertyTypes); foreach ($propertyTypes as $key => $value) { $apiRequestParams["query.PropertyTypes[{$key}]"] = $value; } } if ($atts["linkid"]) { $apiRequestParams["query.LinkID"] = $atts["linkid"]; $apiRequestParams["query.ForceUsePropertySearchConstraints"] = "true"; } $apiRequestParams["directive.ResultsPerPage"] = $atts["count"]; $apiRequestParams["directive.SortOrders[0].Column"] = $atts["orderby"]; $apiRequestParams["directive.SortOrders[0].Direction"] = $atts["orderdir"]; $apiHttpResponse = dsSearchAgent_ApiRequest::FetchData("Results", $apiRequestParams); dsidx_footer::ensure_disclaimer_exists(); if (empty($apiHttpResponse["errors"]) && $apiHttpResponse["response"]["code"] == "200") { return $apiHttpResponse["body"]; } else { if ($apiHttpResponse["response"]["code"] == "403") { return '<p class="dsidx-error">' . DSIDXPRESS_INACTIVE_ACCOUNT_MESSAGE . '</p>'; } return '<p class="dsidx-error">' . DSIDXPRESS_IDX_ERROR_MESSAGE . '</p>'; } }