22-03-2022

This commit is contained in:
2022-03-22 19:28:28 +01:00
parent 0a3eb3d379
commit 414346b7f1
10 changed files with 1440 additions and 39 deletions

215
photo-du-mois-ng.php Normal file
View File

@@ -0,0 +1,215 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="css/sls.css">
<script src='https://code.jquery.com/jquery-3.2.1.min.js' type='text/javascript'></script>
<!-- nanogallery2 -->
<link href="https://cdn.jsdelivr.net/npm/nanogallery2@3/dist/css/nanogallery2.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/nanogallery2@3/dist/jquery.nanogallery2.min.js"></script>
<?php include 'functions.php'; ?>
</head>
<body>
<h1 class="_h1"><?php echo gettext("Photo du mois"); ?></h1>
<?php
if (!isset($_GET['page'])) $page = 1;
// sinon on recupere la valeur numerique reçue en paramètre
else $page = intval($_GET['page']);
?>
<?php
try {
$conn4 = new PDO('sqlite:db_photo.sqlite3');
$query4 = "SELECT filename, date, lens, exposure, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, titre, createur, keywords FROM photos ORDER BY date DESC LIMIT ? OFFSET ?";
//nb d'archive par page
$limit = 13;
$offset = $limit * ($page -1);
//echo "offset: " . $offset;
$stmt = $conn4->prepare($query4);
$stmt->execute(array($limit, $offset));
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$rowcount = count($result);
$conn4 = null;
}
catch(PDOException $e) {
echo $e->getMessage();
}
$photo_du_mois = $result[0];
$z = $photo_du_mois['date'];
$photo_du_mois['titre'] = "Titre";
$photo_du_mois['legende'] = "Légende";
?>
<p class="month"><?php echo month($z); ?></p>
<?php
//_pr($photo_du_mois);
echo '<div class="cadre">';
echo '<img src="' . $photo_du_mois['filename'] . '" class="trois" />';
echo '</div>';
if (!empty($photo_du_mois['titre']) || !empty($photo_du_mois['legende'])) {
?>
<p class="titrePhoto"><?php echo $photo_du_mois['titre']; ?></p>
<p class="legendePhoto"><?php echo $photo_du_mois['legende']; ?></p>
<?php }
echo '<div class="exif">';
echo $photo_du_mois['model'] . " \u{30FB} " . $photo_du_mois['lens'] . " \u{30FB} ";
echo $photo_du_mois['exposure'] . " \u{30FB} " . $photo_du_mois['aperture'] . " \u{30FB} " . $photo_du_mois['iso'] . " ISO";
echo '</div>';
?>
<!--div class="myGallery" id="lcl_elems_wrapper"-->
<div class="myGallery" id="nanogallery2" data-nanogallery2 = '{
"thumbnailHeight": 300,
"thumbnailWidth": 300,
"itemsBaseURL": "https://airbook.local/sls/"
}' >
<?php
/**/
for ($i = 1; $i <= ($rowcount -1); $i++) {
$file = $result[$i]['filename'];
$date = $result[$i]['date'];
$objectif = $result[$i]['lens'];
$exposure = $result[$i]['exposure'];
$iso = $result[$i]['iso'];
$width = $result[$i]['width'];
$height = $result[$i]['height'];
$html = $result[$i]['html'];
$aperture = $result[$i]['aperture'];
$model = $result[$i]['model'];
$lat = $result[$i]['lat'];
$long = $result[$i]['long'];
$alt = $result[$i]['alt'];
$legende = $result[$i]['legende'];
$copy = $result[$i]['copyright'];
$titre = $result[$i]['titre'];
$createur = $result[$i]['createur'];
$keywords = $result[$i]['keywords'];
//$keywords = str_replace(',', ' - ', $keywords);
$keywords = "\u{1F3F7} " . str_replace(',', " \u{30FB} ", $keywords);
if (!empty($titre)) {
$x = $titre;
$y = $legende;
}
elseif (!empty($legende)) {
$x = $legende;
}
else {
$x = basename($file);
$y = "";
}
$exif = $model . " \u{30FB} " . $objectif . " \u{30FB} " . $exposure . " \u{30FB} " . $aperture . " \u{30FB} " . $iso ;
// $x = $x . "\r\n" . $exif;
$thumb = str_replace("photos/img", "photos/thumb", $file);
echo '<div class="item">';
//echo '<a href ="' . $file . '" data-lg-size="' . $width . '">';
echo '<a href ="' . $file . '">';
echo '<img src="' . $thumb . '" alt="' . $x . '" />';
//echo "bla";
echo "</a>";
//echo '<span class="caption">' . month($date) . '</span>';
echo '</div>';
}
/*
$rowcount = 5 - 10 - 15 => add 0
$rowcount = 4 - 9 - 14 => add 1
$rowcount = 3 - 8 - 13 => add 2
$rowcount = 2 - 7 - 12 => add 3
$rowcount = 1 - 6 - 11 => add 4
*/
if ($rowcount % 4 == 0) $blank = 1;
elseif ($rowcount % 3 == 0) $blank = 2;
elseif ($rowcount % 2 == 0) $blank = 3;
elseif ($rowcount % 1 == 0) $blank = 4;
for ($i = 1; $i <= $blank; $i++) {
echo '<div class="item">';
echo '</div>';
}
?>
</div>
<?php
try {
$conn4 = new PDO('sqlite:db_photo.sqlite3');
$query4 = "SELECT COUNT(*) AS count FROM photos";
$stmt = $conn4->prepare($query4);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$numRows = $result['count'];
$conn4 = null;
}
catch(PDOException $e) {
echo $e->getMessage();
}
// calcul du nombre de pages (arrondi a l'entier supérieur)
$nbpages = ceil($numRows / 12);
$prec = $page - 1;
$suiv = $page + 1;
echo '<div class="navPage">' . gettext("Page: ");
if ($page >= 2) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$prec.'" title="'.gettext("Previous Page").'">&laquo; '.gettext("prev").'</a>&nbsp;';
for ($i = 1; $i <= $nbpages; $i++) {
if ($i != $page) {
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$i.'" title="'.gettext("Page").' '.$i.'">'.$i.' </a>&nbsp;';
}
else {
echo "<span class='gras'>".$i."</span>&nbsp;&nbsp;";
}
}
if ($page < $nbpages) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$suiv.'" title="'.gettext("Next Page").'">'.gettext("next").' &raquo;</a>&nbsp;';
echo '</div>';
?>
<p><em><small>@ 2022</small></em></p>
</body>
</html>