/** * 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']; }
/** * Generate email files of user * @author Howard R <*****@*****.**> * @static * @param int $user_id */ public static function generate_email_files($user_id) { /** import library **/ _wpl_import('libraries.images'); $user_data = (array) wpl_users::get_user($user_id); $path = wpl_items::get_path($user_id, 2); /** delete images **/ if (wpl_file::exists($path . 'main_email.png')) { wpl_file::delete($path . 'main_email.png'); } if (wpl_file::exists($path . 'second_email.png')) { wpl_file::delete($path . 'second_email.png'); } if (is_object($user_data['data']) and trim($user_data['data']->wpl_data->main_email) != '') { wpl_images::text_to_image($user_data['data']->wpl_data->main_email, '000000', $path . 'main_email.png'); } if (is_object($user_data['data']) and trim($user_data['data']->wpl_data->secondary_email) != '') { wpl_images::text_to_image($user_data['data']->wpl_data->secondary_email, '000000', $path . 'second_email.png'); } }
if (isset($gallery["items"]["gallery"][0])) { $params = array(); $params['image_name'] = $gallery["items"]["gallery"][0]->item_name; $params['image_parentid'] = $gallery["items"]["gallery"][0]->parent_id; $params['image_parentkind'] = $gallery["items"]["gallery"][0]->parent_kind; $params['image_source'] = wpl_global::get_upload_base_path() . $params['image_parentid'] . DS . $params['image_name']; $image_title = wpl_property::update_property_title($gallery['raw']); if (isset($gallery['items']['gallery'][0]->item_extra2) and trim($gallery['items']['gallery'][0]->item_extra2) != '') { $image_alt = $gallery['items']['gallery'][0]->item_extra2; } else { $image_alt = $gallery['raw']['meta_keywords']; } $image_description = $gallery["items"]["gallery"][0]->item_extra2; if ($gallery["items"]["gallery"][0]->item_cat != 'external') { $image_url = wpl_images::create_gallary_image($image_width, $image_height, $params); $thumbnail_url = wpl_images::create_gallary_image($thumbnail_width, $thumbnail_height, $params); } else { $image_url = $gallery["items"]["gallery"][0]->item_extra3; $thumbnail_url = $gallery["items"]["gallery"][0]->item_extra3; } $larg_images .= ' <li> <img itemprop="image" src="' . $image_url . '" alt="' . $image_alt . '" style="width: ' . $image_width . 'px; height: ' . $image_height . 'px;" /> <div class="ei-title"> <h2>' . $image_title . '</h2> <h3>' . $gallery["rendered"][10]["value"] . ' - ' . $gallery["location_text"] . '</h3> <a itemprop="url" class="more_info" href="' . $gallery["property_link"] . '">' . __('More info', WPL_TEXTDOMAIN) . '</a> </div> </li>'; $thumbnail .= '<li><a href="#">' . $image_title . '</a><img src="' . $thumbnail_url . '" alt="' . $image_alt . '" width="' . $thumbnail_width . '" height="' . $thumbnail_height . '" style="width: ' . $thumbnail_width . 'px; height: ' . $thumbnail_height . 'px;" /></li>'; }
$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'] : ''; ?> <div class="wpl_agent_info" id="wpl_agent_info<?php echo $user_id; ?> " itemscope > <div class="wpl_agent_info_l"> <div class="image_container"> <div class="front <?php if ($logo_image) { echo 'has_logo'; }
echo '<div class="no_image_box"></div>'; } else { $image_url = $gallery[0]['url']; if (isset($gallery[0]['item_extra2'])) { $image_alt = $gallery[0]['item_extra2']; } elseif (isset($wpl_properties['current']['raw']['meta_keywords'])) { $image_alt = $wpl_properties['current']['raw']['meta_keywords']; } if ($this->resize and $this->image_width and $this->image_height and $this->img_category != 'external') { /** set resize method parameters **/ $params = array(); $params['image_name'] = $gallery[0]['raw']['item_name']; $params['image_parentid'] = $gallery[0]['raw']['parent_id']; $params['image_parentkind'] = $gallery[0]['raw']['parent_kind']; $params['image_source'] = $gallery[0]['path']; /** resize image if does not exist **/ $image_url = wpl_images::create_gallary_image($this->image_width, $this->image_height, $params, $this->watermark, $this->rewrite); } echo '<img itemprop="image" id="wpl_gallery_image' . $this->property_id . '" src="' . $image_url . '" class="wpl_gallery_image ' . $this->image_class . '" alt="' . $image_alt . '" width="' . $this->image_width . '" height="' . $this->image_height . '" style="width: ' . $this->image_width . 'px; height: ' . $this->image_height . 'px;" />'; } ?> <div class="wpl-listing-tags-wp"> <div class="wpl-listing-tags-cnt"> <?php /* Property tags */ echo $features . $hot_offer . $open_house . $forclosure; ?> </div> </div> </div>
<div id="main_infowindow"> <div class="main_infowindow_l"> <?php if (isset($property['items']['gallery'])) { $i = 0; $images_total = count($property['items']['gallery']); foreach ($property['items']['gallery'] as $key1 => $image) { /** 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'] = wpl_global::get_upload_base_path() . $image->parent_id . DS . $image->item_name; /** resize image if does not exist **/ if (isset($image->item_cat) and $image->item_cat != 'external') { $image_url = wpl_images::create_gallary_image($image_width, $image_height, $params); } else { $image_url = $image->item_extra3; } echo '<img itemprop="image" id="wpl_gallery_image' . $property_id . '_' . $i . '" src="' . $image_url . '" class="wpl_gallery_image" onclick="wpl_Plisting_slider(' . $i . ',' . $images_total . ',' . $property_id . ');" width="' . $image_width . '" height="' . $image_height . '" style="width: ' . $image_width . 'px; height: ' . $image_height . 'px;" />'; $i++; } } else { echo '<div class="no_image_box"></div>'; } ?> </div> <div class="main_infowindow_r"> <div class="main_infowindow_r_t"> <?php echo '<a itemprop="url" class="main_infowindow_title" href="' . $property['property_link'] . '">' . $property['property_title'] . '</a>';
/** * 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; }
/** * Returns image URL * @author Howard R <*****@*****.**> * @static * @param string $image * @return string|boolean */ public static function get_images_url($image = '') { /** first validation **/ if (trim($image) == '') { return false; } $path = wpl_global::get_wpl_root_path() . 'libraries' . DS . 'notifications' . DS . 'templates' . DS . 'cache' . DS . $image . '.png'; $url = wpl_global::get_wpl_url() . 'libraries/notifications/templates/cache/' . $image . '.png'; if (!wpl_file::exists($path)) { wpl_images::text_to_image($image, '000000', $path); } return $url; }
$image_thumbnail_url = $image['url']; if (isset($image['item_extra2'])) { $image_alt = $image['item_extra2']; } else { $image_alt = $wpl_properties['current']['raw']['meta_keywords']; } if ($this->resize and $this->image_width and $this->image_height and $image['category'] != 'external') { /** set resize method parameters **/ $params = array(); $params['image_name'] = $image['raw']['item_name']; $params['image_parentid'] = $image['raw']['parent_id']; $params['image_parentkind'] = $image['raw']['parent_kind']; $params['image_source'] = $image['path']; /** resize image if does not exist and add watermark **/ $image_url = wpl_images::create_gallary_image($this->image_width, $this->image_height, $params, $this->watermark, $this->rewrite); $image_thumbnail_url = wpl_images::create_gallary_image(100, 80, $params, $this->watermark, $this->rewrite); } /** start loading images **/ echo '<li><img src="' . $image_url . '" itemprop="image" class="wpl_gallery_image ' . $this->image_class . '" id="wpl_gallery_image' . $image['raw']['id'] . '" width="' . $this->image_width . '" height="' . $this->image_height . '" alt="' . $image_alt . '" /></li>'; $pager_box .= '<a data-slide-index="' . $i . '" href=""><img src="' . $image_thumbnail_url . '" width="100" height="80" style="width: 100px; height: 80px;" itemprop="image" alt="' . $image_alt . '" /></a>'; $i++; } echo '</ul>'; ?> <div id="bx-pager"> <?php echo '<div id="img_count">' . count($this->gallery) . '</div>' . $pager_box; ?> </div> <?php }
/** * Add watermark to an image * @author Francis R <*****@*****.**> * @param string $source: source file string path * @param string $dest : destination file string path * @param int $watermark: 0 if watermark is disable, 1 if watermark is enable * @param array $options: array consist of status, opacity, position and user_logo * @return string : destination file path */ public static function add_watermark_image($source, $dest, $options = '') { if ($options == '') { $options['status'] = 0; } if ($options['status'] != 1) { return; } $filename = $source; //default path for watermark $watermark = WPL_ABSPATH . 'assets' . DS . 'img' . DS . 'system' . DS; if (trim($options['url']) != '') { $watermark .= trim($options['url']); } if (!wpl_file::exists($watermark)) { return; } $source = strtolower($source); $extension = wpl_file::getExt($source); $w_extension = wpl_file::getExt($watermark); list($w_width, $w_height, $w_type, $w_attr) = getimagesize($filename); list($markwidth, $markheight, $w_type1, $w_attr1) = getimagesize($watermark); switch ($extension) { case 'jpg': case 'jpeg': $w_dest = imagecreatefromjpeg($filename); break; case 'gif': $w_dest = imagecreatefromgif($filename); break; case 'png': $w_dest = imagecreatefrompng($filename); break; default: return; } switch ($w_extension) { case 'jpg': case 'jpeg': $w_src = imagecreatefromjpeg($watermark); break; case 'gif': $w_src = imagecreatefromgif($watermark); break; case 'png': $w_src = imagecreatefrompng($watermark); break; default: return; } // Copy and merge $opacity = $options['opacity']; $position = strtolower($options['position']); switch ($position) { case 'center': wpl_images::imagecopymerge_alpha($w_dest, $w_src, $w_width - $markwidth >> 1, $w_height - $markheight >> 1, 0, 0, $markwidth, $markheight, $opacity); break; case 'left': wpl_images::imagecopymerge_alpha($w_dest, $w_src, $w_width - $markwidth > 1, $w_height - $markheight >> 1, 0, 0, $markwidth, $markheight, $opacity); break; case 'right': wpl_images::imagecopymerge_alpha($w_dest, $w_src, $w_width - $markwidth, $w_height - $markheight >> 1, 0, 0, $markwidth, $markheight, $opacity); break; case 'top': wpl_images::imagecopymerge_alpha($w_dest, $w_src, $w_width - $markwidth >> 1, $w_height - $markheight > 1, 0, 0, $markwidth, $markheight, $opacity); break; case 'bottom': wpl_images::imagecopymerge_alpha($w_dest, $w_src, $w_width - $markwidth >> 1, $w_height - $markheight, 0, 0, $markwidth, $markheight, $opacity); break; case 'top-left': wpl_images::imagecopymerge_alpha($w_dest, $w_src, $w_width - $markwidth > 1, $w_height - $markheight > 1, 0, 0, $markwidth, $markheight, $opacity); break; case 'top-right': wpl_images::imagecopymerge_alpha($w_dest, $w_src, $w_width - $markwidth, $w_height - $markheight > 1, 0, 0, $markwidth, $markheight, $opacity); break; case 'bottom-left': wpl_images::imagecopymerge_alpha($w_dest, $w_src, $w_width - $markwidth > 1, $w_height - $markheight, 0, 0, $markwidth, $markheight, $opacity); break; case 'bottom-right': wpl_images::imagecopymerge_alpha($w_dest, $w_src, $w_width - $markwidth, $w_height - $markheight, 0, 0, $markwidth, $markheight, $opacity); break; } if ($extension == 'jpg' || $extension == 'jpeg') { $quality = 95; if (wpl_global::check_addon('optimizer') && wpl_global::get_client() === 0) { $quality = wpl_addon_optimizer::optimize_image(wpl_addon_optimizer::IMAGE_JPEG, $w_dest); } ob_start(); imagejpeg($w_dest, NULL, $quality); $out_image = ob_get_clean(); wpl_file::write($dest, $out_image); } elseif ($extension == 'png') { $quality = 9; if (wpl_global::check_addon('optimizer') && wpl_global::get_client() === 0) { $quality = wpl_addon_optimizer::optimize_image(wpl_addon_optimizer::IMAGE_PNG, $w_dest); } ob_start(); imagepng($w_dest, NULL, $quality); $out_image = ob_get_clean(); wpl_file::write($dest, $out_image); } elseif ($extension == 'gif') { ob_start(); imagegif($w_dest); $out_image = ob_get_clean(); wpl_file::write($dest, $out_image); } imagedestroy($w_src); imagedestroy($w_dest); // Return Destination return $source; }
$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; $image_thumbnail_url = wpl_images::create_gallary_image(80, 60, $params, 1, 0); if ($image->item_cat == 'external') { $image_thumbnail_url = $image->item_extra3; } ?> <li class="ui-state-default" id="ajax_gallery<?php echo $image->index; ?> " > <input type="hidden" class="gal_name" value="<?php echo $image->item_name; ?> " /> <div class="image-box-wp"> <div class="image-wp">