forked from ZwiiCMS-Team/ZwiiCMS
galerie avec nouvelles options
This commit is contained in:
parent
aea20bb2ae
commit
8da52e715a
@ -51,7 +51,9 @@ class gallery extends common {
|
||||
'sortGalleries' => self::GROUP_MODERATOR,
|
||||
'sortPictures' => self::GROUP_MODERATOR,
|
||||
'edit' => self::GROUP_MODERATOR,
|
||||
'add' => self::GROUP_MODERATOR,
|
||||
'theme' => self::GROUP_MODERATOR,
|
||||
'option' => self::GROUP_MODERATOR,
|
||||
'index' => self::GROUP_VISITOR
|
||||
];
|
||||
|
||||
@ -411,6 +413,58 @@ class gallery extends common {
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajout d'une galerie
|
||||
*/
|
||||
public function add() {
|
||||
// Soumission du formulaire d'ajout d'une galerie
|
||||
if($this->isPost()) {
|
||||
if (!$this->getInput('galleryAddFilterResponse')) {
|
||||
$galleryId = helper::increment($this->getInput('galleryAddName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0), 'content']));
|
||||
// définir une vignette par défaut
|
||||
$directory = $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true);
|
||||
$iterator = new DirectoryIterator($directory);
|
||||
foreach($iterator as $fileInfos) {
|
||||
if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) {
|
||||
// Créer la miniature si manquante
|
||||
if (!file_exists( str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()))) {
|
||||
$this->makeThumb($fileInfos->getPathname(),
|
||||
str_replace('source','thumb',$fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()),
|
||||
self::THUMBS_WIDTH);
|
||||
}
|
||||
// Miniatures
|
||||
$homePicture = strtolower($fileInfos->getFilename());
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->setData(['module', $this->getUrl(0), 'content', $galleryId, [
|
||||
'config' => [
|
||||
'name' => $this->getInput('galleryAddName'),
|
||||
'directory' => $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true),
|
||||
'homePicture' => $homePicture,
|
||||
'sort' => $this->getInput('galleryAddSort'),
|
||||
'position' => count($this->getData(['module', $this->getUrl(0), 'content'])) + 1,
|
||||
'fullScreen' => $this->getInput('galleryAddFullscreen', helper::FILTER_BOOLEAN),
|
||||
'showPageContent' => $this->getInput('galleryAddShowPageContent', helper::FILTER_BOOLEAN)
|
||||
],
|
||||
'legend' => [],
|
||||
'positions' => []
|
||||
]]);
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', // '#galleryAddForm'*/,
|
||||
'notification' => 'Modifications enregistrées',
|
||||
'state' => true
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'title' => 'Ajout d\'une galerie',
|
||||
'view' => 'add'
|
||||
]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Suppression
|
||||
*/
|
||||
@ -815,6 +869,41 @@ class gallery extends common {
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Option de configuration de la galerie
|
||||
*/
|
||||
public function option() {
|
||||
// Jeton incorrect
|
||||
if ($this->getUrl(2) !== $_SESSION['csrf']) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
|
||||
'notification' => 'Action non autorisée'
|
||||
]);
|
||||
}
|
||||
// Soumission du formulaire
|
||||
if($this->isPost()) {
|
||||
// Dossier de l'instance
|
||||
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) {
|
||||
mkdir (self::DATADIRECTORY . $this->getUrl(0), 0755, true);
|
||||
}
|
||||
$this->setData(['module', $this->getUrl(0), 'config', [
|
||||
'showUniqueGallery' => $this->getinput('galleryOptionShowUniqueGallery', helper::FILTER_BOOLEAN)
|
||||
]]);
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . $this->getUrl() . '/option',
|
||||
'notification' => 'Modifications enregistrées',
|
||||
'state' => true
|
||||
]);
|
||||
}
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'title' => "Options",
|
||||
'view' => 'option'
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class galleriesHelper extends helper {
|
||||
|
19
module/gallery/view/add/add.css
Normal file
19
module/gallery/view/add/add.css
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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-2022, Frédéric Tempez
|
||||
* @license GNU General Public License, version 3
|
||||
* @link http://zwiicms.fr/
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** NE PAS EFFACER
|
||||
* admin.css
|
||||
*/
|
87
module/gallery/view/add/add.js.php
Normal file
87
module/gallery/view/add/add.js.php
Normal file
@ -0,0 +1,87 @@
|
||||
/**
|
||||
* 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-2022, Frédéric Tempez
|
||||
* @license GNU General Public License, version 3
|
||||
* @link http://zwiicms.fr/
|
||||
*/
|
||||
|
||||
$( document ).ready(function() {
|
||||
|
||||
|
||||
/**
|
||||
* Tri de la galerie avec drag and drop
|
||||
*/
|
||||
$("#galleryTable").tableDnD({
|
||||
onDrop: function(table, row) {
|
||||
$("#galleryAddFilterResponse").val($.tableDnD.serialize());
|
||||
},
|
||||
onDragStop : function(table, row) {
|
||||
// Affiche le bouton de tri après un déplacement
|
||||
//$(":input[type='submit']").prop('disabled', false);
|
||||
// Sauvegarde le tri
|
||||
sortGalleries();
|
||||
},
|
||||
// Supprime le tiret des séparateurs
|
||||
serializeRegexp: ""
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Confirmation de suppression
|
||||
*/
|
||||
$(".galleryAddDelete").on("click", function() {
|
||||
var _this = $(this);
|
||||
return core.confirm("Êtes-vous sûr de vouloir supprimer cette galerie ?", function() {
|
||||
$(location).attr("href", _this.attr("href"));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 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());
|
||||
});
|
68
module/gallery/view/add/add.php
Normal file
68
module/gallery/view/add/add.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php echo template::formOpen('galleryAddForm'); ?>
|
||||
<div class="row">
|
||||
<div class="col2">
|
||||
<?php echo template::button('galleryAddBack', [
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/config' ,
|
||||
'ico' => 'left',
|
||||
'value' => 'Retour'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col2 offset8">
|
||||
<?php echo template::submit('galleryAddSubmit', [
|
||||
'ico' => 'plus',
|
||||
'value' => ' Ajouter',
|
||||
'class' => 'gallerySubmit'
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<div class="block">
|
||||
<h4>Ajouter une galerie</h4>
|
||||
<div class="row">
|
||||
<div class="col6">
|
||||
<?php echo template::text('galleryAddName', [
|
||||
'label' => 'Nom'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col5">
|
||||
<?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>
|
||||
<div class="row">
|
||||
<div class="col3">
|
||||
<?php echo template::select('galleryAddSort', $module::$sort, [
|
||||
'selected' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'sort']),
|
||||
'label' => 'Tri des images',
|
||||
'help' => 'Tri manuel : déplacez le images dans le tableau ci-dessous. L\'ordre est sauvegardé automatiquement.'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col7 verticalAlignBottom">
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<?php echo template::checkbox('galleryAddFullscreen', true, 'Mode plein écran automatique' , [
|
||||
'checked' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'fullScreen']),
|
||||
'help' => 'A l\'ouverture de la galerie, la première image est affichée en plein écran.'
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<?php echo template::checkbox('galleryAddShowPageContent', true, 'Afficher le contenu de la page dans les galeries' , [
|
||||
'checked' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'showPageContent']),
|
||||
'help' => 'Le contenu de la page est toujours affiché dans la liste des galeries. Quand une seule galerie est disponible, il est possible de l\'afficher directement, cette option est utile dans ce cas précis.'
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo template::formClose(); ?>
|
@ -31,59 +31,6 @@ $( document ).ready(function() {
|
||||
// Supprime le tiret des séparateurs
|
||||
serializeRegexp: ""
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Confirmation de suppression
|
||||
*/
|
||||
$(".galleryConfigDelete").on("click", function() {
|
||||
var _this = $(this);
|
||||
return core.confirm("Êtes-vous sûr de vouloir supprimer cette galerie ?", function() {
|
||||
$(location).attr("href", _this.attr("href"));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Liste des dossiers
|
||||
*/
|
||||
var oldResult = [];
|
||||
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('galleryConfigForm'); ?>
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<div class="col2">
|
||||
<?php echo template::button('galleryConfigBack', [
|
||||
'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0),
|
||||
@ -7,70 +7,28 @@
|
||||
'value' => 'Retour'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col2 offset8">
|
||||
<?php echo template::button('galleryConfigBack', [
|
||||
<div class="col1 offset7">
|
||||
<?php echo template::button('galleryConfigOption', [
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/option/' . $_SESSION['csrf'],
|
||||
'value' => '',
|
||||
'ico' => 'sliders',
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col1">
|
||||
<?php echo template::button('galleryConfigTheme', [
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/theme/' . $_SESSION['csrf'],
|
||||
'value' => template::ico('brush','right') . 'Thème'
|
||||
'value' => '',
|
||||
'ico' => 'brush',
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<div class="block">
|
||||
<h4>Ajouter une galerie</h4>
|
||||
<div class="row">
|
||||
<div class="col6">
|
||||
<?php echo template::text('galleryConfigName', [
|
||||
'label' => 'Nom'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col5">
|
||||
<?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="col1 verticalAlignBottom">
|
||||
<?php echo template::submit('galleryConfigSubmit', [
|
||||
<div class="col1">
|
||||
<?php echo template::button('galleryAdd', [
|
||||
'ico' => '',
|
||||
'value' => template::ico('plus'),
|
||||
'class' => 'gallerySubmit'
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/add/',
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col3">
|
||||
<?php echo template::select('galleryConfigSort', $module::$sort, [
|
||||
'selected' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'sort']),
|
||||
'label' => 'Tri des images',
|
||||
'help' => 'Tri manuel : déplacez le images dans le tableau ci-dessous. L\'ordre est sauvegardé automatiquement.'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col7 verticalAlignBottom">
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<?php echo template::checkbox('galleryConfigFullscreen', true, 'Mode plein écran automatique' , [
|
||||
'checked' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'fullScreen']),
|
||||
'help' => 'A l\'ouverture de la galerie, la première image est affichée en plein écran.'
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<?php echo template::checkbox('galleryConfigShowPageContent', true, 'Afficher le contenu de la page dans les galeries' , [
|
||||
'checked' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'showPageContent']),
|
||||
'help' => 'Le contenu de la page est toujours affiché dans la liste des galeries. Quand une seule galerie est disponible, il est possible de l\'afficher directement, cette option est utile dans ce cas précis.'
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo template::formClose(); ?>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
|
39
module/gallery/view/option/option.php
Normal file
39
module/gallery/view/option/option.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php echo template::formOpen('galleryOptionForm'); ?>
|
||||
<div class="row">
|
||||
<div class="col2">
|
||||
<?php echo template::button('galleryOptionBack', [
|
||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/config',
|
||||
'ico' => 'left',
|
||||
'value' => 'Retour'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col2 offset8">
|
||||
<?php echo template::submit('galleryOptionSubmit'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<div class="block">
|
||||
<h4>Galerie unique</h4>
|
||||
<div class="row">
|
||||
<div class="col12 verticalAlignBottom">
|
||||
<?php echo template::checkbox('galleryOptionShowUniqueGallery', true, 'Masquer l\'index des galeries lorsque le module ne contient qu\'une galerie' , [
|
||||
'checked' => count($this->getData(['module', $this->getUrl(0), 'content'])) === 1
|
||||
? $this->getData(['module', $this->getUrl(0), 'theme', 'showUniqueGallery'])
|
||||
: false,
|
||||
'disabled' => count($this->getData(['module', $this->getUrl(0), 'content'])) > 1,
|
||||
'help' => 'Cette option est active lorsque le module ne contient qu\'une seule galerie, elle permet d\'éviter la page listant toutes les galeries et affiche directement la galerie'
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo template::formClose(); ?>
|
||||
<div class="row">
|
||||
<div class="col12">
|
||||
<div class="moduleVersion">Version n°
|
||||
<?php echo $module::VERSION; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
18
module/gallery/view/option/options.css
Normal file
18
module/gallery/view/option/options.css
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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-2022, Frédéric Tempez
|
||||
* @license GNU General Public License, version 3
|
||||
* @link http://zwiicms.fr/
|
||||
*/
|
||||
|
||||
|
||||
/** NE PAS EFFACER
|
||||
* admin.css
|
||||
*/
|
Loading…
Reference in New Issue
Block a user