/** * 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; }
/** * Get language .mo path * @author Howard <*****@*****.**> * @static * @param string $locale * @return string */ public static function get_language_mo_path($locale = NULL) { if (!$locale) { $locale = wpl_global::get_current_language(); } $path = WP_LANG_DIR . DS . WPL_BASENAME . DS . WPL_TEXTDOMAIN . '-' . $locale . '.mo'; if (!wpl_file::exists($path)) { $path = wpl_global::get_wpl_root_path() . 'languages' . DS . WPL_TEXTDOMAIN . '-' . $locale . '.mo'; } return $path; }
</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
<?php /** no direct access **/ defined('_WPLEXEC') or die('Restricted access'); if ($type == 'meta_desc' and !$done_this) { $current_language = wpl_global::get_current_language(); if (isset($field->multilingual) and $field->multilingual == 1 and wpl_global::check_multilingual_status()) { wp_enqueue_script('jquery-effects-clip', false, array('jquery-effects-core')); ?> <label class="wpl-multiling-label wpl-multiling-text"> <?php echo __($label, WPL_TEXTDOMAIN); ?> <?php if (in_array($mandatory, array(1, 2))) { ?> <span class="required-star">*</span><?php } ?> </label> <div class="wpl-multiling-field wpl-multiling-text"> <div class="wpl-multiling-flags-wp"> <div class="wpl-multiling-flag-cnt"> <?php foreach ($wpllangs as $wpllang) { $lang_column = wpl_addon_pro::get_column_lang_name($field->table_column, $wpllang, false); ?> <div data-wpl-field="wpl_c_<?php echo $field->id; ?>
/** * 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; }
/** * 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('&', '&', $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('&', '&', $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('&', '&', $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'] . '" />'); } } }
} $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;
/** * 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; }