Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version 4.4.4 / 5.0.0 #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions plugin/jw_sig.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.plugin.plugin');
use Joomla\CMS\Plugin\CMSPlugin as JPlugin;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Uri\Uri as JURI;
use Joomla\CMS\Plugin\PluginHelper as JPluginHelper;
use Joomla\Registry\Registry as JRegistry;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\HTML\HTMLHelper as JHtml;

if (version_compare(JVERSION, '2.5.0', 'ge')) {
jimport('joomla.html.parameter');
}
Expand Down Expand Up @@ -119,6 +126,7 @@ public function renderSimpleImageGallery(&$row, &$params, $page = 0)

// Check for basic requirements
if (!extension_loaded('gd') && !function_exists('gd_info')) {

if (version_compare(JVERSION, '4', 'ge')) {
$app->enqueueMessage(JText::_('JW_PLG_SIG_NOTICE_01'), 'notice');
} else {
Expand All @@ -127,6 +135,7 @@ public function renderSimpleImageGallery(&$row, &$params, $page = 0)
return;
}
if (!is_writable($sitePath.'/cache')) {

if (version_compare(JVERSION, '4', 'ge')) {
$app->enqueueMessage(JText::_('JW_PLG_SIG_NOTICE_02'), 'notice');
} else {
Expand All @@ -142,6 +151,7 @@ public function renderSimpleImageGallery(&$row, &$params, $page = 0)

// Check if Simple Image Gallery Free (old) is present and show a warning
if (JPluginHelper::isEnabled('content', 'jw_simpleImageGallery') == true) {

if (version_compare(JVERSION, '4', 'ge')) {
$app->enqueueMessage(JText::_('JW_PLG_SIG_NOTICE_OLD_SIG'), 'notice');
} else {
Expand Down Expand Up @@ -245,7 +255,7 @@ public function renderSimpleImageGallery(&$row, &$params, $page = 0)
$gallery = $SIGHelper->renderGallery();

if (!$gallery) {
if (version_compare(JVERSION, '4', 'ge')) {
if (version_compare(JVERSION, '4', 'ge')) {
$app->enqueueMessage(JText::_('JW_PLG_SIG_NOTICE_03'), 'notice');
} else {
JError::raiseNotice('', JText::_('JW_PLG_SIG_NOTICE_03'));
Expand Down
76 changes: 55 additions & 21 deletions plugin/jw_sig/includes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@

// no direct access
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Uri\Uri as JUri;
use Joomla\CMS\Filesystem\Folder as JFolder;
use Joomla\CMS\Filesystem\File as JFile;
use Joomla\CMS\Object\CMSObject as JObject;

class SimpleImageGalleryHelper
{
public $srcimgfolder;
Expand All @@ -20,6 +25,34 @@ class SimpleImageGalleryHelper
public $cache_expire_time;
public $gal_id;
public $format;

public function read_image($original_file)
{
$original_extension = strtolower(pathinfo($original_file, PATHINFO_EXTENSION));
$exif_data = exif_read_data($original_file);
$exif_orientation = $exif_data['Orientation'];
// load the image
if($original_extension == "jpg" or $original_extension == "jpeg"){
$original_image = imagecreatefromjpeg($original_file);
}
if($original_extension == "gif"){
$original_image = imagecreatefromgif($original_file);
}
if($original_extension == "png"){
$original_image = imagecreatefrompng($original_file);
}
if($exif_orientation=='3' or $exif_orientation=='6' or $exif_orientation=='8'){
$new_angle[3] = 180;
$new_angle[6] = -90;
$new_angle[8] = 90;
imagesetinterpolation($original_image, IMG_MITCHELL);
$rotated_image = imagerotate($original_image, $new_angle[$exif_orientation], 0);
imagedestroy($original_image);
}else {
$rotated_image = $original_image;
}
return $rotated_image;
}

public function renderGallery()
{
Expand All @@ -39,16 +72,18 @@ public function renderGallery()
// Path assignment
$sitePath = JPATH_SITE.'/';
if ($format == 'feed') {
$siteUrl = JURI::root(true).'';
$siteUrl = JUri::root(true).'';
} else {
$siteUrl = JURI::root(true).'/';
$siteUrl = JUri::root(true).'/';
}

// Internal parameters
$prefix = "jw_sig_cache_";

// Set the cache folder
$cacheFolderPath = JPATH_SITE.'/cache/jw_sig';
//$cacheFolderPath = JPATH_SITE.'/cache/jw_sig';
$cacheFolderPath = $sitePath.$srcimgfolder . '/jw_sig';
$cacheFolderUrl = $siteUrl.$srcimgfolder . '/jw_sig';
if (file_exists($cacheFolderPath) && is_dir($cacheFolderPath)) {
// all OK
} else {
Expand Down Expand Up @@ -113,22 +148,17 @@ public function renderGallery()
// Otherwise create the thumb image

// Begin by getting the details of the original
list($width, $height, $type) = getimagesize($original);
list($originalwidth, $originalheight, $type) = getimagesize($original);

// Create an image resource for the original
switch ($type) {
case 1:
// GIF
$source = imagecreatefromgif($original);
break;
case 1:
case 2:
// JPEG
$source = imagecreatefromjpeg($original);
break;
case 3:
// PNG
$source = imagecreatefrompng($original);
break;
//take into account orientation see https://www.php.net/manual/en/function.exif-read-data.php#121742
$source = $this->read_image($original);

break;
case 18:
// WEBP
if (version_compare(PHP_VERSION, '7.1.0', 'ge')) {
Expand All @@ -141,6 +171,8 @@ public function renderGallery()
$source = null;
}



// Bail out if the image resource is not OK
if (!$source) {
if (version_compare(JVERSION, '4', 'ge')) {
Expand All @@ -151,9 +183,10 @@ public function renderGallery()
}
return;
}

$width = imagesx($source);
$height = imagesy($source);
// Calculate thumbnails
$thumbnail = $this->thumbDimCalc($width, $height, $thb_width, $thb_height, $smartResize);
$thumbnail = $this->thumbDimCalc($width, $height, ($thb_width * $width)/$originalwidth, ($thb_height * $height) /$originalheight, $smartResize);

$thumb_width = $thumbnail['width'];
$thumb_height = $thumbnail['height'];
Expand All @@ -180,7 +213,8 @@ public function renderGallery()
// Assemble the image elements
$gallery[$key]->filename = $filename;
$gallery[$key]->sourceImageFilePath = $siteUrl.$srcimgfolder.'/'.$this->replaceWhiteSpace($filename);
$gallery[$key]->thumbImageFilePath = $siteUrl.'cache/jw_sig/'.$prefix.$gal_id.'_'.strtolower($this->cleanThumbName($thumbfilename));
//$gallery[$key]->thumbImageFilePath = $siteUrl.'cache/jw_sig/'.$prefix.$gal_id.'_'.strtolower($this->cleanThumbName($thumbfilename));
$gallery[$key]->thumbImageFilePath = $cacheFolderUrl.'/' . $prefix.$gal_id.'_'.strtolower($this->cleanThumbName($thumbfilename));
$gallery[$key]->width = $thb_width;
$gallery[$key]->height = $thb_height;
}
Expand Down Expand Up @@ -296,16 +330,16 @@ public function getTemplatePath($pluginName, $file, $tmpl)

if (file_exists(JPATH_SITE.'/templates/'.$template.'/html/'.$pluginName.'/'.$tmpl.'/'.$file)) {
$p->file = JPATH_SITE.'/templates/'.$template.'/html/'.$pluginName.'/'.$tmpl.'/'.$file;
$p->http = JURI::root(true)."/templates/".$template."/html/{$pluginName}/{$tmpl}/{$file}";
$p->http = JUri::root(true)."/templates/".$template."/html/{$pluginName}/{$tmpl}/{$file}";
} else {
if (version_compare(JVERSION, '2.5.0', 'ge')) {
// Joomla 2.5+
$p->file = JPATH_SITE.'/plugins/content/'.$pluginName.'/'.$pluginName.'/tmpl/'.$tmpl.'/'.$file;
$p->http = JURI::root(true)."/plugins/content/{$pluginName}/{$pluginName}/tmpl/{$tmpl}/{$file}";
$p->http = JUri::root(true)."/plugins/content/{$pluginName}/{$pluginName}/tmpl/{$tmpl}/{$file}";
} else {
// Joomla 1.5
$p->file = JPATH_SITE.'/plugins/content/'.$pluginName.'/tmpl/'.$tmpl.'/'.$file;
$p->http = JURI::root(true)."/plugins/content/{$pluginName}/tmpl/{$tmpl}/{$file}";
$p->http = JUri::root(true)."/plugins/content/{$pluginName}/tmpl/{$tmpl}/{$file}";
}
}
return $p;
Expand Down
4 changes: 4 additions & 0 deletions plugin/jw_sig/includes/js/jquery_fancybox/popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Plugin\CMSPlugin as JPlugin;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\HTML\HTMLHelper as JHtml;

$extraClass = 'fancybox-gallery';
$customLinkAttributes = 'data-fancybox="gallery'.$gal_id.'"';
Expand Down
2 changes: 1 addition & 1 deletion plugin/jw_sig/tmpl/Classic/css/template.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ul.sigFreeClassic {margin:8px auto!important;padding:8px 0!important;list-style:
/* Thumbnails */
ul.sigFreeClassic li.sigFreeThumb {float:left;background:#fff!important;margin:0 1px 1px 0;padding:0;list-style:none!important;}
ul.sigFreeClassic li.sigFreeThumb a.sigFreeLink,
ul.sigFreeClassic li.sigFreeThumb a.sigFreeLink:hover {display:block;float:left;padding:0;margin:0;border:0;background-color:#000;position:relative;}
ul.sigFreeClassic li.sigFreeThumb a.sigFreeLink:hover {display:block;float:left;padding:0;margin:0;border:0;background-color:#FFF;position:relative;}
ul.sigFreeClassic li.sigFreeThumb a.sigFreeLink {}
ul.sigFreeClassic li.sigFreeThumb a.sigFreeLink:hover {}
ul.sigFreeClassic li.sigFreeThumb a.sigFreeLink img.sigFreeImg,
Expand Down
4 changes: 2 additions & 2 deletions plugin/jw_sig/tmpl/Classic/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

// no direct access
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Language\Text as JText;
?>

<ul id="sigFreeId<?php echo $gal_id; ?>" class="sigFreeContainer sigFreeClassic<?php echo $extraWrapperClass; ?>">
<?php foreach($gallery as $count=>$photo): ?>
<li class="sigFreeThumb">
<a href="<?php echo $photo->sourceImageFilePath; ?>" class="sigFreeLink<?php echo $extraClass; ?>" style="width:<?php echo $photo->width; ?>px;height:<?php echo $photo->height; ?>px;" title="<?php echo JText::_('JW_PLG_SIG_YOU_ARE_VIEWING').' '.$photo->filename; ?>" data-thumb="<?php echo $photo->thumbImageFilePath; ?>" target="_blank"<?php echo $customLinkAttributes; ?>>
<a href="<?php echo $photo->sourceImageFilePath; ?>" class="sigFreeLink<?php echo $extraClass; ?>" style="width:<?php echo $photo->width; ?>px;height:<?php echo $photo->height; ?>px;" title="<?php echo JText::_('JW_PLG_SIG_YOU_ARE_VIEWING').' '.$photo->filename; ?>" data-thumb="'<?php echo $photo->thumbImageFilePath; ?>'" target="_blank"<?php echo $customLinkAttributes; ?>>
<img class="sigFreeImg" src="<?php echo $transparent; ?>" alt="<?php echo JText::_('JW_PLG_SIG_CLICK_TO_ENLARGE_IMAGE').' '.$photo->filename; ?>" title="<?php echo JText::_('JW_PLG_SIG_CLICK_TO_ENLARGE_IMAGE').' '.$photo->filename; ?>" style="width:<?php echo $photo->width; ?>px;height:<?php echo $photo->height; ?>px;background-image:url('<?php echo $photo->thumbImageFilePath; ?>');" />
</a>
</li>
Expand Down