gallery 2.23 le tri des images ne nécessite plus une validation

This commit is contained in:
Fred Tempez 2020-04-28 19:29:24 +02:00
parent fe0e40cb99
commit 906ed547a6
6 changed files with 65 additions and 37 deletions

View File

@ -24,6 +24,7 @@
- Nouveau masque dédié à la sauvegarde automatique, à l'import et à l'export des données de site.
- Modifications :
- Module gallery optimisé, tri dynamique, choix du thème.
- Module blog présentation optimisée avec options de position de l'image, la métadescription est le contenu de l'article.
- Chargement paresseux des images.
- Edition de page : suppression de l'option d'ouverture dans une lity.
- Accès concurrents, modification simultanée d'une même ressource (page, config, thème, utilisateur) interdite.

View File

@ -19,7 +19,7 @@ class gallery extends common {
const SORT_ASC = 'SORT_ASC';
const SORT_DSC = 'SORT_DSC';
const SORT_HAND = 'SORT_HAND';
const GALLERY_VERSION = '2.22';
const GALLERY_VERSION = '2.23';
public static $directories = [];
@ -36,13 +36,14 @@ class gallery extends common {
public static $thumbs = [];
public static $actions = [
'config' => self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR,
'dirs' => self::GROUP_MODERATOR,
'sort' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR,
'theme' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR
'config' => self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR,
'dirs' => self::GROUP_MODERATOR,
'sortGalleries' => self::GROUP_MODERATOR,
'sortPictures' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR,
'theme' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR
];
public static $sort = [
@ -130,7 +131,7 @@ class gallery extends common {
* Tri de la liste des galeries
*
*/
public function sort() {
public function sortGalleries() {
if($_POST['response']) {
$data = explode('&',$_POST['response']);
$data = str_replace('galleryTable%5B%5D=','',$data);
@ -152,6 +153,32 @@ class gallery extends common {
}
}
/**
* Tri de la liste des images
*
*/
public function sortPictures() {
if($_POST['response']) {
$galleryName = $_POST['gallery'];
$data = explode('&',$_POST['response']);
$data = str_replace('galleryTable%5B%5D=','',$data);
// Sauvegarder
$this->setData(['module', $this->getUrl(0), $galleryName, [
'config' => [
'name' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','name']),
'directory' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','directory']),
'homePicture' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','homePicture']),
'sort' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','sort']),
'position' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','position']),
'fullScreen' => $this->getData(['module',$this->getUrl(0),$galleryName,'config','fullScreen'])
],
'legend' => $this->getData(['module',$this->getUrl(0),$galleryName,'legend']),
'position' => array_flip($data)
]]);
}
}
/**
* Configuration
@ -313,23 +340,6 @@ class gallery extends common {
else {
// Soumission du formulaire
if($this->isPost()) {
/**
* $picturesPosition contient un tableau avec les images triées
*/
$picturesPosition = [];
if ($this->getInput('galleryEditFormResponse') &&
$this->getInput('galleryEditSort') === self::SORT_HAND) {
// Tri des images si valeur de retour et choix manuel
$picturesPosition = explode('&',($this->getInput('galleryEditFormResponse',helper::FILTER_STRING_LONG)));
$picturesPosition = str_replace('galleryTable%5B%5D=','',$picturesPosition);
$picturesPosition = array_flip($picturesPosition);
}
// Tri manuel sélectionné mais de déplacement, reprendre la config sauvegardée
if ($this->getInput('galleryEditSort') === self::SORT_HAND &&
empty($picturesPosition)) {
$picturesPosition = $this->getdata(['module', $this->getUrl(0), $this->getUrl(2), 'position']);
// Si la position sauvegardée est vide, on activera le tri alpha
}
// Si l'id a changée
$galleryId = $this->getInput('galleryEditName', helper::FILTER_ID, true);
if($galleryId !== $this->getUrl(2)) {
@ -359,13 +369,13 @@ class gallery extends common {
'directory' => $this->getInput('galleryEditDirectory', helper::FILTER_STRING_SHORT, true),
'homePicture' => $homePicture,
// pas de positions, on active le tri alpha
'sort' => (empty($picturesPosition) && $this->getInput('galleryEditSort') === self::SORT_HAND) ? self::SORT_ASC : $this->getInput('galleryEditSort'),
'sort' => $this->getInput('galleryEditSort'),
'position' => $this->getData(['module', $this->getUrl(0), $galleryId,'config','position']) === '' ? count($this->getData(['module',$this->getUrl(0)]))-1 : $this->getData(['module', $this->getUrl(0), $galleryId,'config','position']),
'fullScreen' => $this->getInput('galleryEditFullscreen', helper::FILTER_BOOLEAN)
],
'legend' => $legends,
'position' => $picturesPosition
'position' => $this->getdata(['module', $this->getUrl(0), $galleryId, 'position'])
]]);
// Valeurs en sortie
$this->addOutput([

View File

@ -24,7 +24,7 @@ $( document ).ready(function() {
},
onDragStop : function(table, row) {
// Affiche le bouton de tri après un déplacement
$(":input[type='submit']").prop('disabled', false);
//$(":input[type='submit']").prop('disabled', false);
// Sauvegarde le tri
sortGalleries();
},
@ -92,7 +92,7 @@ directoryDOM.on("change", function() {
*/
function sortGalleries() {
var url = "<?php echo helper::baseUrl() . $this->getUrl(0); ?>/sort";
var url = "<?php echo helper::baseUrl() . $this->getUrl(0); ?>/sortGalleries";
var data = $("#galleryConfigFilterResponse").val();
$.ajax({
type: "POST",

View File

@ -52,10 +52,7 @@
<h4>Galeries installées</h4>
<?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::hidden('galleryConfigFilterResponse'); ?>
<?php echo template::hidden('galleryConfigFilterSubmit',[
'value' => false
]); ?>
<?php echo template::hidden('galleryConfigFilterResponse'); ?>
<?php else: ?>
<?php echo template::speech('Aucune galerie.'); ?>
<?php endif; ?>

View File

@ -65,6 +65,11 @@ $( document ).ready(function() {
onDrop: function(table, row) {
$("#galleryEditFormResponse").val($.tableDnD.serialize());
},
onDragStop : function(table, row) {
// Sauvegarde le tri
sortPictures();
$("#galleryEditFormResponse").val("");
},
serializeRegexp: ""
});
@ -92,4 +97,21 @@ $("#galleryEditSort").change(function() {
}
});
/**
* Tri dynamique des images
*/
function sortPictures() {
var url = "<?php echo helper::baseUrl() . $this->getUrl(0); ?>/sortPictures";
var d1 = $("#galleryEditFormResponse").val();
var d2 = $("#galleryEditFormGalleryName").val();
//var data = $('#galleryEditForm').serialize();
$.ajax({
type: "POST",
url: url ,
data: {
response : d1,
gallery: d2
}
});
}

View File

@ -53,9 +53,7 @@
<?php if($module::$pictures): ?>
<?php echo template::table([1, 4, 1, 5, 1], $module::$pictures, ['','Image', 'Couverture','Légende',''],['id' => 'galleryTable'], $module::$picturesId ); ?>
<?php echo template::hidden('galleryEditFormResponse'); ?>
<?php echo template::hidden('galleryEditSubmit',[
'value' => false
]); ?>
<?php echo template::hidden('galleryEditFormGalleryName',['value' => $this->getUrl(2)]); ?>
<?php else: ?>
<?php echo template::speech('Aucune image.'); ?>
<?php endif; ?>