<?php /*------------------------------------------------------------------------ # mod_authorlist - Author List Module # ------------------------------------------------------------------------ # author Joomla!Vargas # copyright Copyright (C) 2010 joomla.vargas.co.cr. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://joomla.vargas.co.cr # Technical Support: Forum - http://joomla.vargas.co.cr/forum -------------------------------------------------------------------------*/ defined('_JEXEC') or die; require_once __DIR__ . '/helper.php'; $list = modAuthorListHelper::getList($params); $moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx')); require JModuleHelper::getLayoutPath('mod_authorlist', $params->get('layout', 'default'));
public static function getThumbnail($item, &$params) { $width = $params->get('thumb_width', 30); $height = $params->get('thumb_height', 30); $proportion = $params->get('thumb_proportions', 'bestfit'); $img_type = $params->get('thumb_type', ''); $bgcolor = hexdec($params->get('thumb_bg', '#FFFFFF')); $def_image = $params->get('def_image', ''); $author_img = $item->image ? $item->image : $def_image; $img_name = pathinfo($author_img, PATHINFO_FILENAME); $img_ext = pathinfo($author_img, PATHINFO_EXTENSION); $img_path = JPATH_BASE . '/' . $author_img; $img_base = str_replace('modules/mod_authorlist/assets/', '', JURI::base(false)); $size = @getimagesize($img_path); $errors = array(); if (!$size) { $errors[] = 'There was a problem loading image ' . $img_name . '.' . $img_ext . ' in mod_authorlist'; } else { $sub_folder = $item->image ? '0' . substr($item->id, -1) : 'default'; if ($img_type) { $img_ext = $img_type; } $origw = $size[0]; $origh = $size[1]; if ($origw < $width && $origh < $height) { $width = $origw; $height = $origh; } $prefix = substr($proportion, 0, 1) . "_" . $width . "_" . $height . "_" . ($proportion == 'fill' ? $bgcolor . "_" : "") . ($item->image ? $item->id . "_" : ""); $thumb_file = $prefix . str_replace(array(JPATH_ROOT, ':', '/', '\\', '?', '&', '%20', ' '), '_', urlencode($img_name) . '.' . $img_ext); //$thumb_path = __DIR__ . '/thumbs/' . $sub_folder . '/' . $thumb_file; $thumb_path = dirname(__FILE__) . '/thumbs/' . $sub_folder . '/' . $thumb_file; $attribs = array(); if (file_exists($thumb_path)) { $size = @getimagesize($thumb_path); if ($size) { $attribs['width'] = $size[0]; $attribs['height'] = $size[1]; } } else { modAuthorListHelper::calculateSize($origw, $origh, $width, $height, $proportion, $newwidth, $newheight, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h); switch (strtolower($size['mime'])) { case 'image/png': $imagecreatefrom = "imagecreatefrompng"; break; case 'image/gif': $imagecreatefrom = "imagecreatefromgif"; break; case 'image/jpeg': $imagecreatefrom = "imagecreatefromjpeg"; break; default: $errors[] = "Unsupported image type {$img_name}.{$img_ext} " . $size['mime']; } if (!function_exists($imagecreatefrom)) { $errors[] = "Failed to process {$img_name}.{$img_ext} in mod_authorlist. Function {$imagecreatefrom} doesn't exist."; } $src_img = $imagecreatefrom($img_path); if (!$src_img) { $errors[] = "There was a problem to process image {$img_name}.{$img_ext} " . $size['mime'] . ' in mod_authorlist'; } $dst_img = ImageCreateTrueColor($width, $height); // $bgcolor = imagecolorallocatealpha($image, 200, 200, 200, 127); imagefill($dst_img, 0, 0, $bgcolor); if ($proportion == 'transparent') { imagecolortransparent($dst_img, $bgcolor); } imagecopyresampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $newwidth, $newheight, $src_w, $src_h); switch (strtolower($img_ext)) { case 'png': $imagefunction = "imagepng"; break; case 'gif': $imagefunction = "imagegif"; break; default: $imagefunction = "imagejpeg"; } if ($imagefunction == 'imagejpeg') { $result = @$imagefunction($dst_img, $thumb_path, 80); } else { $result = @$imagefunction($dst_img, $thumb_path); } imagedestroy($src_img); if (!$result) { if (!isset($disablepermissionwarning)) { $errors[] = 'Could not create image:<br />' . $thumb_path . ' in mod_authorlist.<br /> Check if the folder exists and if you have write permissions:<br /> ' . dirname(__FILE__) . '/thumbs/' . $sub_folder; } $disablepermissionwarning = true; } else { imagedestroy($dst_img); } } } if (count($errors)) { JError::raiseWarning(404, implode("\n", $errors)); return false; } $image = $img_base . "modules/mod_authorlist/thumbs/{$sub_folder}/" . urlencode(basename($thumb_path)); return JHTML::_('image', $image, $item->name, $attribs); }