Line 46... |
Line 46... |
46 |
|
46 |
|
Line 47... |
Line 47... |
47 |
$this->definirValeurParDefautDesParametres();
|
47 |
$this->definirValeurParDefautDesParametres();
|
48 |
|
48 |
|
49 |
$this->format = (isset($this->parametres['retour.format']) && $this->parametres['retour.format'] != '') ? $this->parametres['retour.format'] : $this->format;
|
- |
|
50 |
$this->retour_mime = (isset($this->parametres['retour']) && $this->parametres['retour'] != '') ? $this->parametres['retour'] : $this->retour_mime;
|
- |
|
51 |
// TODO: décommenter lors de la mise en prod
|
- |
|
52 |
//$photographies = $this->obtenirImages();
|
49 |
$this->format = (isset($this->parametres['retour.format']) && $this->parametres['retour.format'] != '') ? $this->parametres['retour.format'] : $this->format;
|
- |
|
50 |
$this->retour_mime = (isset($this->parametres['retour']) && $this->parametres['retour'] != '') ? $this->parametres['retour'] : $this->retour_mime;
|
- |
|
51 |
$photographies = $this->getResultatTest();
|
53 |
//TODO commenter lors de la mise en prod
|
52 |
if($this->retour_mime == self::MIME_JPEG) {
|
54 |
$photographies = $this->getResultatTest();
|
53 |
$photo = $this->obtenirPremiereImage();
|
55 |
$this->nbreImages = count($photographies);
|
54 |
$retour = $this->formaterRetourImageBinaire($photo);
|
- |
|
55 |
echo $retour;
|
- |
|
56 |
} elseif($this->retour_mime == self::MIME_JSON) {
|
56 |
|
57 |
$photographies = $this->obtenirImages();
|
57 |
if($this->retour_mime == self::MIME_JSON) {
|
58 |
$this->nbreImages = count($photographies);
|
58 |
$photographies_formatees = $this->formaterRetourJson($photographies);
|
59 |
$photographies_formatees = $this->formaterRetourJson($photographies);
|
59 |
$resultat = $photographies_formatees;
|
60 |
$resultat = $photographies_formatees;
|
60 |
$entete = $this->construireEntete();
|
61 |
$entete = $this->construireEntete();
|
- |
|
62 |
return array('entete' => $entete, 'resultats' => $resultat);
|
- |
|
63 |
} elseif ($this->retour_mime == self::MIME_XML) {
|
61 |
return array('entete' => $entete, 'resultats' => $resultat);
|
64 |
$photographies = $this->obtenirImages();
|
62 |
} elseif ($this->retour_mime == self::MIME_XML) {
|
65 |
$this->nbreImages = count($photographies);
|
63 |
$photographies_formatees = $this->formaterRetourXml($photographies);
|
66 |
$photographies_formatees = $this->formaterRetourXml($photographies);
|
64 |
header('Content-Type: '.self::MIME_XML);
|
67 |
header('Content-Type: '.self::MIME_XML);
|
65 |
echo $photographies_formatees;
|
68 |
echo $photographies_formatees;
|
Line 103... |
Line 106... |
103 |
}
|
106 |
}
|
104 |
if (isset($this->parametres['navigation.limite']) == false) {
|
107 |
if (isset($this->parametres['navigation.limite']) == false) {
|
105 |
$this->parametres['navigation.limite'] = 100;
|
108 |
$this->parametres['navigation.limite'] = 100;
|
106 |
}
|
109 |
}
|
107 |
}
|
110 |
}
|
- |
|
111 |
|
- |
|
112 |
public function obtenirPremiereImage() {
|
- |
|
113 |
$this->parametres['navigation.depart'] = 0;
|
- |
|
114 |
$this->parametres['navigation.limite'] = 1;
|
- |
|
115 |
$images = $this->obtenirImages();
|
- |
|
116 |
if (!is_array($images) || count($images) <= 0) {
|
- |
|
117 |
$message = "Aucune image ne correspond au numéro numenclatural $refTax:$numNom";
|
- |
|
118 |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
|
- |
|
119 |
throw new Exception($message, $code);
|
- |
|
120 |
} else {
|
- |
|
121 |
return $images[0];
|
- |
|
122 |
}
|
- |
|
123 |
}
|
Line 108... |
Line 124... |
108 |
|
124 |
|
- |
|
125 |
public function obtenirImages() {
|
- |
|
126 |
//TODO: tri par date, mais les dates dans la bdd photoflora sont des chaines en entités HTML
|
109 |
public function obtenirImages() {
|
127 |
// donc un tri dessus n'a pas de sens
|
110 |
$requete = 'SELECT photos.*,taxons.NumTaxon, taxons.NumNomen, taxons.Combinaison, photographes.Nom, photographes.Prenom, photographes.Initiales, photographes.Mail '.
|
128 |
$requete = 'SELECT photos.*,taxons.NumTaxon, taxons.NumNomen, taxons.Combinaison, photographes.Nom, photographes.Prenom, photographes.Initiales, photographes.Mail '.
|
111 |
'FROM '.self::BDD_PF.'.photos, '.self::BDD_PF.'.photographes, '.self::BDD_PF.'.taxons '.
|
129 |
'FROM '.self::BDD_PF.'.photos, '.self::BDD_PF.'.photographes, '.self::BDD_PF.'.taxons '.
|
112 |
'WHERE '.
|
130 |
'WHERE '.
|
113 |
'photos.Auteur = photographes.ID '.
|
131 |
'photos.Auteur = photographes.ID '.
|
Line 146... |
Line 164... |
146 |
'Mail LIKE '.$auteur_like.') ';
|
164 |
'Mail LIKE '.$auteur_like.') ';
|
147 |
}
|
165 |
}
|
148 |
return $requete_auteur;
|
166 |
return $requete_auteur;
|
149 |
}
|
167 |
}
|
Line -... |
Line 168... |
- |
|
168 |
|
- |
|
169 |
private function formaterRetourImageBinaire($photo) {
|
- |
|
170 |
$image = '';
|
- |
|
171 |
$chemin = $url = $this->getUrlPhotoPourInitiales($photo['Initiales'], $photo['NumPhoto'], $this->format);
|
- |
|
172 |
$image = file_get_contents($chemin);
|
- |
|
173 |
if ($image === false) {
|
- |
|
174 |
$message = "L'image demandée est introuvable sur le serveur : $chemin";
|
- |
|
175 |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
|
- |
|
176 |
throw new Exception($message, $code);
|
- |
|
177 |
}
|
- |
|
178 |
return $image;
|
- |
|
179 |
}
|
150 |
|
180 |
|
151 |
private function formaterRetourJson($photographies) {
|
181 |
private function formaterRetourJson($photographies) {
|
152 |
$resultat = array();
|
182 |
$resultat = array();
|
153 |
if(is_array($photographies)) {
|
183 |
if(is_array($photographies)) {
|