1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-07 15:16:30 +02:00

Use Library Manager to load libraries. Use JS behaviors. Add "Order images by" pref.

This commit is contained in:
Lóna Lore
2016-03-29 11:22:25 +02:00
parent 3198440697
commit 6b9838ae99
11 changed files with 467 additions and 322 deletions

View File

@@ -14,20 +14,24 @@
* $Author: e107coders $ * $Author: e107coders $
*/ */
// TODO: lan
// TODO: prefs for prettyPhoto library, e.g. theme settings
$eplug_admin = true; $eplug_admin = true;
require_once("../../class2.php"); require_once("../../class2.php");
if (!getperms("P") || !e107::isInstalled('gallery')) if(!getperms("P") || !e107::isInstalled('gallery'))
{ {
e107::redirect('admin'); e107::redirect('admin');
exit() ; exit();
} }
$e_sub_cat = 'gallery'; $e_sub_cat = 'gallery';
class plugin_gallery_admin extends e_admin_dispatcher class plugin_gallery_admin extends e_admin_dispatcher
{ {
/** /**
* Format: 'MODE' => array('controller' =>'CONTROLLER_CLASS'[, 'index' => 'list', 'path' => 'CONTROLLER SCRIPT PATH', 'ui' => 'UI CLASS NAME child of e_admin_ui', 'uipath' => 'UI SCRIPT PATH']); * Format: 'MODE' => array('controller' =>'CONTROLLER_CLASS'[, 'index' => 'list', 'path' => 'CONTROLLER SCRIPT PATH', 'ui' => 'UI CLASS NAME child of e_admin_ui', 'uipath' => 'UI SCRIPT PATH']);
* Note - default mode/action is autodetected in this order: * Note - default mode/action is autodetected in this order:
@@ -36,18 +40,18 @@ class plugin_gallery_admin extends e_admin_dispatcher
* - $modes (first key == mode, corresponding 'index' key == action) * - $modes (first key == mode, corresponding 'index' key == action)
* @var array * @var array
*/ */
protected $modes = array ( protected $modes = array(
'main' => array ( 'main' => array(
'controller' => 'gallery_cat_admin_ui', 'controller' => 'gallery_cat_admin_ui',
'path' => null, 'path' => null,
'ui' => 'gallery_cat_admin_form_ui', 'ui' => 'gallery_cat_admin_form_ui',
'uipath' => null 'uipath' => null
), ),
'cat' => array ( 'cat' => array(
'controller' => 'gallery_cat_ui', 'controller' => 'gallery_cat_ui',
'path' => null, 'path' => null,
'ui' => 'gallery_cat_form_ui', 'ui' => 'gallery_cat_form_ui',
'uipath' => null 'uipath' => null
) )
); );
@@ -62,10 +66,10 @@ class plugin_gallery_admin extends e_admin_dispatcher
* @var array * @var array
*/ */
protected $adminMenu = array( protected $adminMenu = array(
// 'main/list' => array('caption'=> LAN_CATEGORY, 'perm' => 'P'), // 'main/list' => array('caption'=> LAN_CATEGORY, 'perm' => 'P'),
// 'main/create' => array('caption'=> LAN_CREATE, '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') 'main/prefs' => array('caption' => LAN_PREFS, 'perm' => 'P')
); );
@@ -76,8 +80,8 @@ class plugin_gallery_admin extends e_admin_dispatcher
* @var array * @var array
*/ */
protected $adminMenuAliases = array( protected $adminMenuAliases = array(
/// 'main/edit' => 'main/list', /// 'main/edit' => 'main/list',
// 'cat/edit' => 'cat/list' // 'cat/edit' => 'cat/list'
); );
/** /**
@@ -90,7 +94,7 @@ class plugin_gallery_admin extends e_admin_dispatcher
{ {
if(E107_DEBUG_LEVEL > 0) if(E107_DEBUG_LEVEL > 0)
{ {
$this->adminMenu['main/list'] = array('caption'=> LAN_CATEGORY, 'perm' => 'P'); $this->adminMenu['main/list'] = array('caption' => LAN_CATEGORY, 'perm' => 'P');
} }
} }
} }
@@ -98,46 +102,46 @@ class plugin_gallery_admin extends e_admin_dispatcher
class gallery_cat_admin_ui extends e_admin_ui class gallery_cat_admin_ui extends e_admin_ui
{ {
protected $pluginTitle = 'Gallery Categories';
protected $pluginName = 'gallery';
protected $table = "core_media_cat";
protected $pid = "media_cat_id";
protected $perPage = 10; //no limit
protected $listOrder = 'media_cat_order';
protected $listQry = "SELECT * FROM `#core_media_cat` WHERE media_cat_owner = 'gallery' "; // without any Order or Limit. protected $pluginTitle = 'Gallery Categories';
protected $pluginName = 'gallery';
protected $table = "core_media_cat";
protected $pid = "media_cat_id";
protected $perPage = 10; //no limit
protected $listOrder = 'media_cat_order';
protected $listQry = "SELECT * FROM `#core_media_cat` WHERE media_cat_owner = 'gallery' "; // without any Order or Limit.
// protected $listQry = "SELECT * FROM #core_media "; // without any Order or Limit. // protected $listQry = "SELECT * FROM #core_media "; // without any Order or Limit.
// protected $editQry = "SELECT * FROM #faq_info WHERE faq_info_id = {ID}"; // protected $editQry = "SELECT * FROM #faq_info WHERE faq_info_id = {ID}";
protected $fields = array( protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), 'checkboxes' => array('title' => '', 'type' => null, 'width' => '5%', 'forced' => true, 'thclass' => 'center', 'class' => 'center'),
// 'media_cat_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readonly'=>TRUE), // 'media_cat_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readonly'=>TRUE),
'media_cat_image' => array('title'=> LAN_IMAGE, 'type' => 'image', 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>FALSE, 'batch' => FALSE, 'filter'=>FALSE), 'media_cat_image' => array('title' => LAN_IMAGE, 'type' => 'image', 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class' => 'center', 'readParms' => 'thumb=60&thumb_urlraw=0&thumb_aw=60', 'readonly' => false, 'batch' => false, 'filter' => false),
'media_cat_owner' => array('title'=> "Owner", 'type' => 'hidden', 'nolist'=>true, 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE, 'writeParms' =>'value=gallery'), 'media_cat_owner' => array('title' => "Owner", 'type' => 'hidden', 'nolist' => true, 'width' => 'auto', 'thclass' => 'left', 'readonly' => false, 'writeParms' => 'value=gallery'),
'media_cat_category' => array('title'=> LAN_CATEGORY, 'type' => 'hidden', 'nolist'=>true, 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE), 'media_cat_category' => array('title' => LAN_CATEGORY, 'type' => 'hidden', 'nolist' => true, 'width' => 'auto', 'thclass' => 'left', 'readonly' => true),
'media_cat_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE), 'media_cat_title' => array('title' => LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly' => false),
'media_cat_sef' => array('title'=> LAN_SEFURL, 'type'=>'text', 'inline'=>true, 'width'=>'auto', 'thclass' => 'left'), 'media_cat_sef' => array('title' => LAN_SEFURL, 'type' => 'text', 'inline' => true, 'width' => 'auto', 'thclass' => 'left'),
'media_cat_diz' => array('title'=> LAN_DESCRIPTION, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=150&bb=1','readonly'=>FALSE), // Display name 'media_cat_diz' => array('title' => LAN_DESCRIPTION, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=150&bb=1', 'readonly' => false), // Display name
'media_cat_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'width' => 'auto', 'data' => 'int', 'filter'=>TRUE, 'batch'=>TRUE), 'media_cat_class' => array('title' => LAN_VISIBILITY, 'type' => 'userclass', 'width' => 'auto', 'data' => 'int', 'filter' => true, 'batch' => true),
'media_cat_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => 'auto', 'thclass' => 'center', 'class'=> 'center' ), 'media_cat_order' => array('title' => LAN_ORDER, 'type' => 'text', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center'),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '5%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'right') 'options' => array('title' => LAN_OPTIONS, 'type' => null, 'width' => '5%', 'forced' => true, 'thclass' => 'center last', 'class' => 'right')
); );
public function beforeCreate($new_data) public function beforeCreate($new_data)
{ {
$replace = array("_"," ","'",'"',"."); //FIXME Improve $replace = array("_", " ", "'", '"', "."); //FIXME Improve
$new_data['media_cat_category'] = strtolower(str_replace($replace,"",$new_data['media_cat_title'])); $new_data['media_cat_category'] = strtolower(str_replace($replace, "", $new_data['media_cat_title']));
return $new_data; return $new_data;
} }
function galleryPage() function galleryPage()
{ {
$mes = e107::getMessage(); $mes = e107::getMessage();
$message = "<b>Gallery</b> is active. Simply import and assign images to the gallery categories using the <a href='".e_ADMIN."image.php'>Media Manager</a>"; $message = "<b>Gallery</b> is active. Simply import and assign images to the gallery categories using the <a href='" . e_ADMIN . "image.php'>Media Manager</a>";
$mes->addInfo($message); $mes->addInfo($message);
} }
@@ -146,63 +150,77 @@ class gallery_cat_admin_ui extends e_admin_ui
protected $preftabs = array('General', 'Slideshow Menu'); protected $preftabs = array('General', 'Slideshow Menu');
protected $prefs = array( protected $prefs = array(
'popup_w' => array('title'=> 'Image Max. Width', 'tab'=>0, '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_w' => array('title' => 'Image Max. Width', 'tab' => 0, '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', 'tab'=>0, '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')), 'popup_h' => array('title' => 'Image Max. Height', 'tab' => 0, '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', 'tab'=>0, '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')), 'downloadable' => array('title' => 'Show "download" link', 'tab' => 0, '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', 'tab'=>1, '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_category' => array('title' => 'Slideshow category', 'tab' => 1, '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')), // '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')),
// 'slideshow_thumb_h' => array('title'=> 'Thumbnail Height', 'type' => 'number', 'data' => 'integer', 'help'=>'Height in px'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')), // 'slideshow_thumb_h' => array('title'=> 'Thumbnail Height', 'type' => 'number', 'data' => 'integer', 'help'=>'Height in px'), // '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_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', 'tab'=>1,'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_duration' => array('title' => 'Slide duration', 'type' => 'number', 'tab' => 1, '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', 'tab'=>1,'data' => 'integer','help' => 'When enabled image-rotation begins automatically when the page is loaded.'), 'slideshow_auto' => array('title' => 'Slide auto-start', 'type' => 'boolean', 'tab' => 1, 'data' => 'integer', 'help' => 'When enabled image-rotation begins automatically when the page is loaded.'),
'slideshow_freq' => array('title'=> 'Slide frequency', 'type' => 'number', 'tab'=>1,'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_freq' => array('title' => 'Slide frequency', 'type' => 'number', 'tab' => 1, '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_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', 'tab'=>1,'data' => 'str', 'help'=>'Type of effect. '), // 'slideshow_effect' => array('title' => 'Slide effect', 'type' => 'dropdown', 'tab' => 1, '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', 'tab'=>0, 'type' => 'number', 'data' => 'int', 'help'=>'Number of images to be shown per page'), // 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')), 'perpage' => array('title' => 'Images per page', 'tab' => 0, 'type' => 'number', 'data' => 'int', 'help' => 'Number of images to be shown per page'), // 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'orderby' => array(
'title' => 'Order images by',
'tab' => 0,
'type' => 'dropdown',
'data' => 'str',
'writeParms' => array(
'optArray' => array(
'media_id ASC' => 'Media ID ASC',
'media_id DESC' => 'Media ID DESC',
'media_name ASC' => 'Media Name ASC',
'media_name DESC' => 'Media Name DESC',
'media_caption ASC' => 'Media Caption ASC',
'media_caption DESC' => 'Media Caption DESC',
),
),
),
); );
function init() function init()
{ {
$effects = array( $effects = array(
'scrollHorz' => 'slide left', 'scrollHorz' => 'slide left',
'scrollVert' => 'slide down', 'scrollVert' => 'slide down',
// 'turnDown' => 'turn Down', // 'turnDown' => 'turn Down',
// 'turnUp' => 'turn Up', // 'turnUp' => 'turn Up',
// 'curtainX' => 'curtainX', // 'curtainX' => 'curtainX',
// 'curtainY' => 'curtainY', // 'curtainY' => 'curtainY',
'fade' => 'fade', 'fade' => 'fade',
// 'zoom' => 'zoom' // 'zoom' => 'zoom'
); );
$this->prefs['slideshow_effect']['writeParms'] = $effects;
$this->prefs['slideshow_effect']['readParms'] = $effects;
//
// $transitions = array('sinoidal'=>'sinoidal','spring'=>'spring');
$this->prefs['slideshow_effect']['writeParms'] = $effects; // $this->prefs['slideshow_transition']['writeParms'] = $transitions;
$this->prefs['slideshow_effect']['readParms'] = $effects; // $this->prefs['slideshow_transition']['readParms'] = $transitions;
//
// $transitions = array('sinoidal'=>'sinoidal','spring'=>'spring');
// $this->prefs['slideshow_transition']['writeParms'] = $transitions;
// $this->prefs['slideshow_transition']['readParms'] = $transitions;
$categories = e107::getMedia()->getCategories('gallery'); $categories = e107::getMedia()->getCategories('gallery');
$cats = array(); $cats = array();
foreach($categories as $k=>$var) foreach($categories as $k => $var)
{ {
$id = preg_replace("/[^0-9]/", '', $k); $id = preg_replace("/[^0-9]/", '', $k);
$cats[$id] = $var['media_cat_title']; $cats[$id] = $var['media_cat_title'];
} }
$this->prefs['slideshow_category']['writeParms'] = $cats; $this->prefs['slideshow_category']['writeParms'] = $cats;
$this->prefs['slideshow_category']['readParms'] = $cats; $this->prefs['slideshow_category']['readParms'] = $cats;
$mes = e107::getMessage(); $mes = e107::getMessage();
$message = "<b>Gallery</b> is active. Simply import and assign images to the gallery categories using the <a href='".e_ADMIN."image.php'>Media Manager</a>"; $message = "<b>Gallery</b> is active. Simply import and assign images to the gallery categories using the <a href='" . e_ADMIN . "image.php'>Media Manager</a>";
$mes->addInfo($message); $mes->addInfo($message);
} }
@@ -210,12 +228,13 @@ class gallery_cat_admin_ui extends e_admin_ui
} }
class gallery_cat_admin_form_ui extends e_admin_form_ui class gallery_cat_admin_form_ui extends e_admin_form_ui
{ {
// Override the default Options field. // Override the default Options field.
public function gallery_category_parent($curVal,$mode) public function gallery_category_parent($curVal, $mode)
{ {
// TODO - catlist combo without current cat ID in write mode, parents only for batch/filter // TODO - catlist combo without current cat ID in write mode, parents only for batch/filter
// Get UI instance // Get UI instance
@@ -224,47 +243,37 @@ class gallery_cat_admin_form_ui extends e_admin_form_ui
{ {
case 'read': case 'read':
return e107::getParser()->toHTML($controller->getDownloadCategoryTree($curVal), false, 'TITLE'); return e107::getParser()->toHTML($controller->getDownloadCategoryTree($curVal), false, 'TITLE');
break; break;
case 'write': case 'write':
return $this->selectbox('gallery_category_parent', $controller->getDownloadCategoryTree(), $curVal); return $this->selectbox('gallery_category_parent', $controller->getDownloadCategoryTree(), $curVal);
break; break;
case 'filter': case 'filter':
case 'batch': case 'batch':
return $controller->getDownloadCategoryTree(); return $controller->getDownloadCategoryTree();
break; break;
} }
} }
} }
class gallery_main_admin_ui extends e_admin_ui class gallery_main_admin_ui extends e_admin_ui
{ {
} }
class gallery_main_admin_form_ui extends e_admin_form_ui class gallery_main_admin_form_ui extends e_admin_form_ui
{ {
} }
new plugin_gallery_admin(); new plugin_gallery_admin();
require_once(e_ADMIN."auth.php"); require_once(e_ADMIN . "auth.php");
e107::getAdminUI()->runPage(); //gallery/includes/admin.php is auto-loaded. e107::getAdminUI()->runPage(); //gallery/includes/admin.php is auto-loaded.
require_once(e_ADMIN."footer.php"); require_once(e_ADMIN . "footer.php");
exit; exit;
?>

View File

@@ -66,24 +66,11 @@ class plugin_gallery_index_controller extends eControllerFront
public function init() public function init()
{ {
e107::plugLan('gallery', 'front'); e107::plugLan('gallery', 'front');
e107::js('gallery', 'jslib/prettyPhoto/js/jquery.prettyPhoto.js','jquery');
e107::css('gallery', 'jslib/prettyPhoto/css/prettyPhoto.css','jquery');
e107::css('gallery', 'gallery_style.css');
$prettyPhoto = <<<JS e107::library('load', 'jquery.prettyPhoto');
$(document).ready(function(){ e107::css('gallery', 'css/gallery.css');
$("a[data-gal^='prettyPhoto']").prettyPhoto( e107::js('gallery', 'js/gallery.js');
{
hook: 'data-gal',
theme: 'pp_default',
overlay_gallery: false,
deeplinking: false
}
);
});
JS;
e107::js('footer-inline',$prettyPhoto,'jquery');
$this->catList = e107::getMedia()->getCategories('gallery'); $this->catList = e107::getMedia()->getCategories('gallery');
} }

View File

@@ -0,0 +1,55 @@
/* IMAGE LIST */
ul.gallery > li > div > h5 { text-align: center }
ul.gallery-cat > li > div > h3 { text-align: center }
/* CATEGORY LIST */
.lb-dataContainer { padding-top:10px; font-size: 110%;}
.lb-caption { }
/* SLIDESHOW */
#gallery-slideshow-wrapper { display:block; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; width: 664px; height: 146px; overflow: hidden; background: #000000; margin-left:auto;margin-right:auto }
#gallery-slideshow-content { width: 3500px; }
#gallery-slideshow-content .slide { float: left; width: 679px; padding:12px; height: 146px; white-space:nowrap }
.gallery-slideshow-controls { clear:both; width: 664px; margin-left:auto; margin-right:auto; padding-top:5px; padding-bottom:10px; }
.gallery-slide-item { margin-right:8px; display: inline-block; }
.gallery-slideshow-thumb { -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; }
.gallery-slideshow-thumb:hover { }
.gallery-slide-jumper-container { text-align:center; padding-left:250px;}
.gallery-slide-jumper { padding:3px;}
.gallery-slide-jumper-selected { font-weight:bold }
/* Fix for Bootstrap2 margin-left issue when wrapping */
.row-fluid .gallery div.span6:nth-child(2n + 3) { margin-left : 0px; }
.row-fluid .gallery div.span4:nth-child(3n + 4) { margin-left : 0px; }
.row-fluid .gallery div.span3:nth-child(4n + 5) { margin-left : 0px; }
.row-fluid .gallery div.span2:nth-child(6n + 7) { margin-left : 0px; }
.row-fluid .gallery-cat div.span6:nth-child(2n + 3) { margin-left : 0px; }
.row-fluid .gallery-cat div.span4:nth-child(3n + 4) { margin-left : 0px; }
.row-fluid .gallery-cat div.span3:nth-child(4n + 5) { margin-left : 0px; }
.row-fluid .gallery-cat div.span2:nth-child(6n + 7) { margin-left : 0px; }
/* Work-around for indent issue. see: https://github.com/twitter/bootstrap/issues/4890 */
.thumbnails .span2:nth-child(6n+1) {
margin-left:0;
}

View File

@@ -5,13 +5,11 @@
* *
* Featurebox shortcode batch class - shortcodes available site-wide. ie. equivalent to multiple .sc files. * Featurebox shortcode batch class - shortcodes available site-wide. ie. equivalent to multiple .sc files.
*/ */
if (!defined('e107_INIT')) { exit; }
//e107::js('gallery', 'jslib/lightbox/js/lightbox.js','jquery');
//e107::css('gallery', 'jslib/lightbox/css/lightbox.css','jquery');
// See: http://www.no-margin-for-errors.com/projects/prettyPhoto-jquery-lightbox-clone
if(!defined('e107_INIT'))
{
exit;
}
if(USER_AREA) if(USER_AREA)
{ {
@@ -20,43 +18,5 @@ if(USER_AREA)
/* Gallery CSS */ /* Gallery CSS */
.thumbnails .span2:nth-child(6n+1) { .thumbnails .span2:nth-child(6n+1) {
margin-left:0; margin-left:0;
}",'jquery'); }", 'jquery');
/*
e107::js('gallery', 'jslib/prettyPhoto/js/jquery.prettyPhoto.js','jquery');
e107::css('gallery', 'jslib/prettyPhoto/css/prettyPhoto.css','jquery');
e107::css('gallery', 'gallery_style.css');
$prettyPhoto = <<<JS
$(document).ready(function(){
$("a[data-gal^='prettyPhoto']").prettyPhoto(
{
hook: 'data-gal',
theme: 'pp_default',
overlay_gallery: false,
deeplinking: false
}
);
});
JS;
e107::js('footer-inline',$prettyPhoto,'jquery');
unset($gp);
*/
} }
?>

View File

@@ -0,0 +1,162 @@
<?php
/**
* @file
* Provides information about external libraries.
*/
/**
* Class PLUGIN_library.
*/
class gallery_library
{
/**
* Return information about external libraries.
*
* @return
* An associative array whose keys are internal names of libraries and whose values are describing each library.
* Each key is the directory name below the '{e_WEB}/lib' directory, in which the library may be found. Each
* value is an associative array containing:
* - name: The official, human-readable name of the library.
* - vendor_url: The URL of the homepage of the library.
* - download_url: The URL of a web page on which the library can be obtained.
* - path: (optional) A relative path from the directory of the library to the actual library. Only required if
* the extracted download package contains the actual library files in a sub-directory.
* - library_path: (optional) The absolute path to the library directory. This should not be declared normally, as
* it is automatically detected, to allow for multiple possible library locations. A valid use-case is an
* external library, in which case the full URL to the library should be specified here.
* - version: (optional) The version of the library. This should not be declared normally, as it is automatically
* detected (see 'version_callback' below) to allow for version changes of libraries without code changes of
* implementing plugins and to support different versions of a library simultaneously. A valid use-case is an
* external library whose version cannot be determined programmatically. Either 'version' or 'version_callback'
* (or 'version_arguments' in case libraryGetVersion() is being used as a version callback) must be declared.
* - version_callback: (optional) The name of a function that detects and returns the full version string of the
* library. The first argument is always $library, an array containing all library information as described here.
* There are two ways to declare the version callback's additional arguments, either as a single $options
* parameter or as multiple parameters, which correspond to the two ways to specify the argument values (see
* 'version_arguments'). Defaults to libraryGetVersion(). Unless 'version' is declared or libraryGetVersion()
* is being used as a version callback, 'version_callback' must be declared. In the latter case, however,
* 'version_arguments' must be declared in the specified way.
* - version_arguments: (optional) A list of arguments to pass to the version callback. Version arguments can be
* declared either as an associative array whose keys are the argument names or as an indexed array without
* specifying keys. If declared as an associative array, the arguments get passed to the version callback as a
* single $options parameter whose keys are the argument names (i.e. $options is identical to the specified
* array). If declared as an indexed array, the array values get passed to the version callback as separate
* arguments in the order they were declared. The default version callback libraryGetVersion() expects a
* single, associative array with named keys:
* - file: The filename to parse for the version, relative to the path specified as the 'library_path' property
* (see above). For example: 'docs/changelog.txt'.
* - pattern: A string containing a regular expression (PCRE) to match the library version. For example:
* '@version\s+([0-9a-zA-Z\.-]+)@'. Note that the returned version is not the match of the entire pattern
* (i.e. '@version 1.2.3' in the above example) but the match of the first sub-pattern (i.e. '1.2.3' in the
* above example).
* - lines: (optional) The maximum number of lines to search the pattern in. Defaults to 20.
* - cols: (optional) The maximum number of characters per line to take into account. Defaults to 200. In case
* of minified or compressed files, this prevents reading the entire file into memory.
* Defaults to an empty array. 'version_arguments' must be specified unless 'version' is declared or the
* specified 'version_callback' does not require any arguments. The latter might be the case with a
* library-specific version callback, for example.
* - files: An associative array of library files to load. Supported keys are:
* - js: A list of JavaScript files to load.
* - css: A list of CSS files to load.
* - php: A list of PHP files to load.
* - dependencies: An array of libraries this library depends on. Similar to declaring plugin dependencies, the
* dependency declaration may contain information on the supported version. Examples of supported declarations:
* @code
* $library['dependencies'] = array(
* // Load the 'example' library, regardless of the version available:
* 'example',
* // Only load the 'example' library, if version 1.2 is available:
* 'example (1.2)',
* // Only load a version later than 1.3-beta2 of the 'example' library:
* 'example (>1.3-beta2)'
* // Only load a version equal to or later than 1.3-beta3:
* 'example (>=1.3-beta3)',
* // Only load a version earlier than 1.5:
* 'example (<1.5)',
* // Only load a version equal to or earlier than 1.4:
* 'example (<=1.4)',
* // Combinations of the above are allowed as well:
* 'example (>=1.3-beta2, <1.5)',
* );
* @endcode
* - variants: (optional) An associative array of available library variants. For example, the top-level 'files'
* property may refer to a default variant that is compressed. If the library also ships with a minified and
* uncompressed/source variant, those can be defined here. Each key should describe the variant type, e.g.
* 'minified' or 'source'. Each value is an associative array of top-level properties that are entirely
* overridden by the variant, most often just 'files'. Additionally, each variant can contain following
* properties:
* - variant_callback: (optional) The name of a function that detects the variant and returns TRUE or FALSE,
* depending on whether the variant is available or not. The first argument is always $library, an array
* containing all library information as described here. The second argument is always a string containing the
* variant name. There are two ways to declare the variant callback's additional arguments, either as a single
* $options parameter or as multiple parameters, which correspond to the two ways to specify the argument
* values (see 'variant_arguments'). If omitted, the variant is expected to always be available.
* - variant_arguments: A list of arguments to pass to the variant callback. Variant arguments can be declared
* either as an associative array whose keys are the argument names or as an indexed array without specifying
* keys. If declared as an associative array, the arguments get passed to the variant callback as a single
* $options parameter whose keys are the argument names (i.e. $options is identical to the specified array).
* If declared as an indexed array, the array values get passed to the variant callback as separate arguments
* in the order they were declared.
* Variants can be version-specific (see 'versions').
* - versions: (optional) An associative array of supported library versions. Naturally, libraries evolve over
* time and so do their APIs. In case a library changes between versions, different 'files' may need to be
* loaded, different 'variants' may become available, or e107 plugins need to load different integration files
* adapted to the new version. Each key is a version *string* (PHP does not support floats as keys). Each value
* is an associative array of top-level properties that are entirely overridden by the version.
* - integration_files: (optional) Sets of files to load for the plugin, using the same notion as the top-level
* 'files' property. Each specified file should contain the path to the file relative to the plugin it belongs
* to.
* Additional top-level properties can be registered as needed.
*/
function config()
{
$libraries['jquery.prettyPhoto'] = array(
// Only used in administrative UI of Libraries API.
'name' => 'prettyPhoto',
'vendor_url' => 'http://www.no-margin-for-errors.com',
'download_url' => 'https://github.com/scaron/prettyphoto',
'version_arguments' => array(
'file' => 'js/jquery.prettyPhoto.js',
// Version: 3.1.6
'pattern' => '/Version: (\d+\.+\d+\.+\d+)/',
'lines' => 5,
),
'files' => array(
'js' => array(
'js/jquery.prettyPhoto.js' => array(
'type' => 'footer',
),
),
'css' => array(
'css/prettyPhoto.css',
),
),
);
$libraries['jquery.cycle'] = array(
// Only used in administrative UI of Libraries API.
'name' => 'jQuery Cycle Plugin',
'vendor_url' => 'http://jquery.malsup.com/cycle/',
'download_url' => 'http://jquery.malsup.com/cycle/',
'version_arguments' => array(
'file' => 'jquery.cycle.all.js',
// Version: 2.9999.5
'pattern' => '/Version: (\d+\.+\d+\.+\d+)/',
'lines' => 5,
),
'files' => array(
'js' => array(
'jquery.cycle.all.js' => array(
'type' => 'footer',
),
),
),
);
return $libraries;
}
}

View File

@@ -30,24 +30,8 @@ class gallery_shortcodes extends e_shortcode
$pop_h = vartrue($prefH, 768); $pop_h = vartrue($prefH, 768);
$this->attFull = array('w'=>$pop_w, 'h'=>$pop_h, 'x'=>1, 'crop'=>0); // 'w='.$pop_w.'&h='.$pop_h.'&x=1'; $this->attFull = array('w'=>$pop_w, 'h'=>$pop_h, 'x'=>1, 'crop'=>0); // 'w='.$pop_w.'&h='.$pop_h.'&x=1';
e107::js('gallery', 'jslib/prettyPhoto/js/jquery.prettyPhoto.js','jquery'); e107::library('load', 'jquery.prettyPhoto');
e107::css('gallery', 'jslib/prettyPhoto/css/prettyPhoto.css','jquery'); e107::js('gallery', 'js/gallery.js');
$prettyPhoto = <<<JS
$(document).ready(function(){
$("a[data-gal^='prettyPhoto']").prettyPhoto(
{
hook: 'data-gal',
theme: 'pp_default',
overlay_gallery: false,
deeplinking: false
}
);
});
JS;
e107::js('footer-inline',$prettyPhoto,'jquery');
} }
function sc_gallery_caption($parm='') function sc_gallery_caption($parm='')

View File

@@ -21,47 +21,21 @@
* Ultra-simple Image-Gallery * Ultra-simple Image-Gallery
*/ */
require_once("../../class2.php"); require_once("../../class2.php");
if (!e107::isInstalled('gallery')) if (!e107::isInstalled('gallery'))
{ {
e107::redirect(); e107::redirect();
exit; exit;
} }
e107::library('load', 'jquery.prettyPhoto');
e107::js('gallery', 'jslib/prettyPhoto/js/jquery.prettyPhoto.js','jquery'); e107::css('gallery', 'css/gallery.css');
e107::css('gallery', 'jslib/prettyPhoto/css/prettyPhoto.css','jquery'); e107::js('gallery', 'js/gallery.js');
e107::css('gallery', 'gallery_style.css');
// Work-around for indent issue. see: https://github.com/twitter/bootstrap/issues/4890
e107::css('inline', "
/* Gallery CSS */
.thumbnails .span2:nth-child(6n+1) {
margin-left:0;
}",'jquery');
$prettyPhoto = <<<JS
$(document).ready(function(){
$("a[data-gal^='prettyPhoto']").prettyPhoto(
{
hook: 'data-gal',
theme: 'pp_default', /* pp_default , light_rounded , dark_rounded , light_square , dark_square ,facebook */
overlay_gallery: false,
deeplinking: false
}
);
});
JS;
e107::js('inline',$prettyPhoto,'jquery');
require_once(HEADERF); require_once(HEADERF);
class gallery class gallery
{ {
private $catList = array(); private $catList = array();

View File

@@ -0,0 +1,49 @@
var e107 = e107 || {'settings': {}, 'behaviors': {}};
(function ($)
{
/**
* Behavior to initialize gallery slideshow.
*
* @type {{attach: Function}}
*/
e107.behaviors.galleryCycle = {
attach: function (context, settings)
{
$(context).find("#gallery-slideshow-content").once('gallery-slideshow-content').each(function ()
{
$(this).cycle({
fx: settings.gallery.fx,
next: '.gal-next',
prev: '.gal-prev',
speed: settings.gallery.speed, // speed of the transition (any valid fx speed value)
timeout: settings.gallery.timeout,
slideExpr: '.slide',
pause: 1, // pause on hover - TODO pref
activePagerClass: '.gallery-slide-jumper-selected',
before: function (currSlideElement, nextSlideElement, options, forwardFlag)
{
var nx = $(nextSlideElement).attr('id').split('item-');
var th = $(currSlideElement).attr('id').split('item-');
$('#gallery-jumper-' + th[1]).removeClass('gallery-slide-jumper-selected');
$('#gallery-jumper-' + nx[1]).addClass('gallery-slide-jumper-selected');
}
});
});
$(context).find(".gallery-slide-jumper").once('gallery-slide-jumper').each(function ()
{
$(this).click(function ()
{
var nid = $(this).attr('id');
var id = nid.split('-jumper-');
var go = parseInt(id[1]) - 1;
$('#gallery-slideshow-content').cycle(go);
return false;
});
});
}
};
})(jQuery);

View File

@@ -0,0 +1,28 @@
var e107 = e107 || {'settings': {}, 'behaviors': {}};
(function ($)
{
/**
* Behavior to initialize prettyPhoto on gallery elements.
*
* @type {{attach: Function}}
*/
e107.behaviors.gallery = {
attach: function (context, settings)
{
$(context).find("a[data-gal^='prettyPhoto']").once('gallery-prettyPhoto').each(function ()
{
$(this).prettyPhoto(
{
hook: 'data-gal',
theme: 'pp_default', /* pp_default , light_rounded , dark_rounded , light_square , dark_square ,facebook */
overlay_gallery: false,
deeplinking: false
}
);
});
}
};
})(jQuery);

View File

@@ -23,5 +23,6 @@
<pref name="slideshow_freq">4000</pref> <pref name="slideshow_freq">4000</pref>
<pref name="slideshow_effect">scrollHorz</pref> <pref name="slideshow_effect">scrollHorz</pref>
<pref name="perpage">12</pref> <pref name="perpage">12</pref>
<pref name="orderby">media_id DESC</pref>
</pluginPrefs> </pluginPrefs>
</e107Plugin> </e107Plugin>

View File

@@ -5,96 +5,32 @@
* *
* Gallery Template * Gallery Template
*/ */
if (!defined('e107_INIT')) { exit; }
if(!defined('e107_INIT'))
{
exit;
}
e107::plugLan('gallery', 'front'); e107::plugLan('gallery', 'front');
$gp = e107::getPlugPref('gallery'); $gp = e107::getPlugPref('gallery');
e107::library('load', 'jquery.cycle');
e107::library('load', 'jquery.prettyPhoto');
e107::js('gallery', 'jslib/prettyPhoto/js/jquery.prettyPhoto.js','jquery'); e107::css('gallery', 'css/gallery.css');
e107::js('gallery', 'js/gallery.js');
e107::js('gallery', 'js/gallery.cycle.js');
e107::css('gallery', 'jslib/prettyPhoto/css/prettyPhoto.css','jquery'); $settings = array(
'fx' => varset($gp['slideshow_effect'], 'scrollHorz'),
'speed' => varset($gp['slideshow_duration'], 1000),
e107::css('gallery', 'gallery_style.css'); 'timeout' => varset($gp['slideshow_freq'], 4000),
);
// Work-around for indent issue. see: https://github.com/twitter/bootstrap/issues/4890
e107::css('inline', "
.thumbnails .span2:nth-child(6n+1) {
margin-left:0;
}",'jquery');
$prettyPhoto = <<<JS
$(document).ready(function(){
$("a[data-gal^='prettyPhoto']").prettyPhoto(
{
hook: 'data-gal',
theme: 'pp_default',
overlay_gallery: false,
deeplinking: false
}
);
});
JS;
e107::js('footer-inline',$prettyPhoto,'jquery');
e107::js('gallery', 'jslib/jquery.cycle.all.js','jquery');
e107::js('footer-inline',"
$(document).ready(function()
{
$('#gallery-slideshow-content').cycle({
fx: '".varset($gp['slideshow_effect'],'scrollHorz')."',
next: '.gal-next',
prev: '.gal-prev',
speed: ".varset($gp['slideshow_duration'],1000).", // speed of the transition (any valid fx speed value)
timeout: ".varset($gp['slideshow_freq'],4000).",
slideExpr: '.slide',
pause: 1, // pause on hover - TODO pref
activePagerClass: '.gallery-slide-jumper-selected',//,
before: function(currSlideElement, nextSlideElement, options, forwardFlag)
{
var nx = $(nextSlideElement).attr('id').split('item-');
var th = $(currSlideElement).attr('id').split('item-');
$('#gallery-jumper-'+th[1]).removeClass('gallery-slide-jumper-selected');
$('#gallery-jumper-'+nx[1]).addClass('gallery-slide-jumper-selected');
}
});
$('.gallery-slide-jumper').click(function() {
var nid = $(this).attr('id');
var id = nid.split('-jumper-');
var go = parseInt(id[1]) - 1;
$('#gallery-slideshow-content').cycle(go);
return false;
});
$('#img.lb-close').on('live', function(e) {
$(this).attr('src','".e_PLUGIN."gallery/jslib/lightbox/images/close.png');
});
});
");
e107::js('settings', array('gallery' => $settings));
$text = e107::getParser()->parseTemplate("{GALLERY_SLIDESHOW}"); $text = e107::getParser()->parseTemplate("{GALLERY_SLIDESHOW}");
e107::getRender()->tablerender("Gallery",$text,'gallery_slideshow'); e107::getRender()->tablerender("Gallery", $text, 'gallery_slideshow');
unset($text); unset($text);
unset($gp); unset($gp);
?>