Line 27... |
Line 27... |
27 |
const MIME_JSON = 'application/json';
|
27 |
const MIME_JSON = 'application/json';
|
Line 28... |
Line 28... |
28 |
|
28 |
|
29 |
private $config = array();
|
29 |
private $config = array();
|
30 |
private $cheminImagesBase = '';
|
30 |
private $cheminImagesBase = '';
|
- |
|
31 |
private $formats_supportes = array(self::MIME_JPEG, self::MIME_JSON);
|
31 |
private $formats_supportes = array(self::MIME_JPEG, self::MIME_JSON);
|
32 |
private $tris_supportes = array('date');
|
32 |
private $ref_tax_demande = array();
|
33 |
private $ref_tax_demande = array();
|
33 |
private $infosImages = array();
|
34 |
private $infosImages = array();
|
34 |
private $nbreImages = 0;
|
35 |
private $nbreImages = 0;
|
35 |
private $Utilisateurs = null;
|
36 |
private $Utilisateurs = null;
|
Line 53... |
Line 54... |
53 |
$this->verifierParametres();
|
54 |
$this->verifierParametres();
|
54 |
$this->analyserMasqueNn();
|
55 |
$this->analyserMasqueNn();
|
Line 55... |
Line 56... |
55 |
|
56 |
|
56 |
$resultat = new ResultatService();
|
57 |
$resultat = new ResultatService();
|
- |
|
58 |
if ($this->parametres['retour'] == self::MIME_JPEG) {
|
- |
|
59 |
if ($this->parametres['retour.tri'] == 'date') {
|
- |
|
60 |
$id_image_a_renvoyer = $this->obtenirIdPremiereImage();
|
57 |
if ($this->parametres['retour'] == self::MIME_JPEG) {
|
61 |
} else {
|
- |
|
62 |
$id_image_a_renvoyer = $this->obtenirIdImageAuHasard();
|
58 |
$id_image_a_renvoyer = $this->obtenirIdImageAuHasard();
|
63 |
}
|
59 |
$resultat->corps = $this->recupererImageBinaire($id_image_a_renvoyer);
|
64 |
$resultat->corps = $this->recupererImageBinaire($id_image_a_renvoyer);
|
60 |
} else if ($this->parametres['retour'] == self::MIME_JSON) {
|
65 |
} else if ($this->parametres['retour'] == self::MIME_JSON) {
|
61 |
$this->chargerListeImages();
|
66 |
$this->chargerListeImages();
|
62 |
$this->chargerNbreImagesTotal();
|
67 |
$this->chargerNbreImagesTotal();
|
Line 106... |
Line 111... |
106 |
$erreurs[] = "Le paramètre de format de retour 'retour.format' est obligatoire.";
|
111 |
$erreurs[] = "Le paramètre de format de retour 'retour.format' est obligatoire.";
|
107 |
}
|
112 |
}
|
108 |
if ($this->verifierValeurParametreFormat() == false) {
|
113 |
if ($this->verifierValeurParametreFormat() == false) {
|
109 |
$erreurs[] = "Le type de format '{$this->parametres['retour.format']}' n'est pas supporté";
|
114 |
$erreurs[] = "Le type de format '{$this->parametres['retour.format']}' n'est pas supporté";
|
110 |
}
|
115 |
}
|
- |
|
116 |
if (isset($this->parametres['retour.tri'])){
|
- |
|
117 |
if ($this->verifierValeurParametreTri() == false) {
|
- |
|
118 |
$erreurs[] = "Le type de tri '{$this->parametres['retour.tri']}' n'est pas supporté";
|
- |
|
119 |
}
|
- |
|
120 |
}
|
111 |
if ($this->verifierValeurParametreNavigationDepart() == false) {
|
121 |
if ($this->verifierValeurParametreNavigationDepart() == false) {
|
112 |
$erreurs[] = "Le paramètre 'navigation.depart' doit possèder un valeur numérique.";
|
122 |
$erreurs[] = "Le paramètre 'navigation.depart' doit possèder un valeur numérique.";
|
113 |
}
|
123 |
}
|
114 |
if ($this->verifierValeurParametreNavigationLimite() == false) {
|
124 |
if ($this->verifierValeurParametreNavigationLimite() == false) {
|
115 |
$erreurs[] = "Le paramètre 'navigation.limite' doit possèder un valeur numérique supérieure à 0.";
|
125 |
$erreurs[] = "Le paramètre 'navigation.limite' doit possèder un valeur numérique supérieure à 0.";
|
Line 148... |
Line 158... |
148 |
private function verifierValeurParametreFormat() {
|
158 |
private function verifierValeurParametreFormat() {
|
149 |
$formats = Outils::recupererTableauConfig('Images.formats');
|
159 |
$formats = Outils::recupererTableauConfig('Images.formats');
|
150 |
$ok = array_key_exists($this->parametres['retour.format'], $formats);
|
160 |
$ok = array_key_exists($this->parametres['retour.format'], $formats);
|
151 |
return $ok;
|
161 |
return $ok;
|
152 |
}
|
162 |
}
|
- |
|
163 |
|
- |
|
164 |
private function verifierValeurParametreTri() {
|
- |
|
165 |
return in_array($this->parametres['retour.tri'], $this->tris_supportes);
|
- |
|
166 |
}
|
Line 153... |
Line 167... |
153 |
|
167 |
|
154 |
private function verifierValeurParametreNavigationDepart() {
|
168 |
private function verifierValeurParametreNavigationDepart() {
|
155 |
$depart = $this->parametres['navigation.depart'];
|
169 |
$depart = $this->parametres['navigation.depart'];
|
156 |
$ok = is_numeric($depart) ? true : false;
|
170 |
$ok = is_numeric($depart) ? true : false;
|
Line 189... |
Line 203... |
189 |
$requete = 'SELECT coi.coi_ce_image AS id_image '.
|
203 |
$requete = 'SELECT coi.coi_ce_image AS id_image '.
|
190 |
'FROM cel_obs_images AS coi '.
|
204 |
'FROM cel_obs_images AS coi '.
|
191 |
' LEFT JOIN cel_inventory AS ci '.
|
205 |
' LEFT JOIN cel_inventory AS ci '.
|
192 |
'ON (coi.coi_ce_observation = ci.ordre AND coi.coi_ce_utilisateur = ci.identifiant) '.
|
206 |
'ON (coi.coi_ce_observation = ci.ordre AND coi.coi_ce_utilisateur = ci.identifiant) '.
|
193 |
'WHERE ci.transmission = 1 '.
|
207 |
'WHERE ci.transmission = 1 '.
|
194 |
" AND ci.num_nom_ret IN ($numNom) ";
|
208 |
" AND ci.num_nom_ret IN ($numNom)";
|
Line 195... |
Line 209... |
195 |
|
209 |
|
Line 196... |
Line 210... |
196 |
$resultat = $this->Bdd->recupererTous($requete);
|
210 |
$resultat = $this->Bdd->recupererTous($requete);
|
197 |
|
211 |
|
Line 202... |
Line 216... |
202 |
}
|
216 |
}
|
Line 203... |
Line 217... |
203 |
|
217 |
|
204 |
$id_image_hasard = $resultat[array_rand($resultat)]['id_image'];
|
218 |
$id_image_hasard = $resultat[array_rand($resultat)]['id_image'];
|
205 |
return $id_image_hasard;
|
219 |
return $id_image_hasard;
|
- |
|
220 |
}
|
- |
|
221 |
|
- |
|
222 |
private function obtenirIdPremiereImage() {
|
- |
|
223 |
$refTax = self::CODE_REFTAX_DEFAUT;
|
- |
|
224 |
$numNom = $this->Bdd->proteger($this->ref_tax_demande[$refTax][0]);
|
- |
|
225 |
$requete = 'SELECT ci.ci_id_image AS id_image '.
|
- |
|
226 |
'FROM cel_images AS ci'.
|
- |
|
227 |
' LEFT JOIN cel_obs_images AS coi '.
|
- |
|
228 |
' ON (coi.coi_ce_image = ci.ci_id_image) '.
|
- |
|
229 |
' LEFT JOIN cel_inventory AS co '.
|
- |
|
230 |
' ON (coi.coi_ce_observation = co.ordre AND coi.coi_ce_utilisateur = co.identifiant) '.
|
- |
|
231 |
'WHERE co.transmission = 1 '.
|
- |
|
232 |
" AND co.num_nom_ret IN ($numNom) ".
|
- |
|
233 |
' AND ci.ci_meta_date != "0000-00-00" ORDER BY ci.ci_meta_date ASC';
|
- |
|
234 |
|
- |
|
235 |
$resultat = $this->Bdd->recupererTous($requete);
|
- |
|
236 |
|
- |
|
237 |
if (!is_array($resultat) || count($resultat) <= 0) {
|
- |
|
238 |
$message = "Aucune image ne correspond au numéro numenclatural $refTax:$numNom";
|
- |
|
239 |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
|
- |
|
240 |
throw new Exception($message, $code);
|
- |
|
241 |
}
|
- |
|
242 |
|
- |
|
243 |
$id_image_hasard = $resultat[0]['id_image'];
|
- |
|
244 |
return $id_image_hasard;
|
Line 206... |
Line 245... |
206 |
}
|
245 |
}
|
207 |
|
246 |
|
208 |
private function recupererImageBinaire($id_image) {
|
247 |
private function recupererImageBinaire($id_image) {
|
209 |
$image = '';
|
248 |
$image = '';
|