forked from ZwiiCMS-Team/ZwiiCMS
Gallery 2.0 : formulaire non séparé
This commit is contained in:
parent
06c42aa8d6
commit
2c0f96ee05
@ -16,10 +16,10 @@ class gallery extends common {
|
|||||||
|
|
||||||
public static $actions = [
|
public static $actions = [
|
||||||
'config' => self::GROUP_MODERATOR,
|
'config' => self::GROUP_MODERATOR,
|
||||||
'add' => self::GROUP_MODERATOR,
|
|
||||||
'delete' => self::GROUP_MODERATOR,
|
'delete' => self::GROUP_MODERATOR,
|
||||||
'dirs' => self::GROUP_MODERATOR,
|
'dirs' => self::GROUP_MODERATOR,
|
||||||
'edit' => self::GROUP_MODERATOR,
|
'edit' => self::GROUP_MODERATOR,
|
||||||
|
'filter' => self::GROUP_MODERATOR,
|
||||||
'index' => self::GROUP_VISITOR
|
'index' => self::GROUP_VISITOR
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -41,15 +41,11 @@ class gallery extends common {
|
|||||||
|
|
||||||
const GALLERY_VERSION = '2.0';
|
const GALLERY_VERSION = '2.0';
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration
|
|
||||||
*/
|
public function filter() {
|
||||||
public function config() {
|
// Traitement du tri
|
||||||
// Traiement du tri
|
$data = explode('&',($this->getInput('galleryConfigFilterResponse')));
|
||||||
// Soumission du formulaire
|
|
||||||
if( $this->isPost() &&
|
|
||||||
$this->getInput('galleryConfigResponse') !== NULL ) {
|
|
||||||
$data = explode('&',($this->getInput('galleryConfigResponse')));
|
|
||||||
$data = str_replace('galleryTable%5B%5D=','',$data);
|
$data = str_replace('galleryTable%5B%5D=','',$data);
|
||||||
for($i=0;$i<count($data);$i++) {
|
for($i=0;$i<count($data);$i++) {
|
||||||
$this->setData(['module', $this->getUrl(0), $data[$i], [
|
$this->setData(['module', $this->getUrl(0), $data[$i], [
|
||||||
@ -64,7 +60,15 @@ class gallery extends common {
|
|||||||
]]);
|
]]);
|
||||||
}
|
}
|
||||||
$this->saveData();
|
$this->saveData();
|
||||||
|
// Valeurs en sortie
|
||||||
|
// Recharge la page
|
||||||
|
header('Refresh: 0;url='. helper::baseUrl() . $this->getUrl() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration
|
||||||
|
*/
|
||||||
|
public function config() {
|
||||||
// Tri des galeries
|
// Tri des galeries
|
||||||
$g = $this->getData(['module', $this->getUrl(0)]);
|
$g = $this->getData(['module', $this->getUrl(0)]);
|
||||||
$p = helper::arrayCollumn(helper::arrayCollumn($g,'config'),'position');
|
$p = helper::arrayCollumn(helper::arrayCollumn($g,'config'),'position');
|
||||||
@ -88,10 +92,7 @@ class gallery extends common {
|
|||||||
}
|
}
|
||||||
// Met en forme le tableau
|
// Met en forme le tableau
|
||||||
self::$galleries[] = [
|
self::$galleries[] = [
|
||||||
template::button($galleryId, [
|
template::ico('sort'),
|
||||||
'value' => template::ico('sort'),
|
|
||||||
'class' => 'disabled'
|
|
||||||
]),
|
|
||||||
$gallery['config']['name'],
|
$gallery['config']['name'],
|
||||||
$gallery['config']['directory'],
|
$gallery['config']['directory'],
|
||||||
template::button('galleryConfigEdit' . $galleryId , [
|
template::button('galleryConfigEdit' . $galleryId , [
|
||||||
@ -108,6 +109,30 @@ class gallery extends common {
|
|||||||
self::$galleriesId[] = $galleryId;
|
self::$galleriesId[] = $galleryId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Soumission du formulaire
|
||||||
|
|
||||||
|
if($this->isPost()) {
|
||||||
|
if ($this->getInput('galleryConfigFilterResponse')) {
|
||||||
|
self::filter();
|
||||||
|
} else {
|
||||||
|
$galleryId = helper::increment($this->getInput('galleryConfigName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0)]));
|
||||||
|
$this->setData(['module', $this->getUrl(0), $galleryId, [
|
||||||
|
'config' => [
|
||||||
|
'name' => $this->getInput('galleryConfigName'),
|
||||||
|
'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true),
|
||||||
|
'sort' => $this->getInput('galleryConfigSort'),
|
||||||
|
'order' => count($this->getData(['module',$this->getUrl(0)])) + 1
|
||||||
|
],
|
||||||
|
'legend' => []
|
||||||
|
]]);
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . $this->getUrl(),
|
||||||
|
'notification' => 'Modifications enregistrées',
|
||||||
|
'state' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'title' => 'Configuration du module',
|
'title' => 'Configuration du module',
|
||||||
@ -118,42 +143,6 @@ class gallery extends common {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Ajouter une galerie
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function add() {
|
|
||||||
// Soumission du formulaire
|
|
||||||
if($this->isPost()) {
|
|
||||||
$success = false;
|
|
||||||
if (!empty($this->getInput('galleryAddName')) ) {
|
|
||||||
$galleryId = helper::increment($this->getInput('galleryAddName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0)]));
|
|
||||||
$this->setData(['module', $this->getUrl(0), $galleryId, [
|
|
||||||
'config' => [
|
|
||||||
'name' => $this->getInput('galleryAddName',helper::FILTER_STRING_SHORT, true),
|
|
||||||
'directory' => $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true),
|
|
||||||
'sort' => $this->getInput('galleryAddSort'),
|
|
||||||
'order' => count($this->getData(['module',$this->getUrl(0)])) + 1
|
|
||||||
],
|
|
||||||
'legend' => []
|
|
||||||
]]);
|
|
||||||
$success = true;
|
|
||||||
}
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => $success ? helper::baseUrl() . $this->getUrl(0) . '/config' : helper::baseUrl() . $this->getUrl(0) . '/add',
|
|
||||||
'notification' => $success ? 'Modifications enregistrées' : 'Le nom de la galerie est obligatoire',
|
|
||||||
'state' => $success
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
// valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'title' => 'Ajouter une galerie',
|
|
||||||
'view' => 'add'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suppression
|
* Suppression
|
||||||
*/
|
*/
|
||||||
@ -358,15 +347,7 @@ class gallery extends common {
|
|||||||
}
|
}
|
||||||
// Liste des galeries
|
// Liste des galeries
|
||||||
else {
|
else {
|
||||||
// Tri des galeries
|
foreach((array) $this->getData(['module', $this->getUrl(0)]) as $galleryId => $gallery) {
|
||||||
$g = $this->getData(['module', $this->getUrl(0)]);
|
|
||||||
$p = helper::arrayCollumn(helper::arrayCollumn($g,'config'),'position');
|
|
||||||
asort($p,SORT_NUMERIC);
|
|
||||||
$galleries = [];
|
|
||||||
foreach ($p as $positionId => $item) {
|
|
||||||
$galleries [$positionId] = $g[$positionId];
|
|
||||||
}
|
|
||||||
foreach((array) $galleries as $galleryId => $gallery) {
|
|
||||||
if(is_dir($gallery['config']['directory'])) {
|
if(is_dir($gallery['config']['directory'])) {
|
||||||
$iterator = new DirectoryIterator($gallery['config']['directory']);
|
$iterator = new DirectoryIterator($gallery['config']['directory']);
|
||||||
foreach($iterator as $fileInfos) {
|
foreach($iterator as $fileInfos) {
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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
|
|
||||||
* @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
|
|
||||||
* @link http://zwiicms.com/
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
@import url("core/layout/admin.css");
|
|
||||||
|
|
||||||
.galleryConfigError {
|
|
||||||
color: #F3674A;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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
|
|
||||||
* @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
|
|
||||||
* @link http://zwiicms.com/
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Liste des dossiers
|
|
||||||
*/
|
|
||||||
var oldResult = [];
|
|
||||||
var directoryDOM = $("#galleryAddDirectory");
|
|
||||||
var directoryOldDOM = $("#galleryAddDirectoryOld");
|
|
||||||
function dirs() {
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: "<?php echo helper::baseUrl() . $this->getUrl(0); ?>/dirs",
|
|
||||||
success: function(result) {
|
|
||||||
if($(result).not(oldResult).length !== 0 || $(oldResult).not(result).length !== 0) {
|
|
||||||
directoryDOM.empty();
|
|
||||||
for(var i = 0; i < result.length; i++) {
|
|
||||||
directoryDOM.append(function(i) {
|
|
||||||
var option = $("<option>").val(result[i]).text(result[i]);
|
|
||||||
if(directoryOldDOM.val() === result[i]) {
|
|
||||||
option.prop("selected", true);
|
|
||||||
}
|
|
||||||
return option;
|
|
||||||
}(i))
|
|
||||||
}
|
|
||||||
oldResult = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dirs();
|
|
||||||
// Actualise la liste des dossiers toutes les trois secondes
|
|
||||||
setInterval(function() {
|
|
||||||
dirs();
|
|
||||||
}, 3000);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stock le dossier choisi pour le re-sélectionner en cas d'actualisation ajax de la liste des dossiers
|
|
||||||
*/
|
|
||||||
directoryDOM.on("change", function() {
|
|
||||||
directoryOldDOM.val($(this).val());
|
|
||||||
});
|
|
@ -1,48 +0,0 @@
|
|||||||
<?php echo template::formOpen('galleryAddForm'); ?>
|
|
||||||
<?php echo template::formOpen('galleryAddOrder'); ?>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col2">
|
|
||||||
<?php echo template::button('galleryAddBack', [
|
|
||||||
'class' => 'buttonGrey',
|
|
||||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/config',
|
|
||||||
'ico' => 'left',
|
|
||||||
'value' => 'Retour'
|
|
||||||
]); ?>
|
|
||||||
</div>
|
|
||||||
<div class="col2 offset8">
|
|
||||||
<?php echo template::submit('galleryAddSubmit'); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col12">
|
|
||||||
<div class="block">
|
|
||||||
<h4>Nouvelle galerie</h4>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col4">
|
|
||||||
<?php echo template::text('galleryAddName', [
|
|
||||||
'label' => 'Nom de la galerie'
|
|
||||||
]); ?>
|
|
||||||
</div>
|
|
||||||
<div class="col4">
|
|
||||||
<?php echo template::hidden('galleryAddDirectoryOld', [
|
|
||||||
'noDirty' => true // Désactivé à cause des modifications en ajax
|
|
||||||
]); ?>
|
|
||||||
<?php echo template::select('galleryAddDirectory', [], [
|
|
||||||
'label' => 'Dossier cible',
|
|
||||||
'noDirty' => true // Désactivé à cause des modifications en ajax
|
|
||||||
]); ?>
|
|
||||||
</div>
|
|
||||||
<div class="col4">
|
|
||||||
<?php echo template::select('galleryAddSort', $module::$sort, [
|
|
||||||
'label' => 'Tri des images',
|
|
||||||
'help' => 'Les images sont triées par nom de fichier grâce à la méthode naturelle qui donne de meilleurs résultats lorsque les images sont numérotées.'
|
|
||||||
]); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php echo template::formClose(); ?>
|
|
||||||
<div class="moduleVersion">Version n°
|
|
||||||
<?php echo $module::GALLERY_VERSION; ?>
|
|
||||||
</div>
|
|
@ -12,6 +12,24 @@
|
|||||||
* @link http://zwiicms.com/
|
* @link http://zwiicms.com/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tri dynamique de la galerie
|
||||||
|
*/
|
||||||
|
$( document ).ready(function() {
|
||||||
|
$("#galleryTable").tableDnD({
|
||||||
|
onDrop: function(table, row) {
|
||||||
|
$("#galleryConfigFilterResponse").val($.tableDnD.serialize());
|
||||||
|
},
|
||||||
|
serializeRegexp: "[^\_]*$"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Activer le bouton de tri uniquement après un tri
|
||||||
|
$("#galleryTable").mouseup(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$(":input[type='submit']").prop('disabled', false);
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Confirmation de suppression
|
* Confirmation de suppression
|
||||||
*/
|
*/
|
||||||
@ -23,15 +41,44 @@ $(".galleryConfigDelete").on("click", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tri dynamique de la galerie
|
|
||||||
*/
|
|
||||||
$( document ).ready(function() {
|
|
||||||
|
|
||||||
$("#galleryTable").tableDnD({
|
/**
|
||||||
onDrop: function(table, row) {
|
* Liste des dossiers
|
||||||
$("#galleryConfigResponse").val($.tableDnD.serialize());
|
*/
|
||||||
},
|
var oldResult = [];
|
||||||
serializeRegexp: "[^\_]*$"
|
var directoryDOM = $("#galleryConfigDirectory");
|
||||||
|
var directoryOldDOM = $("#galleryConfigDirectoryOld");
|
||||||
|
function dirs() {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "<?php echo helper::baseUrl() . $this->getUrl(0); ?>/dirs",
|
||||||
|
success: function(result) {
|
||||||
|
if($(result).not(oldResult).length !== 0 || $(oldResult).not(result).length !== 0) {
|
||||||
|
directoryDOM.empty();
|
||||||
|
for(var i = 0; i < result.length; i++) {
|
||||||
|
directoryDOM.append(function(i) {
|
||||||
|
var option = $("<option>").val(result[i]).text(result[i]);
|
||||||
|
if(directoryOldDOM.val() === result[i]) {
|
||||||
|
option.prop("selected", true);
|
||||||
|
}
|
||||||
|
return option;
|
||||||
|
}(i))
|
||||||
|
}
|
||||||
|
oldResult = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
dirs();
|
||||||
|
// Actualise la liste des dossiers toutes les trois secondes
|
||||||
|
setInterval(function() {
|
||||||
|
dirs();
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stock le dossier choisi pour le re-sélectionner en cas d'actualisation ajax de la liste des dossiers
|
||||||
|
*/
|
||||||
|
directoryDOM.on("change", function() {
|
||||||
|
directoryOldDOM.val($(this).val());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php echo template::formOpen('galleryConfigOrder'); ?>
|
<?php echo template::formOpen('galleryConfigForm'); ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col2">
|
<div class="col2">
|
||||||
<?php echo template::button('galleryConfigBack', [
|
<?php echo template::button('galleryConfigBack', [
|
||||||
'class' => 'buttonGrey',
|
'class' => 'buttonGrey',
|
||||||
@ -8,27 +8,60 @@
|
|||||||
'value' => 'Retour'
|
'value' => 'Retour'
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col2 offset6">
|
</div>
|
||||||
<?php echo template::button('galleryConfigAdd', [
|
<div class="row">
|
||||||
'class' => 'button',
|
<div class="col12">
|
||||||
'href' => helper::baseUrl() . $this->getUrl(0) .'/add',
|
<div class="block">
|
||||||
'ico' => 'plus',
|
<h4>Nouvelle galerie</h4>
|
||||||
'value' => 'Galerie'
|
<div class="row">
|
||||||
|
<div class="col4">
|
||||||
|
<?php echo template::text('galleryConfigName', [
|
||||||
|
'label' => 'Nom'
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col2">
|
<div class="col4">
|
||||||
|
<?php echo template::hidden('galleryConfigDirectoryOld', [
|
||||||
|
'noDirty' => true // Désactivé à cause des modifications en ajax
|
||||||
|
]); ?>
|
||||||
|
<?php echo template::select('galleryConfigDirectory', [], [
|
||||||
|
'label' => 'Dossier cible',
|
||||||
|
'noDirty' => true // Désactivé à cause des modifications en ajax
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
|
<div class="col3">
|
||||||
|
<?php echo template::select('galleryConfigSort', $module::$sort, [
|
||||||
|
'label' => 'Tri des images',
|
||||||
|
'help' => 'Les images sont triées par nom de fichier grâce à la méthode naturelle qui donne de meilleurs résultats lorsque les images sont numérotées.'
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
|
<div class="col1 verticalAlignBottom">
|
||||||
<?php echo template::submit('galleryConfigSubmit', [
|
<?php echo template::submit('galleryConfigSubmit', [
|
||||||
'ico' => '',
|
'ico' => '',
|
||||||
'value' => "Trier"
|
'value' => template::ico('plus')
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col12">
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php echo template::formClose(); ?>
|
||||||
|
<?php echo template::formOpen('galleryConfigFilterForm'); ?>
|
||||||
<?php if($module::$galleries): ?>
|
<?php if($module::$galleries): ?>
|
||||||
<?php echo template::table([1, 4, 5, 1, 1], $module::$galleries, ['','Nom', 'Dossier cible', '', ''], ['id' => 'galleryTable'],$module::$galleriesId); ?>
|
<?php echo template::table([1,4, 6, 1, 1], $module::$galleries, ['','Nom', 'Dossier cible', '', ''], ['id' => 'galleryTable'],$module::$galleriesId); ?>
|
||||||
<?php echo template::hidden('galleryConfigResponse'); ?>
|
<?php echo template::hidden('galleryConfigFilterResponse'); ?>
|
||||||
|
<?php echo template::hidden('galleryConfigFilterSubmit',[
|
||||||
|
'value' => false
|
||||||
|
]); ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php echo template::speech('Aucune galerie.'); ?>
|
<?php echo template::speech('Aucune galerie.'); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col2 offset10">
|
||||||
|
<?php echo template::submit('galleryConfigFilterSubmit', [
|
||||||
|
'value' => 'Trier',
|
||||||
|
'disabled' => true
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php echo template::formClose(); ?>
|
<?php echo template::formClose(); ?>
|
||||||
<div class="moduleVersion">Version n°
|
<div class="moduleVersion">Version n°
|
||||||
|
Loading…
x
Reference in New Issue
Block a user