From e4605efb866381f099205d28fc606dfa18f70849 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Wed, 25 Apr 2012 10:01:24 +0000 Subject: [PATCH] Gallery preferences and fixes. --- e107_plugins/gallery/e_header.php | 18 +++++-- e107_plugins/gallery/e_shortcode.php | 16 ++++--- e107_plugins/gallery/gallery_style.css | 12 ++--- e107_plugins/gallery/includes/admin.php | 47 ++++++++++++++++++- e107_plugins/gallery/plugin.xml | 10 ++++ e107_plugins/gallery/slideshow_menu.php | 14 ++++++ .../gallery/templates/gallery_template.php | 12 ++--- 7 files changed, 104 insertions(+), 25 deletions(-) create mode 100644 e107_plugins/gallery/slideshow_menu.php diff --git a/e107_plugins/gallery/e_header.php b/e107_plugins/gallery/e_header.php index bdd9ef68e..b7b9a3843 100644 --- a/e107_plugins/gallery/e_header.php +++ b/e107_plugins/gallery/e_header.php @@ -16,16 +16,24 @@ e107::getJS()->headerFile("https://ajax.googleapis.com/ajax/libs/scriptaculous/1 e107::getJs()->headerPlugin('gallery', 'jslib/carousel.js'); e107::getJs()->pluginCSS('gallery', 'gallery_style.css'); +$gp = e107::getPlugPref('gallery'); + e107::getJs()->footerInline(" - new Carousel('carousel-wrapper', $$('#carousel-content .slide'), $$('a.carousel-control', 'a.carousel-jumper' ), + new Carousel('gallery-slideshow-wrapper', $$('#gallery-slideshow-content .slide'), $$('a.carousel-control', 'a.carousel-jumper' ), { - auto: true, - circular: true + duration: ".varset($gp['slideshow_duration'],1).", + auto: ".varset($gp['slideshow_auto'],0).", + frequency: ".varset($gp['slideshow_freq'],3).", + circular: ".varset($gp['slideshow_circular'],1).", + wheel: true, + visibleSlides: 1, + effect: '".varset($gp['slideshow_effect'],'scroll')."', + transition: '".varset($gp['slideshow_transition'],'sinoidal')."' + }); "); - - +unset($gp); ?> \ No newline at end of file diff --git a/e107_plugins/gallery/e_shortcode.php b/e107_plugins/gallery/e_shortcode.php index b237883b9..6f8aa16fc 100644 --- a/e107_plugins/gallery/e_shortcode.php +++ b/e107_plugins/gallery/e_shortcode.php @@ -64,14 +64,15 @@ class gallery_shortcodes extends e_shortcode function sc_gallery_slideshow($parm='') { - if($parm){ $this->sliderCat = intval($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) { - $amount = ($parm) ? intval($parm) : 3; + $amount = ($parm) ? intval($parm) : 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'); @@ -80,10 +81,11 @@ class gallery_shortcodes extends e_shortcode foreach($list as $row) { $this->setParserVars($row); + $inner .= ($count == 1) ? "\n\n\n
\n" : ""; - $inner .= "\n".$tp->parseTemplate($item_template,TRUE)."\n"; + $inner .= "\n\t".$tp->parseTemplate($item_template,TRUE)."\n"; $inner .= ($count == $amount) ? "\n
\n\n" : ""; - + if($count == $amount) { $count = 1; @@ -91,11 +93,11 @@ class gallery_shortcodes extends e_shortcode else { $count++; - } + } + } - $inner .= ($count != $amount) ? "" : ""; - + $inner .= ($count != 1) ? "" : ""; return $inner; } diff --git a/e107_plugins/gallery/gallery_style.css b/e107_plugins/gallery/gallery_style.css index b1e53d87f..5b44d5ae7 100644 --- a/e107_plugins/gallery/gallery_style.css +++ b/e107_plugins/gallery/gallery_style.css @@ -31,9 +31,9 @@ .lb-caption { } -/* CAROUSEL */ -#carousel-wrapper { width: 610px; height: 170px; overflow: hidden; background: black; margin-top:10px; margin-left:auto;margin-right:auto } -#carousel-content { width: 2500px; } -#carousel-content .slide { float: left; width: 600px; padding:10px; height: 160px; } -.controls { width: 610px; margin-left:auto;margin-right:auto; margin-bottom:10px; } -.gallery-slide-item { margin-right:5px; } +/* SLIDESHOW */ +#gallery-slideshow-wrapper { width: 610px; height: 170px; overflow: hidden; background: #000000; margin-left:auto;margin-right:auto } +#gallery-slideshow-content { width: 2500px; } +#gallery-slideshow-content .slide { float: left; width: 600px; padding:10px; height: 160px; } +.gallery-slideshow-controls { clear:both; width: 610px; margin-left:auto; margin-right:auto; padding-bottom:10px; } +.gallery-slide-item { margin-right:5px; } diff --git a/e107_plugins/gallery/includes/admin.php b/e107_plugins/gallery/includes/admin.php index 2ad8532bb..31375536a 100644 --- a/e107_plugins/gallery/includes/admin.php +++ b/e107_plugins/gallery/includes/admin.php @@ -55,7 +55,8 @@ class plugin_gallery_admin extends e_admin_dispatcher protected $adminMenu = array( // 'main/list' => array('caption'=> LAN_CATEGORY, 'perm' => 'P'), // 'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'), - 'main/gallery' => array('caption'=> 'Info', 'perm' => 'P')//, 'url'=>'{e_ADMIN}image.php' + //'main/gallery' => array('caption'=> 'Info', 'perm' => 'P'),//, 'url'=>'{e_ADMIN}image.php' + 'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => 'P') ); @@ -75,6 +76,8 @@ class plugin_gallery_admin extends e_admin_dispatcher * @var string */ protected $menuTitle = 'Gallery'; + + } @@ -120,6 +123,48 @@ class gallery_cat_admin_ui extends e_admin_ui $mes->addInfo($message); } + + + protected $prefs = array( + 'slideshow_category' => array('title'=> 'Slideshow category', 'type' => 'dropdown', 'data' => 'integer', 'help'=>'The category of images which should be used.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')), + 'slideshow_perslide' => array('title'=> 'Images per slide', 'type' => 'number', 'data' => 'integer', 'help'=>'Number of images to show per slide.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')), + 'slideshow_duration' => array('title'=> 'Slide duration', 'type' => 'number', 'data' => 'integer', 'help'=>'The duration (in seconds) of a full jump.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')), + 'slideshow_auto' => array('title'=> 'Slide auto-start', 'type'=>'boolean', 'data' => 'integer','help' => 'When enabled image-rotation begins automatically when the page is loaded.'), + '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. ') // + ); + + + + function init() + { + $effects = array('scroll'=>'scroll','fade'=>'fade'); + $this->prefs['slideshow_effect']['writeParms'] = $effects; + $this->prefs['slideshow_effect']['readParms'] = $effects; + + $transitions = array('sinoidal'=>'sinoidal','spring'=>'spring'); + $this->prefs['slideshow_transition']['writeParms'] = $transitions; + $this->prefs['slideshow_transition']['readParms'] = $transitions; + + $categories = e107::getMedia()->getCategories('gallery'); + $cats = array(); + foreach($categories as $k=>$var) + { + list($tmp,$id) = explode("_",$k); + $cats[$id] = $var['media_cat_title']; + } + + $this->prefs['slideshow_category']['writeParms'] = $cats; + $this->prefs['slideshow_category']['readParms'] = $cats; + + $mes = e107::getMessage(); + $message = "Gallery is active. Simply import and assign images to the gallery categories using the Media Manager"; + + $mes->addInfo($message); + } + } diff --git a/e107_plugins/gallery/plugin.xml b/e107_plugins/gallery/plugin.xml index ab9960a3c..df3584990 100644 --- a/e107_plugins/gallery/plugin.xml +++ b/e107_plugins/gallery/plugin.xml @@ -15,4 +15,14 @@ + + 1 + 3 + 1 + 1 + 3 + 1 + scroll + sinoidal + diff --git a/e107_plugins/gallery/slideshow_menu.php b/e107_plugins/gallery/slideshow_menu.php new file mode 100644 index 000000000..4ca111724 --- /dev/null +++ b/e107_plugins/gallery/slideshow_menu.php @@ -0,0 +1,14 @@ +parseTemplate("{GALLERY_SLIDESHOW}"); +e107::getRender()->tablerender("Gallery",$text,'gallery_slideshow'); +unset($text); + +?> diff --git a/e107_plugins/gallery/templates/gallery_template.php b/e107_plugins/gallery/templates/gallery_template.php index b4c9a8d1c..068fdb695 100644 --- a/e107_plugins/gallery/templates/gallery_template.php +++ b/e107_plugins/gallery/templates/gallery_template.php @@ -44,15 +44,15 @@ $GALLERY_TEMPLATE['CAT_END'] = "; -// {GALLERY_SLIDESHOW=X} X = Gallery Category. Default: 1 (ie. 'gallery_1') -// {GALLERY_SLIDES=X} X = number of items per slide. +// {GALLERY_SLIDESHOW=X} X = Gallery Category. Default: 1 (ie. 'gallery_1') Overrides preference in admin. +// {GALLERY_SLIDES=X} X = number of items per slide. (Overrides preference in admin.) $GALLERY_TEMPLATE['SLIDESHOW_WRAPPER'] = ' -