/** * 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']; }
/** * This function will generate rendered data of user and save them into db * @author Howard R <*****@*****.**> * @static * @param int $user_id * @return string */ public static function generate_rendered_data($user_id) { _wpl_import('libraries.render'); /** get user data **/ $user_data = (array) wpl_users::get_wpl_user($user_id); /** location text **/ $location_text = wpl_users::generate_location_text($user_data); /** render data **/ $find_files = array(); $rendered_fields = self::render_profile($user_data, wpl_users::get_plisting_fields(), $find_files, true); $result = json_encode(array('rendered' => $rendered_fields['ids'], 'materials' => $rendered_fields['columns'], 'location_text' => $location_text)); $column = 'rendered'; if (wpl_global::check_multilingual_status()) { $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false); } $query = "UPDATE `#__wpl_users` SET `{$column}`='" . wpl_db::escape($result) . "' WHERE `id`='{$user_id}'"; /** update **/ wpl_db::q($query, 'update'); return $result; }
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'] : '';