416 |
aurelien |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* PHP Version 5
|
|
|
4 |
*
|
|
|
5 |
* @category PHP
|
|
|
6 |
* @package jrest
|
|
|
7 |
* @author aurelien <aurelien@tela-botanica.org>
|
|
|
8 |
* @copyright 2010 Tela-Botanica
|
|
|
9 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
|
|
10 |
* @version SVN: <svn_id>
|
|
|
11 |
* @link /doc/jrest/
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
Class ImageContribution extends DBAccessor {
|
|
|
15 |
|
|
|
16 |
var $config;
|
|
|
17 |
|
|
|
18 |
function ImageContribution($config) {
|
|
|
19 |
|
|
|
20 |
$this->config=$config;
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
function getElement($uid){
|
|
|
24 |
|
|
|
25 |
$DB=$this->connectDB($this->config,'cel_db');
|
|
|
26 |
|
|
|
27 |
/* $query='SELECT * FROM cel_images';
|
|
|
28 |
$query .= ' WHERE ci_ce_utilisateur ="'.$uid[0].'"' ;
|
|
|
29 |
$query .= ' ORDER BY ci_meta_date_ajout DESC LIMIT 0,5' ;*/
|
|
|
30 |
|
|
|
31 |
$query = 'SELECT * FROM cel_inventory'.
|
|
|
32 |
' WHERE identifiant = "'.$uid[1].'"'.
|
|
|
33 |
' AND ordre IN (SELECT coi_ce_observation
|
|
|
34 |
FROM cel_obs_images
|
|
|
35 |
WHERE coi_ce_utilisateur ="'.$uid[1].'" )'.
|
|
|
36 |
' AND transmission = 1'.
|
|
|
37 |
' ORDER BY date_modification DESC LIMIT 0,5';
|
|
|
38 |
|
|
|
39 |
$res =& $DB->query($query);
|
|
|
40 |
|
|
|
41 |
if (DB::isError($res)) {
|
|
|
42 |
die($res->getMessage());
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
$html = '<div id="resume_cel">';
|
|
|
46 |
|
|
|
47 |
while ($obs =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
|
|
|
48 |
|
|
|
49 |
$chemin_sur_serveur = $this->config['cel_db']['url_images'];
|
|
|
50 |
|
|
|
51 |
$req_liaison = 'SELECT * FROM cel_images WHERE ci_id_image IN (SELECT coi_ce_image FROM cel_obs_images WHERE coi_ce_observation = "'.$obs['ordre'].'") AND ci_ce_utilisateur = "'.$obs['identifiant'].'"' ;
|
|
|
52 |
$res_liaison =& $DB->query($req_liaison);
|
|
|
53 |
|
|
|
54 |
if (DB::isError($res_liaison)) {
|
|
|
55 |
die($res_liaison->getMessage());
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
while ($img =& $res_liaison->fetchrow(DB_FETCHMODE_ASSOC)) {
|
|
|
59 |
$row = $img;
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
$row['ci_nom_original'] = htmlspecialchars($row['ci_nom_original']);
|
|
|
63 |
$row['ci_id_image'] = htmlspecialchars($row['ci_id_image']);
|
|
|
64 |
$id = $row['ci_id_image'];
|
|
|
65 |
|
|
|
66 |
$tailleXY = $this->calculerDimensions(array($row['ci_meta_width'], $row['ci_meta_height']));
|
|
|
67 |
|
|
|
68 |
$id = sprintf('%09s', $id) ;
|
|
|
69 |
$id = wordwrap($id, 3 , '_', true) ;
|
|
|
70 |
|
|
|
71 |
$id_fichier = $id.".jpg" ;
|
|
|
72 |
|
|
|
73 |
$niveauDossier = split("_", $id) ;
|
|
|
74 |
|
|
|
75 |
$dossierNiveau1 = $niveauDossier[0] ;
|
|
|
76 |
$dossierNiveau2 = $niveauDossier[1] ;
|
|
|
77 |
|
|
|
78 |
$chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
|
|
|
79 |
|
|
|
80 |
$chemin_fichier = $chemin_sur_serveur_final.'/L/'.$id."_L.jpg" ;
|
|
|
81 |
$chemin_fichier_s = $chemin_sur_serveur_final.'/M/'.$id."_M.jpg" ;
|
|
|
82 |
|
|
|
83 |
$html .= '<div class="item_resume_cel">';
|
|
|
84 |
|
|
|
85 |
$html .= '<h4><a href="'.$chemin_fichier.'">'.$obs['nom_ret'].'</a></h4>'.
|
|
|
86 |
'<img src="'.$chemin_fichier_s.'" alt="'.$row['ci_nom_original'].'" height="'.$tailleXY[1].'px" width="'.$tailleXY[0].'px"></img><br/>';
|
|
|
87 |
$html .= '<span>Datée du '.$obs['date_modification'].'<br/>' ;
|
|
|
88 |
$html .= 'Lieu : '.trim($obs['location'],'000null').' ('.trim($obs['id_location'],'000null').') '.trim($obs['station'],'000null').' '.trim($obs['lieudit'],'000null').'<br/></p>' ;
|
|
|
89 |
$html .= '</span>';
|
|
|
90 |
|
|
|
91 |
$html .= '</div>';
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
$html.= '</div>';
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
header("Content-Type: text/html; charset=UTF-8");
|
|
|
98 |
print $html;
|
|
|
99 |
exit;
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
public function calculerDimensions($tailleXY) {
|
|
|
103 |
|
|
|
104 |
$tailleOr = 75 ;
|
|
|
105 |
|
|
|
106 |
if($tailleXY[1] == 0) {
|
|
|
107 |
$tailleXY[1] = $tailleOr;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
if($tailleXY[0] == 0) {
|
|
|
111 |
$tailleXY[0] = $tailleOr;
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
$maxTaille = max($tailleXY[1],$tailleXY[0]) ;
|
|
|
115 |
|
|
|
116 |
if($maxTaille == $tailleXY[1]) {
|
|
|
117 |
|
|
|
118 |
$rapport = $tailleXY[1]/$tailleXY[0] ;
|
|
|
119 |
$tailleXY[1] = 75 ;
|
|
|
120 |
$tailleXY[0] = round($tailleXY[1]/$rapport,0) ;
|
|
|
121 |
|
|
|
122 |
}else {
|
|
|
123 |
$rapport = $tailleXY[0]/$tailleXY[1] ;
|
|
|
124 |
$tailleXY[0] = 75 ;
|
|
|
125 |
$tailleXY[1] = round($tailleXY[0]/$rapport,0) ;
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
return $tailleXY ;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
}
|
|
|
132 |
?>
|