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; }
/** * 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; }
$js_string .= ' if (wplj("#wp-' . $field_id . '-wrap").hasClass("tmce-active")) txtarea_val = tinyMCE.get("' . $field_id . '").getContent(); else txtarea_val = wplj("#' . $field_id . '").val(); if(wplj.trim(txtarea_val) == "" && wplj("#wpl_listing_field_container' . $field->id . '").css("display") != "none") { wpl_alert("' . __('Enter a valid', WPL_TEXTDOMAIN) . ' ' . __($label, WPL_TEXTDOMAIN) . '!"); return false; } '; } } else { if ($field->multilingual == 1 and wpl_global::check_multilingual_status()) { $default_language = wpl_addon_pro::get_default_language(); $field_id = 'wpl_c_' . $field->id . '_' . strtolower($default_language); $js_string .= ' if(wplj.trim(wplj("#' . $field_id . '").val()) == "" && wplj("#wpl_listing_field_container' . $field->id . '").css("display") != "none") { wpl_alert("' . sprintf(__('Enter a valid %s for %s!', WPL_TEXTDOMAIN), __($label, WPL_TEXTDOMAIN), $default_language) . '"); return false; } '; } else { $field_id = 'wpl_c_' . $field->id; $js_string .= ' if(wplj.trim(wplj("#' . $field_id . '").val()) == "" && wplj("#wpl_listing_field_container' . $field->id . '").css("display") != "none") { wpl_alert("' . __('Enter a valid', WPL_TEXTDOMAIN) . ' ' . __($label, WPL_TEXTDOMAIN) . '!"); return false;