diff --git a/e107_plugins/gallery/admin_gallery.php b/e107_plugins/gallery/admin_gallery.php
index 3c2d9132f..ce121198e 100644
--- a/e107_plugins/gallery/admin_gallery.php
+++ b/e107_plugins/gallery/admin_gallery.php
@@ -138,7 +138,7 @@ class gallery_cat_admin_ui extends e_admin_ui
'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')),
- 'downloadable' => array('title'=> 'Show "download" link', 'type' => 'boolean', 'integer' => 'int', 'help'=>'A download option will be shown next to the popup caption'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
+ 'downloadable' => array('title'=> 'Show "download" link', 'type' => 'boolean', 'data' => 'int', 'help'=>'A download option will be shown next to the popup caption'), // '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')),
@@ -150,7 +150,8 @@ class gallery_cat_admin_ui extends e_admin_ui
'slideshow_freq' => array('title'=> 'Slide frequency', 'type' => 'number', 'data' => 'integer', 'help'=>'When auto-start is enabled, this dictates how long a slides stays put before the next jump. '), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
// 'slideshow_circular' => array('title'=> 'Slide circular-mode', 'type' => 'boolean', 'data' => 'integer', 'help'=>'By default when the first/last slide is reached, calling prev/next does nothing. If you want the effect to continue enable this option.'), //
'slideshow_effect' => array('title'=> 'Slide effect', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Type of effect. '), //
- // 'slideshow_transition' => array('title'=> 'Slide transition', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Type of transition. ') //
+ // 'slideshow_transition' => array('title'=> 'Slide transition', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Type of transition. ') //
+ 'perpage' => array('title'=> 'Images per page', 'type' => 'number', 'data' => 'int', 'help'=>'Number of images to be shown per page', 'validate' => 'required'), // 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
);
diff --git a/e107_plugins/gallery/controllers/index.php b/e107_plugins/gallery/controllers/index.php
new file mode 100644
index 000000000..e711abc06
--- /dev/null
+++ b/e107_plugins/gallery/controllers/index.php
@@ -0,0 +1,153 @@
+ array(var => validationArray)
+ * @var array
+ */
+ protected $filter = array(
+ 'category' => array(
+ 'cat' => array('regex', '/[\w\pL\s\-+.,\']+/u'),
+ ),
+ 'list' => array(
+ 'cat' => array('regex', '/[\w\pL\s\-+.,\']+/u'),
+ 'frm' => array('int'),
+ ),
+ );
+
+ /**
+ * @var array
+ */
+ protected $catList;
+
+ public function init()
+ {
+ $this->catList = e107::getMedia()->getCategories('gallery');
+ }
+
+ public function actionIndex()
+ {
+ if(isset($_GET['cat']) && !empty($_GET['cat']))
+ {
+ $this->_forward('list');
+ }
+ else
+ {
+ $this->_forward('category');
+ }
+ }
+
+ public function actionCategory()
+ {
+ $template = e107::getTemplate('gallery');
+ $sc = e107::getScBatch('gallery',TRUE);
+
+ $text = "";
+ foreach($this->catList as $val)
+ {
+ $sc->setParserVars($val);
+ $text .= e107::getParser()->parseTemplate($template['CAT_ITEM'],TRUE);
+ }
+ $text = $template['CAT_START'].$text.$template['CAT_END'];
+ $this->addBody($text);
+ }
+
+ public function actionList()
+ {
+ $request = $this->getRequest();
+
+ // use only filtered variables
+ $cid = $request->getRequestParam('cat');
+
+ if($cid && !isset($this->catList[$cid]))
+ {
+ // get ID by SEF
+ $_cid = null;
+ foreach ($this->catList as $id => $row)
+ {
+ if($cid === $row['media_cat_title'])
+ {
+ $_cid = $id;
+ break;
+ }
+ }
+ $cid = $_cid;
+ }
+
+ if(empty($cid) || !isset($this->catList[$cid]))
+ {
+ $this->_forward('category');
+ return;
+ }
+
+ $tp = e107::getParser();
+ $template = e107::getTemplate('gallery');
+ $sc = e107::getScBatch('gallery',TRUE);
+
+ $sc->total = e107::getMedia()->countImages($cid);
+ $sc->amount = e107::getPlugPref('gallery','perpage', 12); // TODO Add Pref. amount per page.
+ $sc->curCat = $cid;
+ $sc->from = $request->getRequestParam('frm', 0);
+
+ $list = e107::getMedia()->getImages($cid,$sc->from,$sc->amount);
+ $catname = $tp->toHtml($this->catList[$cid]['media_cat_title'],false,'defs');
+ $cat = $this->catList[$cid];
+
+ $inner = "";
+
+ foreach($list as $row)
+ {
+ $sc->setVars($row)
+ ->addVars($cat);
+
+ $inner .= $tp->parseTemplate($template['LIST_ITEM'],TRUE);
+ }
+
+ $text = $tp->parseTemplate($template['LIST_START'],TRUE);
+ $text .= $inner;
+ $text .= $tp->parseTemplate($template['LIST_END'],TRUE);
+
+ $this->addBody($text);
+ }
+}
+
\ No newline at end of file
diff --git a/e107_plugins/gallery/e_header.php b/e107_plugins/gallery/e_header.php
index 3996aa836..bb0d18633 100644
--- a/e107_plugins/gallery/e_header.php
+++ b/e107_plugins/gallery/e_header.php
@@ -7,6 +7,13 @@
*/
if (!defined('e107_INIT')) { exit; }
+// Override support
+if(file_exists(e_PLUGIN.'gallery/custom_header.php'))
+{
+ include(e_PLUGIN.'gallery/custom_header.php');
+ return;
+}
+
e107::js('gallery', 'jslib/lightbox/js/lightbox.js','jquery');
e107::css('gallery', 'jslib/lightbox/css/lightbox.css','jquery');
diff --git a/e107_plugins/gallery/e_shortcode.php b/e107_plugins/gallery/e_shortcode.php
index ba33d7788..a2b007653 100644
--- a/e107_plugins/gallery/e_shortcode.php
+++ b/e107_plugins/gallery/e_shortcode.php
@@ -20,7 +20,7 @@ class gallery_shortcodes extends e_shortcode
public $slideCount = 1;
private $downloadable = FALSE;
- function __construct()
+ function init()
{
$this->downloadable = e107::getPlugPref('gallery','downloadable');
}
@@ -34,21 +34,47 @@ class gallery_shortcodes extends e_shortcode
return $text;
}
+ function sc_gallery_description($parm='')
+ {
+ $tp = e107::getParser();
+ return $tp->toHTML($this->var['media_description'], true, 'BODY');
+ }
+
+ /**
+ * All possible parameters
+ * {GALLERY_THUMB=w=200&h=200&thumburl&thumbsrc&imageurl&orig}
+ * w and h - optional width and height of the thumbnail
+ * thumburl - return only the URL of the destination image (large one)
+ * thumbsrc - url to the thumb, as it's written in the src attribute of the image
+ * imageurl - full path to the destination image (no proxy)
+ * actualPreview - large preview will use the original size of the image (if available!), prefs will be ignored
+ */
function sc_gallery_thumb($parm='')
{
$tp = e107::getParser();
- $w = 190;
- $h = 150;
+ $parms = eHelper::scParams($parm);
+
+ $w = vartrue($parms['w']) ? $parms['w'] : 190;
+ $h = vartrue($parms['h']) ? $parms['h'] : 150;
$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.'&x=1' ; // 'aw=190&ah=150';
+ $att = '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.'&x=1';
+ if(isset($parm['actualPreview']) && !empty($this->var['media_dimensions']))
+ {
+ list($pop_w, $pop_w) = array_map('trim', explode('x', $this->var['media_dimensions']));
+ }
+
+ $attFull = 'w='.$pop_w.'&h='.$pop_h.'&x=1';
+
// echo "
".$attFull;
+ if(isset($parms['thumburl'])) return $tp->thumbUrl($this->var['media_url'], $attFull);
+ elseif(isset($parms['thumbsrc'])) return $tp->thumbUrl($this->var['media_url'],$att);
+ elseif(isset($parms['imageurl'])) return $tp->replaceConstants($this->var['media_url'], 'full');
$caption = $tp->toAttribute($this->var['media_caption']) ;
$caption .= ($this->downloadable) ? " Download" : "";
@@ -63,16 +89,43 @@ class gallery_shortcodes extends e_shortcode
function sc_gallery_cat_title($parm='')
{
$tp = e107::getParser();
- $text = "";
- $text .= $tp->toHtml($this->var['media_cat_title']);
+ $url = e107::getUrl()->create('gallery/index/list', $this->var);
+ if($parm == 'title') return $tp->toHtml($this->var['media_cat_title'], false, 'TITLE');
+ $text = "";
+ $text .= $tp->toHtml($this->var['media_cat_title'], false, 'TITLE');
$text .= "";
return $text;
}
+ function sc_gallery_cat_url($parm='')
+ {
+ return e107::getUrl()->create('gallery/index/list', $this->var);
+ }
+
+ function sc_gallery_cat_description($parm='')
+ {
+ $tp = e107::getParser();
+ return $tp->toHTML($this->var['media_cat_diz'], true, 'BODY');
+ }
+
+ function sc_gallery_baseurl()
+ {
+ return e107::getUrl()->create('gallery');
+ }
+
function sc_gallery_cat_thumb($parm='')
{
- $att = ($parm) ?$parm : 'aw=190&ah=150';
- $text = "";
+ $parms = eHelper::scParams($parm);
+
+ $w = vartrue($parms['w']) ? $parms['w'] : 190;
+ $h = vartrue($parms['h']) ? $parms['h'] : 150;
+ $att = 'aw='.$w.'&ah='.$h.'&x=1'; // 'aw=190&ah=150';
+
+ $url = e107::getUrl()->create('gallery/index/list', $this->var);
+
+ if(isset($parms['thumbsrc'])) return e107::getParser()->thumbUrl($this->var['media_cat_image'],$att);
+
+ $text = "";
$text .= "";
$text .= "";
return $text;
@@ -80,8 +133,9 @@ class gallery_shortcodes extends e_shortcode
function sc_gallery_nextprev($parm='')
{
- $url = e_SELF."?cat=".$this->curCat."--AMP--frm=--FROM--";
- $parm = 'total='.$this->total.'&amount='.$this->amount.'¤t='.$this->from.'&url='.$url; // .'&url='.$url;
+ // we passs both fields, the router will convert one of them to 'cat' variable, based on the current URL config
+ $url = 'url::gallery/index/list?media_cat_category='.$this->curCat.'--AMP--media_cat_title='.$this->var['media_cat_title'].'--AMP--frm=--FROM--::full=1';
+ $parm = 'total='.$this->total.'&amount='.$this->amount.'¤t='.$this->from.'&url='.rawurlencode($url); // .'&url='.$url;
$text .= e107::getParser()->parseTemplate("{NEXTPREV=".$parm."}");
return $text;
}
@@ -102,11 +156,13 @@ class gallery_shortcodes extends e_shortcode
$limit = varset($gp['slideshow_limit'],16);
$list = e107::getMedia()->getImages('gallery_'.$this->sliderCat,0,$limit);
$item_template = e107::getTemplate('gallery','gallery','SLIDESHOW_SLIDE_ITEM');
+ $cat = $this->catList[$this->sliderCat];
$count = 1;
foreach($list as $row)
{
- $this->setParserVars($row);
+ $this->setVars($row)
+ ->addVars($cat);
$inner .= ($count == 1) ? "\n\n\n