Beispiel #1
0
function shandora_get_search_listing_form_idx()
{
    global $bon;
    $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);
    if ($account_options && isset($account_options['response'])) {
        $account_options = $account_options["response"]["code"] == "200" ? json_decode($account_options["body"]) : null;
    }
    $autoload_options = bon_get_option('idx_enable_search_autoload');
    if ($autoload_options == 'no') {
        $manual_city = explode("\n", bon_get_option('idx_manual_city'));
        sort($manual_city);
        $manual_community = explode("\n", bon_get_option('idx_manual_community'));
        sort($manual_community);
        $manual_tract = explode("\n", bon_get_option('idx_manual_tract'));
        sort($manual_tract);
        $manual_zip = explode("\n", bon_get_option('idx_manual_zip'));
        sort($manual_zip);
        $searchOptions = array('cities' => $manual_city, 'communities' => $manual_community, 'tracts' => $manual_tract, 'zips' => $manual_zip);
    } else {
        $searchOptions = array('cities' => shandora_get_idx_options('City'), 'communities' => shandora_get_idx_options('Community'), 'tracts' => shandora_get_idx_options('Tract'), 'zips' => shandora_get_idx_options('Zip'));
    }
    $ro = '<div class="row search-listing-form">';
    // row open
    $rc = '</div>';
    // row close
    $cc = $rc;
    //column close
    $co = '<div class="large-4 column form-column small-11 small-centered large-uncentered">';
    // column open
    ?>
			
			<form id="search-listing-form" action="<?php 
    echo $formAction;
    ?>
" method="get" class="custom" onsubmit="return dsidx_w.searchWidget.validate();" >
				<?php 
    echo $ro . '<div class="column large-10 small-12 large-uncentered small-centered">' . $ro;
    ?>


				<?php 
    echo $co;
    ?>
				<label for="idx-q-PropertyTypes"><?php 
    _e('Property Type', 'bon');
    ?>
</label>
				<select name="idx-q-PropertyTypes" class="select-dark 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 
            selected('idx-q-PropertyTypes', $propertyType->SearchSetupPropertyTypeID);
            ?>
><?php 
            echo $name;
            ?>
</option>
					<?php 
        }
    }
    ?>
				</select>
				<label id="idx-search-invalid-msg" style="color:red"></label>
				<?php 
    echo $cc;
    ?>
				<?php 
    echo $co;
    ?>
					<label for="idx-q-Cities"><?php 
    _e('City', 'bon');
    ?>
</label>
					<select id="idx-q-Cities" name="idx-q-Cities" class="select-dark idx-q-Location-Filter">
						<option value=""><?php 
    _e('Any', 'bon');
    ?>
</option>
						<?php 
    if (!empty($searchOptions['cities'])) {
        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 = $autoload_options == 'no' ? htmlentities(trim($city)) : htmlentities(trim($city->Name));
            ?>

						<option value="<?php 
            echo $city;
            ?>
" <?php 
            selected('idx-q-Cities', $city);
            ?>
><?php 
            echo $city;
            ?>
</option>
						<?php 
        }
    }
    ?>
					</select>
				<?php 
    echo $cc;
    ?>
				<?php 
    echo $co;
    ?>
					<?php 
    $bed_opt = absint(bon_get_option('maximum_bed', 5));
    if (!is_int($bed_opt)) {
        $bed_opt = 5;
    }
    ?>
		
					<label for="idx-q-BedsMin"><?php 
    _e('Beds', 'bon');
    ?>
</label>
					<!--<input id="idx-q-BedsMin" name="idx-q-BedsMin" type="text" class="dsidx-beds" placeholder="min bedrooms" /> -->
					<div class="ui-slider-wrapper-custom beds-wrapper">
					<select name="idx-q-BedsMin" id="idx-q-BedsMin" class="bon-dsidx-beds2 dsidx-beds no-custom select-slider">
						<option value=""><?php 
    _e('Any', 'bon');
    ?>
</option>
						<?php 
    for ($i = 1; $i <= $bed_opt; $i++) {
        ?>
							<option value="<?php 
        echo $i;
        ?>
" <?php 
        selected('idx-q-BedsMin', $i);
        ?>
><?php 
        echo $i;
        ?>
</option>
						<?php 
    }
    ?>
					</select>
					</div>
				<?php 
    echo $cc . $rc;
    ?>

				<?php 
    echo $ro . $co;
    ?>
				<label for="idx-q-TractIdentifiers"><?php 
    _e('Tract', 'bon');
    ?>
</label>
				<select id="idx-q-TractIdentifiers" name="idx-q-TractIdentifiers" class="select-dark idx-q-Location-Filter">
					<option value=""><?php 
    _e('Any', 'bon');
    ?>
</option>
					<?php 
    if (!empty($searchOptions['tracts'])) {
        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 = $autoload_options == 'no' ? htmlentities(trim($tract)) : htmlentities(trim($tract->Name));
            ?>
						<option value="<?php 
            echo $tract;
            ?>
" <?php 
            selected('idx-q-TractIdentifiers', $tract);
            ?>
><?php 
            echo $tract;
            ?>
</option>
					<?php 
        }
    }
    ?>
				</select>
				<?php 
    echo $cc;
    ?>
				<?php 
    echo $co;
    ?>
				<label for="idx-q-ZipCodes"><?php 
    _e('Zip', 'bon');
    ?>
</label>
				<select id="idx-q-ZipCodes" name="idx-q-ZipCodes" class="select-dark idx-q-Location-Filter">
					<option value=""><?php 
    _e('Any', 'bon');
    ?>
</option>
					<?php 
    if (!empty($searchOptions['zips'])) {
        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 = $autoload_options == 'no' ? htmlentities(trim($zip)) : htmlentities(trim($zip->Name));
            ?>
					<option value="<?php 
            echo $zip;
            ?>
" <?php 
            selected('idx-q-ZipCodes', $zip);
            ?>
><?php 
            echo $zip;
            ?>
</option>
					<?php 
        }
    }
    ?>
				</select>
				<?php 
    echo $cc;
    ?>
				<?php 
    echo $co;
    ?>
				<?php 
    $bath_opt = absint(bon_get_option('maximum_bath', 5));
    if (!is_int($bath_opt)) {
        $bath_opt = 5;
    }
    ?>
					<label for="idx-q-BathsMin"><?php 
    _e('Baths', 'bon');
    ?>
</label>
					<div class="ui-slider-wrapper-custom baths-wrapper">
					<select name="idx-q-BathsMin" id="idx-q-BathsMin" class="bon-dsidx-baths2 dsidx-baths no-custom select-slider">
						<option value=""><?php 
    _e('Any', 'bon');
    ?>
</option>
						<?php 
    for ($i = 1; $i <= $bath_opt; $i++) {
        ?>
							<option value="<?php 
        echo $i;
        ?>
" <?php 
        selected('idx-q-BathsMin', $i);
        ?>
><?php 
        echo $i;
        ?>
</option>
						<?php 
    }
    ?>
					</select>
					</div>
				<?php 
    echo $cc . $rc;
    ?>
				
				<?php 
    echo $ro . $co;
    ?>
				<label for="idx-q-Communities"><?php 
    _e('Community', 'bon');
    ?>
</label>
				<select id="idx-q-Communities" name="idx-q-Communities" class="select-dark idx-q-Location-Filter">
					<option value=""><?php 
    _e('Any', 'bon');
    ?>
</option>
					<?php 
    if (!empty($searchOptions['communities'])) {
        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 = $autoload_options == 'no' ? htmlentities(trim($community)) : htmlentities(trim($community->Name));
            ?>
						<option value="<?php 
            echo $community;
            ?>
" <?php 
            selected('idx-q-Communities', $community);
            ?>
><?php 
            echo $community;
            ?>
</option>
					<?php 
        }
    }
    ?>
				</select>
				<?php 
    echo $cc;
    ?>
				<?php 
    echo $co;
    ?>
				<label for="idx-q-MlsNumbers"><?php 
    _e('MLS #', 'bon');
    ?>
</label>
				<input id="idx-q-MlsNumbers" name="idx-q-MlsNumbers" type="text" class="dsidx-mlsnumber" value="<?php 
    isset($_GET['idx-q-MlsNumbers']) ? $_GET['idx-q-MlsNumbers'] : '';
    ?>
" />
					
				<?php 
    echo $cc;
    ?>
				<?php 
    echo $co;
    ?>

				<label for="idx-q-PriceMin"><?php 
    _e('Price Range', 'bon');
    ?>
					<span class="price-text" id="idx-min-price-text"></span>
					<span class="price-text" id="idx-max-price-text"></span>
				</label>
				<div class="price-slider-wrapper ui-slider-wrapper-custom">
					<div id="idx-slider-range2"></div>
				</div>
				<input id="idx-q-PriceMin" name="idx-q-PriceMin" type="hidden" class="dsidx-price bon-dsidx-price-min2" value="<?php 
    isset($_GET['idx-q-PriceMin']) ? $_GET['idx-q-PriceMin'] : '';
    ?>
" placeholder="min price" />
				<input id="idx-q-PriceMax" name="idx-q-PriceMax" type="hidden" class="dsidx-price bon-dsidx-price-max2" value="<?php 
    isset($_GET['idx-q-PriceMax']) ? $_GET['idx-q-PriceMax'] : '';
    ?>
" placeholder="max price" />
				
				<?php 
    echo $cc . $rc . $cc;
    ?>
					<div class="column large-2 small-11 large-uncentered small-centered" id="submit-button">
					<?php 
    $button_color = bon_get_option('search_button_color', 'red');
    $search_label = bon_get_option('search_button_label', __('Find Property', 'bon'));
    ?>
					<input type="submit" class="button flat <?php 
    echo $button_color;
    ?>
 expand small radius submit" value="<?php 
    echo $search_label;
    ?>
" />
					</div>
				</div>
			</form>
			
	<?php 
}
    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");
    }