[2.4] Constantes de tri - pas de tri dans la création de galerie dans la config

This commit is contained in:
Fred Tempez 2020-04-13 18:13:01 +02:00
parent bc0185729c
commit ea2085d584
2 changed files with 17 additions and 19 deletions

View File

@ -14,6 +14,10 @@
class gallery extends common {
const SORT_ASC = 'SORT_ASC';
const SORT_DSC = 'SORT_DSC';
const SORT_HAND = 'SORT_HAND';
public static $actions = [
'config' => self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR,
@ -24,9 +28,9 @@ class gallery extends common {
];
public static $sort = [
'SORT_ASC' => 'Alphabétique ',
'SORT_DSC' => 'Alphabétique inversé',
'SORT_HAND' => 'Tri manuel'
self::SORT_ASC => 'Alphabétique ',
self::SORT_DSC => 'Alphabétique inversé',
self::SORT_HAND => 'Tri manuel'
];
public static $directories = [];
@ -140,7 +144,7 @@ class gallery extends common {
'name' => $this->getInput('galleryConfigName'),
'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true),
'homePicture' => $homePicture,
'sort' => $this->getInput('galleryConfigSort'),
'sort' => self::SORT_ASC,
'position' => count($this->getData(['module',$this->getUrl(0)])) + 1
],
'legend' => [],
@ -235,7 +239,7 @@ class gallery extends common {
*/
$picturesPosition = [];
if ($this->getInput('galleryEditFormResponse') &&
$this->getInput('galleryEditSort') === 'SORT_HAND') {
$this->getInput('galleryEditSort') === self::SORT_HAND) {
// Tri des images si valeur de retour et choix manuel
$picturesPosition = explode('&',($this->getInput('galleryEditFormResponse')));
$picturesPosition = str_replace('galleryTable%5B%5D=','',$picturesPosition);
@ -306,7 +310,7 @@ class gallery extends common {
}
// Tri des images
switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort'])) {
case 'SORT_HAND':
case self::SORT_HAND:
$positions = $this->getdata(['module',$this->getUrl(0), $this->getUrl(2),'position']);
if ($positions) {
foreach ($positions as $position => $name) {
@ -317,11 +321,11 @@ class gallery extends common {
self::$picturesId = $tempPicturesId;
}
break;
case 'SORT_ASC':
case self::SORT_ASC:
ksort(self::$pictures,SORT_NATURAL);
sort(self::$picturesId,SORT_NATURAL);
break;
case 'SORT_DSC':
case self::SORT_DSC:
krsort(self::$pictures,SORT_NATURAL);
rsort(self::$picturesId,SORT_NATURAL);
break;
@ -375,7 +379,7 @@ class gallery extends common {
}
// Tri des images par ordre alphabétique
switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'sort'])) {
case 'SORT_HAND':
case self::SORT_HAND:
asort($picturesSort);
if ($picturesSort) {
foreach ($picturesSort as $name => $position) {
@ -384,10 +388,10 @@ class gallery extends common {
self::$pictures = $temp;
break;
}
case 'SORT_DSC':
case self::SORT_DSC:
krsort(self::$pictures,SORT_NATURAL);
break;
case 'SORT_ASC':
case self::SORT_ASC:
default:
ksort(self::$pictures,SORT_NATURAL);
break;

View File

@ -14,12 +14,12 @@
<div class="block">
<h4>Ajouter une galerie</h4>
<div class="row">
<div class="col4">
<div class="col6">
<?php echo template::text('galleryConfigName', [
'label' => 'Nom'
]); ?>
</div>
<div class="col4">
<div class="col5">
<?php echo template::hidden('galleryConfigDirectoryOld', [
'noDirty' => true // Désactivé à cause des modifications en ajax
]); ?>
@ -28,12 +28,6 @@
'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', [
'ico' => '',