Améliorations

This commit is contained in:
Fred Tempez 2024-08-08 11:33:55 +02:00
parent dfed3ecf11
commit 0fbf9ef188
3 changed files with 34 additions and 75 deletions

View File

@ -49,12 +49,8 @@ class geogallery extends common
'config' => self::GROUP_EDITOR, 'config' => self::GROUP_EDITOR,
'delete' => self::GROUP_EDITOR, 'delete' => self::GROUP_EDITOR,
'dirs' => self::GROUP_EDITOR, 'dirs' => self::GROUP_EDITOR,
'sortGalleries' => self::GROUP_EDITOR,
'sortPictures' => self::GROUP_EDITOR,
'edit' => self::GROUP_EDITOR, 'edit' => self::GROUP_EDITOR,
'add' => self::GROUP_EDITOR, 'add' => self::GROUP_EDITOR,
'theme' => self::GROUP_EDITOR,
'option' => self::GROUP_EDITOR,
'index' => self::GROUP_VISITOR 'index' => self::GROUP_VISITOR
]; ];
@ -66,7 +62,7 @@ class geogallery extends common
private function update() private function update()
{ {
$versionData = $this->getData(['module', $this->getUrl(0), 'config', 'versionData']); //$versionData = $this->getData(['module', $this->getUrl(0), 'config', 'versionData']);
} }
@ -322,15 +318,15 @@ class geogallery extends common
'value' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'legend', str_replace('.', '', $fileInfos->getFilename())]) 'value' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'legend', str_replace('.', '', $fileInfos->getFilename())])
]), ]),
/*template::text('gpslong[' . $fileInfos->getFilename() . ']', [ /*template::text('gpslong[' . $fileInfos->getFilename() . ']', [
'value' => $longitude, 'value' => $longitude,
'readonly' => true, 'readonly' => true,
]),*/ ]),*/
$longitude, $longitude,
/* template::text('gpslat[' . $fileInfos->getFilename() . ']', [ /* template::text('gpslat[' . $fileInfos->getFilename() . ']', [
'value' => $latitude, 'value' => $latitude,
'readonly' => true, 'readonly' => true,
]), ]),
*/$latitude, */ $latitude,
'<a href="' . str_replace('source', 'thumb', $directory) . '/' . self::THUMBS_SEPARATOR . $fileInfos->getFilename() . '" rel="data-lity" data-lity=""><img src="' . str_replace('source', 'thumb', $directory) . '/' . $fileInfos->getFilename() . '"></a>', '<a href="' . str_replace('source', 'thumb', $directory) . '/' . self::THUMBS_SEPARATOR . $fileInfos->getFilename() . '" rel="data-lity" data-lity=""><img src="' . str_replace('source', 'thumb', $directory) . '/' . $fileInfos->getFilename() . '"></a>',
]; ];
self::$picturesId[] = str_replace('.', '', $fileInfos->getFilename()); self::$picturesId[] = str_replace('.', '', $fileInfos->getFilename());
@ -360,7 +356,7 @@ class geogallery extends common
$directory = $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'config', 'directory']); $directory = $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'config', 'directory']);
if (is_dir($directory)) { if (is_dir($directory)) {
$iterator = new DirectoryIterator($directory); $iterator = new DirectoryIterator($directory);
foreach ($iterator as $fileInfos) { foreach ($iterator as $fileInfos) {
if ($fileInfos->isDot() === false and $fileInfos->isFile() and @getimagesize($fileInfos->getPathname())) { if ($fileInfos->isDot() === false and $fileInfos->isFile() and @getimagesize($fileInfos->getPathname())) {
@ -373,6 +369,7 @@ class geogallery extends common
self::THUMBS_WIDTH self::THUMBS_WIDTH
); );
} }
$exif = exif_read_data($fileInfos->getPath() . '/' . $fileInfos->getFilename()); $exif = exif_read_data($fileInfos->getPath() . '/' . $fileInfos->getFilename());
// Vérifier si les données EXIF contiennent des informations de géolocalisation // Vérifier si les données EXIF contiennent des informations de géolocalisation
@ -381,7 +378,7 @@ class geogallery extends common
self::$galleries[] = [ self::$galleries[] = [
'lat' => $this->gps_decimal($exif['GPSLatitude'], $exif['GPSLatitudeRef']), 'lat' => $this->gps_decimal($exif['GPSLatitude'], $exif['GPSLatitudeRef']),
'long' => $this->gps_decimal($exif['GPSLongitude'], $exif['GPSLatitudeRef']), 'long' => $this->gps_decimal($exif['GPSLongitude'], $exif['GPSLatitudeRef']),
'img'=> $fileInfos->getPath() . '/' . strtolower($fileInfos->getFilename()), 'img' => $fileInfos->getPath() . '/' . strtolower($fileInfos->getFilename()),
'thumb' => str_replace('source', 'thumb', $fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()), 'thumb' => str_replace('source', 'thumb', $fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()),
'label' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'legend', str_replace('.', '', $fileInfos->getFilename())]) 'label' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'legend', str_replace('.', '', $fileInfos->getFilename())])
]; ];
@ -389,7 +386,7 @@ class geogallery extends common
self::$galleries[] = [ self::$galleries[] = [
'lat' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'position', 'directory', str_replace('.', '', $fileInfos->getFilename())]), 'lat' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'position', 'directory', str_replace('.', '', $fileInfos->getFilename())]),
'long' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'position', 'directory', str_replace('.', '', $fileInfos->getFilename())]), 'long' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'position', 'directory', str_replace('.', '', $fileInfos->getFilename())]),
'img'=> $fileInfos->getPath() . '/' . strtolower($fileInfos->getFilename()), 'img' => $fileInfos->getPath() . '/' . strtolower($fileInfos->getFilename()),
'thumb' => str_replace('source', 'thumb', $fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()), 'thumb' => str_replace('source', 'thumb', $fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()),
'label' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'legend', str_replace('.', '', $fileInfos->getFilename())]) 'label' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'legend', str_replace('.', '', $fileInfos->getFilename())])
]; ];
@ -416,16 +413,24 @@ class geogallery extends common
// Calculer la distance maximale au centre pour déterminer le niveau de zoom // Calculer la distance maximale au centre pour déterminer le niveau de zoom
$maxDistance = 0; $maxDistance = 0;
foreach (self::$galleries as $coordinate) { foreach (self::$galleries as $coordinate) {
$distance = $this->haversineGreatCircleDistance($centerLat, $centerLong, $coordinate["lat"], $coordinate["long"]); if (
if ($distance > $maxDistance) { is_numeric($centerLat)
$maxDistance = $distance; && is_numeric($centerLong)
&& $coordinate["lat"]
&& $coordinate["long"]
) {
$distance = $this->haversineGreatCircleDistance($centerLat, $centerLong, $coordinate["lat"], $coordinate["long"]);
if ($distance > $maxDistance) {
$maxDistance = $distance;
}
} }
} }
$zoomLevel = $this->getZoomLevel($maxDistance); $zoomLevel = $this->getZoomLevel($maxDistance);
self::$galleriesCenter = array( self::$galleriesCenter = array(
'lat' => $centerLat, 'lat' => $centerLat,
'long' => $centerLong, 'long' => $centerLong,
'zoom' => $zoomLevel 'zoom' => $zoomLevel
); );
@ -443,44 +448,6 @@ class geogallery extends common
} }
} }
/**
* Thème de la galerie
*/
public function theme()
{
// Soumission du formulaire
if (
$this->getUser('permission', __CLASS__, __FUNCTION__) === true &&
$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),
'theme',
[
]
]);
$success = true;
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl() . '/theme',
'notification' => $success ? 'Modifications enregistrées' : 'Modifications non enregistrées !',
'state' => $success
]);
}
// Valeurs en sortie
$this->addOutput([
'title' => helper::translate('Thème'),
'view' => 'theme',
'vendor' => [
'tinycolorpicker'
]
]);
}
// Fonction pour convertir les coordonnées GPS au format décimal // Fonction pour convertir les coordonnées GPS au format décimal
private function gps_decimal($coordinate, $hemisphere) private function gps_decimal($coordinate, $hemisphere)

View File

@ -13,22 +13,10 @@
*/ */
#map { #map {
height: 400px; height: 500px;
}
.lity-wrap {
width: auto !important;
height: auto !important;
max-width: 90%;
max-height: 90%;
display: flex;
align-items: center;
justify-content: center;
}
.lity-content img {
width: auto; width: auto;
max-width: 100%; }
height: auto; .leaflet-popup-content {
max-height: 100%; text-align: center;
font-weight: bold;
} }

View File

@ -35,5 +35,9 @@ const objOptions = JSON.parse(jsonOptions);
obj.forEach(function(location) { obj.forEach(function(location) {
var marker = L.marker([location.lat, location.long], {title: location.label}); var marker = L.marker([location.lat, location.long], {title: location.label});
marker.addTo(map); marker.addTo(map);
marker.bindPopup('<p>' + location.label + '</p><a href="' + location.img + '" data-lity><img src="' + location.thumb + '" alt="Thumbnail" class="thumbnail"></a>'); marker.bindPopup('<p>' + location.label + '</p><a href="' + location.img + '" data-lity><img src="' + location.thumb + '" alt="Thumbnail" class="thumbnail"></a>',{
minWidth: 150,
maxWidth: 150,
minHeight: 150
});
}); });