forked from ZwiiCMS-Team/ZwiiCMS
gallery master
This commit is contained in:
parent
89c5b3e535
commit
f42f0745ea
@ -23,8 +23,8 @@ class gallery extends common {
|
|||||||
];
|
];
|
||||||
|
|
||||||
public static $sort = [
|
public static $sort = [
|
||||||
'asc' => 'Alphabétique naturel',
|
'SORT_ASC' => 'Alphabétique naturel',
|
||||||
'dsc' => 'Alphabétique naturel inverse',
|
'SORT_DSC' => 'Alphabétique naturel inverse',
|
||||||
'none' => 'Aucun tri',
|
'none' => 'Aucun tri',
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -44,8 +44,9 @@ class gallery extends common {
|
|||||||
public function config() {
|
public function config() {
|
||||||
// Liste des galeries
|
// Liste des galeries
|
||||||
$galleries = $this->getData(['module', $this->getUrl(0)]);
|
$galleries = $this->getData(['module', $this->getUrl(0)]);
|
||||||
|
$countGalleries = count($this->getData(['module',$this->getUrl(0)]));
|
||||||
|
|
||||||
if($galleries) {
|
if($galleries) {
|
||||||
ksort($galleries,SORT_NATURAL);
|
|
||||||
foreach($galleries as $galleryId => $gallery) {
|
foreach($galleries as $galleryId => $gallery) {
|
||||||
// Erreur dossier vide
|
// Erreur dossier vide
|
||||||
if(is_dir($gallery['config']['directory'])) {
|
if(is_dir($gallery['config']['directory'])) {
|
||||||
@ -57,10 +58,20 @@ class gallery extends common {
|
|||||||
else {
|
else {
|
||||||
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . ' (dossier introuvable)</span>';
|
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . ' (dossier introuvable)</span>';
|
||||||
}
|
}
|
||||||
|
// Ordre des galeries
|
||||||
|
// Element 0 chaine vide
|
||||||
|
$galeryOrder = range(1,count($this->getData(['module',$this->getUrl(0)])));
|
||||||
// Met en forme le tableau
|
// Met en forme le tableau
|
||||||
self::$galleries[] = [
|
self::$galleries[] = [
|
||||||
$gallery['config']['name'],
|
$gallery['config']['name'],
|
||||||
$gallery['config']['directory'],
|
$gallery['config']['directory'],
|
||||||
|
$gallery['config']['order'],
|
||||||
|
/*
|
||||||
|
template::select('galleryConfigOrder', $galeryOrder , [
|
||||||
|
'selected' => $gallery['config']['order'],
|
||||||
|
'class' => 'configOrder'
|
||||||
|
|
||||||
|
]),*/
|
||||||
template::button('galleryConfigEdit' . $galleryId , [
|
template::button('galleryConfigEdit' . $galleryId , [
|
||||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $galleryId . '/' . $_SESSION['csrf'],
|
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $galleryId . '/' . $_SESSION['csrf'],
|
||||||
'value' => template::ico('pencil')
|
'value' => template::ico('pencil')
|
||||||
@ -80,7 +91,8 @@ class gallery extends common {
|
|||||||
'config' => [
|
'config' => [
|
||||||
'name' => $this->getInput('galleryConfigName'),
|
'name' => $this->getInput('galleryConfigName'),
|
||||||
'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true),
|
'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true),
|
||||||
'sort' => $this->getInput('galleryConfigSort')
|
'sort' => $this->getInput('galleryConfigSort'),
|
||||||
|
'order' => count($this->getData(['module',$this->getUrl(0)])) + 1
|
||||||
],
|
],
|
||||||
'legend' => []
|
'legend' => []
|
||||||
]]);
|
]]);
|
||||||
@ -223,10 +235,10 @@ class gallery extends common {
|
|||||||
switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort'])) {
|
switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort'])) {
|
||||||
case 'none':
|
case 'none':
|
||||||
break;
|
break;
|
||||||
case 'dsc':
|
case 'SORT_DSC':
|
||||||
krsort(self::$pictures,SORT_NATURAL);
|
krsort(self::$pictures,SORT_NATURAL);
|
||||||
break;
|
break;
|
||||||
case 'asc':
|
case 'SORT_ASC':
|
||||||
default:
|
default:
|
||||||
ksort(self::$pictures,SORT_NATURAL);
|
ksort(self::$pictures,SORT_NATURAL);
|
||||||
break;
|
break;
|
||||||
@ -268,10 +280,10 @@ class gallery extends common {
|
|||||||
switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'sort'])) {
|
switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'sort'])) {
|
||||||
case 'none':
|
case 'none':
|
||||||
break;
|
break;
|
||||||
case 'dsc':
|
case 'SORT_DSC':
|
||||||
krsort(self::$pictures,SORT_NATURAL);
|
krsort(self::$pictures,SORT_NATURAL);
|
||||||
break;
|
break;
|
||||||
case 'asc':
|
case 'SORT_ASC':
|
||||||
default:
|
default:
|
||||||
ksort(self::$pictures,SORT_NATURAL);
|
ksort(self::$pictures,SORT_NATURAL);
|
||||||
break;
|
break;
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
*
|
*
|
||||||
* @author Rémi Jean <remi.jean@outlook.com>
|
* @author Rémi Jean <remi.jean@outlook.com>
|
||||||
* @copyright Copyright (C) 2008-2018, Rémi Jean
|
* @copyright Copyright (C) 2008-2018, Rémi Jean
|
||||||
|
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
||||||
|
* @copyright Copyright (C) 2018-2020, Frédéric Tempez
|
||||||
* @license GNU General Public License, version 3
|
* @license GNU General Public License, version 3
|
||||||
* @link http://zwiicms.com/
|
* @link http://zwiicms.com/
|
||||||
*/
|
*/
|
||||||
@ -59,3 +61,21 @@ setInterval(function() {
|
|||||||
directoryDOM.on("change", function() {
|
directoryDOM.on("change", function() {
|
||||||
directoryOldDOM.val($(this).val());
|
directoryOldDOM.val($(this).val());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tri dynamique de la galerie
|
||||||
|
*/
|
||||||
|
$( document ).ready(function() {
|
||||||
|
var $tbody = $('#galleryTable tbody');
|
||||||
|
$tbody.find('tr').sort(function (a, b) {
|
||||||
|
var tda = $(a).find('td.pos3:eq(0)').text();
|
||||||
|
var tdb = $(b).find('td.pos3:eq(0)').text();
|
||||||
|
// if a < b return 1
|
||||||
|
return tda > tdb ? 1
|
||||||
|
// else if a > b return -1
|
||||||
|
: tda < tdb ? -1
|
||||||
|
// else they are equal - return 0
|
||||||
|
: 0;
|
||||||
|
}).appendTo($tbody);
|
||||||
|
});
|
@ -45,7 +45,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php if($module::$galleries): ?>
|
<?php if($module::$galleries): ?>
|
||||||
<?php echo template::table([4, 6, 1, 1], $module::$galleries, ['Nom', 'Dossier cible', '', '']); ?>
|
<?php echo template::table([4, 6,1, 1, 1], $module::$galleries, ['Nom', 'Dossier cible', 'Ordre', '', ''], ['id' => 'galleryTable']); ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php echo template::speech('Aucune galerie.'); ?>
|
<?php echo template::speech('Aucune galerie.'); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<div class="block">
|
<div class="block">
|
||||||
<h4>Informations générales</h4>
|
<h4>Informations générales</h4>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col4">
|
<div class="col5">
|
||||||
<?php echo template::text('galleryEditName', [
|
<?php echo template::text('galleryEditName', [
|
||||||
'label' => 'Nom',
|
'label' => 'Nom',
|
||||||
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'name'])
|
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'name'])
|
||||||
@ -33,7 +33,7 @@
|
|||||||
'noDirty' => true // Désactivé à cause des modifications en ajax
|
'noDirty' => true // Désactivé à cause des modifications en ajax
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col4">
|
<div class="col3">
|
||||||
<?php echo template::select('galleryEditSort', $module::$sort, [
|
<?php echo template::select('galleryEditSort', $module::$sort, [
|
||||||
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort']),
|
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort']),
|
||||||
'label' => 'Tri des images',
|
'label' => 'Tri des images',
|
||||||
|
25
module/gallery/view/index/index.js.php
Normal file
25
module/gallery/view/index/index.js.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* This file is part of Zwii.
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @author Rémi Jean <remi.jean@outlook.com>
|
||||||
|
* @copyright Copyright (C) 2008-2018, Rémi Jean
|
||||||
|
* @authorFrédéric Tempez <frederic.tempez@outlook.com>
|
||||||
|
* @copyright Copyright (C) 2018-2020, Frédéric Tempez
|
||||||
|
* @license GNU General Public License, version 3
|
||||||
|
* @link http://zwiicms.com/
|
||||||
|
*/
|
||||||
|
|
||||||
|
$( document ).ready(function() {
|
||||||
|
/*
|
||||||
|
asc=false;
|
||||||
|
var sorted=$('.pictureBox').sort(function(a,b){
|
||||||
|
return (asc ==
|
||||||
|
($(a).data('sort') < $(b).data('sort'))) ? 1 : -1;
|
||||||
|
});
|
||||||
|
asc = asc ? false : true;
|
||||||
|
$('body').html(sorted);
|
||||||
|
*/
|
||||||
|
});
|
@ -5,7 +5,7 @@
|
|||||||
<?php if($i % 2 === 1): ?>
|
<?php if($i % 2 === 1): ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="col6">
|
<div class="col6" div="pos<?php echo $gallery['config']['order']; ?>" >
|
||||||
<a
|
<a
|
||||||
href="<?php echo helper::baseUrl() . $this->getUrl(0); ?>/<?php echo $galleryId; ?>"
|
href="<?php echo helper::baseUrl() . $this->getUrl(0); ?>/<?php echo $galleryId; ?>"
|
||||||
class="galleryPicture"
|
class="galleryPicture"
|
||||||
|
Loading…
Reference in New Issue
Block a user