function renderSIGP(&$row, &$params, $page = 0) { // API jimport('joomla.filesystem.file'); $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); // Requests $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); $layout = JRequest::getCmd('layout'); $page = JRequest::getCmd('page'); $secid = JRequest::getInt('secid'); $catid = JRequest::getInt('catid'); $itemid = JRequest::getInt('Itemid'); if (!$itemid) { $itemid = 999999; } // Dev requests $sigplt = JRequest::getCmd('sigplt'); $sigppe = JRequest::getCmd('sigppe'); $sigpw = JRequest::getInt('sigpw'); $sigph = JRequest::getInt('sigph'); // Assign paths $sitePath = JPATH_SITE; $siteUrl = JURI::root(true); if (version_compare(JVERSION, '1.6.0', 'ge')) { $pluginLivePath = $siteUrl . '/plugins/content/' . $this->plg_name . '/' . $this->plg_name; $defaultImagePath = 'images'; } else { $pluginLivePath = $siteUrl . '/plugins/content/' . $this->plg_name; $defaultImagePath = 'images/stories'; } // Check if plugin is enabled if (JPluginHelper::isEnabled('content', $this->plg_name) == false) { return; } // Bail out if the page format is not what we want $allowedFormats = array('', 'html', 'feed', 'json'); if (!in_array(JRequest::getCmd('format'), $allowedFormats)) { return; } // Simple performance check to determine whether plugin should process further if (JString::strpos($row->text, $this->plg_tag) === false) { return; } // expression to search for $regex = "#{" . $this->plg_tag . "}(.*?){/" . $this->plg_tag . "}#s"; // Find all instances of the plugin and put them in $matches preg_match_all($regex, $row->text, $matches); // Number of plugins $count = count($matches[0]); // Plugin only processes if there are any instances of the plugin in the text if (!$count) { return; } // Load the plugin language file the proper way JPlugin::loadLanguage('plg_content_' . $this->plg_name, JPATH_ADMINISTRATOR); // Check for basic requirements if (!extension_loaded('gd') && !function_exists('gd_info')) { JError::raiseNotice('', JText::_('JW_SIGP_PLG_NOTICE_01')); return; } if (!is_writable($sitePath . DS . 'cache')) { JError::raiseNotice('', JText::_('JW_SIGP_PLG_NOTICE_02')); return; } // Check if Simple Image Gallery is present and enabled and prompt to disable if (JPluginHelper::isEnabled('content', 'jw_simpleImageGallery') == true) { JError::raiseNotice('', JText::_('JW_SIGP_PLG_NOTICE_00')); return; } // ----------------------------------- Get plugin parameters ----------------------------------- // Get plugin info $plugin = JPluginHelper::getPlugin('content', $this->plg_name); // Control external parameters and set variable for controlling plugin layout within modules if (!$params) { $params = class_exists('JParameter') ? new JParameter(null) : new JRegistry(null); } $parsedInModule = $params->get('parsedInModule'); $pluginParams = JComponentHelper::getParams('com_sigpro'); $galleries_rootfolder = $params->get('galleries_rootfolder') ? $params->get('galleries_rootfolder') : $pluginParams->get('galleries_rootfolder', $defaultImagePath); $popup_engine = $pluginParams->get('popup_engine', 'jquery_fancybox'); $jQueryHandling = $pluginParams->get('jQueryHandling', '1.8'); $thb_template = $pluginParams->get('thb_template', 'Classic'); $thb_width = $pluginParams->get('thb_width', 200); $thb_height = $pluginParams->get('thb_height', 160); $smartResize = $pluginParams->get('smartResize', 1); $jpg_quality = $pluginParams->get('jpg_quality', 80); $singlethumbmode = $pluginParams->get('singlethumbmode', 0); $sortorder = $pluginParams->get('sortorder', '0'); $showcaptions = $pluginParams->get('showcaptions', 1); $wordLimit = $pluginParams->get('wordlimit', 0); $enabledownload = $pluginParams->get('enabledownload', 1); $loadmoduleposition = $pluginParams->get('loadmoduleposition', ''); $flickrApiKey = $pluginParams->get('flickrApiKey', '82a76fbf755902903859df58d1dd5934'); $flickrImageCount = $pluginParams->get('flickrImageCount', 20); $yqlMaxAge = $pluginParams->get('yqlMaxAge', 60) * 60; $resizeSrcImage = (int) $pluginParams->get('resizeSrcImage', 0); $cache_expire_time = $pluginParams->get('cache_expire_time', 120) * 60; // Cache expiration time in minutes // Advanced $memoryLimit = (int) $pluginParams->get('memoryLimit'); if ($memoryLimit) { ini_set("memory_limit", $memoryLimit . "M"); } $debugMode = $pluginParams->get('debugMode', 1); if ($debugMode == 0) { error_reporting(0); // Turn off all error reporting } // Cleanups // Remove first and last slash if they exist if (substr($galleries_rootfolder, 0, 1) == '/') { $galleries_rootfolder = substr($galleries_rootfolder, 1); } if (substr($galleries_rootfolder, -1, 1) == '/') { $galleries_rootfolder = substr($galleries_rootfolder, 0, -1); } // Includes require_once dirname(__FILE__) . DS . $this->plg_name . DS . 'includes' . DS . 'helper.php'; // Other assignments $transparent = $pluginLivePath . '/includes/images/transparent.gif'; $downloadFile = $enabledownload ? $pluginLivePath . '/includes/download.php' : NULL; $modulePosition = $loadmoduleposition ? htmlentities('<div class="sigProModulePosition">' . SimpleImageGalleryProHelper::loadModulePosition($loadmoduleposition, -1) . '</div>', ENT_QUOTES, 'utf-8') : NULL; // When used with K2 extra fields if (!isset($row->title)) { $row->title = ''; } // Variable cleanups for K2 if (JRequest::getCmd('format') == 'raw') { $this->plg_copyrights_start = ''; $this->plg_copyrights_end = ''; } // ----------------------------------- Prepare the output ----------------------------------- // Process plugin tags if (preg_match_all($regex, $row->text, $matches, PREG_PATTERN_ORDER) > 0) { // start the replace loop foreach ($matches[0] as $key => $match) { $tagcontent = preg_replace("/{.+?}/", "", $match); if (strpos($tagcontent, 'www.flickr.com') === false) { /* example tag: {gallery}folder:200:80:1:2:jquery_colorbox:Galleria{/gallery} */ $tagparams = explode(':', $tagcontent); $galleryFolder = $tagparams[0]; $gal_width = array_key_exists(1, $tagparams) && $tagparams[1] != '' ? $tagparams[1] : $thb_width; $gal_height = array_key_exists(2, $tagparams) && $tagparams[2] != '' ? $tagparams[2] : $thb_height; $gal_singlethumbmode = array_key_exists(3, $tagparams) && $tagparams[3] != '' ? $tagparams[3] : $singlethumbmode; $gal_captions = array_key_exists(4, $tagparams) && $tagparams[4] != '' ? $tagparams[4] : $showcaptions; $gal_engine = array_key_exists(5, $tagparams) && $tagparams[5] != '' ? $tagparams[5] : $popup_engine; $gal_template = array_key_exists(6, $tagparams) && $tagparams[6] != '' ? $tagparams[6] : $thb_template; // Backwards compatibility if ($gal_template == 'Default') { $gal_template = 'Classic'; } // Dev assignments if ($sigplt) { $gal_template = $sigplt; } if ($sigppe) { $gal_engine = $sigppe; } if ($sigpw) { $gal_width = $sigpw; } if ($sigph) { $gal_height = $sigph; } // HTML & CSS assignments if ($gal_singlethumbmode) { $singleThumbClass = ' singleThumbGallery'; } else { $singleThumbClass = ''; } // Normalize the source image folder if (strpos($galleryFolder, 'media/jw_sigpro/users') !== false) { $srcimgfolder = substr($galleryFolder, 1); } else { $srcimgfolder = $galleries_rootfolder . '/' . $galleryFolder; } // Create a unique gallery ID $gal_id = substr(md5($key . $srcimgfolder), 1, 10); $flickrSetUrl = null; // Render the gallery $gallery = SimpleImageGalleryProHelper::renderGallery($srcimgfolder, $gal_width, $gal_height, $smartResize, $jpg_quality, $sortorder, $gal_captions, $row->title, $wordLimit, $cache_expire_time, $downloadFile, $gal_id, $resizeSrcImage); if (!$gallery) { JError::raiseNotice('', JText::_('JW_SIGP_PLG_NOTICE_03') . ' ' . $srcimgfolder); continue; } } else { // Make sure we got PHP5 if (version_compare(PHP_VERSION, '5.0.0', '<')) { JError::raiseNotice('', JText::_('PHP 5 is required for Flickr sets to be rendered by Simple Image Gallery Pro. Please consult your hosting company for upgrading your server to PHP5.')); continue; } // Get the Flickr set /* example tag: {gallery}http://www.flickr.com/photos/joomlaworks/sets/72157626907305094/:20:200:80:1:2:jquery_colorbox:Galleria{/gallery} */ if (substr($tagcontent, 0, 4) != 'http') { $tagcontent = 'http://' . $tagcontent; } $tempFlickrParams = explode('://', $tagcontent); // remove the protocol so it doesn't mess with the produced param array $flickrParams = explode(':', $tempFlickrParams[1]); $flickrSetUrl = 'http://' . $flickrParams[0]; // re-insert the protocol $gal_count = array_key_exists(1, $flickrParams) && $flickrParams[1] != '' ? $flickrParams[1] : $flickrImageCount; $gal_width = array_key_exists(2, $flickrParams) && $flickrParams[2] != '' ? $flickrParams[2] : $thb_width; $gal_height = array_key_exists(3, $flickrParams) && $flickrParams[3] != '' ? $flickrParams[3] : $thb_height; $gal_singlethumbmode = array_key_exists(4, $flickrParams) && $flickrParams[4] != '' ? $flickrParams[4] : $singlethumbmode; $gal_captions = array_key_exists(5, $flickrParams) && $flickrParams[5] != '' ? $flickrParams[5] : $showcaptions; $gal_engine = array_key_exists(6, $flickrParams) && $flickrParams[6] != '' ? $flickrParams[6] : $popup_engine; $gal_template = array_key_exists(7, $flickrParams) && $flickrParams[7] != '' ? $flickrParams[7] : $thb_template; // Backwards compatibility if ($gal_template == 'Default') { $gal_template = 'Classic'; } // Dev assignments if ($sigplt) { $gal_template = $sigplt; } if ($sigppe) { $gal_engine = $sigppe; } if ($sigpw) { $gal_width = $sigpw; } if ($sigph) { $gal_height = $sigph; } // Get Flickr required stuff $flickrRegex = "#flickr.com/photos/(.*?)/sets/(.*?)/#s"; if (preg_match_all($flickrRegex, $flickrSetUrl, $flickrMatches, PREG_PATTERN_ORDER) > 0) { $flickrUsername = $flickrMatches[1][0]; $flickrSetId = $flickrMatches[2][0]; $flickrJson = 'http://query.yahooapis.com/v1/public/yql?q=' . urlencode('SELECT * FROM query.multi WHERE queries=\'SELECT * FROM flickr.photosets.info WHERE api_key="' . $flickrApiKey . '" and photoset_id="' . $flickrSetId . '"; SELECT * FROM flickr.photosets.photos(' . $gal_count . ') WHERE api_key="' . $flickrApiKey . '" and photoset_id="' . $flickrSetId . '" and extras="description, date_upload, date_taken, path_alias, url_sq, url_t, url_s, url_m, url_o"\'') . '&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys'; if ($yqlMaxAge) { $flickrJson .= '&_maxage=' . $yqlMaxAge; } $flickrJson .= '&callback='; $getFlickrJson = SimpleImageGalleryProHelper::readFile($flickrJson, 'jw_sigpro'); $getFlickrData = json_decode($getFlickrJson); if (is_null($getFlickrData)) { continue; } $flickrSetTitle = $getFlickrData->query->results->results[0]->photoset->title; // Initiate array to hold gallery $gallery = array(); $galleryData = @$getFlickrData->query->results->results[1]->photo; if (!count($galleryData)) { continue; } foreach ($galleryData as $key => $photo) { $gallery[$key] = new stdClass(); // Caption display if ($gal_captions == 2) { $gallery[$key]->captionTitle = $photo->title; if (!$photo->description) { $photo->description = $photo->title; } $gallery[$key]->captionDescription = $photo->description . ' - ' . JText::_('JW_SIGP_LABELS_11') . ' <a href="' . $flickrSetUrl . '">' . $flickrSetTitle . '</a> ' . JText::_('JW_SIGP_LABELS_12') . ' <a target="_blank" href="http://www.flickr.com/photos/' . $flickrUsername . '">' . $flickrUsername . '</a>'; } elseif ($gal_captions == 1) { $gallery[$key]->captionTitle = JText::_('JW_SIGP_LABELS_09'); $gallery[$key]->captionDescription = JText::_('JW_SIGP_LABELS_10') . ' <a target="_blank" href="' . $flickrSetUrl . '">' . $flickrSetTitle . '</a> ' . JText::_('JW_SIGP_LABELS_12') . ' <a target="_blank" href="http://www.flickr.com/photos/' . $flickrUsername . '">' . $flickrUsername . '</a>'; } else { $gallery[$key]->captionTitle = ''; $gallery[$key]->captionDescription = ''; } $gallery[$key]->captionTitle = htmlentities(strip_tags($gallery[$key]->captionTitle), ENT_QUOTES, 'utf-8'); if ($wordLimit) { $gallery[$key]->captionTitle = SimpleImageGalleryProHelper::wordLimit($gallery[$key]->captionTitle, $wordLimit); } $gallery[$key]->captionDescription = htmlentities($gallery[$key]->captionDescription, ENT_QUOTES, 'utf-8'); if (!isset($photo->url_o)) { $photo->url_o = $photo->url_m; } if ($downloadFile) { $gallery[$key]->downloadLink = SimpleImageGalleryProHelper::replaceHtml('<br /><a class="sigProDownloadLink" target="_blank" href="' . $photo->url_o . '" download>' . JText::_('JW_SIGP_LABELS_13') . '</a>'); } else { $gallery[$key]->downloadLink = ''; } $tempFlickrFilename = array_slice(explode('/', substr($photo->url_m, 0, -4) . '_b.jpg'), -1); $gallery[$key]->filename = $tempFlickrFilename[0]; $gallery[$key]->sourceImageFilePath = substr($photo->url_m, 0, -4) . '_b.jpg'; if ($resizeSrcImage) { $gallery[$key]->sourceImageFilePath = 'http://src' . rand(1, 6) . '.sencha.io/' . $resizeSrcImage . '/' . $gallery[$key]->sourceImageFilePath; } $gallery[$key]->thumbImageFilePath = $photo->url_s; $gallery[$key]->width = $gal_width; $gallery[$key]->height = $gal_height; } // HTML & CSS assignments if ($gal_singlethumbmode) { $singleThumbClass = ' singleThumbGallery'; } else { $singleThumbClass = ''; } $gal_id = substr(md5($key . $getFlickrData->query->results->results[0]->photoset->id), 1, 10); } else { JError::raiseNotice('', JText::_('JW_SIGP_PLG_NOTICE_03')); continue; } } // CSS & JS includes: Append head includes, but not when we're outputing raw content (like in K2) if (JRequest::getCmd('format') == '' || JRequest::getCmd('format') == 'html') { // Initiate variables $relName = ''; $extraClass = ''; $extraWrapperClass = ''; $legacyHeadIncludes = ''; $customLinkAttributes = ''; $popupPath = "{$pluginLivePath}/includes/js/{$gal_engine}"; $popupRequire = dirname(__FILE__) . DS . $this->plg_name . DS . 'includes' . DS . 'js' . DS . $gal_engine . DS . 'popup.php'; if (file_exists($popupRequire) && is_readable($popupRequire)) { require $popupRequire; } if (version_compare(JVERSION, '1.6.0', 'ge')) { JHtml::_('behavior.framework'); } else { JHTML::_('behavior.mootools'); } if (count($stylesheets)) { foreach ($stylesheets as $stylesheet) { $document->addStyleSheet($popupPath . '/' . $stylesheet); } } if (count($stylesheetDeclarations)) { foreach ($stylesheetDeclarations as $stylesheetDeclaration) { $document->addStyleDeclaration($stylesheetDeclaration); } } if (strpos($gal_engine, 'jquery_') !== false && $jQueryHandling != 0 || $gal_template == 'Galleria') { if (version_compare(JVERSION, '3.0', 'ge') !== false) { JHtml::_('jquery.framework'); } else { if ($jQueryHandling == '1.9') { $document->addScript('//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'); } else { $document->addScript('//ajax.googleapis.com/ajax/libs/jquery/' . $jQueryHandling . '/jquery.min.js'); } } } if (count($scripts)) { foreach ($scripts as $script) { if (substr($script, 0, 4) == 'http' || substr($script, 0, 2) == '//') { $document->addScript($script); } else { $document->addScript($popupPath . '/' . $script); } } } if (count($scriptDeclarations)) { foreach ($scriptDeclarations as $scriptDeclaration) { $document->addScriptDeclaration($scriptDeclaration); } } if ($legacyHeadIncludes) { $document->addCustomTag($this->plg_copyrights_start . $legacyHeadIncludes . $this->plg_copyrights_end); } if ($extraClass) { $extraClass = ' ' . $extraClass; } if ($extraWrapperClass) { $extraWrapperClass = ' ' . $extraWrapperClass; } if ($customLinkAttributes) { $customLinkAttributes = ' ' . $customLinkAttributes; } $pluginCSS = SimpleImageGalleryProHelper::getTemplatePath($this->plg_name, 'css/template.css', $gal_template); $pluginCSS = $pluginCSS->http; $document->addStyleSheet($pluginCSS, 'text/css', 'screen'); // Print CSS $document->addStyleSheet($pluginLivePath . '/includes/css/print.css', 'text/css', 'print'); // Message to show when printing an article/item with a gallery $websiteURL = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off" ? "https://" . $_SERVER['HTTP_HOST'] : "http://" . $_SERVER['HTTP_HOST']; $itemPrintURL = $websiteURL . $_SERVER['REQUEST_URI']; $itemPrintURL = explode("#", $itemPrintURL); $itemPrintURL = $itemPrintURL[0] . '#sigProId' . $gal_id; } else { $itemPrintURL = false; } // Fetch the template ob_start(); $templatePath = SimpleImageGalleryProHelper::getTemplatePath($this->plg_name, 'default.php', $gal_template); $templatePath = $templatePath->file; include $templatePath; $getTemplate = $this->plg_copyrights_start . ob_get_contents() . $this->plg_copyrights_end; ob_end_clean(); // Output $plg_html = $getTemplate; // Do the replace $row->text = preg_replace("#{" . $this->plg_tag . "}" . $tagcontent . "{/" . $this->plg_tag . "}#s", $plg_html, $row->text); } // end foreach // Global head includes if (JRequest::getCmd('format') == '' || JRequest::getCmd('format') == 'html') { $document->addScript($pluginLivePath . '/includes/js/behaviour.js'); } } // end if }
function renderGallery($srcimgfolder, $thb_width, $thb_height, $smartResize, $jpg_quality, $sortorder, $showcaptions, $itemTitle, $wordLimit, $cache_expire_time, $downloadFile, $gal_id) { // API jimport('joomla.filesystem.folder'); // Get site language $language = JFactory::getLanguage(); $currentLanguage = $language->getTag(); $defaultLanguage = $language->getDefault(); // Path assignment $sitePath = JPATH_SITE . '/'; $siteUrl = JURI::root(true) . '/'; // Internal parameters $prefix = "jwsigpro_cache_"; $captionDummyTitle = JText::_('JW_SIGP_LABELS_01'); $captionDummyDesc = JText::_('JW_SIGP_LABELS_02'); // Set the cache folder $cacheFolderPath = JPATH_SITE . DS . 'cache' . DS . 'jw_sigpro'; if (file_exists($cacheFolderPath) && is_dir($cacheFolderPath)) { // all OK } else { mkdir($cacheFolderPath); } // Check if the source folder exists and read it $srcFolder = JFolder::files($sitePath . $srcimgfolder); // Proceed if the folder is OK or fail silently if (!$srcFolder) { return; } // Loop through the source folder for images $fileTypes = array('jpg', 'jpeg', 'gif', 'png'); // Create an array of file types $found = array(); // Create an array for matching files foreach ($srcFolder as $srcImage) { $fileInfo = pathinfo($srcImage); if (array_key_exists('extension', $fileInfo) && in_array(strtolower($fileInfo['extension']), $fileTypes)) { $found[] = $srcImage; } } // Bail out if there are no images found if (count($found) == 0) { return; } // Sort array switch ($sortorder) { case 0: sort($found); break; case 1: natsort($found); break; // Sort in natural, case-sensitive order // Sort in natural, case-sensitive order case 2: natcasesort($found); break; // Sort in natural, case-insensitive order // Sort in natural, case-insensitive order case 3: rsort($found); break; case 4: shuffle($found); break; } // Caption handling $defaultCaptionFilePath = JPATH_SITE . DS . str_replace('/', DS, $srcimgfolder) . DS . $defaultLanguage . '.labels.txt'; $currentCaptionFilePath = JPATH_SITE . DS . str_replace('/', DS, $srcimgfolder) . DS . $currentLanguage . '.labels.txt'; $legacyCaptionFilePath = JPATH_SITE . DS . str_replace('/', DS, $srcimgfolder) . DS . 'labels.txt'; if ($currentLanguage == $defaultLanguage) { if (file_exists($legacyCaptionFilePath)) { $captionFile = "labels.txt"; } else { $captionFile = $defaultLanguage . ".labels.txt"; } } else { $captionFile = $currentLanguage . ".labels.txt"; } $captionFilePath = JPATH_SITE . DS . str_replace('/', DS, $srcimgfolder) . DS . $captionFile; if (file_exists($captionFilePath) && is_readable($captionFilePath)) { // read the captions file into an array $captionsfile = file($captionFilePath); foreach ($captionsfile as $caption) { $temp = explode("|", $caption); if (isset($temp[0]) && file_exists(JPATH_SITE . DS . $srcimgfolder . DS . $temp[0])) { $captions[JPATH_SITE . DS . $srcimgfolder . DS . strtolower($temp[0])]['title'] = @$temp[1]; // maintain backwards compatibility regarding captions if (isset($temp[2])) { $captions[JPATH_SITE . DS . $srcimgfolder . DS . strtolower($temp[0])]['description'] = @$temp[2]; } else { $captions[JPATH_SITE . DS . $srcimgfolder . DS . strtolower($temp[0])]['description'] = @$temp[1]; } } } } else { if ($showcaptions == 2) { // Check if a captions file exists and if not write a new captions file and fill it with the image file list and content placeholders $captionsfile = fopen($captionFilePath, 'w'); foreach ($found as $filename) { fwrite($captionsfile, "{$filename}|{$captionDummyTitle}|{$captionDummyDesc}\n"); } fclose($captionsfile); // Read the new file $newcaptionsfile = file($captionFilePath); foreach ($newcaptionsfile as $caption) { $temp = explode("|", $caption); if (isset($temp[0]) && file_exists(JPATH_SITE . DS . $srcimgfolder . "/" . $temp[0])) { $captions[JPATH_SITE . DS . $srcimgfolder . "/" . strtolower($temp[0])]['title'] = @$temp[1]; $captions[JPATH_SITE . DS . $srcimgfolder . "/" . strtolower($temp[0])]['description'] = @$temp[2]; } } } } // Initiate array to hold gallery $gallery = array(); // Loop through the image file list foreach ($found as $key => $filename) { // Determine thumb image filename if (strtolower(substr($filename, -4, 4)) == 'jpeg') { $thumbfilename = substr($filename, 0, -4) . 'jpg'; } elseif (strtolower(substr($filename, -3, 3)) == 'gif' || strtolower(substr($filename, -3, 3)) == 'png' || strtolower(substr($filename, -3, 3)) == 'jpg') { $thumbfilename = substr($filename, 0, -3) . 'jpg'; } // Object to hold each image elements $gallery[$key] = new JObject(); // Assign source image and path to a variable $original = $sitePath . str_replace('/', DS, $srcimgfolder) . DS . $filename; // Caption display if ($showcaptions == 2) { $gallery[$key]->captionTitle = $captions[JPATH_SITE . DS . $srcimgfolder . DS . strtolower($filename)]['title']; $gallery[$key]->captionDescription = $captions[JPATH_SITE . DS . $srcimgfolder . DS . strtolower($filename)]['description']; } elseif ($showcaptions == 1) { $gallery[$key]->captionTitle = JText::_('JW_SIGP_LABELS_03'); $gallery[$key]->captionDescription = JText::_('JW_SIGP_LABELS_04') . '<br /><span class="sigProPopupCaption">' . $itemTitle . "</span>"; } else { $gallery[$key]->captionTitle = ''; $gallery[$key]->captionDescription = ''; } if ($wordLimit) { $gallery[$key]->captionTitle = SimpleImageGalleryProHelper::wordLimit($gallery[$key]->captionTitle, $wordLimit); } $gallery[$key]->captionTitle = htmlentities(strip_tags($gallery[$key]->captionTitle), ENT_QUOTES, 'utf-8'); $gallery[$key]->captionDescription = htmlentities($gallery[$key]->captionDescription, ENT_QUOTES, 'utf-8'); if ($downloadFile) { $gallery[$key]->downloadLink = SimpleImageGalleryProHelper::replaceHtml('<br /><br /><a class="sigProDownloadLink" href="' . $downloadFile . '?file=' . $srcimgfolder . '/' . SimpleImageGalleryProHelper::replaceWhiteSpace($filename) . '">' . JText::_('JW_SIGP_LABELS_05') . '</a>'); } else { $gallery[$key]->downloadLink = ''; } // Check if thumb image exists already $thumbimage = $cacheFolderPath . DS . $prefix . $gal_id . '_' . strtolower(SimpleImageGalleryProHelper::replaceWhiteSpace($thumbfilename)); if (file_exists($thumbimage) && is_readable($thumbimage) && filemtime($thumbimage) + $cache_expire_time > time()) { // do nothing } else { // Otherwise create the thumb image // begin by getting the details of the original list($width, $height, $type) = getimagesize($original); // strip the extension off the image filename (case insensitive) //$imagetypes = array('/\.gif$/i', '/\.jpg$/i', '/\.jpeg$/i', '/\.png$/i'); //$name = preg_replace($imagetypes, '', basename($original)); // create an image resource for the original switch ($type) { case 1: $source = @imagecreatefromgif($original); if (!$source) { JError::raiseNotice('', JText::_('JW_SIGP_LABELS_06')); return; } break; case 2: $source = imagecreatefromjpeg($original); break; case 3: $source = imagecreatefrompng($original); break; default: $source = NULL; } // Bail out if the image resource is not OK if (!$source) { JError::raiseNotice('', JText::_('JW_SIGP_LABELS_07')); return; } // calculate thumbnails $thumbnail = SimpleImageGalleryProHelper::thumbDimCalc($width, $height, $thb_width, $thb_height, $smartResize); $thumb_width = $thumbnail['width']; $thumb_height = $thumbnail['height']; // create an image resource for the thumbnail $thumb = imagecreatetruecolor($thumb_width, $thumb_height); // create the resized copy imagecopyresampled($thumb, $source, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height); // convert and save all thumbs to .jpg $success = imagejpeg($thumb, $thumbimage, $jpg_quality); // Bail out if there is a problem in the GD conversion if (!$success) { return; } // remove the image resources from memory imagedestroy($source); imagedestroy($thumb); } // Assemble the image elements $gallery[$key]->filename = $filename; $gallery[$key]->sourceImageFilePath = $siteUrl . $srcimgfolder . '/' . SimpleImageGalleryProHelper::replaceWhiteSpace($filename); $gallery[$key]->thumbImageFilePath = $siteUrl . 'cache/jw_sigpro/' . $prefix . $gal_id . '_' . strtolower(SimpleImageGalleryProHelper::replaceWhiteSpace($thumbfilename)); $gallery[$key]->width = $thb_width; $gallery[$key]->height = $thb_height; } // foreach loop // OUTPUT return $gallery; }