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 2009 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 PlantNetRss extends DBAccessor {
|
|
|
15 |
|
|
|
16 |
var $config;
|
|
|
17 |
|
|
|
18 |
function PlantNetRss($config) {
|
|
|
19 |
|
|
|
20 |
$this->config=$config;
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
function getElement($uid){
|
|
|
24 |
|
|
|
25 |
$rss = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n";
|
|
|
26 |
$rss .= "<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
|
|
|
27 |
$rss .='
|
|
|
28 |
<channel>
|
|
|
29 |
<title>Carnet en ligne</title>
|
|
|
30 |
<link>http://www.tela-botanica.org/cel/jrest/ImageRss</link>
|
|
|
31 |
<description>Carnet en ligne</description>
|
|
|
32 |
<language>fr</language>';
|
|
|
33 |
|
|
|
34 |
$DB=$this->connectDB($this->config,'cel_db');
|
|
|
35 |
$motcle = 'plantnet';
|
|
|
36 |
$query_id_id_img = 'SELECT cmc_id_mot_cle_utilisateur, cmc_id_proprietaire FROM cel_mots_cles_images WHERE cmc_id_mot_cle_general = md5("'.$motcle.'")' ;
|
|
|
37 |
|
|
|
38 |
$res =& $DB->query($query_id_id_img);
|
|
|
39 |
|
|
|
40 |
if (DB::isError($res)) {
|
|
|
41 |
|
|
|
42 |
die($res->getMessage());
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
$query='SELECT * FROM cel_images';
|
|
|
46 |
|
|
|
47 |
$premier_item = true ;
|
|
|
48 |
while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
|
|
|
49 |
|
|
|
50 |
if($premier_item) {
|
|
|
51 |
$query .= ' WHERE ';
|
|
|
52 |
$premier_item = false ;
|
|
|
53 |
}
|
|
|
54 |
else{
|
|
|
55 |
$query .= ' OR ';
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
$query .= '(ci_meta_mots_cles LIKE "%'.$row['cmc_id_mot_cle_utilisateur'].'%" AND ci_ce_utilisateur ="'.$row['cmc_id_proprietaire'].'")' ;
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
$query .= ' ORDER BY ci_meta_date_ajout DESC LIMIT 0,100' ;
|
|
|
62 |
|
|
|
63 |
$res =& $DB->query($query);
|
|
|
64 |
|
|
|
65 |
if (DB::isError($res)) {
|
|
|
66 |
die($res->getMessage());
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
|
|
|
70 |
$row['ci_nom_original'] = htmlspecialchars($row['ci_nom_original']);
|
|
|
71 |
$row['ci_id_image'] = htmlspecialchars($row['ci_id_image']);
|
|
|
72 |
$row['ci_meta_date_ajout'] = htmlspecialchars($row['ci_meta_date_ajout']);
|
|
|
73 |
$row['ci_ce_utilisateur'] = htmlspecialchars($row['ci_ce_utilisateur']);
|
|
|
74 |
$row['ci_meta_user_comment'] = htmlspecialchars($row['ci_meta_user_comment']);
|
|
|
75 |
$row['ci_note_image'] = htmlspecialchars($row['ci_note_image']);
|
|
|
76 |
$tailleXY = $this->calculerDimensions(array($row['ci_meta_width'], $row['ci_meta_height']));
|
|
|
77 |
|
|
|
78 |
$id = $row['ci_id_image'];
|
|
|
79 |
$chemin_sur_serveur = $this->config['cel_db']['url_images'];
|
|
|
80 |
|
|
|
81 |
$req_liaison = 'SELECT * FROM cel_inventory WHERE ordre IN (SELECT coi_ce_observation FROM cel_obs_images WHERE coi_ce_image = "'.$row['ci_id_image'].'") AND identifiant = "'.$row['ci_ce_utilisateur'].'"' ;
|
|
|
82 |
$res_liaison =& $DB->query($req_liaison);
|
|
|
83 |
|
|
|
84 |
if (DB::isError($res_liaison)) {
|
|
|
85 |
die($res_liaison->getMessage());
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
if (DB::isError($res_liaison)) {
|
|
|
89 |
die($res_liaison->getMessage());
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
$id = sprintf('%09s', $id) ;
|
|
|
93 |
$id = wordwrap($id, 3 , '_', true) ;
|
|
|
94 |
|
|
|
95 |
$id_fichier = $id.".jpg" ;
|
|
|
96 |
|
|
|
97 |
$niveauDossier = split("_", $id) ;
|
|
|
98 |
|
|
|
99 |
$dossierNiveau1 = $niveauDossier[0] ;
|
|
|
100 |
$dossierNiveau2 = $niveauDossier[1] ;
|
|
|
101 |
|
|
|
102 |
$chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
|
|
|
103 |
|
|
|
104 |
$chemin_fichier = $chemin_sur_serveur_final.'/L/'.$id."_L.jpg" ;
|
|
|
105 |
$chemin_fichier_m = $chemin_sur_serveur_final.'/M/'.$id."_M.jpg" ;
|
|
|
106 |
|
|
|
107 |
$rss.= ' <item>
|
|
|
108 |
<title>'.$row['ci_nom_original']." (".$row['ci_id_image'].") ". ' par ' . $row['ci_ce_utilisateur'].'</title>
|
|
|
109 |
<author>'.$row['ci_ce_utilisateur'].'</author>
|
|
|
110 |
<link>'.$chemin_fichier.'</link>
|
|
|
111 |
<guid>'.$chemin_fichier.'</guid>
|
|
|
112 |
<description>'.
|
|
|
113 |
' <![CDATA[<img src="'.$chemin_fichier_m.'" alt="'.$row['ci_nom_original'].'" height="'.$tailleXY[1].'px" width="'.$tailleXY[0].'px"></img><br/>'.
|
|
|
114 |
$row['ci_nom_original']. ' modifiée le ' .$row['ci_meta_date_ajout'] . ' par ' . $row['ci_ce_utilisateur'].'<br/>' ;
|
|
|
115 |
|
|
|
116 |
if(trim($row['ci_meta_mots_cles']) != '') {
|
|
|
117 |
$row['ci_meta_mots_cles'] = rtrim($row['ci_meta_mots_cles'],',');
|
|
|
118 |
|
|
|
119 |
$mots_cles_chaine = '' ;
|
|
|
120 |
$mots_cles_tab = split(',',$row['ci_meta_mots_cles']);
|
|
|
121 |
foreach($mots_cles_tab as $item) {
|
|
|
122 |
$mots_cles_chaine .= '\''.$item.'\',';
|
|
|
123 |
}
|
|
|
124 |
$mots_cles_chaine = rtrim($mots_cles_chaine,',');
|
|
|
125 |
|
|
|
126 |
$req_mots_cles = 'SELECT cmc_mot_cle FROM cel_mots_cles_images WHERE cmc_id_mot_cle_utilisateur IN ('.$mots_cles_chaine.') AND cmc_id_proprietaire = "'.$row['ci_ce_utilisateur'].'"' ;
|
|
|
127 |
$res_mots_cles =& $DB->query($req_mots_cles);
|
|
|
128 |
|
|
|
129 |
if (DB::isError($res_mots_cles)) {
|
|
|
130 |
die($res_mots_cles->getMessage());
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
$mots_cles = '' ;
|
|
|
135 |
|
|
|
136 |
while($mot_cle = & $res_mots_cles->fetchrow(DB_FETCHMODE_ASSOC)) {
|
|
|
137 |
$mots_cles .= $mot_cle['cmc_mot_cle'].' , ' ;
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
$mots_cles = rtrim($mots_cles,', ');
|
|
|
141 |
|
|
|
142 |
if(trim($mots_cles) != '') {
|
|
|
143 |
// $rss .= 'Mot clés : '.mb_convert_encoding($mots_cles,'HTML-ENTITIES','UTF-8').' <br/>' ;
|
|
|
144 |
}
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
if(trim($row['ci_meta_comment']) != '') {
|
|
|
148 |
// $rss .= 'Commentaire : '.mb_convert_encoding($row['ci_meta_comment'],'HTML-ENTITIES','UTF-8').' <br/>';
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
/* while($ligne = & $res_liaison->fetchrow(DB_FETCHMODE_ASSOC)) {
|
|
|
152 |
$rss .= '<p> Liée à l\'observation '.$ligne['id'].'<br/>' ;
|
|
|
153 |
$rss .= 'Nom saisi : '.$ligne['nom_sel'].'<br/>' ;
|
|
|
154 |
$rss .= 'Nom retenu : '.$ligne['nom_ret'].'<br/>' ;
|
|
|
155 |
$rss .= 'Datée du '.$ligne['date_observation'].'<br/>' ;
|
|
|
156 |
$rss .= 'Lieu : '.trim($ligne['location'],'000null').' ('.trim($ligne['id_location'],'000null').') '.trim($ligne['station'],'000null').' '.trim($ligne['lieudit'],'000null').'<br/></p>' ;
|
|
|
157 |
}*/
|
|
|
158 |
$rss .= ']]>' ;
|
|
|
159 |
$rss .= '</description>
|
|
|
160 |
<dc:format>text/html</dc:format>
|
|
|
161 |
</item>';
|
|
|
162 |
}
|
|
|
163 |
|
|
|
164 |
$rss.= '</channel> </rss>';
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
header("Content-Type: text/xml; charset=UTF-8");
|
|
|
168 |
print $rss;
|
|
|
169 |
exit;
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
function getRessource(){
|
|
|
174 |
|
|
|
175 |
$uid[] = array() ;
|
|
|
176 |
$this->getElement($uid);
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
function calculerDimensions($tailleXY) {
|
|
|
180 |
|
|
|
181 |
$tailleOr = 300 ;
|
|
|
182 |
|
|
|
183 |
if($tailleXY[1] == 0) {
|
|
|
184 |
$tailleXY[1] = $tailleOr;
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
if($tailleXY[0] == 0) {
|
|
|
188 |
$tailleXY[0] = $tailleOr;
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
$maxTaille = max($tailleXY[1],$tailleXY[0]) ;
|
|
|
192 |
|
|
|
193 |
if($maxTaille == $tailleXY[1]) {
|
|
|
194 |
|
|
|
195 |
$rapport = $tailleXY[1]/$tailleXY[0] ;
|
|
|
196 |
$tailleXY[1] = 300 ;
|
|
|
197 |
$tailleXY[0] = round($tailleXY[1]/$rapport,0) ;
|
|
|
198 |
|
|
|
199 |
}else {
|
|
|
200 |
$rapport = $tailleXY[0]/$tailleXY[1] ;
|
|
|
201 |
$tailleXY[0] = 300 ;
|
|
|
202 |
$tailleXY[1] = round($tailleXY[0]/$rapport,0) ;
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
return $tailleXY ;
|
|
|
206 |
}
|
|
|
207 |
}
|
|
|
208 |
|
|
|
209 |
|
|
|
210 |
/* +--Fin du code ---------------------------------------------------------------------------------------+
|
|
|
211 |
* $Log$
|
|
|
212 |
* Revision 1.5 2008-11-13 11:29:12 ddelon
|
|
|
213 |
* Reecriture gwt-ext
|
|
|
214 |
*
|
|
|
215 |
* Revision 1.4 2007-06-06 13:31:16 ddelon
|
|
|
216 |
* v0.09
|
|
|
217 |
*
|
|
|
218 |
* Revision 1.3 2007-05-22 12:54:09 ddelon
|
|
|
219 |
* Securisation acces utilisateur
|
|
|
220 |
*
|
|
|
221 |
*
|
|
|
222 |
*
|
|
|
223 |
*/
|
|
|
224 |
|
|
|
225 |
?>
|