public function build() { $this->model = new wpl_property(); $property = (array) $this->model->get_property_raw_data($this->pid); /** no property found **/ if (!$property) { $this->error = "ERROR: Property id is not valid."; return false; } $items = wpl_items::get_items($this->pid, '', $property['kind'], '', 1); /** render gallery **/ $images = wpl_items::render_gallery($items['gallery']); $this->built['listing']['images'] = $images; return $this->built; }
public function build() { /** property listing model **/ $this->model = new wpl_property(); $property = (array) $this->model->get_property_raw_data($this->pid); /** no property found **/ if (!$property) { $this->error = "ERROR: Property id is not valid."; return false; } $this->pshow_fields = $this->model->get_pshow_fields('', $property['kind']); $this->pshow_categories = wpl_flex::get_categories('', '', " AND `enabled`>='1' AND `kind`='" . $property['kind'] . "' AND `pshow`='1'"); /** BUILD **/ $this->built['listing']['raw'] = $property; $find_files = array(); $rendered_fields = $this->model->render_property($property, $this->pshow_fields, $find_files, true); $this->built['listing']['materials'] = $rendered_fields['columns']; foreach ($this->pshow_categories as $pshow_category) { $pshow_cat_fields = $this->model->get_pshow_fields($pshow_category->id, $property['kind']); $this->built['listing']['rendered'][$pshow_category->id]['self'] = (array) $pshow_category; $this->built['listing']['rendered'][$pshow_category->id]['data'] = $this->model->render_property($property, $pshow_cat_fields); } $items = wpl_items::get_items($this->pid, '', $property['kind'], '', 1); /** render gallery **/ $this->built['listing']['images'] = wpl_items::render_gallery($items['gallery']); /** render attachments **/ $this->built['listing']['attachments'] = wpl_items::render_attachments($items['attachment']); /** render videos **/ $this->built['listing']['videos'] = wpl_items::render_videos($items['video']); /** render rooms **/ $this->built['listing']['rooms'] = $items['rooms']; /** render gallery custom sizes **/ if (is_array($this->image_sizes)) { $this->built['listing']['custom_sizes'] = wpl_items::render_gallery_custom_sizes($this->pid, $items['gallery'], $this->image_sizes); } /** property full link **/ $this->built['listing']['property_link'] = $this->model->get_property_link($property); /** location text **/ $this->built['listing']['location_text'] = $property['location_text']; /** render agent data **/ $rendered_agent = wpl_users::full_render($property['user_id']); unset($rendered_agent['data']); $this->built['listing']['agent'] = $rendered_agent; /** updating the visited times and etc **/ $this->model->property_visited($this->pid); return $this->built; }
/** * 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; }
public function display($instance = array()) { /** do cronjobs **/ _wpl_import('libraries.events'); wpl_events::do_cronjobs(); /** check access **/ if (!wpl_users::check_access('propertyshow')) { /** import message tpl **/ $this->message = __("You don't have access to this part!", WPL_TEXTDOMAIN); return parent::render($this->tpl_path, 'message', false, true); } $this->tpl = wpl_request::getVar('tpl', 'default'); /** property listing model **/ $this->model = new wpl_property(); $this->pid = wpl_request::getVar('pid', 0); $listing_id = wpl_request::getVar('mls_id', 0); if (trim($listing_id)) { $this->pid = wpl_property::pid($listing_id); wpl_request::setVar('pid', $this->pid); } $property = $this->model->get_property_raw_data($this->pid); /** no property found **/ if (!$property or $property['finalized'] == 0 or $property['confirmed'] == 0 or $property['deleted'] == 1 or $property['expired'] >= 1) { /** import message tpl **/ $this->message = __("No property found or it's not available now!", WPL_TEXTDOMAIN); return parent::render($this->tpl_path, 'message', false, true); } $this->pshow_fields = $this->model->get_pshow_fields('', $property['kind']); $this->pshow_categories = wpl_flex::get_categories('', '', " AND `enabled`>='1' AND `kind`='" . $property['kind'] . "' AND `pshow`='1'"); $wpl_properties = array(); /** define current index **/ $wpl_properties['current']['data'] = (array) $property; $wpl_properties['current']['raw'] = (array) $property; $find_files = array(); $rendered_fields = $this->model->render_property($property, $this->pshow_fields, $find_files, true); $wpl_properties['current']['rendered_raw'] = $rendered_fields['ids']; $wpl_properties['current']['materials'] = $rendered_fields['columns']; foreach ($this->pshow_categories as $pshow_category) { $pshow_cat_fields = $this->model->get_pshow_fields($pshow_category->id, $property['kind']); $wpl_properties['current']['rendered'][$pshow_category->id]['self'] = (array) $pshow_category; $wpl_properties['current']['rendered'][$pshow_category->id]['data'] = $this->model->render_property($property, $pshow_cat_fields); } $wpl_properties['current']['items'] = wpl_items::get_items($this->pid, '', $property['kind'], '', 1); /** property location text **/ $wpl_properties['current']['location_text'] = $this->model->generate_location_text((array) $property); /** property full link **/ $wpl_properties['current']['property_link'] = $this->model->get_property_link((array) $property); /** property page title **/ $wpl_properties['current']['property_page_title'] = $this->model->update_property_page_title($property); /** property title **/ $wpl_properties['current']['property_title'] = $this->model->update_property_title($property); /** apply filters (This filter must place after all proccess) **/ _wpl_import('libraries.filters'); @extract(wpl_filters::apply('property_listing_after_render', array('wpl_properties' => $wpl_properties))); $this->wpl_properties = $wpl_properties; $this->kind = $property['kind']; $this->property = $wpl_properties['current']; /** updating the visited times and etc **/ wpl_property::property_visited($this->pid); /** trigger event **/ wpl_global::event_handler('property_show', array('id' => $this->pid)); /** import tpl **/ $this->tpl = wpl_flex::get_kind_tpl($this->tpl_path, $this->tpl, $this->kind); return parent::render($this->tpl_path, $this->tpl, false, true); }
/** * Render gallery of a property based on custom sizes * @author Howard R <*****@*****.**> * @static * @param int $property_id * @param array $images * @param array $custom_sizes * @return array */ public static function render_gallery_custom_sizes($property_id, $images = '', $custom_sizes = array()) { $kind = wpl_property::get_property_kind($property_id); if (!$images) { $images = wpl_items::get_items($property_id, 'gallery', $kind); } /** no image gallery **/ if (!count($images)) { return array(); } $return = array(); foreach ($custom_sizes as $custom_size) { $custom_size = str_replace('*', '_', $custom_size); list($x, $y) = explode('_', $custom_size); if (trim($x) == '' or trim($y) == '') { continue; } if (!is_numeric($x) or !is_numeric($y)) { continue; } $i = 0; foreach ($images as $image) { /** force to array **/ $image = (array) $image; $source_path = self::get_path($image['parent_id'], $image['parent_kind']) . $image['item_name']; $source_url = self::get_folder($image['parent_id'], $image['parent_kind']) . $image['item_name']; $params = array('image_name' => $image['item_name'], 'image_source' => $source_path, 'image_parentid' => $image['parent_id'], 'image_parentkind' => $image['parent_kind']); /** taking care for external images **/ if ($image['item_cat'] != 'external') { $dest_url = wpl_images::create_gallary_image($x, $y, $params, 0, 0); $pathinfo = @pathinfo($dest_url); $dest_path = self::get_path($image['parent_id'], $image['parent_kind']) . $pathinfo['basename']; } else { $dest_url = $source_url; $pathinfo = @pathinfo($dest_url); $dest_path = $source_path; } $return[$custom_size][$i]['item_id'] = $image['id']; $return[$custom_size][$i]['custom_size'] = $custom_size; $return[$custom_size][$i]['path'] = $dest_path; $return[$custom_size][$i]['url'] = $dest_url; $return[$custom_size][$i]['size'] = @filesize($dest_path); $return[$custom_size][$i]['title'] = (string) $image['item_extra1']; $return[$custom_size][$i]['description'] = (string) $image['item_extra2']; $return[$custom_size][$i]['category'] = $image['item_cat']; $return[$custom_size][$i]['ext'] = $pathinfo['extension']; $return[$custom_size][$i]['raw'] = $image; $i++; } } return $return; }
</div> </div> <!-- The global progress bar --> <div id="progress_vid"> <div id="progress" class="progress progress-success progress-striped"> <div class="bar"></div> </div> </div> <div class="error_uploaded_message" id="error_ajax_vid"> </div> <!-- The container for the uploaded files --> <div id="video" class="video-list-wp wpl_files_container"> <ul class="ui-sortable" id="ajax_vid_sortable"> <?php // get uploaded videos and show them $vid_items = wpl_items::get_items($item_id, 'video', $this->kind, 'video', ''); $vid_folder = wpl_items::get_folder($item_id, $this->kind); $video_categories = wpl_items::get_item_categories('addon_video', $this->kind); $max_index_vid = 0; foreach ($vid_items as $video) { $video->index = intval($video->index); if ($max_index_vid < $video->index) { $max_index_vid = $video->index; } ?> <li class="ui-state-default" id="ajax_video<?php echo $video->index; ?> "> <input type="hidden" class="vid_name" value="<?php echo $video->item_name;
/** * 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; }
<?php /** no direct access * */ defined('_WPLEXEC') or die('Restricted access'); if ($type == 'googlemap' and !$done_this) { /** WPL Demographic addon **/ $demographic_objects = array(); if (wpl_global::check_addon('demographic')) { _wpl_import('libraries.addon_demographic'); $demographic = new wpl_addon_demographic(); $demographic_objects = wpl_items::get_items($item_id, 'demographic', $kind); } $w = 450; $h = 300; $ln_table_col = 'googlemap_ln'; $lt_table_col = 'googlemap_lt'; $javascript = (object) array('param1' => 'wpl-googlemap-api3', 'param2' => 'http' . (stristr(wpl_global::get_full_url(), 'https://') != '' ? 's' : '') . '://maps.google.com/maps/api/js?libraries=places,drawing&sensor=false', 'external' => true); wpl_extensions::import_javascript($javascript); ?> <script type="text/javascript"> wplj(document).ready(function() { try { wplj(".wpl_listing_all_location_container_locations, .wpl_c_field_42, .wpl_c_post_code, .wpl_c_street_no").change(function() { wpl_address_creator(); wpl_code_address(wplj("#wpl_map_address<?php echo $field->id; ?> ").val());
<!-- The global progress bar --> <div id="progress_att"> <div id="progress" class="progress progress-success progress-striped"> <div class="bar"></div> </div> </div> <div class="error_uploaded_message" id="error_ajax_att"> </div> <!-- The container for the uploaded files --> <div id="attaches" class="attachment-wp wpl_files_container"> <ul class="ui-sortable" id="ajax_att_sortable"> <?php // get uploaded attachments and show them $att_items = wpl_items::get_items($item_id, 'attachment', $this->kind, '', ''); $att_folder = wpl_items::get_folder($item_id, $this->kind); $attachment_categories = wpl_items::get_item_categories('attachment', $this->kind); $max_index_att = 0; foreach ($att_items as $attachment) { $attachment->index = intval($attachment->index); if ($max_index_att < $attachment->index) { $max_index_att = $attachment->index; } ?> <li class="ui-state-default" id="ajax_attachment<?php echo $attachment->index; ?> "> <input type="hidden" class="att_name" value="<?php echo $attachment->item_name;
<?php /** no direct access **/ defined('_WPLEXEC') or die('Restricted access'); if ($type == 'rooms' and !$done_this) { _wpl_import('libraries.items'); _wpl_import('libraries.room_types'); $room_items = wpl_items::get_items($item_id, 'rooms', $this->kind); $all_room_type = wpl_room_types::get_room_types(); ?> <script type="text/javascript"> function wpl_delete_room(id) { var ajax = wpl_run_ajax_query('<?php echo wpl_global::get_full_url(); ?> ', "wpl_format=b:listing:rooms&wpl_function=delete_room&pid=<?php echo $item_id; ?> &kind=<?php echo $this->kind; ?> &item_id=" + id); ajax.success(function(data) { wplj(".room_" + id).hide(500).remove(); }); } function wpl_save_room() {
<!-- The global progress bar --> <div id="progress_img"> <div id="progress" class="progress progress-success progress-striped"> <div class="bar"></div> </div> </div> <div class="error_uploaded_message" id="error_ajax_img"> </div> <!-- The container for the uploaded files --> <div id="files" class="gallary-images-wp wpl_files_container"> <ul class="ui-sortable" id="ajax_gal_sortable"> <?php // get uploaded images and show them $gall_items = wpl_items::get_items($item_id, 'gallery', $this->kind, '', ''); $image_folder = wpl_items::get_folder($item_id, $this->kind); $image_path = wpl_items::get_path($item_id, $this->kind); $image_categories = wpl_items::get_item_categories('gallery', $this->kind); $max_img_index = 0; foreach ($gall_items as $image) { $image->index = intval($image->index); if ($max_img_index < $image->index) { $max_img_index = $image->index; } /** set resize method parameters **/ $params = array(); $params['image_name'] = $image->item_name; $params['image_parentid'] = $image->parent_id; $params['image_parentkind'] = $image->parent_kind; $params['image_source'] = $image_path . $image->item_name;