示例#1
0
 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;
 }
示例#2
0
 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;
 }
示例#3
0
 /**
  * Returns property featured image if exists otherwise it returns empty string
  * @author Howard <*****@*****.**>
  * @static
  * @param int $property_id
  * @param string $sizes
  * @return string
  */
 public static function get_property_image($property_id, $sizes = '150*150')
 {
     if (!trim($property_id)) {
         return false;
     }
     if (!trim($sizes)) {
         $sizes = '150*150';
     }
     $images = wpl_items::render_gallery_custom_sizes($property_id, NULL, array($sizes));
     $size_alias = str_replace('*', '_', $sizes);
     return count($images) ? $images[$size_alias][0]['url'] : '';
 }