Skip to content

Commit 67ff962

Browse files
committed
#52 - Stocker la version utilisée d'Imagick pour la génération des miniatures
1 parent b6a5c52 commit 67ff962

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

classes/MiniatureObject.class.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class MiniatureObject extends RessourceObject implements RessourceInterface
3131
{
3232
private int $idImage;
3333
private bool $isPreview = false;
34+
private string $versionImagick;
3435

3536
/**
3637
* Constructeur
@@ -77,6 +78,7 @@ public function charger(string $value, string $fromField = RessourceObject::SEAR
7778
$this->setNomNouveau($resultat->new_name);
7879
$this->setIdImage($resultat->images_id);
7980
$this->setIsPreview($resultat->is_preview);
81+
$this->setVersionImagick($resultat->version_imagick);
8082

8183
// Reprise des informations de l'image maitresse
8284
$imageParente = new ImageObject();
@@ -102,7 +104,7 @@ public function charger(string $value, string $fromField = RessourceObject::SEAR
102104
public function sauver(): void
103105
{
104106
// J'enregistre les infos en BDD
105-
$req = MaBDD::getInstance()->prepare('UPDATE thumbnails SET images_id = :imagesId, is_preview = :isPreview, date_action = :dateCreation, new_name = :newName, size = :size, height = :height, width = :width, last_view = :lastView, nb_view_v4 = :nbViewV4, nb_view_v6 = :nbViewV6, md5 = :md5 WHERE id = :id');
107+
$req = MaBDD::getInstance()->prepare('UPDATE thumbnails SET images_id = :imagesId, is_preview = :isPreview, date_action = :dateCreation, new_name = :newName, size = :size, height = :height, width = :width, last_view = :lastView, nb_view_v4 = :nbViewV4, nb_view_v6 = :nbViewV6, md5 = :md5, version_imagick = :version_imagick WHERE id = :id');
106108

107109
$req->bindValue(':imagesId', $this->getIdImage(), PDO::PARAM_INT);
108110
$req->bindValue(':isPreview', $this->getIsPreview(), PDO::PARAM_INT);
@@ -116,6 +118,7 @@ public function sauver(): void
116118
$req->bindValue(':nbViewV6', $this->getNbViewIPv6(), PDO::PARAM_INT);
117119
$req->bindValue(':md5', $this->getMd5());
118120
$req->bindValue(':id', $this->getId(), PDO::PARAM_INT);
121+
$req->bindValue(':version_imagick', $this->getVersionImagick());
119122

120123
$req->execute();
121124
}
@@ -184,18 +187,21 @@ public function creer(): bool
184187
$this->setHauteur($imageInfo[1]);
185188
// Poids
186189
$this->setPoids(filesize($this->getPathMd5()));
190+
// Version d'Imagick
191+
$this->setVersionImagick(HelperSysteme::getImagickVersion());
187192

188193
/**
189194
* Création en BDD
190195
*/
191-
$req = MaBDD::getInstance()->prepare('INSERT INTO thumbnails (images_id, date_action, new_name, size, height, width, md5) VALUES (:imagesId, NOW(), :newName, :size, :height, :width, :md5)');
196+
$req = MaBDD::getInstance()->prepare('INSERT INTO thumbnails (images_id, date_action, new_name, size, height, width, md5, version_imagick) VALUES (:imagesId, NOW(), :newName, :size, :height, :width, :md5, :version_imagick)');
192197
$req->bindValue(':imagesId', $this->getIdImage(), PDO::PARAM_INT);
193198
// Date : NOW()
194199
$req->bindValue(':newName', $this->getNomNouveau());
195200
$req->bindValue(':size', $this->getPoids(), PDO::PARAM_INT);
196201
$req->bindValue(':height', $this->getHauteur(), PDO::PARAM_INT);
197202
$req->bindValue(':width', $this->getLargeur(), PDO::PARAM_INT);
198203
$req->bindValue(':md5', $this->getMd5());
204+
$req->bindValue(':version_imagick', $this->getVersionImagick());
199205

200206
if (!$req->execute()) {
201207
// Gestion de l'erreur d'insertion en BDD
@@ -245,4 +251,21 @@ public function setIsPreview(bool $isPreview): void
245251
{
246252
$this->isPreview = $isPreview;
247253
}
254+
255+
/**
256+
* @return string
257+
*/
258+
public function getVersionImagick(): string
259+
{
260+
return $this->versionImagick;
261+
}
262+
263+
/**
264+
* @param string $versionImagick
265+
* @return void
266+
*/
267+
public function setVersionImagick(string $versionImagick): void
268+
{
269+
$this->versionImagick = $versionImagick;
270+
}
248271
}

database.sql

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,19 @@ CREATE TABLE IF NOT EXISTS `possede`
113113

114114
CREATE TABLE IF NOT EXISTS `thumbnails`
115115
(
116-
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
117-
`images_id` int UNSIGNED NOT NULL,
118-
`is_preview` tinyint UNSIGNED NOT NULL,
119-
`date_action` datetime NOT NULL,
120-
`new_name` varchar(30) NOT NULL,
121-
`size` int UNSIGNED NOT NULL,
122-
`height` int UNSIGNED NOT NULL,
123-
`width` int UNSIGNED NOT NULL,
124-
`last_view` date NOT NULL,
125-
`nb_view_v4` int UNSIGNED NOT NULL,
126-
`nb_view_v6` int UNSIGNED NOT NULL,
127-
`md5` varchar(32) NOT NULL,
116+
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
117+
`images_id` int UNSIGNED NOT NULL,
118+
`is_preview` tinyint UNSIGNED NOT NULL,
119+
`date_action` datetime NOT NULL,
120+
`new_name` varchar(30) NOT NULL,
121+
`size` int UNSIGNED NOT NULL,
122+
`height` int UNSIGNED NOT NULL,
123+
`width` int UNSIGNED NOT NULL,
124+
`last_view` date NOT NULL,
125+
`nb_view_v4` int UNSIGNED NOT NULL,
126+
`nb_view_v6` int UNSIGNED NOT NULL,
127+
`md5` varchar(32) NOT NULL,
128+
`version_imagick` VARCHAR(255) NOT NULL,
128129
PRIMARY KEY (`id`),
129130
KEY `images_id` (`images_id`) USING BTREE,
130131
KEY `new_name` (`new_name`) USING BTREE,

0 commit comments

Comments
 (0)