mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 20:58:30 +01:00
169 lines
5.6 KiB
PHP
169 lines
5.6 KiB
PHP
<?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;
|
|
public $slideMode = FALSE;
|
|
public $slideCount = 1;
|
|
|
|
function sc_gallery_caption($parm='')
|
|
{
|
|
$tp = e107::getParser();
|
|
$text = "<a class='gallery-caption' title='".$tp->toAttribute($this->var['media_caption'])."' href='".e107::getParser()->replaceConstants($this->var['media_url'],'abs')."' rel='lightbox.Gallery2' >";
|
|
$text .= $this->var['media_caption'];
|
|
$text .= "</a>";
|
|
return $text;
|
|
}
|
|
|
|
function sc_gallery_thumb($parm='')
|
|
{
|
|
$tp = e107::getParser();
|
|
$w = 190;
|
|
$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 ; // '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;
|
|
|
|
$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>";
|
|
|
|
return $text;
|
|
}
|
|
|
|
function sc_gallery_cat_title($parm='')
|
|
{
|
|
$tp = e107::getParser();
|
|
$text = "<a href='".e_SELF."?cat=".$this->var['media_cat_category']."'>";
|
|
$text .= $tp->toHtml($this->var['media_cat_title']);
|
|
$text .= "</a>";
|
|
return $text;
|
|
}
|
|
|
|
function sc_gallery_cat_thumb($parm='')
|
|
{
|
|
$att = ($parm) ?$parm : 'aw=190&ah=150';
|
|
$text = "<a href='".e_SELF."?cat=".$this->var['media_cat_category']."'>";
|
|
$text .= "<img src='".e107::getParser()->thumbUrl($this->var['media_cat_image'],$att)."' alt='' />";
|
|
$text .= "</a>";
|
|
return $text;
|
|
}
|
|
|
|
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;
|
|
$text .= e107::getParser()->parseTemplate("{NEXTPREV=".$parm."}");
|
|
return $text;
|
|
}
|
|
|
|
function sc_gallery_slideshow($parm='')
|
|
{
|
|
$this->sliderCat = ($parm) ? intval($parm) : vartrue(e107::getPlugPref('gallery','slideshow_category'),1);
|
|
|
|
$template = e107::getTemplate('gallery','gallery','SLIDESHOW_WRAPPER');
|
|
return e107::getParser()->parseTemplate($template);
|
|
}
|
|
|
|
function sc_gallery_slides($parm)
|
|
{
|
|
$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);
|
|
$item_template = e107::getTemplate('gallery','gallery','SLIDESHOW_SLIDE_ITEM');
|
|
|
|
$count = 1;
|
|
foreach($list as $row)
|
|
{
|
|
$this->setParserVars($row);
|
|
|
|
$inner .= ($count == 1) ? "\n\n<!-- SLIDE ".$count." -->\n<div class='slide' id='gallery-item-".$this->slideCount."'>\n" : "";
|
|
$inner .= "\n\t".$tp->parseTemplate($item_template,TRUE)."\n";
|
|
$inner .= ($count == $amount) ? "\n</div>\n\n" : "";
|
|
|
|
if($count == $amount)
|
|
{
|
|
$count = 1;
|
|
$this->slideCount++;
|
|
}
|
|
else
|
|
{
|
|
$count++;
|
|
}
|
|
}
|
|
|
|
$inner .= ($count != 1) ? "</div><!-- END SLIDES -->" : "";
|
|
return $inner;
|
|
}
|
|
|
|
function sc_gallery_jumper($parm)
|
|
{
|
|
// echo "SlideCount=".$this->slideCount;
|
|
if($this->slideCount ==1 ){ return "gallery-jumper must be loaded after Gallery-Slides"; }
|
|
|
|
$text = '';
|
|
for($i=1; $i < ($this->slideCount +1); $i++)
|
|
{
|
|
$val = ($parm == 'space') ? " " : $i;
|
|
$text .= '<a href="#" class="gallery-slide-jumper" id="gallery-jumper-'.$i.'">'.$val.'</a>';
|
|
}
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
?>
|