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; }
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); }
/** * Generate Text search field * @author Howard R <*****@*****.**> * @static * @param int $user_id */ public static function update_text_search_field($user_id) { $user_data = (array) wpl_users::get_wpl_user($user_id); /** get text_search fields **/ $fields = wpl_flex::get_fields('', 1, 2, 'text_search', '1'); $rendered = self::render_profile($user_data, $fields); $text_search_data = array(); foreach ($rendered as $data) { if (isset($data['type']) and !trim($data['type']) or isset($data['value']) and !trim($data['value'])) { continue; } /** default value **/ $value = isset($data['value']) ? $data['value'] : ''; $value2 = ''; $type = isset($data['type']) ? $data['type'] : ''; if ($type == 'text' or $type == 'textarea') { $value = $data['name'] . ' ' . $data['value']; } elseif ($type == 'locations' and isset($data['locations']) and is_array($data['locations'])) { $location_value = ''; foreach ($data['locations'] as $location_level => $value) { $location_value .= $data['keywords'][$location_level] . ' '; $abbr = wpl_locations::get_location_abbr_by_name($data['raw'][$location_level], $location_level); $name = wpl_locations::get_location_name_by_abbr($abbr, $location_level); $location_value .= $name . ' ' . ($name != $abbr ? $abbr . ' ' : NULL); } $location_value .= __('County', WPL_TEXTDOMAIN); $value = $location_value; } elseif (isset($data['value'])) { $value = $data['name'] . ' ' . $data['value']; if (is_numeric($data['value'])) { $value2 = $data['name'] . ' ' . wpl_global::number_to_word($data['value']); } } /** set value in text search data **/ $text_search_data[] = $value; if (trim($value2) != '') { $text_search_data[] = $value2; } } $column = 'textsearch'; if (wpl_global::check_multilingual_status()) { $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false); } wpl_db::set('wpl_users', $user_id, $column, implode(' ', wpl_db::escape($text_search_data))); }
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; }
} $multiple_values = array_reverse($multiple_values); if (count($multiple_values)) { $qqqq = array(); foreach ($multiple_values as $value) { $values_raw = array_reverse(explode(',', $value)); $values = array(); $l = 0; foreach ($values_raw as $value_raw) { $l++; if (trim($value_raw) == '') { continue; } $value_raw = trim($value_raw); if (strlen($value_raw) == 2 and $l <= 2) { $value_raw = wpl_locations::get_location_name_by_abbr($value_raw, $l); } $ex_space = explode(' ', $value_raw); foreach ($ex_space as $value_raw) { array_push($values, $value_raw); } } if (count($values)) { $qqq = array(); $qq = array(); $column = 'textsearch'; /** Multilingual location text search **/ if (wpl_global::check_multilingual_status()) { $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false); } foreach ($values as $val) {
<?php /** no direct access **/ defined('_WPLEXEC') or die('Restricted access'); if ($format == 'radiussearchunit' and !$done_this) { /** importing library **/ _wpl_import('libraries.locations'); $unit_id = $value; $address = isset($vars['sf_radiussearch']) ? $vars['sf_radiussearch'] : ''; $radius = $vars['sf_radiussearchradius']; if (trim($address)) { $location_point = wpl_locations::get_LatLng($address); $latitude = $location_point[0]; $longitude = $location_point[1]; } else { $latitude = isset($vars['sf_radiussearch_lat']) ? $vars['sf_radiussearch_lat'] : 0; $longitude = isset($vars['sf_radiussearch_lng']) ? $vars['sf_radiussearch_lng'] : 0; } if ($latitude and $longitude and $radius and $unit_id) { $unit = wpl_units::get_unit($unit_id); if ($unit) { $tosi = 6371 * 1000 / $unit['tosi']; $radius_si = $radius * $unit['tosi']; $query .= " AND (( " . $tosi . " * acos( cos( radians(" . $latitude . ") ) * cos( radians( googlemap_lt ) ) * cos( radians( googlemap_ln ) - radians(" . $longitude . ") ) + sin( radians(" . $latitude . ") ) * sin( radians( googlemap_lt ) ) ) ) < " . $radius . ") AND `show_address`='1'"; } } $done_this = true; } elseif ($format == 'polygonsearch' and wpl_global::check_addon('aps') and !$done_this) { /** importing library **/ _wpl_import('libraries.addon_aps'); $raw_points = isset($vars['sf_polygonsearchpoints']) ? $vars['sf_polygonsearchpoints'] : '[]';
{ 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>';
private function location_save($table_name, $table_column, $value, $item_id) { $location_settings = wpl_global::get_settings('3'); # location settings $location_level = str_replace('_id', '', $table_column); $location_level = substr($location_level, -1); if ($table_column == 'zip_id') { $location_level = 'zips'; } $location_data = wpl_locations::get_location($value, $location_level); $location_name_column = $location_level != 'zips' ? 'location' . $location_level . '_name' : 'zip_name'; /** update property location data **/ if ($location_settings['location_method'] == 2 or $location_settings['location_method'] == 1 and in_array($location_level, array(1, 2))) { $res = wpl_db::update($table_name, array($table_column => $value, $location_name_column => $location_data->name), 'id', $item_id); } else { $res = wpl_db::update($table_name, array($location_name_column => $value), 'id', $item_id); } $res = (int) $res; $message = $res ? __('Saved.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN); $data = NULL; $response = array('success' => $res, 'message' => $message, 'data' => $data); echo json_encode($response); exit; }
<?php /** no direct access **/ defined('_WPLEXEC') or die('Restricted access'); /** set params **/ $html_element_id = isset($params['html_element_id']) ? $params['html_element_id'] : ''; $root_url = isset($params['root_url']) ? $params['root_url'] : wpl_global::get_full_url(); $element_class = isset($params['element_class']) ? $params['element_class'] : 'location_breadcrumb'; $separator = isset($params['separator']) ? $params['separator'] : ' > '; $location_level = isset($params['location_level']) ? $params['location_level'] : 1; $location_id = isset($params['location_id']) ? $params['location_id'] : ''; $load_zipcodes = isset($params['load_zipcodes']) ? $params['load_zipcodes'] : 0; $location_tree = wpl_locations::get_location_tree($location_id, $location_level - 1); $levels = count($location_tree) + 1; $breadcrumb_str = ""; $i = 1; foreach ($location_tree as $branch) { if (trim($branch['name']) == '') { continue; } $link = wpl_global::add_qs_var('level', $levels, $root_url); $link = wpl_global::add_qs_var('sf_select_parent', $branch['id'], $link); if ($load_zipcodes and $i == 1) { $link = wpl_global::add_qs_var('load_zipcodes', 1, $link); } $breadcrumb_str = $separator . '<a href="' . $link . '">' . (($load_zipcodes and $i == 1) ? $branch['name'] . ' (' . __('Zipcodes', WPL_TEXTDOMAIN) . ')' : $branch['name']) . '</a>' . $breadcrumb_str; $levels--; $i++; } ?> <div class="<?php
/** * Updates text search field * @author Howard <*****@*****.**> * @static * @param int $property_id */ public static function update_text_search_field($property_id) { $property_data = wpl_property::get_property_raw_data($property_id); /** get text_search fields **/ $fields = wpl_flex::get_fields('', 1, $property_data['kind'], 'text_search', '1'); $rendered = self::render_property($property_data, $fields); $text_search_data = array(); foreach ($rendered as $data) { if (!isset($data['type'])) { continue; } if (isset($data['type']) and !trim($data['type']) or isset($data['value']) and !trim($data['value'])) { continue; } /** default value **/ $value = isset($data['value']) ? $data['value'] : ''; $value2 = ''; $type = $data['type']; if ($type == 'text' or $type == 'textarea') { $value = $data['name'] . ' ' . $data['value']; } elseif ($type == 'neighborhood') { $value = $data['name'] . (isset($data['distance']) ? ' (' . $data['distance'] . ' ' . __('MINUTES', WPL_TEXTDOMAIN) . ' ' . __('BY', WPL_TEXTDOMAIN) . ' ' . $data['by'] . ')' : ''); } elseif ($type == 'feature') { $feature_value = $data['name']; if (isset($data['values'][0])) { $feature_value .= ' '; foreach ($data['values'] as $val) { $feature_value .= $val . ', '; } $feature_value = rtrim($feature_value, ', '); } $value = $feature_value; } elseif ($type == 'locations' and isset($data['locations']) and is_array($data['locations'])) { $location_value = ''; foreach ($data['locations'] as $location_level => $value) { $location_value .= $data['keywords'][$location_level] . ' '; $abbr = wpl_locations::get_location_abbr_by_name($data['raw'][$location_level], $location_level); $name = wpl_locations::get_location_name_by_abbr($abbr, $location_level); $location_value .= $name . ' ' . ($name != $abbr ? $abbr . ' ' : NULL); } $location_value .= __('County', WPL_TEXTDOMAIN); $value = $location_value; } elseif (isset($data['value'])) { $value = $data['name'] . ' ' . $data['value']; if (is_numeric($data['value'])) { $value2 = $data['name'] . ' ' . wpl_global::number_to_word($data['value']); } } /** set value in text search data **/ if (trim($value) != '') { $text_search_data[] = strip_tags($value); } if (trim($value2) != '') { $text_search_data[] = strip_tags($value2); } } $column = 'textsearch'; if (wpl_global::check_multilingual_status()) { $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false); } wpl_db::set('wpl_properties', $property_id, $column, wpl_db::escape(implode(' ', $text_search_data))); }
private function delete_location($level, $location_id) { $res = wpl_locations::delete_location($location_id, $level, true); /** trigger event **/ wpl_global::event_handler('location_deleted', array('level' => $level, 'location_id' => $location_id)); $res = $res ? 1 : 0; $message = $res ? __('Location(s) Deleted.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN); $data = NULL; $response = array('success' => $res, 'message' => $message, 'data' => $data); echo json_encode($response); exit; }
/** * Updates text search field * @author Howard <*****@*****.**> * @static * @param int $property_id */ public static function update_text_search_field($property_id) { $property_data = wpl_property::get_property_raw_data($property_id); $kind = wpl_property::get_property_kind($property_id); /** get text_search fields **/ $fields = wpl_flex::get_fields('', 1, $property_data['kind'], 'text_search', '1'); $rendered = self::render_property($property_data, $fields); $text_search_data = array(); foreach ($rendered as $data) { if (!isset($data['type'])) { continue; } if (isset($data['type']) and !trim($data['type']) or isset($data['value']) and !trim($data['value'])) { continue; } /** default value **/ $value = isset($data['value']) ? $data['value'] : ''; $value2 = ''; $type = $data['type']; if ($type == 'text' or $type == 'textarea') { $value = $data['name'] . ' ' . $data['value']; } elseif ($type == 'neighborhood') { $value = $data['name'] . (isset($data['distance']) ? ' (' . $data['distance'] . ' ' . __('MINUTES', WPL_TEXTDOMAIN) . ' ' . __('BY', WPL_TEXTDOMAIN) . ' ' . $data['by'] . ')' : ''); } elseif ($type == 'feature') { $feature_value = $data['name']; if (isset($data['values'][0])) { $feature_value .= ' '; foreach ($data['values'] as $val) { $feature_value .= $val . ', '; } $feature_value = rtrim($feature_value, ', '); } $value = $feature_value; } elseif ($type == 'locations' and isset($data['locations']) and is_array($data['locations'])) { $location_values = array(); foreach ($data['locations'] as $location_level => $value) { array_push($location_values, $data['keywords'][$location_level]); $abbr = wpl_locations::get_location_abbr_by_name($data['raw'][$location_level], $location_level); $name = wpl_locations::get_location_name_by_abbr($abbr, $location_level); $ex_space = explode(' ', $name); foreach ($ex_space as $value_raw) { array_push($location_values, $value_raw); } if ($name !== $abbr) { array_push($location_values, $abbr); } } /** Add all location fields to the location text search **/ $location_category = wpl_flex::get_category(NULL, " AND `kind`='{$kind}' AND `prefix`='ad'"); $location_fields = wpl_flex::get_fields($location_category->id, 1, $kind); foreach ($location_fields as $location_field) { if (!isset($rendered[$location_field->id])) { continue; } if (!trim($location_field->table_column)) { continue; } if (!isset($rendered[$location_field->id]['value']) or isset($rendered[$location_field->id]['value']) and !trim($rendered[$location_field->id]['value'])) { continue; } $ex_space = explode(' ', strip_tags($rendered[$location_field->id]['value'])); foreach ($ex_space as $value_raw) { array_push($location_values, $value_raw); } } $location_suffix_prefix = wpl_locations::get_location_suffix_prefix(); foreach ($location_suffix_prefix as $suffix_prefix) { array_push($location_values, $suffix_prefix); } $location_string = ''; $location_values = array_unique($location_values); foreach ($location_values as $location_value) { $location_string .= 'LOC-' . __($location_value, WPL_TEXTDOMAIN) . ' '; } $value = trim($location_string); } elseif (isset($data['value'])) { $value = $data['name'] . ' ' . $data['value']; if (is_numeric($data['value'])) { $value2 = $data['name'] . ' ' . wpl_global::number_to_word($data['value']); } } /** set value in text search data **/ if (trim($value) != '') { $text_search_data[] = strip_tags($value); } if (trim($value2) != '') { $text_search_data[] = strip_tags($value2); } } $column = 'textsearch'; if (wpl_global::check_multilingual_status()) { $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false); } wpl_db::set('wpl_properties', $property_id, $column, wpl_db::escape(implode(' ', $text_search_data))); }