Exemplo n.º 1
0
 private function save_multilingual()
 {
     $dbst_id = wpl_request::getVar('dbst_id');
     $value = wpl_db::escape(wpl_request::getVar('value'));
     $item_id = wpl_request::getVar('item_id');
     $lang = wpl_request::getVar('lang');
     $field = wpl_flex::get_field($dbst_id);
     $table_name = $field->table_name;
     $table_column1 = wpl_addon_pro::get_column_lang_name($field->table_column, $lang, false);
     $default_language = wpl_addon_pro::get_default_language();
     $table_column2 = NULL;
     if (strtolower($default_language) == strtolower($lang)) {
         $table_column2 = wpl_addon_pro::get_column_lang_name($field->table_column, $lang, true);
     }
     wpl_db::set($table_name, $item_id, $table_column1, $value, 'id');
     if ($table_column2) {
         wpl_db::set($table_name, $item_id, $table_column2, $value, 'id');
     }
     $res = 1;
     $message = $res ? __('Saved.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN);
     $data = NULL;
     $response = array('success' => $res, 'message' => $message, 'data' => $data);
     echo json_encode($response);
     exit;
 }
Exemplo n.º 2
0
 /**
  * Generate location text of User
  * @author Howard R <*****@*****.**>
  * @static
  * @param array $user_data
  * @param int $user_id
  * @param string $glue
  * @return string
  */
 public static function generate_location_text($user_data, $user_id = 0, $glue = ',')
 {
     /** fetch user data if user id is setted **/
     if ($user_id) {
         $user_data = (array) wpl_users::get_wpl_user($user_id);
     }
     if (!$user_id) {
         $user_id = $user_data['id'];
     }
     $locations = array();
     if (isset($user_data['location7_name']) and trim($user_data['location7_name']) != '') {
         $locations['location7_name'] = __($user_data['location7_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['location6_name']) and trim($user_data['location6_name']) != '') {
         $locations['location6_name'] = __($user_data['location6_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['location5_name']) and trim($user_data['location5_name']) != '') {
         $locations['location5_name'] = __($user_data['location5_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['location4_name']) and trim($user_data['location4_name']) != '') {
         $locations['location4_name'] = __($user_data['location4_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['location3_name']) and trim($user_data['location3_name']) != '') {
         $locations['location3_name'] = __($user_data['location3_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['location2_name']) and trim($user_data['location2_name']) != '') {
         $locations['location2_name'] = __($user_data['location2_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['zip_name']) and trim($user_data['zip_name']) != '') {
         $locations['zip_name'] = __($user_data['zip_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['location1_name']) and trim($user_data['location1_name']) != '') {
         $locations['location1_name'] = __($user_data['location1_name'], WPL_TEXTDOMAIN);
     }
     $location_pattern = wpl_global::get_setting('user_location_pattern');
     if (trim($location_pattern) == '') {
         $location_pattern = '[location5_name][glue][location4_name][glue][location3_name][glue][location2_name][glue][location1_name] [zip_name]';
     }
     $location_text = '';
     $location_text = isset($locations['location7_name']) ? str_replace('[location7_name]', $locations['location7_name'], $location_pattern) : str_replace('[location7_name]', '', $location_pattern);
     $location_text = isset($locations['location6_name']) ? str_replace('[location6_name]', $locations['location6_name'], $location_pattern) : str_replace('[location6_name]', '', $location_pattern);
     $location_text = isset($locations['location5_name']) ? str_replace('[location5_name]', $locations['location5_name'], $location_pattern) : str_replace('[location5_name]', '', $location_pattern);
     $location_text = isset($locations['location4_name']) ? str_replace('[location4_name]', $locations['location4_name'], $location_text) : str_replace('[location4_name]', '', $location_text);
     $location_text = isset($locations['location3_name']) ? str_replace('[location3_name]', $locations['location3_name'], $location_text) : str_replace('[location3_name]', '', $location_text);
     $location_text = isset($locations['location2_name']) ? str_replace('[location2_name]', $locations['location2_name'], $location_text) : str_replace('[location2_name]', '', $location_text);
     $location_text = isset($locations['zip_name']) ? str_replace('[zip_name]', $locations['zip_name'], $location_text) : str_replace('[zip_name]', '', $location_text);
     $location_text = isset($locations['location1_name']) ? str_replace('[location1_name]', $locations['location1_name'], $location_text) : str_replace('[location1_name]', '', $location_text);
     $location_text = str_replace('[glue]', $glue, $location_text);
     /** apply filters **/
     _wpl_import('libraries.filters');
     @extract(wpl_filters::apply('generate_user_location_text', array('location_text' => $location_text, 'glue' => $glue, 'user_data' => $user_data)));
     $final = '';
     $ex = explode($glue, $location_text);
     foreach ($ex as $value) {
         if (trim($value) == '') {
             continue;
         }
         $final .= trim($value) . $glue . ' ';
     }
     $location_text = trim($final, $glue . ' ');
     $column = 'location_text';
     $field_id = wpl_flex::get_dbst_id($column, 2);
     $field = wpl_flex::get_field($field_id);
     if (isset($field->multilingual) and $field->multilingual and wpl_global::check_multilingual_status()) {
         $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false);
     }
     /** update **/
     $query = "UPDATE `#__wpl_users` SET `{$column}`='" . $location_text . "' WHERE `id`='{$user_id}'";
     wpl_db::q($query, 'update');
     return $location_text;
 }
Exemplo n.º 3
0
 /**
  * Updates property title
  * @author Howard <*****@*****.**>
  * @static
  * @param array $property_data
  * @param int $property_id
  * @param boolean $force
  * @return string
  */
 public static function update_property_title($property_data, $property_id = 0, $force = false)
 {
     /** fetch property data if property id is setted **/
     if ($property_id) {
         $property_data = self::get_property_raw_data($property_id);
     }
     if (!$property_id) {
         $property_id = $property_data['id'];
     }
     $column = 'field_313';
     $field_id = wpl_flex::get_dbst_id($column, $property_data['kind']);
     $field = wpl_flex::get_field($field_id);
     $base_column = NULL;
     if (isset($field->multilingual) and $field->multilingual and wpl_global::check_multilingual_status()) {
         $base_column = wpl_global::get_current_language() == wpl_addon_pro::get_default_language() ? $column : NULL;
         $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false);
     }
     /** return current title if exists **/
     if (isset($property_data[$column]) and trim($property_data[$column]) != '' and !$force) {
         return $property_data[$column];
     }
     /** first validation **/
     if (!$property_data) {
         return '';
     }
     $listing_data = wpl_global::get_listings($property_data['listing']);
     $listing = isset($listing_data->name) ? $listing_data->name : '';
     $property_type_data = wpl_global::get_property_types($property_data['property_type']);
     $property_type = isset($property_type_data->name) ? $property_type_data->name : '';
     $title = array();
     $title['property_type'] = __($property_type, WPL_TEXTDOMAIN);
     $title['listing'] = __($listing, WPL_TEXTDOMAIN);
     if ($property_data['kind']) {
         $kind_label = wpl_flex::get_kind_label($property_data['kind']);
         if (trim($kind_label)) {
             $title['kind'] = '(' . __($kind_label, WPL_TEXTDOMAIN) . ')';
         }
     }
     $title_str = implode(' ', $title);
     /** apply filters **/
     _wpl_import('libraries.filters');
     @extract(wpl_filters::apply('generate_property_title', array('title' => $title, 'title_str' => $title_str)));
     /** update **/
     if (wpl_db::columns('wpl_properties', $column)) {
         $query = "UPDATE `#__wpl_properties` SET `" . $column . "`='" . $title_str . "' WHERE `id`='" . $property_id . "'";
         wpl_db::q($query, 'update');
     }
     /** update **/
     if ($base_column and wpl_db::columns('wpl_properties', $base_column)) {
         $query = "UPDATE `#__wpl_properties` SET `" . $base_column . "`='" . $title_str . "' WHERE `id`='" . $property_id . "'";
         wpl_db::q($query, 'update');
     }
     return $title_str;
 }
Exemplo n.º 4
0
 public function render_search_fields($instance, $widget_id, $finds = array())
 {
     /** first validation **/
     if (!$instance) {
         return array();
     }
     $path = WPL_ABSPATH . DS . 'libraries' . DS . 'widget_search' . DS . 'frontend';
     $files = array();
     if (wpl_folder::exists($path)) {
         $files = wpl_folder::files($path, '.php$');
     }
     $fields = $instance['data'];
     uasort($fields, array('wpl_global', 'wpl_array_sort'));
     $rendered = array();
     foreach ($fields as $key => $field) {
         /** proceed to next field if field is not enabled **/
         if (!isset($field['enable']) or isset($field['enable']) and $field['enable'] != 'enable') {
             continue;
         }
         /** Fix empty id issue **/
         if ((!isset($field['id']) or isset($field['id']) and !$field['id']) and $key) {
             $field['id'] = $key;
         }
         $field_data = (array) wpl_flex::get_field($field['id']);
         if (!$field_data) {
             continue;
         }
         $field['name'] = $field_data['name'];
         $type = $field_data['type'];
         $field_id = $field['id'];
         $options = json_decode($field_data['options'], true);
         $display = '';
         $done_this = false;
         $html = '';
         /** listing and property type specific **/
         if (trim($field_data['listing_specific']) != '') {
             $specified_listings = explode(',', trim($field_data['listing_specific'], ', '));
             $this->listing_specific_array[$field_data['id']] = $specified_listings;
         } elseif (trim($field_data['property_type_specific']) != '') {
             $specified_property_types = explode(',', trim($field_data['property_type_specific'], ', '));
             $this->property_type_specific_array[$field_data['id']] = $specified_property_types;
         }
         /** Accesses **/
         if (trim($field_data['accesses']) != '') {
             $accesses = explode(',', trim($field_data['accesses'], ', '));
             $cur_membership_id = wpl_users::get_user_membership();
             if (!in_array($cur_membership_id, $accesses)) {
                 continue;
             }
         }
         if (isset($finds[$type])) {
             $html .= '<div class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '">';
             include $path . DS . $finds[$type];
             $html .= '</div>';
             $rendered[$field_id]['id'] = $field_id;
             $rendered[$field_id]['field_data'] = $field_data;
             $rendered[$field_id]['field_options'] = json_decode($field_data['options'], true);
             $rendered[$field_id]['search_options'] = isset($field['extoption']) ? $field['extoption'] : NULL;
             $rendered[$field_id]['html'] = $html;
             $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL;
             $rendered[$field_id]['display'] = $display;
             continue;
         }
         $html .= '<div class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '" style="' . $display . '">';
         foreach ($files as $file) {
             include $path . DS . $file;
             /** proceed to next field **/
             if ($done_this) {
                 $finds[$type] = $file;
                 break;
             }
         }
         $html .= '</div>';
         $rendered[$field_id]['id'] = $field_id;
         $rendered[$field_id]['field_data'] = $field_data;
         $rendered[$field_id]['field_options'] = json_decode($field_data['options'], true);
         $rendered[$field_id]['search_options'] = isset($field['extoption']) ? $field['extoption'] : NULL;
         $rendered[$field_id]['html'] = $html;
         $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL;
         $rendered[$field_id]['display'] = $display;
     }
     return $rendered;
 }
Exemplo n.º 5
0
 /**
  * Checke proeprty alias and 301 redirect the page to the correct link
  * @author Howard <*****@*****.**>
  * @param int $proeprty_id
  */
 public function check_property_link($proeprty_id)
 {
     $wpl_qs = urldecode(wpl_global::get_wp_qvar('wpl_qs'));
     /** check property alias for avoiding duplicate content **/
     $called_alias = $wpl_qs;
     $column = 'alias';
     $field_id = wpl_flex::get_dbst_id($column, wpl_property::get_property_kind($proeprty_id));
     $field = wpl_flex::get_field($field_id);
     if (isset($field->multilingual) and $field->multilingual and wpl_global::check_multilingual_status()) {
         $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false);
     }
     $property_alias = $proeprty_id . '-' . urldecode(wpl_db::get($column, 'wpl_properties', 'id', $proeprty_id));
     if (trim($property_alias) != '' and $called_alias != $property_alias) {
         $url = wpl_sef::get_wpl_permalink(true) . '/' . urlencode($property_alias);
         header('HTTP/1.1 301 Moved Permanently');
         header('Location: ' . $url);
         exit;
     }
 }