Пример #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;
 }
Пример #2
0
 /**
  * This is a very useful function for rendering whole data of user. you need to just pass user_id and get everything!
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $user_id
  * @param array $plisting_fields
  * @param array $profile
  * @param array $params
  * @return array
  */
 public static function full_render($user_id, $plisting_fields = NULL, $profile = NULL, $params = array())
 {
     /** get plisting fields **/
     if (!$plisting_fields) {
         $plisting_fields = self::get_plisting_fields();
     }
     $raw_data = (array) self::get_wpl_user($user_id);
     if (!$profile) {
         $profile = (object) $raw_data;
     }
     $column = 'rendered';
     if (wpl_global::check_multilingual_status()) {
         $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false);
     }
     /** generate rendered data if rendered data is empty **/
     if (!trim($raw_data[$column]) and wpl_settings::get('cache')) {
         $rendered = json_decode(wpl_users::generate_rendered_data($user_id), true);
     } elseif (!wpl_settings::get('cache')) {
         $rendered = array();
     } else {
         $rendered = json_decode($raw_data[$column], true);
     }
     $result = array();
     $result['data'] = (array) $profile;
     $result['items'] = wpl_items::get_items($profile->id, '', 2, '', 1);
     $result['raw'] = $raw_data;
     if (!isset($rendered['rendered']) or !isset($rendered['materials'])) {
         /** render data on the fly **/
         $find_files = array();
         $rendered_fields = self::render_profile($profile, $plisting_fields, $find_files, true);
     }
     if (isset($rendered['rendered'])) {
         $result['rendered'] = $rendered['rendered'];
     } else {
         $result['rendered'] = $rendered_fields['ids'];
     }
     if (isset($rendered['materials']) and $rendered['materials']) {
         $result['materials'] = $rendered['materials'];
     } else {
         $result['materials'] = $rendered_fields['columns'];
     }
     /** location text **/
     if (isset($rendered['location_text'])) {
         $result['location_text'] = $rendered['location_text'];
     } else {
         $result['location_text'] = self::generate_location_text($raw_data);
     }
     /** profile full link **/
     $target_id = isset($params['wpltarget']) ? $params['wpltarget'] : 0;
     $result['profile_link'] = self::get_profile_link($profile->id, $target_id);
     /** profile picture **/
     if (trim($raw_data['profile_picture']) != '') {
         $result['profile_picture'] = array('url' => wpl_items::get_folder($profile->id, 2) . $raw_data['profile_picture'], 'path' => wpl_items::get_path($profile->id, 2) . $raw_data['profile_picture'], 'name' => $raw_data['profile_picture']);
     }
     /** company logo **/
     if (trim($raw_data['company_logo']) != '') {
         $result['company_logo'] = array('url' => wpl_items::get_folder($profile->id, 2) . $raw_data['company_logo'], 'path' => wpl_items::get_path($profile->id, 2) . $raw_data['company_logo'], 'name' => $raw_data['company_logo']);
     }
     /** Emails url **/
     if (wpl_file::exists(wpl_items::get_path($profile->id, 2) . 'main_email.png')) {
         $result['main_email_url'] = wpl_items::get_folder($profile->id, 2) . 'main_email.png';
     }
     if (wpl_file::exists(wpl_items::get_path($profile->id, 2) . 'second_email.png')) {
         $result['second_email_url'] = wpl_items::get_folder($profile->id, 2) . 'second_email.png';
     }
     return $result;
 }
Пример #3
0
            </div>
        </div>
        <div class="wpl_prp_container_content">
            <div class="wpl_prp_container_content_title">
                <?php 
echo '<h1 class="title_text">' . $prp_title . '</h1>';
echo '<h2 class="location_build_up">' . (trim($build_up_area) ? $build_up_area . ' - ' : '') . '<span itemprop="address">' . $location_string . '</span></h2>';
/** load QR Code **/
wpl_activity::load_position('pshow_qr_code', array('wpl_properties' => $this->wpl_properties));
?>
            </div>
            <div class="wpl_prp_container_content_left">
				<?php 
$description_column = 'field_308';
if (wpl_global::check_multilingual_status()) {
    $description_column = wpl_addon_pro::get_column_lang_name($description_column, wpl_global::get_current_language(), false);
}
if ($this->wpl_properties['current']['data'][$description_column]) {
    ?>
                <div class="wpl_prp_show_detail_boxes">
                    <div class="wpl_prp_show_detail_boxes_title"><?php 
    echo __('Property Description', WPL_TEXTDOMAIN);
    ?>
</div>
                    <div class="wpl_prp_show_detail_boxes_cont" itemprop="description">
                        <?php 
    echo apply_filters('the_content', stripslashes($this->wpl_properties['current']['data'][$description_column]));
    ?>
                    </div>
                </div>
                <?php 
Пример #4
0
            echo $wpllang;
            ?>
" class="wpl-multiling-flag wpl-multiling-flag-<?php 
            echo strtolower(substr($wpllang, -2));
            echo empty($values[$lang_column]) ? ' wpl-multiling-empty' : '';
            ?>
"></div>
            <?php 
        }
        ?>
        </div>
        <div class="wpl-multiling-edit-btn"></div>
        <div class="wpl-multilang-field-cnt">
            <?php 
        foreach ($wpllangs as $wpllang) {
            $lang_column = wpl_addon_pro::get_column_lang_name($field->table_column, $wpllang, false);
            ?>
            <div class="wpl-lang-cnt" id="wpl_langs_cnt_<?php 
            echo $field->id;
            ?>
_<?php 
            echo strtolower($wpllang);
            ?>
">
                <label for="wpl_c_<?php 
            echo $field->id;
            ?>
_<?php 
            echo strtolower($wpllang);
            ?>
"><?php 
Пример #5
0
 /**
  * Returns column with multilingual columns
  * @author Howard <*****@*****.**>
  * @static
  * @param array $columns
  * @param string $table
  * @return array
  */
 public static function get_multilingual_columns($columns, $validation = true, $table = 'wpl_properties')
 {
     if (wpl_global::check_multilingual_status()) {
         $valid_columns = wpl_db::columns($table);
         $languages = wpl_addon_pro::get_wpl_languages();
         foreach ($columns as $column) {
             foreach ($languages as $language) {
                 $language_column = wpl_addon_pro::get_column_lang_name($column, $language, false);
                 if ($validation and in_array($language_column, $valid_columns)) {
                     $columns[] = $language_column;
                 } elseif (!$validation) {
                     $columns[] = $language_column;
                 }
             }
         }
     }
     return $columns;
 }
Пример #6
0
 /**
  * This is a very useful function for rendering whole data of property. you need to just pass property_id and get everything!
  * @author Howard <*****@*****.**>
  * @static
  * @param int $property_id
  * @param array $plisting_fields
  * @param array $property
  * @param array $params
  * @return array
  */
 public static function full_render($property_id, $plisting_fields = NULL, $property = NULL, $params = array())
 {
     /** get plisting fields **/
     if (!$plisting_fields) {
         $plisting_fields = self::get_plisting_fields();
     }
     $raw_data = self::get_property_raw_data($property_id);
     if (!$raw_data) {
         return array();
     }
     if (!$property) {
         $property = (object) $raw_data;
     }
     $column = 'rendered';
     if (wpl_global::check_multilingual_status()) {
         $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false);
     }
     /** generate rendered data if rendered data is empty **/
     if (!trim($raw_data[$column]) and wpl_settings::get('cache')) {
         $rendered = json_decode(wpl_property::generate_rendered_data($property_id), true);
     } elseif (!wpl_settings::get('cache')) {
         $rendered = array();
     } else {
         $rendered = json_decode($raw_data[$column], true);
     }
     $result = array();
     $result['data'] = (array) $property;
     if (!isset($rendered['rendered']) or !isset($rendered['materials'])) {
         /** render data on the fly **/
         $find_files = array();
         $rendered_fields = self::render_property($property, $plisting_fields, $find_files, true);
     }
     if (isset($rendered['rendered']) and $rendered['rendered']) {
         $result['rendered'] = $rendered['rendered'];
     } else {
         $result['rendered'] = $rendered_fields['ids'];
     }
     if (isset($rendered['materials']) and $rendered['materials']) {
         $result['materials'] = $rendered['materials'];
     } else {
         $result['materials'] = $rendered_fields['columns'];
     }
     $result['items'] = wpl_items::get_items($property_id, '', $property->kind, '', 1);
     $result['raw'] = $raw_data;
     /** location text **/
     $result['location_text'] = self::generate_location_text($raw_data);
     /** property full link **/
     $target_page = isset($params['wpltarget']) ? $params['wpltarget'] : 0;
     $result['property_link'] = self::get_property_link($raw_data, NULL, $target_page);
     $result['property_title'] = self::update_property_title($raw_data);
     return $result;
 }
Пример #7
0
 /**
  * Sets property single page parameters
  * @author Howard <*****@*****.**>
  * @param int $proeprty_id
  */
 public function set_property_page_params($proeprty_id)
 {
     _wpl_import('libraries.property');
     $current_link_url = wpl_global::get_full_url();
     $property_data = wpl_property::get_property_raw_data($proeprty_id);
     $locale = wpl_global::get_current_language();
     $this->property_page_title = wpl_property::update_property_page_title($property_data);
     $meta_keywords_column = 'meta_keywords';
     if (wpl_global::check_multilingual_status() and wpl_addon_pro::get_multiligual_status_by_column($meta_keywords_column, $property_data['kind'])) {
         $meta_keywords_column = wpl_addon_pro::get_column_lang_name($meta_keywords_column, $locale, false);
     }
     $this->property_keywords = $property_data[$meta_keywords_column];
     $meta_description_column = 'meta_description';
     if (wpl_global::check_multilingual_status() and wpl_addon_pro::get_multiligual_status_by_column($meta_description_column, $property_data['kind'])) {
         $meta_description_column = wpl_addon_pro::get_column_lang_name($meta_description_column, $locale, false);
     }
     $this->property_description = $property_data[$meta_description_column];
     $html = wpl_html::getInstance();
     /** set title **/
     $html->set_title($this->property_page_title);
     /** set meta keywords **/
     $html->set_meta_keywords($this->property_keywords);
     /** set meta description **/
     $html->set_meta_description($this->property_description);
     /** SET og meta parameters for social websites like facebook etc **/
     wpl_html::$canonical = str_replace('&', '&amp;', $current_link_url);
     $html->set_custom_tag('<meta property="og:type" content="property" />');
     $html->set_custom_tag('<meta property="og:locale" content="' . $locale . '" />');
     $content_column = 'field_308';
     if (wpl_global::check_multilingual_status() and wpl_addon_pro::get_multiligual_status_by_column($content_column, $property_data['kind'])) {
         $content_column = wpl_addon_pro::get_column_lang_name($content_column, $locale, false);
     }
     $html->set_custom_tag('<meta property="og:url" content="' . str_replace('&', '&amp;', $current_link_url) . '" />');
     $html->set_custom_tag('<meta property="og:title" data-page-subject="true" content="' . $this->property_page_title . '" />');
     $html->set_custom_tag('<meta property="og:description" content="' . strip_tags($property_data[$content_column]) . '" />');
     $html->set_custom_tag('<meta property="twitter:card" content="summary" />');
     $html->set_custom_tag('<meta property="twitter:title" content="' . $this->property_page_title . '" />');
     $html->set_custom_tag('<meta property="twitter:description" content="' . strip_tags($property_data[$content_column]) . '" />');
     $html->set_custom_tag('<meta property="twitter:url" content="' . str_replace('&', '&amp;', $current_link_url) . '" />');
     $gallery = wpl_items::get_gallery($proeprty_id, $property_data['kind']);
     if (is_array($gallery) and count($gallery)) {
         foreach ($gallery as $image) {
             $html->set_custom_tag('<meta property="og:image" content="' . $image['url'] . '" />');
             $html->set_custom_tag('<meta property="twitter:image" content="' . $image['url'] . '" />');
         }
     }
 }
Пример #8
0
    }
    $done_this = true;
} elseif ($format == 'parent' and !$done_this) {
    if ($value != '-1' and trim($value) != '') {
        /** converts listing id to property id **/
        if ($value) {
            $value = wpl_property::pid($value);
        }
        $query .= " AND `parent` = '" . $value . "'";
    }
    $done_this = true;
} elseif ($format == 'textsearch' and !$done_this) {
    if (trim($value) != '') {
        /** If the field is multilingual or it is textsearch field **/
        if (wpl_global::check_multilingual_status() and (wpl_addon_pro::get_multiligual_status_by_column($table_column, wpl_request::getVar('kind', 0)) or $table_column == 'textsearch')) {
            $table_column = wpl_addon_pro::get_column_lang_name($table_column, wpl_global::get_current_language(), false);
        }
        $query .= " AND `" . $table_column . "` LIKE '%" . $value . "%'";
    }
    $done_this = true;
} elseif ($format == 'text' and !$done_this) {
    if (trim($value) != '') {
        $query .= " AND `" . $table_column . "` LIKE '%" . $value . "%'";
    }
    $done_this = true;
} elseif ($format == 'unit' and !$done_this) {
    /** importing library **/
    _wpl_import('libraries.units');
    if ($value != '-1' and trim($value) != '') {
        $unit_data = wpl_units::get_unit($value);
        $min = isset($vars['sf_min_' . $table_column]) ? $vars['sf_min_' . $table_column] : 0;
Пример #9
0
        if (isset($options['if_zero']) and $options['if_zero'] == 2 and $value == '0') {
            $return['value'] = __($options['call_text'], WPL_TEXTDOMAIN);
        }
        if (isset($options['if_zero']) and !$options['if_zero'] and $value == '0') {
            $return = array();
        }
    }
    $done_this = true;
} elseif ($type == 'textarea' and !$done_this) {
    if (trim($value) != '') {
        $return['field_id'] = $field->id;
        $return['type'] = $field->type;
        $return['name'] = __($field->name, WPL_TEXTDOMAIN);
        if (isset($field->multilingual) and $field->multilingual and wpl_global::check_multilingual_status()) {
            $current_language = wpl_global::get_current_language();
            $lang_column = wpl_addon_pro::get_column_lang_name($field->table_column, $current_language, false);
            if (isset($values[$lang_column])) {
                $value = $values[$lang_column];
            }
        }
        $value = stripslashes($value);
        if (in_array($field->id, array(308, 1160))) {
            $value = apply_filters('the_content', $value);
        }
        $value = wpl_global::do_shortcode($value);
        $return['value'] = $value;
    }
    $done_this = true;
} elseif ($type == 'select' and !$done_this) {
    if (trim($value) and trim($value) != '-1') {
        $return['field_id'] = $field->id;
Пример #10
0
 /**
  * Returns property meta description, This function calls on sef service when meta description of listing is empty
  * @author Howard <*****@*****.**>
  * @static
  * @param array $property_data
  * @param int $property_id
  * @return string
  */
 public static function get_meta_description($property_data, $property_id = 0)
 {
     /** 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'];
     }
     $locale = wpl_global::get_current_language();
     $column = 'field_308';
     if (wpl_global::check_multilingual_status() and wpl_addon_pro::get_multiligual_status_by_column($column, $property_data['kind'])) {
         $column = wpl_addon_pro::get_column_lang_name($column, $locale, false);
     }
     $description = substr($property_data[$column], 0, 250);
     /** apply filters **/
     _wpl_import('libraries.filters');
     @extract(wpl_filters::apply('generate_meta_description', array('description' => $description, 'property_data' => $property_data)));
     return $description;
 }