예제 #1
0
 public function home()
 {
     /** check permission **/
     wpl_global::min_access('administrator');
     $this->level = trim(wpl_request::getVar('level')) != '' ? wpl_request::getVar('level') : 1;
     $this->parent = trim(wpl_request::getVar('sf_select_parent')) != '' ? wpl_request::getVar('sf_select_parent') : "";
     $this->enabled = trim(wpl_request::getVar('sf_select_enabled')) != '' ? wpl_request::getVar('sf_select_enabled') : 1;
     $this->text_search = trim(wpl_request::getVar('sf_text_name')) != '' ? wpl_request::getVar('sf_text_name') : '';
     $this->admin_url = wpl_global::get_wp_admin_url();
     $this->load_zipcodes = trim(wpl_request::getVar('load_zipcodes')) != '' ? 1 : 0;
     /** set show all based on level **/
     if ($this->level != 1) {
         $this->enabled = '';
     }
     $possible_orders = array('id', 'name');
     $orderby = in_array(wpl_request::getVar('orderby'), $possible_orders) ? wpl_request::getVar('orderby') : $possible_orders[0];
     $order = in_array(strtoupper(wpl_request::getVar('order')), array('ASC', 'DESC')) ? wpl_request::getVar('order') : 'ASC';
     $page_size = trim(wpl_request::getVar('page_size')) != '' ? wpl_request::getVar('page_size') : NULL;
     /** create where **/
     $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     $vars = array_merge($vars, array('sf_select_parent' => $this->parent, 'sf_select_enabled' => $this->enabled));
     $where_query = wpl_db::create_query($vars);
     $num_result = wpl_db::num("SELECT COUNT(id) FROM `#__wpl_location" . $this->level . "` WHERE 1 " . $where_query);
     $this->pagination = wpl_pagination::get_pagination($num_result, $page_size);
     $where_query .= " ORDER BY {$orderby} {$order} " . $this->pagination->limit_query;
     $this->wp_locations = wpl_locations::get_locations(!$this->load_zipcodes ? $this->level : 'zips', '', '', $where_query);
     $this->zipcode_parent_level = wpl_settings::get('zipcode_parent_level');
     /** import tpl **/
     parent::render($this->tpl_path, $this->tpl);
 }
예제 #2
0
 private function get_locations($location_level = '', $parent = '', $current_location_id = '', $widget_id)
 {
     $location_settings = wpl_global::get_settings('3');
     # location settings
     if ($location_settings['zipcode_parent_level'] == $location_level - 1) {
         $location_level = 'zips';
     }
     $location_data = wpl_locations::get_locations($location_level, $parent, $location_level == '1' ? 1 : '');
     $res = count($location_data) ? 1 : 0;
     $message = $res ? __('Fetched.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN);
     $name_id = $location_level != 'zips' ? 'sf' . $widget_id . '_select_location' . $location_level . '_id' : 'sf' . $widget_id . '_select_zip_id';
     $html = '<select name="' . $name_id . '" id="' . $name_id . '"';
     if ($location_level != 'zips') {
         $html .= 'onchange="wpl' . $widget_id . '_search_widget_load_location(\'' . $location_level . '\', this.value, \'' . $current_location_id . '\');"';
     }
     $html .= '>';
     $html .= '<option value="-1">' . __(trim($location_settings['location' . $location_level . '_keyword']) != '' ? $location_settings['location' . $location_level . '_keyword'] : 'Select', WPL_TEXTDOMAIN) . '</option>';
     foreach ($location_data as $location) {
         $html .= '<option value="' . $location->id . '" ' . ($current_location_id == $location->id ? 'selected="selected"' : '') . '>' . __($location->name, WPL_TEXTDOMAIN) . '</option>';
     }
     $html .= '</select>';
     $response = array('success' => $res, 'message' => $message, 'data' => $location_data, 'html' => $html, 'keyword' => __($location_settings['location' . $location_level . '_keyword'], WPL_TEXTDOMAIN));
     echo json_encode($response);
     exit;
 }
예제 #3
0
 private function get_locations($location_level, $parent, $current_location_id = '')
 {
     $location_data = wpl_locations::get_locations($location_level, $parent, '');
     $location_settings = wpl_global::get_settings('3');
     # location settings
     $res = count($location_data) ? 1 : 0;
     if (!is_numeric($parent)) {
         $res = 1;
     }
     $message = $res ? __('Fetched.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN);
     $data = $location_data;
     /** website is configured to use location text **/
     if ($location_settings['location_method'] == 1 and ($location_level >= 3 or $location_level == 'zips')) {
         $html = '<input type="text" name="wpl_listing_location' . $location_level . '_select" id="wpl_listing_location' . $location_level . '_select" onchange="wpl_listing_location_change(\'' . $location_level . '\', this.value);" />';
     } elseif ($location_settings['location_method'] == 2 or $location_settings['location_method'] == 1 and $location_level <= 2) {
         $html = '<select name="wpl_listing_location' . $location_level . '_select" id="wpl_listing_location' . $location_level . '_select" onchange="wpl_listing_location_change(\'' . $location_level . '\', this.value);">';
         $html .= '<option value="0">' . __('Select', WPL_TEXTDOMAIN) . '</option>';
         foreach ($location_data as $location) {
             $html .= '<option value="' . $location->id . '" ' . ($current_location_id == $location->id ? 'selected="selected"' : '') . '>' . __($location->name, WPL_TEXTDOMAIN) . '</option>';
         }
         $html .= '</select>';
     }
     $response = array('success' => $res, 'message' => $message, 'data' => $data, 'html' => $html, 'keyword' => __($location_settings['location' . $location_level . '_keyword'], WPL_TEXTDOMAIN));
     echo json_encode($response);
     exit;
 }
            break;
        }
        $html .= '<div class="wpl_search_widget_location_level_container" id="wpl' . $widget_id . '_search_widget_location_level_container' . $i . '">';
        $html .= '<label class="wpl_search_widget_location_level_label" for="sf' . $widget_id . '_select_location' . $i . '_id">' . $location_settings['location' . $i . '_keyword'] . '</label>';
        $html .= '<select name="sf' . $widget_id . '_select_location' . $i . '_id" id="sf' . $widget_id . '_select_location' . $i . '_id" onchange="wpl' . $widget_id . '_search_widget_load_location(\'' . $i . '\', this.value, \'' . $current_location_id . '\');">';
        $html .= '<option value="-1">' . __(trim($location_settings['location' . $i . '_keyword']) != '' ? $location_settings['location' . $i . '_keyword'] : 'Select', WPL_TEXTDOMAIN) . '</option>';
        foreach ($locations as $location) {
            $html .= '<option value="' . $location->id . '" ' . ($current_location_id == $location->id ? 'selected="selected"' : '') . '>' . __($location->name, WPL_TEXTDOMAIN) . '</option>';
        }
        $html .= '</select>';
        $html .= '</div>';
    }
    if ($current_values['zip_id']) {
        $parent = $current_values['location' . $location_settings['zipcode_parent_level'] . '_id'];
        $current_location_id = $current_values['zip_id'];
        $locations = wpl_locations::get_locations('zips', $parent, '');
        if (count($locations)) {
            $html .= '<div class="wpl_search_widget_location_level_container" id="wpl' . $widget_id . '_search_widget_location_level_containerzips">';
            $html .= '<label class="wpl_search_widget_location_level_label" for="sf' . $widget_id . '_select_zip_id">' . $location_settings['locationzips_keyword'] . '</label>';
            $html .= '<select name="sf' . $widget_id . '_select_zip_id" id="sf' . $widget_id . '_select_zip_id">';
            $html .= '<option value="-1">' . __(trim($location_settings['locationzips_keyword']) != '' ? $location_settings['locationzips_keyword'] : 'Select', WPL_TEXTDOMAIN) . '</option>';
            foreach ($locations as $location) {
                $html .= '<option value="' . $location->id . '" ' . ($current_location_id == $location->id ? 'selected="selected"' : '') . '>' . __($location->name, WPL_TEXTDOMAIN) . '</option>';
            }
            $html .= '</select>';
            $html .= '</div>';
        }
    }
    $html .= '</div>';
    $done_this = true;
}
예제 #5
0
			{
				wplj("#wpl' . $widget_id . '_search_widget_location_level_container"+next_level).html("");
			}
		});
	}
	</script>';
    $html .= '<div class="wpl_search_widget_location_container" id="wpl' . $widget_id . '_search_fields_location_' . $field['id'] . '">';
    /** location levels **/
    for ($i = 1; $i <= 2; $i++) {
        if ($i != 1 and !trim($current_values['location' . ($i - 1) . '_id'])) {
            continue;
        }
        $parent = $i != 1 ? $current_values['location' . ($i - 1) . '_id'] : '';
        $current_location_id = $current_values['location' . $i . '_id'];
        $enabled = $i != 1 ? '' : '1';
        $locations = wpl_locations::get_locations($i, $parent, $enabled);
        /** select first location if just one location exists **/
        if (count($locations) == 1) {
            $T_locations = array_values($locations);
            if (!trim($current_values['location' . $i . '_id'])) {
                $current_values['location' . $i . '_id'] = $T_locations[0]->id;
                $current_location_id = $T_locations[0]->id;
            }
        }
        if (!count($locations)) {
            break;
        }
        $html .= '<div class="wpl_search_widget_location_level_container" id="wpl' . $widget_id . '_search_widget_location_level_container' . $i . '">';
        $html .= '<label class="wpl_search_widget_location_level_label" for="sf' . $widget_id . '_select_location' . $i . '_id">' . $location_settings['location' . $i . '_keyword'] . '</label>';
        $html .= '<select name="sf' . $widget_id . '_select_location' . $i . '_id" id="sf' . $widget_id . '_select_location' . $i . '_id" onchange="wpl' . $widget_id . '_search_widget_load_location(\'' . $i . '\', this.value, \'' . $current_location_id . '\');">';
        $html .= '<option value="-1">' . __(trim($location_settings['location' . $i . '_keyword']) != '' ? $location_settings['location' . $i . '_keyword'] : 'Select', WPL_TEXTDOMAIN) . '</option>';