2012-04-25 03:21:02 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Copyright (c) e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
|
|
|
* $Id: e_shortcode.php 12438 2011-12-05 15:12:56Z secretr $
|
|
|
|
*
|
|
|
|
* Featurebox shortcode batch class - shortcodes available site-wide. ie. equivalent to multiple .sc files.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!defined('e107_INIT')) { exit; }
|
|
|
|
|
|
|
|
class gallery_shortcodes extends e_shortcode
|
|
|
|
{
|
|
|
|
|
|
|
|
public $total = 0;
|
|
|
|
public $amount = 3;
|
|
|
|
public $from = 0;
|
|
|
|
public $curCat = null;
|
|
|
|
public $sliderCat = 1;
|
2012-04-25 10:38:12 +00:00
|
|
|
public $slideMode = FALSE;
|
2012-04-25 21:01:05 +00:00
|
|
|
public $slideCount = 1;
|
2012-08-14 04:22:40 +00:00
|
|
|
private $downloadable = FALSE;
|
2012-08-24 09:05:32 +00:00
|
|
|
private $attFull = null;
|
2012-08-14 04:22:40 +00:00
|
|
|
|
2012-08-23 12:08:06 +00:00
|
|
|
function init()
|
2012-08-14 04:22:40 +00:00
|
|
|
{
|
|
|
|
$this->downloadable = e107::getPlugPref('gallery','downloadable');
|
2012-08-24 09:05:32 +00:00
|
|
|
$pop_w = vartrue(e107::getPlugPref('gallery','pop_w'),1024);
|
|
|
|
$pop_h = vartrue(e107::getPlugPref('gallery','pop_h'),768);
|
|
|
|
$this->attFull = 'w='.$pop_w.'&h='.$pop_h.'&x=1';
|
2012-08-14 04:22:40 +00:00
|
|
|
}
|
2012-04-25 03:21:02 +00:00
|
|
|
|
|
|
|
function sc_gallery_caption($parm='')
|
|
|
|
{
|
|
|
|
$tp = e107::getParser();
|
2015-02-01 17:27:05 -08:00
|
|
|
$text = "<a class='gallery-caption' title='".$tp->toAttribute($this->var['media_caption'])."' href='".$tp->thumbUrl($this->var['media_url'], $this->attFull)."' data-gal='prettyPhoto[slide]' >"; // Erase rel"lightbox.Gallery2" - Write "prettyPhoto[slide]"
|
2012-04-25 03:21:02 +00:00
|
|
|
$text .= $this->var['media_caption'];
|
|
|
|
$text .= "</a>";
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
2012-08-23 12:08:06 +00:00
|
|
|
function sc_gallery_description($parm='')
|
|
|
|
{
|
|
|
|
$tp = e107::getParser();
|
|
|
|
return $tp->toHTML($this->var['media_description'], true, 'BODY');
|
|
|
|
}
|
|
|
|
|
2013-06-23 19:55:52 -07:00
|
|
|
function sc_gallery_breadcrumb($parm='')
|
|
|
|
{
|
|
|
|
$breadcrumb = array();
|
|
|
|
|
|
|
|
$breadcrumb[] = array('text'=> LAN_PLUGIN_GALLERY_TITLE, 'url'=> e107::getUrl()->create('gallery', $this->var));
|
|
|
|
|
|
|
|
if(vartrue($this->curCat))
|
|
|
|
{
|
|
|
|
$breadcrumb[] = array('text'=> $this->sc_gallery_cat_title('title'), 'url'=> e107::getUrl()->create('gallery/index/list', $this->var));
|
|
|
|
}
|
|
|
|
|
|
|
|
return e107::getForm()->breadcrumb($breadcrumb);
|
|
|
|
}
|
|
|
|
|
2012-08-23 12:08:06 +00:00
|
|
|
/**
|
|
|
|
* 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)
|
2012-08-23 12:41:37 +00:00
|
|
|
* actualPreview - large preview will use the original path to the image (no proxy)
|
2012-08-23 12:08:06 +00:00
|
|
|
*/
|
2012-04-25 03:21:02 +00:00
|
|
|
function sc_gallery_thumb($parm='')
|
|
|
|
{
|
2012-07-02 01:32:56 +00:00
|
|
|
$tp = e107::getParser();
|
2012-08-23 12:41:37 +00:00
|
|
|
$parms = eHelper::scParams($parm);
|
2012-08-23 12:08:06 +00:00
|
|
|
|
2014-01-14 08:16:12 -08:00
|
|
|
$w = vartrue($parms['w']) ? $parms['w'] : $tp->thumbWidth(); // 190; // 160;
|
|
|
|
$h = vartrue($parms['h']) ? $parms['h'] : $tp->thumbHeight(); // 130;
|
2012-07-01 10:12:27 +00:00
|
|
|
|
2015-02-04 23:16:27 -08:00
|
|
|
$class = ($this->slideMode == TRUE) ? 'gallery-slideshow-thumb img-responsive img-rounded' : varset($parms['class'],'gallery-thumb img-responsive');
|
2013-04-14 12:32:15 -07:00
|
|
|
// $rel = ($this->slideMode == TRUE) ? 'lightbox.SlideGallery' : 'lightbox.Gallery';
|
|
|
|
$rel = ($this->slideMode == TRUE) ? 'prettyPhoto[slide]' : 'prettyPhoto[gal]';
|
2012-08-23 12:08:06 +00:00
|
|
|
$att = 'aw='.$w.'&ah='.$h.'&x=1'; // 'aw=190&ah=150';
|
2012-07-02 01:32:56 +00:00
|
|
|
|
2012-08-24 09:05:32 +00:00
|
|
|
$srcFull = $tp->thumbUrl($this->var['media_url'], $this->attFull);
|
2013-01-15 15:27:26 -08:00
|
|
|
|
|
|
|
if(vartrue($parms['actualPreview']))
|
2012-08-23 12:08:06 +00:00
|
|
|
{
|
2012-08-23 12:41:37 +00:00
|
|
|
$srcFull = $tp->replaceConstants($this->var['media_url'], 'full');
|
2012-08-23 12:08:06 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 12:41:37 +00:00
|
|
|
if(isset($parms['thumburl'])) return $srcFull;
|
2012-08-23 12:08:06 +00:00
|
|
|
elseif(isset($parms['thumbsrc'])) return $tp->thumbUrl($this->var['media_url'],$att);
|
|
|
|
elseif(isset($parms['imageurl'])) return $tp->replaceConstants($this->var['media_url'], 'full');
|
2012-08-23 12:41:37 +00:00
|
|
|
|
2012-08-14 04:22:40 +00:00
|
|
|
$caption = $tp->toAttribute($this->var['media_caption']) ;
|
2013-04-14 12:32:15 -07:00
|
|
|
$description = ($this->downloadable) ? " <a class='btn btn-mini e-tip' title='Right-click > Save Link As' href='".$srcFull."'>Download</a>" : "";
|
2012-08-14 04:22:40 +00:00
|
|
|
|
2013-04-14 12:32:15 -07:00
|
|
|
$description .= $tp->toAttribute($this->var['media_description']);
|
|
|
|
|
2015-02-01 17:27:05 -08:00
|
|
|
$text = "<a class='".$class."' title=\"".$description."\" href='".$srcFull."' data-gal='{$rel}' >";
|
2013-04-14 12:32:15 -07:00
|
|
|
$text .= "<img class='".$class."' src='".$tp->thumbUrl($this->var['media_url'],$att)."' alt=\"".$caption."\" />";
|
2012-04-25 03:21:02 +00:00
|
|
|
$text .= "</a>";
|
2012-07-02 01:32:56 +00:00
|
|
|
|
2012-04-25 03:21:02 +00:00
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
function sc_gallery_cat_title($parm='')
|
|
|
|
{
|
|
|
|
$tp = e107::getParser();
|
2012-08-23 12:08:06 +00:00
|
|
|
$url = e107::getUrl()->create('gallery/index/list', $this->var);
|
|
|
|
if($parm == 'title') return $tp->toHtml($this->var['media_cat_title'], false, 'TITLE');
|
|
|
|
$text = "<a href='".$url."'>";
|
|
|
|
$text .= $tp->toHtml($this->var['media_cat_title'], false, 'TITLE');
|
2012-04-25 03:21:02 +00:00
|
|
|
$text .= "</a>";
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
2012-08-23 12:08:06 +00:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
2012-04-25 03:21:02 +00:00
|
|
|
function sc_gallery_cat_thumb($parm='')
|
|
|
|
{
|
2012-08-23 12:08:06 +00:00
|
|
|
$parms = eHelper::scParams($parm);
|
|
|
|
|
2013-03-22 19:57:00 -07:00
|
|
|
$w = vartrue($parms['w']) ? $parms['w'] : 300; // 260;
|
|
|
|
$h = vartrue($parms['h']) ? $parms['h'] : 200; // 180;
|
2012-08-23 12:08:06 +00:00
|
|
|
$att = 'aw='.$w.'&ah='.$h.'&x=1'; // 'aw=190&ah=150';
|
|
|
|
|
|
|
|
$url = e107::getUrl()->create('gallery/index/list', $this->var);
|
|
|
|
|
2013-12-25 01:53:38 -08:00
|
|
|
if(isset($parms['thumbsrc'])) return e107::getParser()->thumbUrl($this->var['media_cat_image'],$att);
|
2012-08-23 12:08:06 +00:00
|
|
|
|
2013-03-22 19:57:00 -07:00
|
|
|
$text = "<a class='thumbnail' href='".$url."'>";
|
2014-01-14 08:16:12 -08:00
|
|
|
$text .= "<img class='img-responsive' data-src='holder.js/".$w."x".$h."' src='".e107::getParser()->thumbUrl($this->var['media_cat_image'],$att)."' alt='' />";
|
2012-04-25 03:21:02 +00:00
|
|
|
$text .= "</a>";
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
function sc_gallery_nextprev($parm='')
|
|
|
|
{
|
2012-08-23 12:08:06 +00:00
|
|
|
// we passs both fields, the router will convert one of them to 'cat' variable, based on the current URL config
|
2013-02-07 09:05:48 +02:00
|
|
|
$url = 'route::gallery/index/list?media_cat_category='.$this->curCat.'--AMP--media_cat_sef='.$this->var['media_cat_sef'].'--AMP--frm=--FROM--::full=1';
|
2012-08-23 12:08:06 +00:00
|
|
|
$parm = 'total='.$this->total.'&amount='.$this->amount.'¤t='.$this->from.'&url='.rawurlencode($url); // .'&url='.$url;
|
2012-04-25 03:21:02 +00:00
|
|
|
$text .= e107::getParser()->parseTemplate("{NEXTPREV=".$parm."}");
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
function sc_gallery_slideshow($parm='')
|
|
|
|
{
|
2012-08-30 13:41:04 +00:00
|
|
|
$this->sliderCat = ($parm) ? $parm : vartrue(e107::getPlugPref('gallery','slideshow_category'),1);
|
2012-04-25 10:01:24 +00:00
|
|
|
|
2013-12-25 01:53:38 -08:00
|
|
|
$tmpl = e107::getTemplate('gallery','gallery');
|
|
|
|
$template = array_change_key_case($tmpl);
|
|
|
|
|
|
|
|
return e107::getParser()->parseTemplate($template['slideshow_wrapper']);
|
2012-04-25 03:21:02 +00:00
|
|
|
}
|
|
|
|
|
2014-01-14 08:16:12 -08:00
|
|
|
/**
|
|
|
|
* Display a Grid of thumbnails - useful for home pages.
|
|
|
|
* Amount per row differs according to device, so they are not set here, only the amount.
|
|
|
|
* @example {GALLERY_PORTFOLIO: placeholder=1&category=2}
|
|
|
|
*/
|
|
|
|
function sc_gallery_portfolio($parms='')
|
|
|
|
{
|
|
|
|
$ns = e107::getRender();
|
|
|
|
$parm = eHelper::scParams($parms);
|
|
|
|
$cat = ($parm['category']) ? $parm['category'] : vartrue(e107::getPlugPref('gallery','slideshow_category'), 1); //TODO Separate pref?
|
|
|
|
|
|
|
|
$tmpl = e107::getTemplate('gallery','gallery');
|
|
|
|
$limit = vartrue($parm['limit'], 6);
|
|
|
|
|
|
|
|
$list = e107::getMedia()->getImages('gallery_'.$cat.'|gallery_image_'.$cat, 0, $limit);
|
|
|
|
|
|
|
|
if(count($list) < 1 && vartrue($parm['placeholder']))
|
|
|
|
{
|
|
|
|
$list = array();
|
|
|
|
|
|
|
|
for ($i=0; $i < $limit; $i++)
|
|
|
|
{
|
|
|
|
$list[] = array('media_url'=>'');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//NOTE: Using tablerender() allows the theme developer to set the number of columns etc using col-xx-xx
|
|
|
|
foreach($list as $val)
|
|
|
|
{
|
|
|
|
$this->var = $val;
|
|
|
|
$text .= $ns->tablerender('', $this->sc_gallery_thumb('class=gallery_thumb img-responsive img-home-portfolio'),'gallery_portfolio',true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-30 13:41:04 +00:00
|
|
|
/**
|
|
|
|
* All possible parameters
|
|
|
|
* {GALLERY_SLIDES=4|limit=16&template=MY_SLIDESHOW_SLIDE_ITEM}
|
|
|
|
* first parameter is always number of slides, default is 3
|
|
|
|
* limit - (optional) total limit of pcitures to be shown
|
|
|
|
* template - (optional) template - name of template to be used for parsing the slideshow item
|
|
|
|
*/
|
2012-04-25 03:21:02 +00:00
|
|
|
function sc_gallery_slides($parm)
|
|
|
|
{
|
2012-08-30 13:41:04 +00:00
|
|
|
$tp = e107::getParser();
|
|
|
|
$this->slideMode = TRUE;
|
|
|
|
$parms = eHelper::scDualParams($parm);
|
|
|
|
$amount = $parms[1] ? intval($parms[1]) : 3; // vartrue(e107::getPlugPref('gallery','slideshow_perslide'),3);
|
|
|
|
$parms = $parms[2];
|
|
|
|
$limit = (integer) vartrue($parms['limit'], 16);
|
2013-10-09 15:48:19 -07:00
|
|
|
$list = e107::getMedia()->getImages('gallery_'.$this->sliderCat.'|gallery_image_'.$this->sliderCat,0,$limit);
|
2013-12-25 01:53:38 -08:00
|
|
|
$tmpl = e107::getTemplate('gallery','gallery');
|
|
|
|
$tmpl = array_change_key_case($tmpl); // change template key to lowercase (BC fix)
|
|
|
|
$tmpl_key = vartrue($parms['template'],'slideshow_slide_item');
|
|
|
|
$item_template = $tmpl[$tmpl_key]; // e107::getTemplate('gallery','gallery', vartrue($parms['template'], 'SLIDESHOW_SLIDE_ITEM'));
|
2012-08-30 13:41:04 +00:00
|
|
|
$catList = e107::getMedia()->getCategories('gallery');
|
|
|
|
$cat = $catList['gallery_'.$this->sliderCat];
|
2012-08-23 13:06:01 +00:00
|
|
|
|
2012-04-25 03:21:02 +00:00
|
|
|
$count = 1;
|
|
|
|
foreach($list as $row)
|
|
|
|
{
|
2012-08-23 12:08:06 +00:00
|
|
|
$this->setVars($row)
|
|
|
|
->addVars($cat);
|
2014-02-08 20:07:02 +01:00
|
|
|
|
2012-04-25 21:01:05 +00:00
|
|
|
$inner .= ($count == 1) ? "\n\n<!-- SLIDE ".$count." -->\n<div class='slide' id='gallery-item-".$this->slideCount."'>\n" : "";
|
2012-04-25 10:01:24 +00:00
|
|
|
$inner .= "\n\t".$tp->parseTemplate($item_template,TRUE)."\n";
|
2012-04-25 03:21:02 +00:00
|
|
|
$inner .= ($count == $amount) ? "\n</div>\n\n" : "";
|
2012-04-25 10:01:24 +00:00
|
|
|
|
2012-04-25 03:21:02 +00:00
|
|
|
if($count == $amount)
|
|
|
|
{
|
|
|
|
$count = 1;
|
2012-04-25 21:01:05 +00:00
|
|
|
$this->slideCount++;
|
2012-04-25 03:21:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$count++;
|
2012-04-25 21:01:05 +00:00
|
|
|
}
|
2012-04-25 03:21:02 +00:00
|
|
|
}
|
2012-04-25 21:01:05 +00:00
|
|
|
|
2012-04-25 10:01:24 +00:00
|
|
|
$inner .= ($count != 1) ? "</div><!-- END SLIDES -->" : "";
|
2012-04-25 03:21:02 +00:00
|
|
|
return $inner;
|
|
|
|
}
|
|
|
|
|
2012-04-25 21:01:05 +00:00
|
|
|
function sc_gallery_jumper($parm)
|
|
|
|
{
|
|
|
|
// echo "SlideCount=".$this->slideCount;
|
|
|
|
if($this->slideCount ==1 ){ return "gallery-jumper must be loaded after Gallery-Slides"; }
|
|
|
|
|
|
|
|
$text = '';
|
2012-07-14 10:40:40 +00:00
|
|
|
for($i=1; $i < ($this->slideCount); $i++)
|
2012-04-25 21:01:05 +00:00
|
|
|
{
|
|
|
|
$val = ($parm == 'space') ? " " : $i;
|
2012-07-01 10:12:27 +00:00
|
|
|
$text .= '<a href="#" class="gallery-slide-jumper" id="gallery-jumper-'.$i.'">'.$val.'</a>';
|
2012-04-25 21:01:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
|
|
|
}
|
2012-04-25 03:21:02 +00:00
|
|
|
}
|
|
|
|
?>
|