-recherche des tags de l’image du mois (PDO)
-affichage des tags sous l’image, avec liens vers Zenphoto
This commit is contained in:
2019-01-06 11:06:25 +01:00
parent 8b6452fa28
commit 904e6ac59b
3 changed files with 76 additions and 24 deletions

View File

@@ -212,9 +212,6 @@ function imagesFromZPAlbum ($album, $connexion) {
/*
Ajouter: EXIFLensInfo
Array
(
[0] => Array
@@ -226,6 +223,7 @@ function imagesFromZPAlbum ($album, $connexion) {
[EXIFFNumber] => f/7,1
[EXIFISOSpeedRatings] => 500
[EXIFFocalLength] => 700 mm
[EXIFLensInfo] => EF500mm f/4L IS USM
[EXIFGPSLatitude] =>
[EXIFGPSLatitudeRef] =>
[EXIFGPSLongitude] =>
@@ -244,6 +242,68 @@ function imagesFromZPAlbum ($album, $connexion) {
return $fichier;
}
function ZPGetTag ($filename, $album, $connexion) {
$table = array();
$table['images'] = $connexion['zp_prefix'] . "images";
$table['albums'] = $connexion['zp_prefix'] . "albums";
$table['obj_to_tag'] = $connexion['zp_prefix'] . "obj_to_tag";
$table['tags'] = $connexion['zp_prefix'] . "tags";
$charset = 'utf8';
$host = $connexion['host'];
$dbname = $connexion['db_zenphoto'];
$dsn = "mysql:host=$host;dbname=$dbname;charset=$charset";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
$pdo = new PDO($dsn, $connexion['user'], $connexion['password'], $options);
} catch (\PDOException $e) {
throw new \PDOException($e->getMessage(), (int)$e->getCode());
}
// 1. id de l'image:
$query1 = "SELECT `id` FROM `" . $table['images'] . "` WHERE `filename` = ?";
$stmt = $pdo->prepare($query1);
$stmt->execute([$filename]);
//$fichier = $stmt->fetchAll(PDO::FETCH_ASSOC);
while ($row = $stmt->fetch()) {
//echo $row['id'] . "\n";
$id_image = $row['id'];
}
// 2. ids des tags de l'image:
$query2 = "SELECT `tagid` FROM `" . $table['obj_to_tag'] . "` WHERE `objectid` = ?";
$stmt = $pdo->prepare($query2);
$stmt->execute([$id_image]);
//$ids_tag = $stmt->fetchAll(PDO::FETCH_COLUMN);
while ($ids_tag = $stmt->fetch()) {
$query_tags .= " `id` = " . $ids_tag['tagid'] . " OR ";
}
// 3. Liste des tags correspondant aux ids:
$query_tags = substr($query_tags, 0, -4);;
$query3 = "SELECT `name` FROM `_tags` WHERE $query_tags";
$stmt = $pdo->prepare($query3);
$stmt->execute();
$tags = $stmt->fetchAll(PDO::FETCH_COLUMN);
return $tags;
}
/*
page-ce-mois-ci.php
*/

View File

@@ -211,22 +211,18 @@ Array
[gps] =>
)
*/
/*
$keyword = "";
if (isset($iptc['2#025'])) {
foreach ($iptc['2#025'] as $key => $val) {
$keyword .= '<a href="' . $host . '/zenphoto/index.php?p=search&amp;words=' . $val . '" title="Tag > ' . $val . '" rel="tag">' . $val . '</a>';
$keyword .= ', ';
//$title = $imgs['title'];
$mois = strtok($title = $imgs['title'], '_');
$keyword = ZPGetTag($filename, $album, $connexion);
if (isset($keyword)) {
foreach ($keyword as $val) {
$tag_cloud .= '<a href="' . $host . '/zenphoto/index.php?p=search&amp;words=' . strtolower($val) . '" title="Tag > ' . strtolower($val) . '" rel="tag">' . strtolower($val) . '</a>';
$tag_cloud .= ', ';
}
$keyword = substr($keyword, 0, -2);
}
$imgs['img_sd']['keyword'] = $keyword;
}
*/
$exifInfo = "";
$exifInfo = __('The','toppic-child') . " " .date(__("F j, Y, g:i a",'toppic-child'),strtotime($imgs['EXIFDateTimeOriginal'])).' - ';
$exifInfo .= $imgs['EXIFExposureTime'] . __(' at ','toppic-child') . $imgs['EXIFFNumber'] .' - ' . $imgs['EXIFISOSpeedRatings'] .' ISO - ' . __('Focal','toppic-child') .$imgs['EXIFFocalLength'];
@@ -248,7 +244,7 @@ Array
<div class="cadre">
<?php if (($imgs['title'] != "") || ($imgs['desc'] != "")) { ?>
<p class="titrePhoto"><?php echo $imgs['title']; ?></p>
<p class="titrePhoto"><?php echo mois2($mois); ?></p>
<p class="legendePhoto"><?php echo $imgs['desc']; ?></p>
<?php }
@@ -272,13 +268,10 @@ Array
</div><!-- /cadre -->
<?php if (($imgs['img_sd']['titre'] != "") || ($imgs['img_sd']['legende'] != "")) { ?>
<p class="titrePhoto"><?php echo $imgs['img_sd']['titre']; ?>Titre</p>
<p class="legendePhoto"><?php echo $imgs['img_sd']['legende']; ?>Légende</p>
<?php } ?>
<p class="exifs"><?php echo $imgs['exif']; ?></p>
<p class="tags"><?php echo _e("Tags: ",'toppic-child') . $tag_cloud; ?></p>
<!-- /image du mois -->
<?php } ?>

View File

@@ -83,11 +83,10 @@ div.modele {
border: 1px solid #ccc;
}
.exifs {
.exifs, .tags {
text-align: center;
color: #909090;
font-size: smaller;
margin-bottom: 3em;
margin-top: 1em;
}