mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +01:00
Fixes related to Gallery image import, watermarks and thumbnails.
This commit is contained in:
parent
8c497fcee1
commit
4cfe5c4387
@ -230,8 +230,8 @@ class media_form_ui extends e_admin_form_ui
|
||||
|
||||
foreach($options as $key=>$title)
|
||||
{
|
||||
$valW = $curval[$key]['w'];
|
||||
$valH = $curval[$key]['h'];
|
||||
$valW = vartrue($curval[$key]['w']);
|
||||
$valH = vartrue($curval[$key]['h']);
|
||||
|
||||
$text .= "<div style='margin-bottomp:8px;text-align:right;width:280px'>".$title.": ";
|
||||
$text .= "<input class='e-tip' placeholder='ex. 400' style='text-align:right' type='text' name='resize_dimensions[{$key}][w]' value='$valW' size='5' title='maximum width in pixels' /> X ";
|
||||
@ -376,7 +376,13 @@ class media_admin_ui extends e_admin_ui
|
||||
'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'=>'Size of the font in pts'), // '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_margin' => array('title'=> 'Watermark Margin', 'type' => 'text', 'data' => 'int', 'help'=>'The distance that watermark will appear from the edge of the image.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||
|
||||
'watermark_color' => array('title'=> 'Watermark Color', 'type' => 'text', 'data' => 'str', 'help'=>'Color of the watermark eg. 000000'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||
'watermark_shadowcolor' => array('title'=> 'Watermark Shadow-Color', 'type' => 'text', 'data' => 'str', 'help'=>'Shadow Color of the watermark eg. ffffff '), // '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')),
|
||||
|
||||
);
|
||||
@ -1127,7 +1133,7 @@ class media_admin_ui extends e_admin_ui
|
||||
$tp = e107::getParser();
|
||||
$f = e107::getFile()->get_file_info($oldpath,TRUE);
|
||||
|
||||
// $mes->addDebug("checkDupe(): newpath=".$newpath."<br />oldpath=".$oldpath."<br />".print_r($upload,TRUE));
|
||||
$mes->addDebug("checkDupe(): newpath=".$newpath."<br />oldpath=".$oldpath."<br />".print_r($upload,TRUE));
|
||||
if(file_exists($newpath) || e107::getDb()->db_Select("core_media","*","media_url = '".$tp->createConstants($newpath,'rel')."' LIMIT 1") )
|
||||
{
|
||||
// $mes->addWarning($newpath." already exists and was renamed during import.");
|
||||
@ -1195,7 +1201,7 @@ class media_admin_ui extends e_admin_ui
|
||||
$mes->add("Scanning for new media (images, videos, files) in folder: ".e_MEDIA."temp/", E_MESSAGE_INFO);
|
||||
}
|
||||
|
||||
if(!count($files))
|
||||
if(!count($files) && !$_POST['batch_import_selected'])
|
||||
{
|
||||
$mes->add("No media Found! Please upload some files and then refresh this page.", E_MESSAGE_INFO);
|
||||
return;
|
||||
@ -1217,8 +1223,8 @@ class media_admin_ui extends e_admin_ui
|
||||
<th class='center'>".e107::getForm()->checkbox_toggle('e-column-toggle', 'batch_selected')."</th>
|
||||
<th class='center' style='width:50px'>Preview</th>
|
||||
<th class='center'>".LAN_FILE."</th>
|
||||
<th >Title</th>
|
||||
<th >Caption</th>
|
||||
<th >Title (internal use)</th>
|
||||
<th >Caption (seen by public)</th>
|
||||
<th >Author</th>
|
||||
<th>Mime Type</th>
|
||||
<th>File Size</th>
|
||||
@ -1232,6 +1238,13 @@ class media_admin_ui extends e_admin_ui
|
||||
foreach($files as $f)
|
||||
{
|
||||
$default = $this->getFileXml($f['fname']);
|
||||
$f = $fl->cleanFileName($f,true);
|
||||
|
||||
if($f['error'])
|
||||
{
|
||||
$mes->addWarning($f['fname']." couldn't be renamed. Check file perms.");
|
||||
}
|
||||
|
||||
|
||||
$text .= "
|
||||
|
||||
@ -1266,7 +1279,7 @@ class media_admin_ui extends e_admin_ui
|
||||
|
||||
if(is_readable($waterMarkPath))
|
||||
{
|
||||
$text .= $frm->checkbox_label("Add Watermark", 'batch_import_watermark',1);
|
||||
// $text .= $frm->checkbox_label("Add Watermark", 'batch_import_watermark',1);
|
||||
}
|
||||
|
||||
$text .= "
|
||||
|
@ -3539,6 +3539,7 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
*/
|
||||
protected function handleListDeleteBatch($selected)
|
||||
{
|
||||
|
||||
if(!$this->getBatchDelete())
|
||||
{
|
||||
e107::getMessage()->add(LAN_UI_BATCHDEL_ERROR, E_MESSAGE_WARNING);
|
||||
@ -3557,11 +3558,13 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
// already confirmed, resurrect selected values
|
||||
$selected = array_map('intval', explode(',', $this->getPosted('delete_confirm_value')));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// delete one by one - more control, less performance
|
||||
// pass afterDelete() callback to tree delete method
|
||||
$set_messages = true;
|
||||
|
||||
foreach ($selected as $id)
|
||||
{
|
||||
$data = array();
|
||||
@ -3578,11 +3581,16 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$set_messages = "Couldn't get model";
|
||||
}
|
||||
}
|
||||
|
||||
//$this->getTreeModel()->delete($selected);
|
||||
if($set_messages) $this->getTreeModel()->setMessages();
|
||||
$this->redirect();
|
||||
exit;
|
||||
//$this->redirect();
|
||||
}
|
||||
|
||||
/** TODO
|
||||
|
@ -1791,7 +1791,9 @@ class e_parse
|
||||
|
||||
if($raw) $url = $this->createConstants($url, 'mix');
|
||||
|
||||
$thurl = ($full ? SITEURL : e_HTTP).'thumb.php?src='.$url.'&';
|
||||
$baseurl = ($full ? SITEURL : e_HTTP).'thumb.php?';
|
||||
|
||||
$thurl = 'src='.$url.'&';
|
||||
|
||||
if(vartrue($options['aw']) || vartrue($options['ah']))
|
||||
{
|
||||
@ -1803,14 +1805,15 @@ class e_parse
|
||||
$thurl .= 'w='.((integer) vartrue($options['w'], 0)).'&h='.((integer) vartrue($options['h'], 0));
|
||||
}
|
||||
|
||||
if(vartrue($options['wm']))//TODO remove from URL. set session.
|
||||
|
||||
if(vartrue($options['x']))//base64 encode url
|
||||
{
|
||||
$thurl .= "&wm=".$this->replaceConstants($options['wm'],'abs');
|
||||
$thurl = 'id='.base64_encode($thurl);
|
||||
}
|
||||
|
||||
// echo "<br /><br />".$thurl;
|
||||
|
||||
return $thurl;
|
||||
return $baseurl.$thurl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,6 +123,31 @@ class e_file
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean and rename file name
|
||||
* @param $f array as returned by get_files();
|
||||
* @param $rename boolean - set to true to rename file.
|
||||
*/
|
||||
public function cleanFileName($f,$rename=false)
|
||||
{
|
||||
$fullpath = $f['path'].$f['fname'];
|
||||
$newfile = preg_replace("/[^a-z0-9-\.]/", "-", strtolower($f['fname']));
|
||||
$newpath = $f['path'].$newfile;
|
||||
|
||||
if($rename == true)
|
||||
{
|
||||
|
||||
if(!rename($fullpath,$newpath))
|
||||
{
|
||||
$f['error'] = "Couldn't rename $fullpath to $newpath";
|
||||
}
|
||||
}
|
||||
|
||||
$f['fname'] = $newfile;
|
||||
|
||||
return $f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read files from given path
|
||||
*
|
||||
|
@ -1799,11 +1799,11 @@ class e_form
|
||||
if($value)
|
||||
{
|
||||
|
||||
if(!preg_match("/[a-zA-z0-9_-]+\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF)$/",$value))
|
||||
if(!preg_match("/[a-zA-z0-9_-\s\(\)]+\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF)$/",$value))
|
||||
{
|
||||
$value = "{e_IMAGE}filemanager/zip_32.png";
|
||||
$src = $tp->replaceConstants(vartrue($parms['pre']).$value, 'abs');
|
||||
return '<img src="'.$src.'" alt="'.$alt.'" class="e-thumb" />';
|
||||
$icon = "{e_IMAGE}filemanager/zip_32.png";
|
||||
$src = $tp->replaceConstants(vartrue($parms['pre']).$icon, 'abs');
|
||||
return '<img src="'.$src.'" alt="'.$value.'" class="e-thumb" title="'.$value.'" />';
|
||||
}
|
||||
|
||||
if(vartrue($parms['thumb']))
|
||||
@ -1822,7 +1822,7 @@ class e_form
|
||||
$thsrc = $tp->thumbUrl(vartrue($parms['pre']).$value, $thparms, varset($parms['thumb_urlraw']));
|
||||
$alt = $src;
|
||||
$ttl = '<img src="'.$thsrc.'" alt="'.$alt.'" class="e-thumb" />';
|
||||
$value = '<a href="'.$src.'" class="e-image-preview" title="'.$alt.'" rel="external">'.$ttl.'</a>';
|
||||
$value = '<a href="'.$src.'" class="e-dialog e-image-preview" title="'.$alt.'" rel="external">'.$ttl.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -294,7 +294,8 @@ class e_media
|
||||
if(strpos($cat,"+") || !$cat)
|
||||
{
|
||||
$cat = str_replace("+","",$cat);
|
||||
$inc[] = "media_category = '_common_image' ";
|
||||
// $inc[] = "media_category = '_common_image' ";
|
||||
$inc[] = "media_category REGEXP '(^|,)(_common_image)(,|$)' ";
|
||||
}
|
||||
if($cat)
|
||||
{
|
||||
|
@ -47,6 +47,7 @@ class GdWatermarkTTF
|
||||
protected $workingImage;
|
||||
protected $newImage;
|
||||
protected $options;
|
||||
protected $parms;
|
||||
|
||||
private function DebugMessage($val)
|
||||
{
|
||||
@ -55,26 +56,49 @@ class GdWatermarkTTF
|
||||
|
||||
private function shadow_text($im, $size, $angle, $x, $y, $font, $text,$opacity=100)
|
||||
{
|
||||
$black = imagecolorallocatealpha($im, 0, 0, 0, $opacity);
|
||||
$white = imagecolorallocatealpha($im, 255, 255, 255, $opacity);
|
||||
imagettftext($im, $size, 0, $x + 1, $y + 1, $black, $font, $text);
|
||||
imagettftext($im, $size, 0, $x + 0, $y + 1, $black, $font, $text);
|
||||
$col = $this->hex2rgb($this->parms['color']);
|
||||
$scol = $this->hex2rgb($this->parms['shadowcolor']);
|
||||
|
||||
$shadowcolor = imagecolorallocatealpha($im, $scol[0], $scol[1], $scol[2], $opacity);
|
||||
$white = imagecolorallocatealpha($im, $col[0], $col[1], $col[2], $opacity);
|
||||
|
||||
imagettftext($im, $size, 0, $x + 1, $y + 1, $shadowcolor, $font, $text);
|
||||
imagettftext($im, $size, 0, $x -1, $y + 1, $shadowcolor, $font, $text);
|
||||
imagettftext($im, $size, 0, $x + 0, $y + 0, $white, $font, $text);
|
||||
}
|
||||
|
||||
private function hex2rgb($hex) {
|
||||
$hex = str_replace("#", "", $hex);
|
||||
|
||||
if(strlen($hex) == 3) {
|
||||
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
|
||||
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
|
||||
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
|
||||
} else {
|
||||
$r = hexdec(substr($hex,0,2));
|
||||
$g = hexdec(substr($hex,2,2));
|
||||
$b = hexdec(substr($hex,4,2));
|
||||
}
|
||||
$rgb = array($r, $g, $b);
|
||||
//return implode(",", $rgb); // returns the rgb values separated by commas
|
||||
return $rgb; // returns an array with the rgb values
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Taken from http://phpthumb.sourceforge.net/index.php?source=phpthumb.filters.php
|
||||
// public function WatermarkText($text, $size=12, $alignment='BR', $hex_color='000000', $ttffont='', $opacity=100, $margin=5, $angle=0, $bg_color=false, $bg_opacity=0, $fillextend='', &$that)
|
||||
public function WatermarkText($parms, &$that)
|
||||
{
|
||||
$this->parms = $parms;
|
||||
$text = $parms['text'];
|
||||
$size = $parms['size'];
|
||||
$alignment = $parms['pos'];
|
||||
$hex_color = $parms['color'];
|
||||
$ttffont = $parms['font'];
|
||||
$opacity = (isset($parms['opacity'])) ? $parms['opacity'] : 100;
|
||||
$margin = 30; // (isset($parms[6])) ? $parms[6] : 25;
|
||||
$margin = $parms['margin']; // 30; // (isset($parms[6])) ? $parms[6] : 25;
|
||||
$angle = 0; // $parms['angle'];
|
||||
$bg_color = false;
|
||||
$bg_opacity = 0;
|
||||
|
@ -16,6 +16,7 @@ e107::css('gallery', 'gallery_style.css');
|
||||
$gp = e107::getPlugPref('gallery');
|
||||
|
||||
e107::js('inline',"
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
|
||||
@ -23,8 +24,8 @@ $(document).ready(function()
|
||||
fx: '".varset($gp['slideshow_effect'],'scrollHorz')."',
|
||||
next: '.gal-next',
|
||||
prev: '.gal-prev',
|
||||
speed: 1000, // speed of the transition (any valid fx speed value)
|
||||
timeout: 4000,
|
||||
speed: ".varset($gp['slideshow_duration'],1000).", // speed of the transition (any valid fx speed value)
|
||||
timeout: ".varset($gp['slideshow_freq'],4000).",
|
||||
slideExpr: '.slide',
|
||||
|
||||
activePagerClass: '.gallery-slide-jumper-selected',//,
|
||||
@ -48,6 +49,12 @@ $(document).ready(function()
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#img.lb-close').on('live', function(e) {
|
||||
$(this).attr('src','".e_PLUGIN."gallery/jslib/lightbox/images/close.png');
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
");
|
||||
|
||||
|
@ -36,11 +36,11 @@ class gallery_shortcodes extends e_shortcode
|
||||
|
||||
$class = ($this->slideMode == TRUE) ? 'gallery-slideshow-thumb' : 'gallery-thumb';
|
||||
$rel = ($this->slideMode == TRUE) ? 'lightbox.SlideGallery' : 'lightbox.Gallery';
|
||||
$att = vartrue($parm) ? $parm : 'aw='.$w.'&ah='.$h ; // 'aw=190&ah=150';
|
||||
$att = vartrue($parm) ? $parm : 'aw='.$w.'&ah='.$h.'&x=1' ; // 'aw=190&ah=150';
|
||||
|
||||
$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;
|
||||
$attFull = 'w='.$pop_w.'&h='.$pop_h.'&x=1';
|
||||
|
||||
// echo "<br /><br />".$attFull;
|
||||
|
||||
@ -90,7 +90,8 @@ class gallery_shortcodes extends e_shortcode
|
||||
$this->slideMode = TRUE;
|
||||
$amount = ($parm) ? intval($parm) : 3; // vartrue(e107::getPlugPref('gallery','slideshow_perslide'),3);
|
||||
$tp = e107::getParser();
|
||||
$list = e107::getMedia()->getImages('gallery_'.$this->sliderCat);
|
||||
$limit = varset($gp['slideshow_limit'],16);
|
||||
$list = e107::getMedia()->getImages('gallery_'.$this->sliderCat,0,$limit);
|
||||
$item_template = e107::getTemplate('gallery','gallery','SLIDESHOW_SLIDE_ITEM');
|
||||
|
||||
$count = 1;
|
||||
@ -123,7 +124,7 @@ class gallery_shortcodes extends e_shortcode
|
||||
if($this->slideCount ==1 ){ return "gallery-jumper must be loaded after Gallery-Slides"; }
|
||||
|
||||
$text = '';
|
||||
for($i=1; $i < ($this->slideCount +1); $i++)
|
||||
for($i=1; $i < ($this->slideCount); $i++)
|
||||
{
|
||||
$val = ($parm == 'space') ? " " : $i;
|
||||
$text .= '<a href="#" class="gallery-slide-jumper" id="gallery-jumper-'.$i.'">'.$val.'</a>';
|
||||
|
@ -77,11 +77,12 @@ class gallery
|
||||
$sc = e107::getScBatch('gallery',TRUE);
|
||||
|
||||
$sc->total = e107::getMedia()->countImages($cat);
|
||||
$sc->amount = 9; // TODO Add Pref. amount per page.
|
||||
$sc->amount = 12; // TODO Add Pref. amount per page.
|
||||
$sc->curCat = $cat;
|
||||
$sc->from = ($_GET['frm']) ? intval($_GET['frm']) : 0;
|
||||
|
||||
$list = e107::getMedia()->getImages($cat,$sc->from,$sc->amount);
|
||||
$catname = $tp->toHtml($this->catList[$cat]['media_cat_title'],false,'defs');
|
||||
|
||||
$inner = "";
|
||||
|
||||
@ -95,7 +96,7 @@ class gallery
|
||||
$text .= $inner;
|
||||
$text .= $tp->parseTemplate($template['LIST_END'],TRUE);
|
||||
|
||||
e107::getRender()->tablerender("Gallery :: ".str_replace("_"," ",$cat),$mes->render().$text);
|
||||
e107::getRender()->tablerender("Gallery :: ".$catname,$mes->render().$text);
|
||||
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
/* SLIDESHOW */
|
||||
|
||||
#gallery-slideshow-wrapper { -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; width: 660px; height: 146px; overflow: hidden; background: #000000; margin-left:auto;margin-right:auto }
|
||||
#gallery-slideshow-wrapper { display:block; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; width: 660px; height: 146px; overflow: hidden; background: #000000; margin-left:auto;margin-right:auto }
|
||||
|
||||
#gallery-slideshow-content { width: 3500px; }
|
||||
|
||||
|
25
thumb.php
25
thumb.php
@ -128,13 +128,15 @@ class e_thumbpage
|
||||
$pref = $e107->getPref(); //TODO optimize/benchmark
|
||||
|
||||
$this->_watermark = array(
|
||||
'activate' => vartrue($pref['watermark_activate'], false),
|
||||
'text' => vartrue($pref['watermark_text']),
|
||||
'size' => vartrue($pref['watermark_size'], 20),
|
||||
'pos' => vartrue($pref['watermark_pos'],"BR"),
|
||||
'color' => vartrue($pref['watermark_color'],'fff'),
|
||||
'font' => vartrue($pref['watermark_font']),
|
||||
'opacity' => vartrue($pref['watermark_opacity'], 20)
|
||||
'activate' => vartrue($pref['watermark_activate'], false),
|
||||
'text' => vartrue($pref['watermark_text']),
|
||||
'size' => vartrue($pref['watermark_size'], 20),
|
||||
'pos' => vartrue($pref['watermark_pos'],"BR"),
|
||||
'color' => vartrue($pref['watermark_color'],'fff'),
|
||||
'font' => vartrue($pref['watermark_font']),
|
||||
'margin' => vartrue($pref['watermark_margin'],30),
|
||||
'shadowcolor' => vartrue($pref['watermark_shadowcolor'], '000000'),
|
||||
'opacity' => vartrue($pref['watermark_opacity'], 20)
|
||||
);
|
||||
|
||||
// parse request
|
||||
@ -144,7 +146,14 @@ class e_thumbpage
|
||||
function parseRequest()
|
||||
{
|
||||
//echo 'e_query='.str_replace('&', '&', e_QUERY);
|
||||
parse_str(str_replace('&', '&', e_QUERY), $this->_request);
|
||||
$e_QUERY = e_QUERY;
|
||||
|
||||
if(isset($_GET['id'])) // very-basic url-tampering prevention and path cloaking
|
||||
{
|
||||
$e_QUERY = base64_decode($_GET['id']);
|
||||
}
|
||||
|
||||
parse_str(str_replace('&', '&', $e_QUERY), $this->_request);
|
||||
|
||||
// parse_str($_SERVER['QUERY_STRING'], $this->_request);
|
||||
return $this;
|
||||
|
Loading…
x
Reference in New Issue
Block a user