/** * How to display the widget on the screen. */ public function widget($args, $instance) { $this->widget_id = $this->number; if ($this->widget_id < 0) { $this->widget_id = abs($this->widget_id) + 1000; } $this->widget_uq_name = 'wpla' . $this->widget_id; $this->instance = $instance; $widget_id = $this->widget_id; $this->css_class = isset($instance['data']['css_class']) ? $instance['data']['css_class'] : ''; /** render properties **/ $query = self::query($instance); $model = new wpl_users(); $profiles = $model->search($query); /** return if no property found **/ if (!count($profiles)) { return; } $plisting_fields = $model->get_plisting_fields(); $wpl_profiles = array(); $render_params['wpltarget'] = isset($instance['wpltarget']) ? $instance['wpltarget'] : 0; $params = array(); foreach ($profiles as $profile) { $wpl_profiles[$profile->id] = $model->full_render($profile->id, $plisting_fields, $profile, $render_params); $params['image_parentid'] = $profile->id; /** profile picture **/ if (isset($wpl_profiles[$profile->id]['profile_picture']['url'])) { $params['image_name'] = isset($wpl_profiles[$profile->id]['profile_picture']['name']) ? $wpl_profiles[$profile->id]['profile_picture']['name'] : ''; $profile_picture_path = isset($wpl_profiles[$profile->id]['profile_picture']['path']) ? $wpl_profiles[$profile->id]['profile_picture']['path'] : ''; $wpl_profiles[$profile->id]['profile_picture']['url'] = wpl_images::create_profile_images($profile_picture_path, $instance['data']['image_width'], $instance['data']['image_height'], $params); $wpl_profiles[$profile->id]['profile_picture']['image_width'] = isset($instance['data']['image_width']) ? $instance['data']['image_width'] : ''; $wpl_profiles[$profile->id]['profile_picture']['image_height'] = isset($instance['data']['image_height']) ? $instance['data']['image_height'] : ''; } /** company logo **/ if (isset($wpl_profiles[$profile->id]['company_logo']['url'])) { $params['image_name'] = isset($wpl_profiles[$profile->id]['company_logo']['name']) ? $wpl_profiles[$profile->id]['company_logo']['name'] : ''; $company_logo_path = isset($wpl_profiles[$profile->id]['company_logo']['path']) ? $wpl_profiles[$profile->id]['company_logo']['path'] : ''; $wpl_profiles[$profile->id]['company_logo']['url'] = wpl_images::create_profile_images($company_logo_path, $instance['data']['image_width'], $instance['data']['image_height'], $params); } } echo $args['before_widget']; $title = apply_filters('widget_title', $instance['title']); if (trim($title) != '') { echo $args['before_title'] . $title . $args['after_title']; } $layout = 'widgets.agents.tmpl.' . $instance['layout']; $layout = _wpl_import($layout, true, true); if (!wpl_file::exists($layout)) { $layout = _wpl_import('widgets.agents.tmpl.default', true, true); } elseif (wpl_file::exists($layout)) { require $layout; } else { echo __('Widget Layout Not Found!', WPL_TEXTDOMAIN); } echo $args['after_widget']; }
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; }
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; }
<?php /** no direct access **/ defined('_WPLEXEC') or die('Restricted access'); /** set params **/ $user_id = isset($params['user_id']) ? $params['user_id'] : ''; $wpl_properties = isset($params['wpl_properties']) ? $params['wpl_properties'] : NULL; $picture_width = isset($params['picture_width']) ? $params['picture_width'] : '90'; $picture_height = isset($params['picture_height']) ? $params['picture_height'] : '100'; $mailto = isset($params['mailto']) ? $params['mailto'] : 0; /** getting user id from current property (used in property_show and property_listing) **/ if (!trim($user_id)) { $user_id = $wpl_properties['current']['data']['user_id']; } $wpl_user = wpl_users::full_render($user_id, wpl_users::get_pshow_fields(), NULL, array(), true); /** resizing profile image **/ $params = array(); $params['image_parentid'] = $user_id; $params['image_name'] = isset($wpl_user['profile_picture']['name']) ? $wpl_user['profile_picture']['name'] : ''; $profile_path = isset($wpl_user['profile_picture']['path']) ? $wpl_user['profile_picture']['path'] : ''; $profile_image = wpl_images::create_profile_images($profile_path, $picture_width, $picture_height, $params); /** resizing company logo **/ $params = array(); $params['image_parentid'] = $user_id; $params['image_name'] = isset($wpl_user['company_logo']['name']) ? $wpl_user['company_logo']['name'] : ''; $logo_path = isset($wpl_user['company_logo']['path']) ? $wpl_user['company_logo']['path'] : ''; //$logo_image = isset($wpl_user['company_logo']['url']) ? $wpl_user['company_logo']['url'] : ''; $logo_image = wpl_images::create_profile_images($logo_path, $picture_width, $picture_height, $params); $agent_name = isset($wpl_user['materials']['first_name']['value']) ? $wpl_user['materials']['first_name']['value'] : ''; $agent_l_name = isset($wpl_user['materials']['last_name']['value']) ? $wpl_user['materials']['last_name']['value'] : ''; $company_name = isset($wpl_user['materials']['company_name']['value']) ? $wpl_user['materials']['company_name']['value'] : '';
defined('_WPLEXEC') or die('Restricted access'); /** set params **/ $user_id = isset($params['user_id']) ? $params['user_id'] : ''; $wpl_properties = isset($params['wpl_properties']) ? $params['wpl_properties'] : NULL; $picture_width = isset($params['picture_width']) ? $params['picture_width'] : '175'; $picture_height = isset($params['picture_height']) ? $params['picture_height'] : '145'; $mailto = isset($params['mailto']) ? $params['mailto'] : 0; $description_column = 'about'; if (wpl_global::check_multilingual_status() and wpl_addon_pro::get_multiligual_status_by_column($description_column, 2)) { $description_column = wpl_addon_pro::get_column_lang_name($description_column, wpl_global::get_current_language(), false); } /** getting user id from current property (used in property_show and property_listing) **/ if (!trim($user_id)) { $user_id = $wpl_properties['current']['data']['user_id']; } $wpl_user = wpl_users::full_render($user_id, wpl_users::get_plisting_fields()); /** resizing profile image **/ $params = array(); $params['image_parentid'] = $user_id; $params['image_name'] = isset($wpl_user['profile_picture']['name']) ? $wpl_user['profile_picture']['name'] : ''; $picture_path = isset($wpl_user['profile_picture']['path']) ? $wpl_user['profile_picture']['path'] : ''; $profile_image = wpl_images::create_profile_images($picture_path, $picture_width, $picture_height, $params); /** resizing company logo **/ $params = array(); $params['image_parentid'] = $user_id; $params['image_name'] = isset($wpl_user['company_logo']['name']) ? $wpl_user['company_logo']['name'] : ''; $logo_path = isset($wpl_user['company_logo']['path']) ? $wpl_user['company_logo']['path'] : ''; $logo_image = isset($wpl_user['company_logo']['url']) ? $wpl_user['company_logo']['url'] : ''; $agent_name = isset($wpl_user['materials']['first_name']['value']) ? $wpl_user['materials']['first_name']['value'] : ''; $agent_l_name = isset($wpl_user['materials']['last_name']['value']) ? $wpl_user['materials']['last_name']['value'] : ''; $company_name = isset($wpl_user['materials']['company_name']['value']) ? $wpl_user['materials']['company_name']['value'] : '';