Browse Source

Merge pull request #5 from brunoduc/brunoduc-patch-2

Brunoduc patch 2
branche9
Fred 1 year ago
committed by GitHub
parent
commit
50b54f93ed
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      core/core.php
  2. 43
      module/gallery/gallery.php
  3. 20
      module/gallery/view/config/config.js.php
  4. 2
      module/gallery/view/config/config.php
  5. 6
      module/gallery/view/edit/edit.php
  6. 13
      module/gallery/view/gallery/gallery.css
  7. 37
      module/gallery/view/gallery/gallery.php
  8. 25
      module/gallery/view/index/index.js.php
  9. 2
      module/gallery/view/index/index.php

2
core/core.php

@ -3342,7 +3342,7 @@ class template {
$html .= '<tr>';
$i = 0;
foreach($tr as $td) {
$html .= '<td class="col' . $cols[$i++] . '">' . $td . '</td>';
$html .= '<td " class="pos' . ($i+1) . ' col' . $cols[$i++] . '">' . $td . '</td>';
}
$html .= '</tr>';
}

43
module/gallery/gallery.php

@ -23,8 +23,8 @@ class gallery extends common {
];
public static $sort = [
'asc' => 'Alphabétique naturel',
'dsc' => 'Alphabétique naturel inverse',
'SORT_ASC' => 'Alphabétique naturel',
'SORT_DSC' => 'Alphabétique naturel inverse',
'none' => 'Aucun tri',
];
@ -44,8 +44,24 @@ class gallery extends common {
public function config() {
// Liste des galeries
$galleries = $this->getData(['module', $this->getUrl(0)]);
$countGalleries = count($this->getData(['module',$this->getUrl(0)]));
// Tri des éléments de la galerie
/*
echo "<pre>";
if($galleries) {
foreach($galleries as $galleryId => $gallery) {
echo $galleryId;
echo "|";
echo $gallery['config']['order'] ;
echo '<p>';
}
}
echo "</pre>";
*/
if($galleries) {
ksort($galleries,SORT_NATURAL);
foreach($galleries as $galleryId => $gallery) {
// Erreur dossier vide
if(is_dir($gallery['config']['directory'])) {
@ -57,10 +73,20 @@ class gallery extends common {
else {
$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
self::$galleries[] = [
$gallery['config']['name'],
$gallery['config']['directory'],
$gallery['config']['order'],
/*
template::select('galleryConfigOrder', $galeryOrder , [
'selected' => $gallery['config']['order'],
'class' => 'configOrder'
]),*/
template::button('galleryConfigEdit' . $galleryId , [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $galleryId . '/' . $_SESSION['csrf'],
'value' => template::ico('pencil')
@ -80,7 +106,8 @@ class gallery extends common {
'config' => [
'name' => $this->getInput('galleryConfigName'),
'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' => []
]]);
@ -223,10 +250,10 @@ class gallery extends common {
switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort'])) {
case 'none':
break;
case 'dsc':
case 'SORT_DSC':
krsort(self::$pictures,SORT_NATURAL);
break;
case 'asc':
case 'SORT_ASC':
default:
ksort(self::$pictures,SORT_NATURAL);
break;
@ -268,10 +295,10 @@ class gallery extends common {
switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'sort'])) {
case 'none':
break;
case 'dsc':
case 'SORT_DSC':
krsort(self::$pictures,SORT_NATURAL);
break;
case 'asc':
case 'SORT_ASC':
default:
ksort(self::$pictures,SORT_NATURAL);
break;

20
module/gallery/view/config/config.js.php

@ -6,6 +6,8 @@
*
* @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/
*/
@ -58,4 +60,22 @@ setInterval(function() {
*/
directoryDOM.on("change", function() {
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);
});

2
module/gallery/view/config/config.php

@ -45,7 +45,7 @@
</div>
</div>
<?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 echo template::speech('Aucune galerie.'); ?>
<?php endif; ?>

6
module/gallery/view/edit/edit.php

@ -17,7 +17,7 @@
<div class="block">
<h4>Informations générales</h4>
<div class="row">
<div class="col4">
<div class="col5">
<?php echo template::text('galleryEditName', [
'label' => 'Nom',
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'name'])
@ -33,13 +33,13 @@
'noDirty' => true // Désactivé à cause des modifications en ajax
]); ?>
</div>
<div class="col4">
<div class="col3">
<?php echo template::select('galleryEditSort', $module::$sort, [
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', '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>

13
module/gallery/view/gallery/gallery.css

@ -21,4 +21,15 @@
background: rgba(0, 0, 0, .6);
color: #FFF;
text-align: center;
}
}
/* Ajout de régles css ---------------------------- */
.galleryRow {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.col3 {
width : 16em;
max-width: 50%;
}
/* ----------------------------------------------*/

37
module/gallery/view/gallery/gallery.php

@ -8,26 +8,19 @@
]); ?>
</div>
</div>
<?php $i = 1; ?>
<?php $picturesNb = count($module::$pictures); ?>
<!-- Ajout du début de la ligne row en rajoutant la class rowGallery (on supprime $i et $picturesNb) ********************** -->
<div class="row galleryRow">
<?php foreach($module::$pictures as $picture => $legend): ?>
<?php if($i % 4 === 1): ?>
<div class="row">
<?php endif; ?>
<div class="col3">
<a
href="<?php echo helper::baseUrl(false) . $picture; ?>"
class="galleryGalleryPicture"
style="background-image:url('<?php echo helper::baseUrl(false) . $picture; ?>')"
data-caption="<?php echo $legend; ?>"
>
<?php if($legend): ?>
<div class="galleryGalleryName"><?php echo $legend; ?></div>
<?php endif; ?>
</a>
</div>
<?php if($i % 4 === 0 OR $i === $picturesNb): ?>
</div>
<?php endif; ?>
<?php $i++; ?>
<?php endforeach; ?>
<div class="col3">
<a
href="<?php echo helper::baseUrl(false) . $picture; ?>"
class="galleryGalleryPicture"
style="background-image:url('<?php echo helper::baseUrl(false) . $picture; ?>')"
data-caption="<?php echo $legend; ?>"
>
<?php if($legend): ?>
<div class="galleryGalleryName"><?php echo $legend; ?></div>
<?php endif; ?>
</a>
</div>
<?php endforeach; ?>

25
module/gallery/view/index/index.js.php

@ -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);
*/
});

2
module/gallery/view/index/index.php

@ -5,7 +5,7 @@
<?php if($i % 2 === 1): ?>
<div class="row">
<?php endif; ?>
<div class="col6">
<div class="col6" div="pos<?php echo $gallery['config']['order']; ?>" >
<a
href="<?php echo helper::baseUrl() . $this->getUrl(0); ?>/<?php echo $galleryId; ?>"
class="galleryPicture"

Loading…
Cancel
Save