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; }
public function build() { /** property listing model **/ $this->model = new wpl_property(); if (!in_array($this->kind, wpl_flex::get_valid_kinds())) { $this->error = "ERROR: Invalid property kind!"; return false; } $default_where = array('sf_select_confirmed' => 1, 'sf_select_finalized' => 1, 'sf_select_deleted' => 0, 'sf_select_expired' => 0, 'sf_select_kind' => $this->kind); $this->where = array_merge($default_where, $this->where); /** Add search conditions to the where **/ $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET')); $this->where = array_merge($vars, $this->where); /** start search **/ $this->model->start($this->start, $this->limit, $this->orderby, $this->order, $this->where); $this->model->total = $this->model->get_properties_count(); $this->built['listings']['total'] = $this->model->total; /** run the search **/ $query = $this->model->query(); $properties = $this->model->search(); /** finish search **/ $this->model->finish(); $plisting_fields = $this->model->get_plisting_fields(); foreach ($properties as $property) { $rendered = array(); $rendered = $this->model->full_render($property->id, $plisting_fields, $property); $rendered['property_id'] = $property->id; $items = $rendered['items']; /** render gallery **/ if ($this->pictures) { $rendered['images'] = wpl_items::render_gallery($items['gallery']); } /** render attachments **/ if ($this->attachments) { $rendered['attachments'] = wpl_items::render_attachments($items['attachment']); } /** render videos **/ if ($this->videos) { $rendered['videos'] = wpl_items::render_videos($items['video']); } /** render rooms **/ if ($this->rooms) { $rendered['rooms'] = $items['rooms']; } /** render gallery custom sizes **/ if (is_array($this->image_sizes)) { $rendered['custom_sizes'] = wpl_items::render_gallery_custom_sizes($property_id, $items['gallery'], $this->image_sizes); } /** render agent data **/ if ($this->agentinfo) { $rendered['agent'] = wpl_users::full_render($property->user_id); unset($rendered['agent']['data']); unset($rendered['agent']['items']); } unset($rendered['items']); $this->built['listings'][$property->id] = $rendered; } return $this->built; }
<?php /** no direct access **/ defined('_WPLEXEC') or die('Restricted access'); /** set params **/ $wpl_properties = isset($params['wpl_properties']) ? $params['wpl_properties'] : array(); $property_id = isset($wpl_properties['current']['data']['id']) ? $wpl_properties['current']['data']['id'] : NULL; $raw_attachments = isset($wpl_properties['current']['items']['attachment']) ? $wpl_properties['current']['items']['attachment'] : NULL; $attachments = wpl_items::render_attachments($raw_attachments); if (!count($attachments) or !is_array($attachments)) { return; } ?> <div class="wpl_attachments_container" id="wpl_attachments_container<?php echo $property_id; ?> "> <ul class="wpl_attachments_list_container clearfix"> <?php foreach ($attachments as $attachment) { ?> <li class="wpl_attachments_room type_<?php echo $attachment['ext']; ?> " id="wpl_attachments_attachment<?php echo $attachment['item_id']; ?> "> <a class="wpl_attachment_link" href="<?php echo $attachment['url']; ?>