1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Upgrade PHP thumb and watermarks for images added

This commit is contained in:
CaMer0n 2012-07-02 01:32:56 +00:00
parent 92fc540ac6
commit cadadb29b9
11 changed files with 631 additions and 114 deletions

View File

@ -1791,8 +1791,6 @@ class e_parse
if($raw) $url = $this->createConstants($url, 'mix'); if($raw) $url = $this->createConstants($url, 'mix');
// echo "<br />".$url;
$thurl = ($full ? SITEURL : e_HTTP).'thumb.php?src='.$url.'&amp;'; $thurl = ($full ? SITEURL : e_HTTP).'thumb.php?src='.$url.'&amp;';
if(vartrue($options['aw']) || vartrue($options['ah'])) if(vartrue($options['aw']) || vartrue($options['ah']))
@ -1805,6 +1803,13 @@ class e_parse
$thurl .= 'w='.((integer) vartrue($options['w'], 0)).'&amp;h='.((integer) vartrue($options['h'], 0)); $thurl .= 'w='.((integer) vartrue($options['w'], 0)).'&amp;h='.((integer) vartrue($options['h'], 0));
} }
if(vartrue($options['wm']))//TODO remove from URL. set session.
{
$thurl .= "&amp;wm=".$this->replaceConstants($options['wm'],'abs');
}
// echo "<br /><br />".$thurl;
return $thurl; return $thurl;
} }

View File

@ -150,6 +150,73 @@ class GdThumb extends ThumbBase
# ----- API FUNCTIONS ------ # # ----- API FUNCTIONS ------ #
############################## ##############################
/**
* Pad an image to desired dimensions if required
*
* Moves the image into the center and fills the rest with $color
*
* Author: Blake Kus <http://blakek.us>
*
* @param mixed $width
* @param mixed $height
* @param mixed $color
*/
public function pad ($width, $height, $color=array(255, 255, 255))
{
// no resize - woohoo!
if($width == $this->currentDimensions['width'] && $height == $this->currentDimensions['height']){
return $this;
}
// create the working image
if (function_exists('imagecreatetruecolor'))
{
$this->workingImage = imagecreatetruecolor($width, $height);
}
else
{
$this->workingImage = imagecreate($width, $height);
}
// create the fill color
$fillColor = imagecolorallocate(
$this->workingImage,
$color[0],
$color[1],
$color[2]
);
// fill our working image with the fill color
imagefill(
$this->workingImage,
0,
0,
$fillColor
);
// copy the image into the center of our working image
imagecopyresampled
(
$this->workingImage,
$this->oldImage,
intval(($width-$this->currentDimensions['width'])/2),
intval(($height-$this->currentDimensions['height'])/2),
0,
0,
$this->currentDimensions['width'],
$this->currentDimensions['height'],
$this->currentDimensions['width'],
$this->currentDimensions['height']
);
// update all the variables and resources to be correct
$this->oldImage = $this->workingImage;
$this->currentDimensions['width'] = $width;
$this->currentDimensions['height'] = $height;
return $this;
}
/** /**
* Resizes an image to be no larger than $maxWidth or $maxHeight * Resizes an image to be no larger than $maxWidth or $maxHeight
* *
@ -237,14 +304,19 @@ class GdThumb extends ThumbBase
public function adaptiveResize ($width, $height) public function adaptiveResize ($width, $height)
{ {
// make sure our arguments are valid // make sure our arguments are valid
if ((!is_numeric($width) || $width == 0) && (!is_numeric($height) || $height == 0))
{
throw new InvalidArgumentException('$width and $height must be numeric and greater than zero');
}
if (!is_numeric($width) || $width == 0) if (!is_numeric($width) || $width == 0)
{ {
throw new InvalidArgumentException('$width must be numeric and greater than zero'); $width = ( $height * $this->currentDimensions['width'] ) / $this->currentDimensions['height'];
} }
if (!is_numeric($height) || $height == 0) if (!is_numeric($height) || $height == 0)
{ {
throw new InvalidArgumentException('$height must be numeric and greater than zero'); $height = ( $width * $this->currentDimensions['height'] ) / $this->currentDimensions['width'];
} }
// make sure we're not exceeding our image size if we're not supposed to // make sure we're not exceeding our image size if we're not supposed to
@ -325,6 +397,288 @@ class GdThumb extends ThumbBase
return $this; return $this;
} }
/**
* Adaptively Resizes the Image and Crops Using a Percentage
*
* This function attempts to get the image to as close to the provided dimensions as possible, and then crops the
* remaining overflow using a provided percentage to get the image to be the size specified.
*
* The percentage mean different things depending on the orientation of the original image.
*
* For Landscape images:
* ---------------------
*
* A percentage of 1 would crop the image all the way to the left, which would be the same as
* using adaptiveResizeQuadrant() with $quadrant = 'L'
*
* A percentage of 50 would crop the image to the center which would be the same as using
* adaptiveResizeQuadrant() with $quadrant = 'C', or even the original adaptiveResize()
*
* A percentage of 100 would crop the image to the image all the way to the right, etc, etc.
* Note that you can use any percentage between 1 and 100.
*
* For Portrait images:
* --------------------
*
* This works the same as for Landscape images except that a percentage of 1 means top and 100 means bottom
*
* @param int $maxWidth
* @param int $maxHeight
* @param int $percent
* @return GdThumb
*/
public function adaptiveResizePercent ($width, $height, $percent = 50)
{
// make sure our arguments are valid
if (!is_numeric($width) || $width == 0)
{
throw new InvalidArgumentException('$width must be numeric and greater than zero');
}
if (!is_numeric($height) || $height == 0)
{
throw new InvalidArgumentException('$height must be numeric and greater than zero');
}
// make sure we're not exceeding our image size if we're not supposed to
if ($this->options['resizeUp'] === false)
{
$this->maxHeight = (intval($height) > $this->currentDimensions['height']) ? $this->currentDimensions['height'] : $height;
$this->maxWidth = (intval($width) > $this->currentDimensions['width']) ? $this->currentDimensions['width'] : $width;
}
else
{
$this->maxHeight = intval($height);
$this->maxWidth = intval($width);
}
$this->calcImageSizeStrict($this->currentDimensions['width'], $this->currentDimensions['height']);
// resize the image to be close to our desired dimensions
$this->resize($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
// reset the max dimensions...
if ($this->options['resizeUp'] === false)
{
$this->maxHeight = (intval($height) > $this->currentDimensions['height']) ? $this->currentDimensions['height'] : $height;
$this->maxWidth = (intval($width) > $this->currentDimensions['width']) ? $this->currentDimensions['width'] : $width;
}
else
{
$this->maxHeight = intval($height);
$this->maxWidth = intval($width);
}
// create the working image
if (function_exists('imagecreatetruecolor'))
{
$this->workingImage = imagecreatetruecolor($this->maxWidth, $this->maxHeight);
}
else
{
$this->workingImage = imagecreate($this->maxWidth, $this->maxHeight);
}
$this->preserveAlpha();
$cropWidth = $this->maxWidth;
$cropHeight = $this->maxHeight;
$cropX = 0;
$cropY = 0;
// Crop the rest of the image using the quadrant
if ($percent > 100) {
$percent = 100;
} elseif ($percent < 1) {
$percent = 1;
}
if ($this->currentDimensions['width'] > $this->maxWidth)
{
// Image is landscape
$maxCropX = $this->currentDimensions['width'] - $this->maxWidth;
$cropX = intval(($percent / 100) * $maxCropX);
} elseif ($this->currentDimensions['height'] > $this->maxHeight)
{
// Image is portrait
$maxCropY = $this->currentDimensions['height'] - $this->maxHeight;
$cropY = intval(($percent / 100) * $maxCropY);
}
imagecopyresampled
(
$this->workingImage,
$this->oldImage,
0,
0,
$cropX,
$cropY,
$cropWidth,
$cropHeight,
$cropWidth,
$cropHeight
);
// update all the variables and resources to be correct
$this->oldImage = $this->workingImage;
$this->currentDimensions['width'] = $this->maxWidth;
$this->currentDimensions['height'] = $this->maxHeight;
return $this;
}
/**
* Adaptively Resizes the Image and Crops Using a Quadrant
*
* This function attempts to get the image to as close to the provided dimensions as possible, and then crops the
* remaining overflow using the quadrant to get the image to be the size specified.
*
* The quadrants available are Top, Bottom, Center, Left, and Right:
*
*
* +---+---+---+
* | | T | |
* +---+---+---+
* | L | C | R |
* +---+---+---+
* | | B | |
* +---+---+---+
*
* Note that if your image is Landscape and you choose either of the Top or Bottom quadrants (which won't
* make sence since only the Left and Right would be available, then the Center quadrant will be used
* to crop. This would have exactly the same result as using adaptiveResize().
* The same goes if your image is portrait and you choose either the Left or Right quadrants.
*
* @param int $maxWidth
* @param int $maxHeight
* @param string $quadrant T, B, C, L, R
* @return GdThumb
*/
public function adaptiveResizeQuadrant ($width, $height, $quadrant = 'C')
{
// make sure our arguments are valid
if (!is_numeric($width) || $width == 0)
{
throw new InvalidArgumentException('$width must be numeric and greater than zero');
}
if (!is_numeric($height) || $height == 0)
{
throw new InvalidArgumentException('$height must be numeric and greater than zero');
}
// make sure we're not exceeding our image size if we're not supposed to
if ($this->options['resizeUp'] === false)
{
$this->maxHeight = (intval($height) > $this->currentDimensions['height']) ? $this->currentDimensions['height'] : $height;
$this->maxWidth = (intval($width) > $this->currentDimensions['width']) ? $this->currentDimensions['width'] : $width;
}
else
{
$this->maxHeight = intval($height);
$this->maxWidth = intval($width);
}
$this->calcImageSizeStrict($this->currentDimensions['width'], $this->currentDimensions['height']);
// resize the image to be close to our desired dimensions
$this->resize($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
// reset the max dimensions...
if ($this->options['resizeUp'] === false)
{
$this->maxHeight = (intval($height) > $this->currentDimensions['height']) ? $this->currentDimensions['height'] : $height;
$this->maxWidth = (intval($width) > $this->currentDimensions['width']) ? $this->currentDimensions['width'] : $width;
}
else
{
$this->maxHeight = intval($height);
$this->maxWidth = intval($width);
}
// create the working image
if (function_exists('imagecreatetruecolor'))
{
$this->workingImage = imagecreatetruecolor($this->maxWidth, $this->maxHeight);
}
else
{
$this->workingImage = imagecreate($this->maxWidth, $this->maxHeight);
}
$this->preserveAlpha();
$cropWidth = $this->maxWidth;
$cropHeight = $this->maxHeight;
$cropX = 0;
$cropY = 0;
// Crop the rest of the image using the quadrant
if ($this->currentDimensions['width'] > $this->maxWidth)
{
// Image is landscape
switch ($quadrant) {
case 'L':
$cropX = 0;
break;
case 'R':
$cropX = intval(($this->currentDimensions['width'] - $this->maxWidth));
break;
case 'C':
default:
$cropX = intval(($this->currentDimensions['width'] - $this->maxWidth) / 2);
break;
}
} elseif ($this->currentDimensions['height'] > $this->maxHeight)
{
// Image is portrait
switch ($quadrant) {
case 'T':
$cropY = 0;
break;
case 'B':
$cropY = intval(($this->currentDimensions['height'] - $this->maxHeight));
break;
case 'C':
default:
$cropY = intval(($this->currentDimensions['height'] - $this->maxHeight) / 2);
break;
}
}
imagecopyresampled
(
$this->workingImage,
$this->oldImage,
0,
0,
$cropX,
$cropY,
$cropWidth,
$cropHeight,
$cropWidth,
$cropHeight
);
// update all the variables and resources to be correct
$this->oldImage = $this->workingImage;
$this->currentDimensions['width'] = $this->maxWidth;
$this->currentDimensions['height'] = $this->maxHeight;
return $this;
}
/** /**
* Resizes an image by a given percent uniformly * Resizes an image by a given percent uniformly
* *
@ -552,6 +906,41 @@ class GdThumb extends ThumbBase
return $this; return $this;
} }
/**
* Applies a filter to the image
*
* @param int $filter
* @return GdThumb
*/
public function imageFilter ($filter, $arg1 = false, $arg2 = false, $arg3 = false, $arg4 = false)
{
if (!is_numeric($filter))
{
throw new InvalidArgumentException('$filter must be numeric');
}
if (!function_exists('imagefilter'))
{
throw new RuntimeException('Your version of GD does not support image filters.');
}
$result = false;
if ( $arg1 === false ) $result = imagefilter($this->oldImage, $filter);
else if ( $arg2 === false ) $result = imagefilter($this->oldImage, $filter, $arg1);
else if ( $arg3 === false ) $result = imagefilter($this->oldImage, $filter, $arg1, $arg2);
else if ( $arg4 === false ) $result = imagefilter($this->oldImage, $filter, $arg1, $arg2, $arg3);
else $result = imagefilter($this->oldImage, $filter, $arg1, $arg2, $arg3, $arg4);
if (!$result)
{
throw new RuntimeException('GD imagefilter failed');
}
$this->workingImage = $this->oldImage;
return $this;
}
/** /**
* Shows an image * Shows an image
* *
@ -564,11 +953,17 @@ class GdThumb extends ThumbBase
*/ */
public function show ($rawData = false) public function show ($rawData = false)
{ {
if (headers_sent()) if (headers_sent() && php_sapi_name() != 'cli')
{ {
throw new RuntimeException('Cannot show image, headers have already been sent'); throw new RuntimeException('Cannot show image, headers have already been sent');
} }
// When the interlace option equals true or false call imageinterlace else leave it to default
if ($this->options['interlace'] === true)
imageinterlace($this->oldImage, 1);
elseif ($this->options['interlace'] === false)
imageinterlace($this->oldImage, 0);
switch ($this->format) switch ($this->format)
{ {
case 'GIF': case 'GIF':
@ -663,6 +1058,12 @@ class GdThumb extends ThumbBase
} }
} }
// When the interlace option equals true or false call imageinterlace else leave it to default
if ($this->options['interlace'] === true)
imageinterlace($this->oldImage, 1);
elseif ($this->options['interlace'] === false)
imageinterlace($this->oldImage, 0);
switch ($format) switch ($format)
{ {
case 'GIF': case 'GIF':
@ -713,7 +1114,8 @@ class GdThumb extends ThumbBase
'preserveAlpha' => true, 'preserveAlpha' => true,
'alphaMaskColor' => array (255, 255, 255), 'alphaMaskColor' => array (255, 255, 255),
'preserveTransparency' => true, 'preserveTransparency' => true,
'transparencyMaskColor' => array (0, 0, 0) 'transparencyMaskColor' => array (0, 0, 0),
'interlace' => null
); );
} }
// otherwise, let's use what we've got already // otherwise, let's use what we've got already

View File

@ -19,7 +19,7 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @version 3.0 * @version 3.0
* @package PhpThumb * @package PhpThumb
* @filesource $URL$ * @filesource
*/ */

View File

@ -161,7 +161,7 @@ abstract class ThumbBase
return; return;
} }
if (stristr($this->fileName, 'http://') !== false) if (preg_match('/https?:\/\//', $this->fileName) !== 0)
{ {
$this->remoteImage = true; $this->remoteImage = true;
return; return;
@ -208,7 +208,7 @@ abstract class ThumbBase
{ {
if( array_key_exists($method, $this->importedFunctions)) if( array_key_exists($method, $this->importedFunctions))
{ {
$args[] = $this; $args[] =& $this;
return call_user_func_array(array($this->importedFunctions[$method], $method), $args); return call_user_func_array(array($this->importedFunctions[$method], $method), $args);
} }

View File

@ -24,7 +24,7 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @version 3.0 * @version 3.0
* @package PhpThumb * @package PhpThumb
* @filesource $URL$ * @filesource
*/ */
// define some useful constants // define some useful constants

View File

@ -46,12 +46,16 @@ class GdReflectionLib
public function createReflection ($percent, $reflection, $white, $border, $borderColor, &$that) public function createReflection ($percent, $reflection, $white, $border, $borderColor, &$that)
{ {
// bring stuff from the parent class into this class... // bring stuff from the parent class into this class...
$this->parentInstance = $that; $this->parentInstance = $that;
$this->currentDimensions = $this->parentInstance->getCurrentDimensions(); $this->currentDimensions = $this->parentInstance->getCurrentDimensions();
$this->workingImage = $this->parentInstance->getWorkingImage(); $this->workingImage = $this->parentInstance->getWorkingImage();
$this->newImage = $this->parentInstance->getOldImage(); $this->newImage = $this->parentInstance->getOldImage();
$this->options = $this->parentInstance->getOptions(); $this->options = $this->parentInstance->getOptions();
$width = $this->currentDimensions['width']; $width = $this->currentDimensions['width'];
$height = $this->currentDimensions['height']; $height = $this->currentDimensions['height'];
$reflectionHeight = intval($height * ($reflection / 100)); $reflectionHeight = intval($height * ($reflection / 100));

View File

@ -31,14 +31,54 @@ class gallery_shortcodes extends e_shortcode
function sc_gallery_thumb($parm='') function sc_gallery_thumb($parm='')
{ {
$tp = e107::getParser(); $tp = e107::getParser();
$w = 190; $h = 150; $w = 190;
$h = 150;
$class = ($this->slideMode == TRUE) ? 'gallery-slideshow-thumb' : 'gallery-thumb'; $class = ($this->slideMode == TRUE) ? 'gallery-slideshow-thumb' : 'gallery-thumb';
$rel = ($this->slideMode == TRUE) ? 'lightbox.SlideGallery' : 'lightbox.Gallery'; $rel = ($this->slideMode == TRUE) ? 'lightbox.SlideGallery' : 'lightbox.Gallery';
$att = ($parm) ?$parm : 'aw='.$w.'&ah='.$h ; // 'aw=190&ah=150'; $att = vartrue($parm) ? $parm : 'aw='.$w.'&ah='.$h ; // 'aw=190&ah=150';
$text = "<a class='".$class."' title='".$tp->toAttribute($this->var['media_caption'])."' href='".e107::getParser()->replaceConstants($this->var['media_url'],'abs')."' rel='{$rel}' >";
$text .= "<img class='".$class."' src='".e107::getParser()->thumbUrl($this->var['media_url'],$att)."' alt='' />"; $pop_w = vartrue(e107::getPlugPref('gallery','pop_w'),1024);
$pop_h = vartrue(e107::getPlugPref('gallery','pop_h'),768);
$attFull = 'w='.$pop_w.'&h='.$pop_h;
$wm_text = vartrue(e107::getPlugPref('gallery','watermark_text'));
$wm_font = vartrue(e107::getPlugPref('gallery','watermark_font'));
$wm_size = vartrue(e107::getPlugPref('gallery','watermark_size'),20);
$wm_pos = vartrue(e107::getPlugPref('gallery','watermark_pos'),"BR");
$wm_color = vartrue(e107::getPlugPref('gallery','watermark_color'),"fff");
$wm_opacity = vartrue(e107::getPlugPref('gallery','watermark_opacity'),"70");
$wm_padding = vartrue(e107::getPlugPref('gallery','watermark_padding'),"5");
/*
"wmt" (WaterMarkText)
[ex: &fltr[]=wmt|<t>|<s>|<a>|<c>|<f>|<o>|<m>|<n>]
where:
<t> is the text to use as a watermark,
<s> is the font size (1-5 for built-in font, or point
size for TrueType fonts),
<a> is the alignment (one of BR, BL, TR, TL, C, R, L,
T, B, * where B=bottom, T=top, L=left, R=right,
C=centre, *=tile),
<c> is the hex color of the text
<f> is the filename of the TTF file (optional, if
omitted a built-in font will be used)
<o> is opacity from 0 to 100,
<m> is the edge (and inter-tile) margin in percent
<n> is the angle
*/
if($wm_text)
{
$attFull .= "&wm=".$wm_text."|".$wm_size."|".$wm_pos."|".$wm_color."|".$wm_font."|".$wm_opacity."|".$wm_padding;
}
// echo "<br /><br />".$attFull;
$text = "<a class='".$class."' title='".$tp->toAttribute($this->var['media_caption'])."' href='".$tp->thumbUrl($this->var['media_url'], $attFull)."' rel='{$rel}' >";
$text .= "<img class='".$class."' src='".$tp->thumbUrl($this->var['media_url'],$att)."' alt='' />";
$text .= "</a>"; $text .= "</a>";
return $text; return $text;
} }

View File

@ -126,7 +126,16 @@ class gallery_cat_admin_ui extends e_admin_ui
protected $prefs = array( protected $prefs = array(
'slideshow_category' => array('title'=> 'Slideshow category', 'type' => 'dropdown', 'data' => 'integer', 'help'=>'Images from this category will be used in the sliding menu.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')), 'popup_w' => array('title'=> 'Image Max. Width', 'type' => 'text', 'data' => 'int', 'help'=>'Images will be auto-resized if greater than the width given here'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'popup_h' => array('title'=> 'Image Max. Height', 'type' => 'text', 'data' => 'int', 'help'=>'Images will be auto-resized if greater than the height given here'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_text' => array('title'=> 'Watermark Text', 'type' => 'text', 'data' => 'str', 'help'=>'Optional Watermark Text'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_font' => array('title'=> 'Watermark Font', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Optional Watermark Font. Upload more .ttf fonts to the /fonts folder in your theme directory.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_size' => array('title'=> 'Watermark Size', 'type' => 'text', 'data' => 'int', 'help'=>'Optional Watermark Font'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_pos' => array('title'=> 'Watermark Position', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Watermark Position'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_opacity' => array('title'=> 'Watermark Opacity', 'type' => 'text', 'data' => 'int', 'help'=>'Enter a number between 1 and 100'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'slideshow_category' => array('title'=> 'Slideshow category', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Images from this category will be used in the sliding menu.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
// 'slideshow_thumb_w' => array('title'=> 'Thumbnail Width', 'type' => 'number', 'data' => 'integer', 'help'=>'Width in px'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')), // 'slideshow_thumb_w' => array('title'=> 'Thumbnail Width', 'type' => 'number', 'data' => 'integer', 'help'=>'Width in px'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
// 'slideshow_thumb_h' => array('title'=> 'Thumbnail Height', 'type' => 'number', 'data' => 'integer', 'help'=>'Height in px'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')), // 'slideshow_thumb_h' => array('title'=> 'Thumbnail Height', 'type' => 'number', 'data' => 'integer', 'help'=>'Height in px'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
@ -154,6 +163,38 @@ class gallery_cat_admin_ui extends e_admin_ui
// 'zoom' => 'zoom' // 'zoom' => 'zoom'
); );
$pref = e107::getPref();
$tp = e107::getParser();
$fl = e107::getFile();
$path = e_THEME.$pref['sitetheme']."/fonts/";
$fDir = $fl->get_files(e_THEME.$pref['sitetheme']."/fonts/",".ttf",'',2);
$fonts = array(0=>'None');
foreach($fDir as $f)
{
$id = $tp->createConstants($f['path'].$f['fname'],'rel');
$fonts[$id] = $f['fname'];
}
$this->prefs['watermark_font']['writeParms'] = $fonts;
$this->prefs['watermark_font']['readParms'] = $fonts;
$wm_pos = array(
'BR' => "Bottom Right",
'BL' => "Bottom Left",
'TR' => "Top Right",
'TL' => "Top Left",
'C' => "Center",
'R' => "Right",
'L' => "Left",
'T' => "Top",
'B' => "Bottom",
'*' => "Tile"
);
$this->prefs['watermark_pos']['writeParms'] = $wm_pos;
$this->prefs['watermark_pos']['readParms'] = $wm_pos;
$this->prefs['slideshow_effect']['writeParms'] = $effects; $this->prefs['slideshow_effect']['writeParms'] = $effects;
$this->prefs['slideshow_effect']['readParms'] = $effects; $this->prefs['slideshow_effect']['readParms'] = $effects;

View File

@ -16,6 +16,8 @@
<mainPrefs> <mainPrefs>
</mainPrefs> </mainPrefs>
<pluginPrefs> <pluginPrefs>
<pref name="popup_w">1024</pref>
<pref name="popup_h">768</pref>
<pref name="slideshow_category">1</pref> <pref name="slideshow_category">1</pref>
<pref name="slideshow_duration">1</pref> <pref name="slideshow_duration">1</pref>
<pref name="slideshow_auto">1</pref> <pref name="slideshow_auto">1</pref>

View File

@ -128,6 +128,7 @@ else
if($pref['meta_copyright'][e_LANGUAGE]) e107::meta('copyright',$pref['meta_copyright'][e_LANGUAGE]); if($pref['meta_copyright'][e_LANGUAGE]) e107::meta('copyright',$pref['meta_copyright'][e_LANGUAGE]);
if($pref['meta_author'][e_LANGUAGE]) e107::meta('author',$pref['meta_author'][e_LANGUAGE]); if($pref['meta_author'][e_LANGUAGE]) e107::meta('author',$pref['meta_author'][e_LANGUAGE]);
if($pref['sitelogo']) e107::meta('og:image',$tp->replaceConstants($pref['sitelogo'],'full')); if($pref['sitelogo']) e107::meta('og:image',$tp->replaceConstants($pref['sitelogo'],'full'));
if(defined("VIEWPORT")) e107::meta('viewport',VIEWPORT);
echo e107::getUrl()->response()->renderMeta()."\n"; echo e107::getUrl()->response()->renderMeta()."\n";
@ -436,6 +437,8 @@ function render_meta($type)
echo (defined("META_DESCRIPTION")) ? "\n<meta name=\"description\" content=\"".$diz_merge.META_DESCRIPTION."\" />\n" : render_meta('description'); echo (defined("META_DESCRIPTION")) ? "\n<meta name=\"description\" content=\"".$diz_merge.META_DESCRIPTION."\" />\n" : render_meta('description');
echo (defined("META_KEYWORDS")) ? "\n<meta name=\"keywords\" content=\"".$key_merge.META_KEYWORDS."\" />\n" : render_meta('keywords'); echo (defined("META_KEYWORDS")) ? "\n<meta name=\"keywords\" content=\"".$key_merge.META_KEYWORDS."\" />\n" : render_meta('keywords');
//echo render_meta('copyright'); //echo render_meta('copyright');
//echo render_meta('author'); //echo render_meta('author');
echo render_meta('tag'); echo render_meta('tag');

View File

@ -123,7 +123,9 @@ class e_thumbpage
function parseRequest() function parseRequest()
{ {
//echo 'e_query='.str_replace('&amp;', '&', e_QUERY);
parse_str(str_replace('&amp;', '&', e_QUERY), $this->_request); parse_str(str_replace('&amp;', '&', e_QUERY), $this->_request);
// parse_str($_SERVER['QUERY_STRING'], $this->_request); // parse_str($_SERVER['QUERY_STRING'], $this->_request);
return $this; return $this;
} }
@ -228,6 +230,23 @@ class e_thumbpage
$thumb->adaptiveResize((integer) vartrue($this->_request['aw'], 0), (integer) vartrue($this->_request['ah'], 0)); $thumb->adaptiveResize((integer) vartrue($this->_request['aw'], 0), (integer) vartrue($this->_request['ah'], 0));
} }
//TODO Move to $_SESSION and activate based on width/height ie. watermark all images larger than....
// ie. prevent user tampering with URLs.
if(isset($this->_request['wm']))
{
$tp = e107::getParser();
$tmp = explode("|",$this->_request['wm']);
$tmp[4] = $tp->createConstants($tmp[4], 'mix');
$tmp[4] = realpath($tp->replaceConstants($tmp[4],'rel'));
$thumb->WatermarkText($tmp);
// $alignment='BR', $hex_color='000000', $ttffont='', $opacity=100, $margin=5, $angle=0, $bg_color=false, $bg_opacity=0, $fillextend=''
}
// set cache // set cache
$thumb->save(e_CACHE_IMAGE.$fname); $thumb->save(e_CACHE_IMAGE.$fname);
@ -242,6 +261,7 @@ class e_thumbpage
$ret['h'] = isset($this->_request['h']) ? intval($this->_request['h']) : $ret['w']; $ret['h'] = isset($this->_request['h']) ? intval($this->_request['h']) : $ret['w'];
$ret['aw'] = isset($this->_request['aw']) ? intval($this->_request['aw']) : false; $ret['aw'] = isset($this->_request['aw']) ? intval($this->_request['aw']) : false;
$ret['ah'] = isset($this->_request['ah']) ? intval($this->_request['ah']) : $ret['aw']; $ret['ah'] = isset($this->_request['ah']) ? intval($this->_request['ah']) : $ret['aw'];
$ret['wm'] = isset($this->_request['wm']) ? intval($this->_request['wm']) : $ret['wm'];
return $ret; return $ret;
} }