function form($instance)
    {
        wp_enqueue_script('dsidxwidgets_widget_service_admin', DSIDXWIDGETS_PLUGIN_URL . 'js/widget-service-admin.js', array('jquery'), false, true);
        $personal_info = stripslashes_deep(get_option('personal_info'));
        $city = empty($personal_info['city']) ? 'Irvine' : $personal_info['city'];
        $state = empty($personal_info['state']) ? 'CA' : $personal_info['state'];
        $instance = wp_parse_args($instance, array("title" => "Area Statistics", "tract" => "", "community" => "", "state" => $state, "city" => $city, "zip" => "", "propType" => "", "periodType" => "1", "statusType" => "1", "eDomain" => ""));
        $title = htmlspecialchars($instance["title"]);
        $titleFieldId = $this->get_field_id("title");
        $titleFieldName = $this->get_field_name("title");
        $tract = htmlspecialchars($instance["tract"]);
        $tractFieldId = $this->get_field_id("tract");
        $tractFieldName = $this->get_field_name("tract");
        $community = htmlspecialchars($instance["community"]);
        $communityFieldId = $this->get_field_id("community");
        $communityFieldName = $this->get_field_name("community");
        $state = htmlspecialchars($instance["state"]);
        $stateFieldId = $this->get_field_id("state");
        $stateFieldName = $this->get_field_name("state");
        $city = htmlspecialchars($instance["city"]);
        $cityFieldId = $this->get_field_id("city");
        $cityFieldName = $this->get_field_name("city");
        $zip = htmlspecialchars($instance["zip"]);
        $zipFieldId = $this->get_field_id("zip");
        $zipFieldName = $this->get_field_name("zip");
        $propType = htmlspecialchars($instance["propType"]);
        $propTypeFieldId = $this->get_field_id("propType");
        $propTypeFieldName = $this->get_field_name("propType");
        $period = $instance["periodType"];
        $periodFieldId = $this->get_field_id("periodType");
        $periodFieldName = $this->get_field_name("periodType");
        $status = $instance["statusType"];
        $statusFieldId = $this->get_field_id("statusType");
        $statusFieldName = $this->get_field_name("statusType");
        $eDomain = htmlspecialchars($instance["eDomain"]);
        $eDomainFieldId = $this->get_field_id("eDomain");
        $eDomainFieldName = $this->get_field_name("eDomain");
        $baseFieldId = $this->get_field_id("areastatsOptions");
        $baseFieldName = $this->get_field_name("areastatsOptions");
        $apiStub = dsWidgets_Service_Base::$widgets_admin_api_stub;
        $property_types = dsWidgetAgent_ApiRequest::FetchData('AccountPropertyTypes', array(), false, 60 * 60 * 24);
        $checked_html = $propType == '' ? 'selected' : '';
        $property_types_html = '<option value="-1" {$checked_html} >Select Property Type</option>';
        $randString = dsWidgets_Service_Base::get_random_string('abcdefghijklmnopqrstuvwxyz1234567890', 5);
        $options = get_option(DSIDXWIDGETS_OPTION_NAME);
        $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"];
        }
        if (!empty($property_types)) {
            $property_types = json_decode($property_types["body"]);
            foreach ($property_types as $property_type) {
                $checked_html = '';
                $name = htmlentities($property_type->DisplayName);
                $id = $property_type->PropertyTypeID;
                if ($id == $propType) {
                    $checked_html = 'selected';
                }
                $property_types_html .= <<<HTML
                <option value="{$id}" {$checked_html} >{$name}</option>
HTML;
            }
        }
        echo <<<HTML
\t\t\t<input type='hidden' id='ds_widgets_area_stats_domain' value='{$eDomain}' name="ds_widgets_area_stats_domain" />
        \t<p>
\t\t\t\t<label for="{$titleFieldId}">Title</label>
\t\t\t\t<input id="{$titleFieldId}" name="{$titleFieldName}" value="{$title}" class="widefat" type="text" />
\t\t\t</p>
            <p>
\t\t\t\t<label for="{$tractFieldId}">Tract</label>
\t\t\t\t<input id="{$tractFieldId}" name="{$tractFieldName}" value="{$tract}" class="widefat" type="text" />
\t\t\t</p>
            <p>
\t\t\t\t<label for="{$communityFieldId}">Community</label>
\t\t\t\t<input id="{$communityFieldId}" name="{$communityFieldName}" value="{$community}" class="widefat" type="text" />
\t\t\t</p>
            <p>
\t\t\t\t<label for="{$cityFieldId}">City</label>
\t\t\t\t<input id="{$cityFieldId}" name="{$cityFieldName}" value="{$city}" class="widefat" type="text" />
\t\t\t</p>
            <p>
\t\t\t\t<label for="{$stateFieldId}">State</label>
\t\t\t\t<input id="{$stateFieldId}" name="{$stateFieldName}" value="{$state}" class="widefat" type="text" />
\t\t\t</p>
            <p>
\t\t\t\t<label for="{$zipFieldId}">Zip Code</label>
\t\t\t\t<input id="{$zipFieldId}" name="{$zipFieldName}" value="{$zip}" class="widefat" type="text" />
\t\t\t</p>
            <p>
\t\t\t\t<label for="{$propTypeFieldId}">Property Type</label>
\t\t\t\t<select id="{$propTypeFieldId}" name="{$propTypeFieldName}"  class="widefat" type="text" onchange="jQuery(zWidgets_Area_Listener(this))">
                    {$property_types_html}
                </select>
\t\t\t</p>
            <p>
                <label for="{$periodFieldId}">Period</label>
\t\t\t\t<select class="widefat" id="{$periodFieldId}" name="{$periodFieldName}" onchange="jQuery(zWidgets_Area_Listener(this))">
\t\t\t\t\t<option 
HTML;
        if ($period == '1') {
            echo 'selected';
        }
        echo <<<HTML
                    value="1">Weekly</option>
                    <option 
HTML;
        if ($period == '2') {
            echo 'selected';
        }
        echo <<<HTML
                    value="2" >Monthly</option>
\t\t\t\t</select>
\t\t\t</p>
            <p>
                <label for="{$statusFieldId}">Status</label>
\t\t\t\t<select class="widefat" id="{$statusFieldId}" name="{$statusFieldName}" onchange="jQuery(zWidgets_Area_Listener(this))">
\t\t\t\t\t<option 
HTML;
        if ($status == '1') {
            echo 'selected';
        }
        echo <<<HTML
                    value="1">Active</option>
                    <option 
HTML;
        if ($status == '2') {
            echo 'selected';
        }
        echo <<<HTML
                    value="2" >Pending</option>
                    <option 
HTML;
        if ($status == '3') {
            echo 'selected';
        }
        echo <<<HTML
                    value="3" >Expired</option>
                    <option 
HTML;
        if ($status == '4') {
            echo 'selected';
        }
        echo <<<HTML
                    value="4" >Sold</option>
\t\t\t\t</select>
\t\t\t</p>
            <script>
                jQuery(function(){
                    var a = document.getElementById('ds_widgets_area_stats_domain');
                    if(a.value == ''){
                        zWidgetsAdmin.fetchEncryptedValue(window.location.hostname, 'domain', a, '{$apiStub}');
                    }
                })
                zWidgets_Area_Listener = function (event){
                    zWidgetsAdmin.checkForAreaData_(event, '{$randString}', document.getElementById('ds_widgets_area_stats_domain').value, '{$apiStub}', {$aid}, {$ssid} )
                };
            </script>
HTML;
    }
Esempio n. 2
0
 public static function ShortCircuit()
 {
     if (isset($_GET['zpress_widget_ajax']) && $_GET['zpress_widget_ajax'] == 'true' && isset($_GET['api_target'])) {
         if (defined('DS_API')) {
             dsWidgetAgent_ApiRequest::$ApiEndPoint = DS_API;
         }
         $response = dsWidgetAgent_ApiRequest::FetchData($_GET['api_target'], array(), true, null, null, array('Origin' => $_SERVER['SERVER_NAME']));
         if (isset($response['body'])) {
             echo $response['body'];
         } else {
             echo 'console.log("Error occurred while retrieving API data.");';
         }
         die;
     }
 }