Update gallery module to Gallery 2.0 by @Gilux #4

Closed
brunoduc wants to merge 1 commits from brunoduc-patch-2-Gallery-v2.0 into dev10
  1. 228
      module/gallery/gallery.php
  2. 3
      module/gallery/vendor/js/inc.json
  3. 27
      module/gallery/vendor/js/size.js
  4. BIN
      module/gallery/vendor/leaflet/images/layers-2x.png
  5. BIN
      module/gallery/vendor/leaflet/images/layers.png
  6. BIN
      module/gallery/vendor/leaflet/images/marker-icon-2x.png
  7. BIN
      module/gallery/vendor/leaflet/images/marker-icon.png
  8. BIN
      module/gallery/vendor/leaflet/images/marker-shadow.png
  9. 640
      module/gallery/vendor/leaflet/leaflet.css
  10. 5
      module/gallery/vendor/leaflet/leaflet.js
  11. 52
      module/gallery/vendor/map.php
  12. 61
      module/gallery/vendor/thumbnailer.php
  13. 14
      module/gallery/view/config/config.php
  14. 5
      module/gallery/view/edit/edit.js.php
  15. 13
      module/gallery/view/edit/edit.php
  16. 66
      module/gallery/view/gallery/gallery.css
  17. 7
      module/gallery/view/gallery/gallery.js.php
  18. 85
      module/gallery/view/gallery/gallery.php
  19. 53
      module/gallery/view/index/index.css
  20. 54
      module/gallery/view/index/index.php

228
module/gallery/gallery.php

@ -1,5 +1,4 @@
<?php
/**
* This file is part of Zwii.
*
@ -10,6 +9,7 @@
* @copyright Copyright (C) 2008-2018, Rémi Jean
* @license GNU General Public License, version 3
* @link http://zwiicms.com/
* Modifié par @Gilux 2019
*/
class gallery extends common {
@ -22,12 +22,6 @@ class gallery extends common {
'index' => self::GROUP_VISITOR
];
public static $sort = [
'asc' => 'Alphabétique naturel',
'dsc' => 'Alphabétique naturel inverse',
'none' => 'Aucun tri',
];
public static $directories = [];
public static $firstPictures = [];
@ -36,7 +30,7 @@ class gallery extends common {
public static $pictures = [];
const GALLERY_VERSION = '1.3';
const GALLERY_VERSION = '2.0';
/**
* Configuration
@ -44,8 +38,8 @@ class gallery extends common {
public function config() {
// Liste des galeries
$galleries = $this->getData(['module', $this->getUrl(0)]);
if($galleries) {
ksort($galleries,SORT_NATURAL);
if($galleries) {
ksort($galleries);
foreach($galleries as $galleryId => $gallery) {
// Erreur dossier vide
if(is_dir($gallery['config']['directory'])) {
@ -58,10 +52,10 @@ class gallery extends common {
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . ' (dossier introuvable)</span>';
}
// Met en forme le tableau
self::$galleries[] = [
self::$galleries[] = [
$gallery['config']['name'],
$gallery['config']['directory'],
template::button('galleryConfigEdit' . $galleryId , [
template::button('galleryConfigEdit' . $galleryId, [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $galleryId . '/' . $_SESSION['csrf'],
'value' => template::ico('pencil')
]),
@ -79,8 +73,7 @@ class gallery extends common {
$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')
'directory' => $this->getInput('galleryConfigDirectory', helper::FILTER_STRING_SHORT, true)
],
'legend' => []
]]);
@ -102,7 +95,6 @@ class gallery extends common {
* Suppression
*/
public function delete() {
// $url prend l'adresse sans le token
// La galerie n'existe pas
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) {
// Valeurs en sortie
@ -117,7 +109,7 @@ class gallery extends common {
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
'notification' => 'Suppression non autorisée'
]);
}
}
// Suppression
else {
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]);
@ -152,7 +144,7 @@ class gallery extends common {
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
'notification' => 'Action non autorisée'
]);
}
}
// La galerie n'existe pas
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) {
// Valeurs en sortie
@ -172,24 +164,16 @@ class gallery extends common {
// Supprime l'ancienne galerie
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]);
}
// légendes
$legends = [];
foreach((array) $this->getInput('legend', null) as $file => $legend) {
$file = str_replace('.','',$file);
$legends[$file] = helper::filter($legend, helper::FILTER_STRING_SHORT);
}
// Photo de la page de garde de l'album
$homePictures = [];
foreach((array) $this->getInput('homePicture', null) as $file => $homePicture) {
// null : pas de variable définie (compatibilité) ou choix non effectif
$homePictures[$file] = $file === 0 ? null : helper::filter($file, helper::FILTER_STRING_SHORT) ;
}
$this->setData(['module', $this->getUrl(0), $galleryId, [
'config' => [
'name' => $this->getInput('galleryEditName', helper::FILTER_STRING_SHORT, true),
'directory' => $this->getInput('galleryEditDirectory', helper::FILTER_STRING_SHORT, true),
'homePicture' => $homePictures[$file],
'sort' => $this->getInput('galleryEditSort')
'directory' => $this->getInput('galleryEditDirectory', helper::FILTER_STRING_SHORT, true)
],
'legend' => $legends
]]);
@ -208,29 +192,12 @@ class gallery extends common {
if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) {
self::$pictures[$fileInfos->getFilename()] = [
$fileInfos->getFilename(),
template::checkbox( 'homePicture[' . $fileInfos->getFilename() . ']', true, '', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2),'config', 'homePicture']) === $fileInfos->getFilename() ? true : false,
'class' => 'homePicture'
]),
template::text('legend[' . $fileInfos->getFilename() . ']', [
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'legend', str_replace('.','',$fileInfos->getFilename())])
])
];
}
}
// Tri des images par ordre alphabétique
switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'sort'])) {
case 'none':
break;
case 'dsc':
krsort(self::$pictures,SORT_NATURAL);
break;
case 'asc':
default:
ksort(self::$pictures,SORT_NATURAL);
break;
}
}
// Valeurs en sortie
$this->addOutput([
@ -256,37 +223,26 @@ class gallery extends common {
// La galerie existe
else {
// Images de la galerie
$directory = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'directory']);
$directory = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'directory']);
if(is_dir($directory)) {
$iterator = new DirectoryIterator($directory);
foreach($iterator as $fileInfos) {
if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) {
self::$pictures[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'legend', str_replace('.','',$fileInfos->getFilename())]);
// contrôle et traite éventuellement les images affichées dans la galerie
$imgalerie = str_replace('\\','/',$fileInfos->getPathname());
galleriesHelper::controle($imgalerie);
self::$pictures[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'legend', str_replace('.','',$fileInfos->getFilename())]);
}
}
// Tri des images par ordre alphabétique
switch ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'sort'])) {
case 'none':
break;
case 'dsc':
krsort(self::$pictures,SORT_NATURAL);
break;
case 'asc':
default:
ksort(self::$pictures,SORT_NATURAL);
break;
}
}
// Affichage du template
if(self::$pictures) {
ksort(self::$pictures);
// Valeurs en sortie
$this->addOutput([
'showBarEditButton' => true,
'title' => $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'name']),
/* Désactivé car SLB est actif pour tout le site
'vendor' => [
'simplelightbox'
],*/
'vendor' => ['js'],
'view' => 'gallery'
]);
}
@ -301,23 +257,28 @@ class gallery extends common {
}
// Liste des galeries
else {
else {
foreach((array) $this->getData(['module', $this->getUrl(0)]) as $galleryId => $gallery) {
if(is_dir($gallery['config']['directory'])) {
$iterator = new DirectoryIterator($gallery['config']['directory']);
foreach($iterator as $fileInfos) {
if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) {
self::$galleries[$galleryId] = $gallery;
self::$firstPictures[$galleryId] = $gallery['config']['directory'] . '/' . $fileInfos->getFilename();
continue(2);
// contrôle et traite éventuellement les images affichées dans l'index de la galerie
$imgalerie = str_replace('\\','/',$fileInfos->getPathname());
galleriesHelper::controle($imgalerie);
self::$galleries[$galleryId] = $gallery;
self::$firstPictures[$galleryId] = $gallery['config']['directory'] . '/' . $fileInfos->getFilename();
continue(2);
}
}
}
}
// Valeurs en sortie
$this->addOutput([
'showBarEditButton' => true,
'showPageContent' => true,
'vendor' => ['js'],
'view' => 'index'
]);
}
@ -343,4 +304,137 @@ class galleriesHelper extends helper {
}
return $dirContent;
}
}
// relevés exif gps des photos
public static function gps_exif($foto) {
if (!preg_match('/(\.jpe?g)$/i', $foto)) {
return null;
}
if (function_exists('exif_read_data')) {
$exif = @exif_read_data($foto, 0, true);
if ($exif && @$exif['GPS']['GPSLongitude'][0]) {
$latitude = self::gps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']);
$longitude = self::gps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']);
if (!empty($exif['GPS']['GPSAltitude'])) {
$alt = explode('/',$exif['GPS']['GPSAltitude']);
$altitude = round($alt[0] / $alt[1]);
}
else { $altitude = 0; }
if (!isset($latitude) || !isset($longitude)) {
return null; }
else {
return ($latitude.'¤'.$longitude.'¤'.$altitude);
}
}
}
}
public static function gps($coordinate, $hemisphere) {
if (is_string($coordinate)) {
$coordinate = array_map('trim', explode(',', $coordinate));
}
for ($i = 0; $i < 3; $i++) {
$part = explode('/', $coordinate[$i]);
if (count($part) == 1) {
$coordinate[$i] = $part[0];
} elseif (count($part) == 2) {
$coordinate[$i] = floatval($part[0])/floatval($part[1]);
} else {
$coordinate[$i] = 0;
}
}
list($degrees, $minutes, $seconds) = $coordinate;
$sign = ($hemisphere == 'W' || $hemisphere == 'S') ? -1 : 1;
return $sign * ($degrees + $minutes/60 + $seconds/3600);
}
// formatage light des noms d'images
public static function formate($foto) {
$foto = trim($foto);
$foto = preg_replace('/[^[:alnum:]_.\-\/]/', '', $foto);
return $foto;
}
// reorientation
public static function reorientation($foto) {
$size = getimagesize($foto);
$mime = $size['mime'];
if ((function_exists('exif_read_data')) && ($mime == 'image/jpeg'))
{
$exif = @exif_read_data($foto);
$image = imagecreatefromstring(file_get_contents($foto));
if ($image !== false) {
$orientation = isset($exif['Orientation']) === true ? $exif['Orientation'] : '';
if ( (!empty($orientation)) && ($orientation != 1) )
{
switch($orientation)
{
case 3:
$image = imagerotate($image,180,0);
break;
case 6:
$image = imagerotate($image,-90,0);
break;
case 8:
$image = imagerotate($image,90,0);
break;
}
imagejpeg($image, $foto, 90);
}
}
}
}
// redimension
public static function redimension($foto) {
$max_size = 1280;// dimension du plus petit côté
$infoto = getimagesize($foto);
$large = $infoto[0];
$haut = $infoto[1];
$type = $infoto[2];
// seules les images/jpeg sont redimensionnées
if (($type == 2) && ($large > $max_size) && ($haut > $max_size)) {
$imar = substr(strrchr($foto, '/'), 1);
$urlimar = str_replace($imar,'',$foto);
$backup = $urlimar.'backup';
if(!is_dir($backup)) {
@mkdir($backup);
}
$extension = strrchr($imar,'.');
$namimar = str_replace($extension,'',$imar);
$redimg = $urlimar.$namimar.'_t1280.jpg';
$backimg = $backup.'/'.strtolower(str_replace('.jpeg','.jpg',$imar));
$src = imagecreatefromjpeg($foto);
imageinterlace($src, true);
if ($large > $haut) {
$im = imagecreatetruecolor(round(($max_size/$haut)*$large), $max_size);
imagecopyresampled($im, $src, 0, 0, 0, 0, round(($max_size/$haut)*$large), $max_size, $large, $haut);
} else {
$im = imagecreatetruecolor($max_size, round(($max_size/$large)*$haut));
imagecopyresampled($im, $src, 0, 0, 0, 0, $max_size, round($haut*($max_size/$large)), $large, $haut);
}
imagejpeg($im, $redimg, 80);
imagedestroy($im);
rename($foto,$backimg);
echo '<script>document.location.reload(false);</script>';
exit(0);
}
}
// contrôle des photos
public static function controle($foto) {
$tn_tmp = substr(strrchr($foto, '/'), 1);
$url_picture = str_replace('/'.$tn_tmp,'',$foto);
$minidos = substr(strrchr($url_picture, '/'), 1);
$mini = 'site/file/cache/'.$minidos.'/'.$tn_tmp;
if (!file_exists($mini)) {
$valid = array('-', '_','.');
if (!ctype_alnum(str_replace($valid, '', $tn_tmp))) {
$nommage = self::formate($foto);
$foto = rename($foto,$nommage);
echo '<script>document.location.reload(false);</script>';
exit(0);
} else {
self::reorientation($foto);
self::redimension($foto);
}
}
return $foto;
clearstatcache();
}
}

3
module/gallery/vendor/js/inc.json

@ -0,0 +1,3 @@
[
"size.js"
]

27
module/gallery/vendor/js/size.js

@ -0,0 +1,27 @@
$(function () {
// @Gilux 2019
var taille = getComputedStyle(site).width;
switch(taille)
{
case '750px':
$('a.galleryPicture').css('height', '200px');
$('a.galleryGalleryPicture').css('height', '110px');
$('div.galleryGalleryName').css('font-size', '0.8em');
break;
case '960px':
$('a.galleryPicture').css('height', '240px');
$('a.galleryGalleryPicture').css('height', '135px');
$('div.galleryGalleryName').css('font-size', '0.85em');
break;
case '1170px':
$('a.galleryPicture').css('height', '300px');
$('a.galleryGalleryPicture').css('height', '160px');
$('div.galleryGalleryName').css('font-size', '0.9em');
break;
default:
$('a.galleryPicture').css('height', '340px');
$('a.galleryGalleryPicture').css('height', '185px');
$('div.galleryGalleryName').css('font-size', '1em');
break;
}
});

BIN
module/gallery/vendor/leaflet/images/layers-2x.png

After

Width: 52  |  Height: 52  |  Size: 1.2 KiB

BIN
module/gallery/vendor/leaflet/images/layers.png

After

Width: 26  |  Height: 26  |  Size: 696 B

BIN
module/gallery/vendor/leaflet/images/marker-icon-2x.png

After

Width: 50  |  Height: 82  |  Size: 2.4 KiB

BIN
module/gallery/vendor/leaflet/images/marker-icon.png

After

Width: 25  |  Height: 41  |  Size: 1.4 KiB

BIN
module/gallery/vendor/leaflet/images/marker-shadow.png

After

Width: 41  |  Height: 41  |  Size: 618 B

640
module/gallery/vendor/leaflet/leaflet.css

@ -0,0 +1,640 @@
/* required styles */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
position: absolute;
left: 0;
top: 0;
}
.leaflet-container {
overflow: hidden;
}
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
-webkit-user-drag: none;
}
/* Prevents IE11 from highlighting tiles in blue */
.leaflet-tile::selection {
background: transparent;
}
/* Safari renders non-retina tile on retina better with this, but Chrome is worse */
.leaflet-safari .leaflet-tile {
image-rendering: -webkit-optimize-contrast;
}
/* hack that prevents hw layers "stretching" when loading new tiles */
.leaflet-safari .leaflet-tile-container {
width: 1600px;
height: 1600px;
-webkit-transform-origin: 0 0;
}
.leaflet-marker-icon,
.leaflet-marker-shadow {
display: block;
}
/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
.leaflet-container .leaflet-overlay-pane svg,
.leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer,
.leaflet-container .leaflet-tile {
max-width: none !important;
max-height: none !important;
}
.leaflet-container.leaflet-touch-zoom {
-ms-touch-action: pan-x pan-y;
touch-action: pan-x pan-y;
}
.leaflet-container.leaflet-touch-drag {
-ms-touch-action: pinch-zoom;
/* Fallback for FF which doesn't support pinch-zoom */
touch-action: none;
touch-action: pinch-zoom;
}
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
-ms-touch-action: none;
touch-action: none;
}
.leaflet-container {
-webkit-tap-highlight-color: transparent;
}
.leaflet-container a {
-webkit-tap-highlight-color: rgba(51, 181, 229, 0.4);
}
.leaflet-tile {
filter: inherit;
visibility: hidden;
}
.leaflet-tile-loaded {
visibility: inherit;
}
.leaflet-zoom-box {
width: 0;
height: 0;
-moz-box-sizing: border-box;
box-sizing: border-box;
z-index: 800;
}
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
.leaflet-overlay-pane svg {
-moz-user-select: none;
}
.leaflet-pane { z-index: 400; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-map-pane canvas { z-index: 100; }
.leaflet-map-pane svg { z-index: 200; }
.leaflet-vml-shape {
width: 1px;
height: 1px;
}
.lvml {
behavior: url(#default#VML);
display: inline-block;
position: absolute;
}
/* control positioning */
.leaflet-control {
position: relative;
z-index: 800;
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
pointer-events: auto;
}
.leaflet-top,
.leaflet-bottom {
position: absolute;
z-index: 1000;
pointer-events: none;
}
.leaflet-top {
top: 0;
}
.leaflet-right {
right: 0;
}
.leaflet-bottom {
bottom: 0;
}
.leaflet-left {
left: 0;
}
.leaflet-control {
float: left;
clear: both;
}
.leaflet-right .leaflet-control {
float: right;
}
.leaflet-top .leaflet-control {
margin-top: 10px;
}
.leaflet-bottom .leaflet-control {
margin-bottom: 10px;
}
.leaflet-left .leaflet-control {
margin-left: 10px;
}
.leaflet-right .leaflet-control {
margin-right: 10px;
}
/* zoom and fade animations */
.leaflet-fade-anim .leaflet-tile {
will-change: opacity;
}
.leaflet-fade-anim .leaflet-popup {
opacity: 0;
-webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear;
transition: opacity 0.2s linear;
}
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
opacity: 1;
}
.leaflet-zoom-animated {
-webkit-transform-origin: 0 0;
-ms-transform-origin: 0 0;
transform-origin: 0 0;
}
.leaflet-zoom-anim .leaflet-zoom-animated {
will-change: transform;
}
.leaflet-zoom-anim .leaflet-zoom-animated {
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
}
.leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile {
-webkit-transition: none;
-moz-transition: none;
transition: none;
}
.leaflet-zoom-anim .leaflet-zoom-hide {
visibility: hidden;
}
/* cursors */
.leaflet-interactive {
cursor: pointer;
}
.leaflet-grab {
cursor: -webkit-grab;
cursor: -moz-grab;
cursor: grab;
}
.leaflet-crosshair,
.leaflet-crosshair .leaflet-interactive {
cursor: crosshair;
}
.leaflet-popup-pane,
.leaflet-control {
cursor: auto;
}
.leaflet-dragging .leaflet-grab,
.leaflet-dragging .leaflet-grab .leaflet-interactive,
.leaflet-dragging .leaflet-marker-draggable {
cursor: move;
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
cursor: grabbing;
}
/* marker & overlays interactivity */
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-image-layer,
.leaflet-pane > svg path,
.leaflet-tile-container {
pointer-events: none;
}
.leaflet-marker-icon.leaflet-interactive,
.leaflet-image-layer.leaflet-interactive,
.leaflet-pane > svg path.leaflet-interactive,
svg.leaflet-image-layer.leaflet-interactive path {
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
pointer-events: auto;
}
/* visual tweaks */
.leaflet-container {
background: #ddd;
outline: 0;
}
.leaflet-container a {
color: #0078A8;
}
.leaflet-container a.leaflet-active {
outline: 2px solid orange;
}
.leaflet-zoom-box {
border: 2px dotted #38f;
background: rgba(255,255,255,0.5);
}
/* general typography */
.leaflet-container {
font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
}
/* general toolbar styles */
.leaflet-bar {
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
border-radius: 4px;
}
.leaflet-bar a,
.leaflet-bar a:hover {
background-color: #fff;
border-bottom: 1px solid #ccc;
width: 26px;
height: 26px;
line-height: 26px;
display: block;
text-align: center;
text-decoration: none;
color: black;
}
.leaflet-bar a,
.leaflet-control-layers-toggle {
background-position: 50% 50%;
background-repeat: no-repeat;
display: block;
}
.leaflet-bar a:hover {
background-color: #f4f4f4;
}
.leaflet-bar a:first-child {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.leaflet-bar a:last-child {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom: none;
}
.leaflet-bar a.leaflet-disabled {
cursor: default;
background-color: #f4f4f4;
color: #bbb;
}
.leaflet-touch .leaflet-bar a {
width: 30px;
height: 30px;
line-height: 30px;
}
.leaflet-touch .leaflet-bar a:first-child {
border-top-left-radius: 2px;
border-top-right-radius: 2px;
}
.leaflet-touch .leaflet-bar a:last-child {
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
}
/* zoom control */
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
font: bold 18px 'Lucida Console', Monaco, monospace;
text-indent: 1px;
}
.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out {
font-size: 22px;
}
/* layers control */
.leaflet-control-layers {
box-shadow: 0 1px 5px rgba(0,0,0,0.4);
background: #fff;
border-radius: 5px;
}
.leaflet-control-layers-toggle {
background-image: url(images/layers.png);
width: 36px;
height: 36px;
}
.leaflet-retina .leaflet-control-layers-toggle {
background-image: url(images/layers-2x.png);
background-size: 26px 26px;
}
.leaflet-touch .leaflet-control-layers-toggle {
width: 44px;
height: 44px;
}
.leaflet-control-layers .leaflet-control-layers-list,
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
display: none;
}
.leaflet-control-layers-expanded .leaflet-control-layers-list {
display: block;
position: relative;
}
.leaflet-control-layers-expanded {
padding: 6px 10px 6px 6px;
color: #333;
background: #fff;
}
.leaflet-control-layers-scrollbar {
overflow-y: scroll;
overflow-x: hidden;
padding-right: 5px;
}
.leaflet-control-layers-selector {
margin-top: 2px;
position: relative;
top: 1px;
}
.leaflet-control-layers label {
display: block;
}
.leaflet-control-layers-separator {
height: 0;
border-top: 1px solid #ddd;
margin: 5px -10px 5px -6px;
}
/* Default icon URLs */
.leaflet-default-icon-path {
background-image: url(images/marker-icon.png);
}
/* attribution and scale controls */
.leaflet-container .leaflet-control-attribution {
background: #fff;
background: rgba(255, 255, 255, 0.7);
margin: 0;
}
.leaflet-control-attribution,
.leaflet-control-scale-line {
padding: 0 5px;
color: #333;
}
.leaflet-control-attribution a {
text-decoration: none;
}
.leaflet-control-attribution a:hover {
text-decoration: underline;
}
.leaflet-container .leaflet-control-attribution,
.leaflet-container .leaflet-control-scale {
font-size: 11px;
}
.leaflet-left .leaflet-control-scale {
margin-left: 5px;
}
.leaflet-bottom .leaflet-control-scale {
margin-bottom: 5px;
}
.leaflet-control-scale-line {
border: 2px solid #777;
border-top: none;
line-height: 1.1;
padding: 2px 5px 1px;
font-size: 11px;
white-space: nowrap;
overflow: hidden;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: #fff;
background: rgba(255, 255, 255, 0.5);
}
.leaflet-control-scale-line:not(:first-child) {
border-top: 2px solid #777;
border-bottom: none;
margin-top: -2px;
}
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
border-bottom: 2px solid #777;
}
.leaflet-touch .leaflet-control-attribution,
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
box-shadow: none;
}
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
border: 2px solid rgba(0,0,0,0.2);
background-clip: padding-box;
}
/* popup */
.leaflet-popup {
position: absolute;
text-align: center;
margin-bottom: 20px;
}
.leaflet-popup-content-wrapper {
padding: 1px;
text-align: left;
border-radius: 12px;
}
.leaflet-popup-content {
margin: 13px 19px;
line-height: 1.4;
}
.leaflet-popup-content p {
margin: 18px 0;
}
.leaflet-popup-tip-container {
width: 40px;
height: 20px;
position: absolute;
left: 50%;
margin-left: -20px;
overflow: hidden;
pointer-events: none;
}
.leaflet-popup-tip {
width: 17px;
height: 17px;
padding: 1px;
margin: -10px auto 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
background: white;
color: #333;
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
}
.leaflet-container a.leaflet-popup-close-button {
position: absolute;
top: 0;
right: 0;
padding: 4px 4px 0 0;
border: none;
text-align: center;
width: 18px;
height: 14px;
font: 16px/14px Tahoma, Verdana, sans-serif;
color: #c3c3c3;
text-decoration: none;
font-weight: bold;
background: transparent;
}
.leaflet-container a.leaflet-popup-close-button:hover {
color: #999;
}
.leaflet-popup-scrolled {
overflow: auto;
border-bottom: 1px solid #ddd;
border-top: 1px solid #ddd;
}
.leaflet-oldie .leaflet-popup-content-wrapper {
zoom: 1;
}
.leaflet-oldie .leaflet-popup-tip {
width: 24px;
margin: 0 auto;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
}
.leaflet-oldie .leaflet-popup-tip-container {
margin-top: -1px;
}
.leaflet-oldie .leaflet-control-zoom,
.leaflet-oldie .leaflet-control-layers,
.leaflet-oldie .leaflet-popup-content-wrapper,
.leaflet-oldie .leaflet-popup-tip {
border: 1px solid #999;
}
/* div icon */
.leaflet-div-icon {
background: #fff;
border: 1px solid #666;
}
/* Tooltip */
/* Base styles for the element that has a tooltip */
.leaflet-tooltip {
position: absolute;
padding: 6px;
background-color: #fff;
border: 1px solid #fff;
border-radius: 3px;
color: #222;
white-space: nowrap;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
pointer-events: none;
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.leaflet-tooltip.leaflet-clickable {
cursor: pointer;
pointer-events: auto;
}
.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
position: absolute;
pointer-events: none;
border: 6px solid transparent;
background: transparent;
content: "";
}
/* Directions */
.leaflet-tooltip-bottom {
margin-top: 6px;
}
.leaflet-tooltip-top {
margin-top: -6px;
}
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-top:before {
left: 50%;
margin-left: -6px;
}
.leaflet-tooltip-top:before {
bottom: 0;
margin-bottom: -12px;
border-top-color: #fff;
}
.leaflet-tooltip-bottom:before {
top: 0;
margin-top: -12px;
margin-left: -6px;
border-bottom-color: #fff;
}
.leaflet-tooltip-left {
margin-left: -6px;
}
.leaflet-tooltip-right {
margin-left: 6px;
}
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
top: 50%;
margin-top: -6px;
}
.leaflet-tooltip-left:before {
right: 0;
margin-right: -12px;
border-left-color: #fff;
}
.leaflet-tooltip-right:before {
left: 0;
margin-left: -12px;
border-right-color: #fff;
}

5
module/gallery/vendor/leaflet/leaflet.js
File diff suppressed because it is too large
View File

52
module/gallery/vendor/map.php

@ -0,0 +1,52 @@
<?php
// création @Gilux 2019 pour ZwiiCMS
$lat = $_GET['lat'];
$lon = $_GET['lon'];
$altitude = $_GET['alt'];
if ($altitude > 0) { $alt = $altitude; }
else {
$alt = "'indéterminée ou 0'";
}
$zoom = $_GET['zoom'];
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Mapop</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="leaflet/leaflet.css">
<script src="leaflet/leaflet.js"></script>
<style>
html, body{
width: 100vw;
height: 100%;
}
body {
padding: 0;
margin: 0;
}
#mapid {
width: 100%;
height: 95vh;
}
</style>
</head>
<body>
<div id="mapid"> </div>
<script>
var mymap = L.map('mapid').setView([<?=$lat?>, <?=$lon?>], <?=$zoom?>);
L.tileLayer('http://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
maxZoom: 17,
attribution: 'map data: © <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors, ' +
'<a href="http://viewfinderpanoramas.org">SRTM</a> | ' +
'map style: © <a href="https://opentopomap.org">OpenTopoMap</a> ' +
'(<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)'
}).addTo(mymap);
var marker = L.marker([<?=$lat?>, <?=$lon?>]).addTo(mymap)
.bindPopup('altitude = '+ <?=$alt?> +' m')
.openPopup();
</script>
</body>
</html>

61
module/gallery/vendor/thumbnailer.php

@ -0,0 +1,61 @@
<?php
// création des miniatures pour la galerie de ZwiiCMS par @Gilux 2019
if (!isset($_GET['img']))
{
exit(0);
}
$ratio = (isset($_GET['ratio'])) ? (int) $_GET['ratio'] : 135;
$img = '../../../'.$_GET['img'];
$dossiercache = '../../../site/file/cache';
if(!is_dir($dossiercache))
{
@mkdir($dossiercache,0755);
}
$par = substr(strrchr($img, '/'), 1);
$url_par = str_replace('/'.$par,'',$img);
$cache = substr(strrchr($url_par, '/'), 1);
if(!is_dir($dossiercache.'/'.$cache))
{
@mkdir($dossiercache.'/'.$cache);
}
$extension = strrchr($par,'.');
$vignette = str_replace($extension,'',$par);
$miniature = $dossiercache.'/'.$cache.'/'.$vignette.'.jpg';
if(!file_exists($miniature))
{
$imginfo = getimagesize($img);
$largeur = $imginfo[0];
$hauteur = $imginfo[1];
$type = $imginfo[2];
if($type == 1)
{
$src = imagecreatefromgif($img);
}
elseif($type == 2)
{
$src = imagecreatefromjpeg($img);
}
elseif($type == 3)
{
$src = imagecreatefrompng($img);
}
imageinterlace($src, true);
if ($largeur > $hauteur)
{
$im = imagecreatetruecolor(round(($ratio/$hauteur)*$largeur), $ratio);
imagecopyresampled($im, $src, 0, 0, 0, 0, round(($ratio/$hauteur)*$largeur), $ratio, $largeur, $hauteur);
}
else
{
$im = imagecreatetruecolor($ratio, round(($ratio/$largeur)*$hauteur));
imagecopyresampled($im, $src, 0, 0, 0, 0, $ratio, round($hauteur*($ratio/$largeur)), $largeur, $hauteur);
}
imagejpeg($im, $miniature, 80);
imagedestroy($im);
}
header('Content-Type: image/jpeg');
$data = file_get_contents($miniature);
echo $data;
clearstatcache();
?>

14
module/gallery/view/config/config.php

@ -14,12 +14,12 @@
<div class="block">
<h4>Nouvelle 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' => '',
@ -45,11 +39,11 @@
</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], $module::$galleries, ['Nom', 'Dossier cible', '', '']); ?>
<?php else: ?>
<?php echo template::speech('Aucune galerie.'); ?>
<?php endif; ?>
<?php echo template::formClose(); ?>
<div class="moduleVersion">Version
<div class="moduleVersion">Module version
<?php echo $module::GALLERY_VERSION; ?>
</div>

5
module/gallery/view/edit/edit.js.php

@ -48,9 +48,4 @@ setInterval(function() {
*/
directoryDOM.on("change", function() {
directoryOldDOM.val($(this).val());
});
$('.homePicture').click(function(){
$('.homePicture').prop('checked', false);
$(this).prop('checked', true);
});

13
module/gallery/view/edit/edit.php

@ -17,13 +17,13 @@
<div class="block">
<h4>Informations générales</h4>
<div class="row">
<div class="col4">
<div class="col6">
<?php echo template::text('galleryEditName', [
'label' => 'Nom',
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'name'])
]); ?>
</div>
<div class="col4">
<div class="col6">
<?php echo template::hidden('galleryEditDirectoryOld', [
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'config', 'directory']),
'noDirty' => true // Désactivé à cause des modifications en ajax
@ -33,18 +33,11 @@
'noDirty' => true // Désactivé à cause des modifications en ajax
]); ?>
</div>
<div class="col4">
<?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>
<?php if($module::$pictures): ?>
<?php echo template::table([4, 1, 7], $module::$pictures, ['Image', 'Album','Légende']); ?>
<?php echo template::table([4, 8], $module::$pictures, ['Image', 'Légende']); ?>
<?php endif; ?>
<?php echo template::formClose(); ?>

66
module/gallery/view/gallery/gallery.css

@ -1,24 +1,58 @@
.galleryGalleryPicture {
display: block;
border: 1px solid #DDD;
height: 150px;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
.gallery {
padding: 5px;
position: relative;
-webkit-transition: opacity .3s ease-out;
transition: opacity .3s ease-out;
}
.galleryGalleryPicture:hover {
opacity: .7;
.galleryGalleryPicture {
display: flex;
align-items: center;
justify-content: center;
position: relative;
height: 110px;
text-align: center;
background-color: rgba(230, 230, 230, 0.7);
border: 1px solid #DDD;
border-radius: 6px;
}
.galleryGalleryName {
position: absolute;
left: 0;
right: 0;
bottom: 0;
padding: 10px;
background: rgba(0, 0, 0, .6);
color: #FFF;
text-align: center;
}
line-height: 1.2;
color: #000;
overflow: hidden;
}
.galleryGalleryPicture img {
max-height: 80%;
max-width: 95%;
}
.galleryGalleryPicture img:hover {
z-index: 2;
}
.picResized {
color: crimson;
}
.osm {
position: absolute;
left:10px;
bottom:10px;
}
/* !important obligatoire */
@media (max-width: 1281px) {
.galleryGalleryPicture {
height: 160px !important;
}
}
@media (max-width: 1025px) {
.galleryGalleryPicture {
height: 145px !important;
}
.galleryGalleryName {
font-size: 0.85em !important;
}
}
@media (max-width: 813px) {
.galleryGalleryPicture {
height: 115px !important;
}
}

7
module/gallery/view/gallery/gallery.js.php

@ -12,11 +12,14 @@
/**
* Galerie d'image
* SLB est activé pour tout le site
*/
var b = new SimpleLightbox('.galleryGalleryPicture', {
$(".galleryGalleryPicture").simpleLightbox({
captionSelector: "self",
captionType: "data",
captionsData: "caption",
closeText: "&times;"
});
$(".galleryGalleryPicture").on("click", function() {
$('body').removeClass("notranslate");
});

85
module/gallery/view/gallery/gallery.php

@ -8,26 +8,65 @@
]); ?>
</div>
</div>
<?php $i = 1; ?>
<?php $picturesNb = count($module::$pictures); ?>
<?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; ?>
<?php
$i = 1;
$picturesNb = count($module::$pictures);
foreach($module::$pictures as $picture => $legend):
// détermination des photos redimensionnées et originales
$photo = substr(strrchr($picture, '/'), 1);
$url_photo = str_replace($photo,'',$picture);
$photo_1280 = strpos($photo, 't1280.');
$original = str_replace('_t1280','',$photo);
$urloriginal = $url_photo.'backup/'.strtolower($original);
$urlback = (isset($urloriginal)) ? $urloriginal : 0;
if (file_exists($urloriginal)) {
$get_location = galleriesHelper::gps_exif($urloriginal);
}
else {
$get_location = galleriesHelper::gps_exif($picture);
}
?>
<?php if($i % 6 === 1): ?>
<div class="row">
<?php endif; ?>
<div class="col2 gallery">
<a href="<?php echo helper::baseUrl(false) . $picture; ?>" class="galleryGalleryPicture" data-caption="<?php echo $legend; ?>">
<img src="<?php echo helper::baseUrl(false) ?>module/gallery/vendor/thumbnailer.php?img=<?php echo $picture; ?>" alt="<?php echo $legend; ?>">
<?php if ($photo_1280 !== false): ?>
<div class="galleryGalleryName picResized" onclick="window.open('<?=helper::baseUrl(false).$urlback?>');" data-tippy-content="image originale">
<?php else: ?>
<div class="galleryGalleryName">
<?php endif;
if (!empty($legend)):
echo $legend;
// nettoyage et affichage du nom des images
else:
$separe = array('_','-','t1280');
$picname = str_replace($separe, ' ', $photo);
$picname = preg_replace('/(\.jpe?g|\.png|\.gif)$/i', '', $picname);
echo substr($picname,0,25);
endif;
?>
</div>
</a>
<?php
// ajout du marqueur aux images contenant des données exif gps
$data = (isset($get_location)) ? $get_location : NULL;
$lis = explode('¤',$data);
if ( ! isset($lis[1])) { $lis[1] = null; }
else {
$altitude = '';
if ((isset($lis[2])) && ($lis[2] > 0)) {
$alt = $lis[2];
}
?>
<div class="osm"><a href="<?=helper::baseUrl(false)?>module/gallery/vendor/map.php?lat=<?=$lis[0]?>&lon=<?=$lis[1]?>&alt=<?=$lis[2]?>&zoom=15" rel="data-lity" title="Géolocalisation"><img src="<?=helper::baseUrl(false)?>module/gallery/vendor/leaflet/images/marker-icon.png" style="width: 20px; height: auto;" alt="GPS"></a></div>
<?php } ?>
</div>
<?php if($i % 6 === 0 OR $i === $picturesNb): ?>
</div>
<?php
endif;
$i++;
endforeach;
?>

53
module/gallery/view/index/index.css

@ -1,24 +1,45 @@
.col4 {
padding: 5px;
}
.galleryPicture {
display: block;
border: 1px solid #DDD;
height: 200px;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
display: flex;
align-items: center;
justify-content: center;
position: relative;
-webkit-transition: opacity .3s ease-out;
transition: opacity .3s ease-out;
}
.galleryPicture:hover {
opacity: .7;
height: 200px;
text-align: center;
background-color: rgba(230, 230, 230, 0.7);
border: 1px solid #DDD;
border-radius: 6px;
}
.galleryName {
position: absolute;
left: 0;
right: 0;
bottom: 0;
padding: 10px;
background: rgba(0, 0, 0, .6);
color: #FFF;
text-align: center;
}
line-height: 1.5;
color: #000;
}
.galleryPicture img {
max-height: 80%;
max-width: 95%;
}
.galleryPicture img:hover {
z-index: 2;
}
/* !important obligatoire */
@media (max-width: 1281px) {
.galleryPicture {
height: 320px !important;
}
}
@media (max-width: 1025px) {
.galleryPicture {
height: 260px !important;
}
}
@media (max-width: 961px) {
.galleryPicture {
height: 200px !important;
}
}

54
module/gallery/view/index/index.php

@ -1,30 +1,24 @@
<?php if($module::$galleries): ?>
<?php $i = 1; ?>
<?php $galleriesNb = count($module::$galleries); ?>
<?php foreach($module::$galleries as $galleryId => $gallery): ?>
<?php if($i % 2 === 1): ?>
<div class="row">
<?php endif; ?>
<div class="col6">
<a
href="<?php echo helper::baseUrl() . $th