diff --git a/functions.php b/functions.php index e5b59bc..dbf34e3 100755 --- a/functions.php +++ b/functions.php @@ -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 */ diff --git a/page-ce-mois-ci.php b/page-ce-mois-ci.php index 252a670..97de1b5 100755 --- a/page-ce-mois-ci.php +++ b/page-ce-mois-ci.php @@ -211,22 +211,18 @@ Array [gps] => ) */ - -/* - - $keyword = ""; - if (isset($iptc['2#025'])) { - foreach ($iptc['2#025'] as $key => $val) { - $keyword .= '' . $val . ''; - $keyword .= ', '; + //$title = $imgs['title']; + $mois = strtok($title = $imgs['title'], '_'); + + $keyword = ZPGetTag($filename, $album, $connexion); + + if (isset($keyword)) { + foreach ($keyword as $val) { + $tag_cloud .= '' . strtolower($val) . ''; + $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
Titre
-Légende
- - + + diff --git a/style.css b/style.css index 8b8ae25..8710d42 100755 --- a/style.css +++ b/style.css @@ -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; }