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 PlantNetRssParEspece 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/PlantnetRss</link>
|
|
|
31 |
<description>Derniers scans de feuilles</description>
|
|
|
32 |
<language>fr</language>';
|
|
|
33 |
|
|
|
34 |
$motcle = 'plantnet' ;
|
|
|
35 |
|
|
|
36 |
$DB=$this->connectDB($this->config,'cel_db');
|
|
|
37 |
|
|
|
38 |
$query_id_id_img = 'SELECT cmc_id_mot_cle_utilisateur, cmc_id_proprietaire FROM cel_mots_cles WHERE cmc_id_mot_cle_general = md5("'.$motcle.'")' ;
|
|
|
39 |
|
|
|
40 |
$res =& $DB->query($query_id_id_img);
|
|
|
41 |
|
|
|
42 |
if (DB::isError($res)) {
|
|
|
43 |
|
|
|
44 |
echo $res->getMessage();
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
$query='SELECT * FROM cel_images';
|
|
|
48 |
|
|
|
49 |
$premier_item = true ;
|
|
|
50 |
while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
|
|
|
51 |
|
|
|
52 |
if($premier_item) {
|
|
|
53 |
$query .= ' WHERE ';
|
|
|
54 |
$premier_item = false ;
|
|
|
55 |
}
|
|
|
56 |
else{
|
|
|
57 |
$query .= ' OR ';
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
$query .= '(ci_meta_mots_cles LIKE "%'.$row['cmc_id_mot_cle_utilisateur'].'%" AND ci_ce_utilisateur ="'.$row['cmc_id_proprietaire'].'")' ;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
$query .= ' ORDER BY ci_meta_date_ajout DESC LIMIT 0,100' ;
|
|
|
64 |
|
|
|
65 |
$res =& $DB->query($query);
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
if (DB::isError($res)) {
|
|
|
69 |
print("req partie 2");
|
|
|
70 |
die($res->getMessage());
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
|
|
|
74 |
$row['ci_nom_original'] = htmlspecialchars($row['ci_nom_original']);
|
|
|
75 |
$row['ci_id_image'] = htmlspecialchars($row['ci_id_image']);
|
|
|
76 |
$row['ci_meta_date_ajout'] = htmlspecialchars($row['ci_meta_date_ajout']);
|
|
|
77 |
$row['ci_ce_utilisateur'] = htmlspecialchars($row['ci_ce_utilisateur']);
|
|
|
78 |
$row['ci_meta_user_comment'] = htmlspecialchars($row['ci_meta_user_comment']);
|
|
|
79 |
$row['ci_note_image'] = htmlspecialchars($row['ci_note_image']);
|
|
|
80 |
$tailleXY = $this->calculerDimensions(array($row['ci_meta_width'], $row['ci_meta_height']));
|
|
|
81 |
|
|
|
82 |
$id = $row['ci_id_image'];
|
|
|
83 |
$chemin_sur_serveur = $this->config['cel_db']['url_images'];
|
|
|
84 |
|
|
|
85 |
$id = sprintf('%09s', $id) ;
|
|
|
86 |
$id = wordwrap($id, 3 , '_', true) ;
|
|
|
87 |
|
|
|
88 |
$id_fichier = $id.".jpg" ;
|
|
|
89 |
|
|
|
90 |
$niveauDossier = split("_", $id) ;
|
|
|
91 |
|
|
|
92 |
$dossierNiveau1 = $niveauDossier[0] ;
|
|
|
93 |
$dossierNiveau2 = $niveauDossier[1] ;
|
|
|
94 |
|
|
|
95 |
$chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
|
|
|
96 |
|
|
|
97 |
$chemin_fichier = $chemin_sur_serveur_final.'/L/'.$id."_L.jpg" ;
|
|
|
98 |
$chemin_fichier_m = $chemin_sur_serveur_final.'/M/'.$id."_M.jpg" ;
|
|
|
99 |
|
|
|
100 |
$rss.= ' <item>
|
|
|
101 |
<title>'.$row['ci_nom_original']." (".$row['ci_id_image'].") ". ' par ' . $row['ci_ce_utilisateur'].'</title>
|
|
|
102 |
<author>'.$row['ci_ce_utilisateur'].'</author>
|
|
|
103 |
<link>'.$chemin_fichier.'</link>
|
|
|
104 |
<description>'.
|
|
|
105 |
' <![CDATA[<img src="'.$chemin_fichier_m.'" alt="'.$row['ci_nom_original'].'" height="'.$tailleXY[1].'px" width="'.$tailleXY[0].'px"></img><br/>]]>'.
|
|
|
106 |
$row['ci_nom_original']. ' ajouté le ' .$row['ci_meta_date_ajout'] . ' par ' . $row['ci_ce_utilisateur'].'
|
|
|
107 |
</description>
|
|
|
108 |
<dc:format>text/html</dc:format>
|
|
|
109 |
</item>';
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
$rss.= '</channel> </rss>';
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
header("Content-Type: text/xml; charset=UTF-8");
|
|
|
116 |
print $rss;
|
|
|
117 |
exit;
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
function getRessource(){
|
|
|
122 |
|
|
|
123 |
$uid[] = array() ;
|
|
|
124 |
$this->getElement($uid);
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
function calculerDimensions($tailleXY) {
|
|
|
128 |
|
|
|
129 |
$tailleOr = 300 ;
|
|
|
130 |
|
|
|
131 |
if($tailleXY[1] == 0) {
|
|
|
132 |
$tailleXY[1] = $tailleOr;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
if($tailleXY[0] == 0) {
|
|
|
136 |
$tailleXY[0] = $tailleOr;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
$maxTaille = max($tailleXY[1],$tailleXY[0]) ;
|
|
|
140 |
|
|
|
141 |
if($maxTaille == $tailleXY[1]) {
|
|
|
142 |
|
|
|
143 |
$rapport = $tailleXY[1]/$tailleXY[0] ;
|
|
|
144 |
$tailleXY[1] = 300 ;
|
|
|
145 |
$tailleXY[0] = round($tailleXY[1]/$rapport,0) ;
|
|
|
146 |
|
|
|
147 |
}else {
|
|
|
148 |
$rapport = $tailleXY[0]/$tailleXY[1] ;
|
|
|
149 |
$tailleXY[0] = 300 ;
|
|
|
150 |
$tailleXY[1] = round($tailleXY[0]/$rapport,0) ;
|
|
|
151 |
}
|
|
|
152 |
|
|
|
153 |
return $tailleXY ;
|
|
|
154 |
}
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
/* +--Fin du code ---------------------------------------------------------------------------------------+
|
|
|
159 |
* $Log$
|
|
|
160 |
* Revision 1.5 2008-11-13 11:29:12 ddelon
|
|
|
161 |
* Reecriture gwt-ext
|
|
|
162 |
*
|
|
|
163 |
* Revision 1.4 2007-06-06 13:31:16 ddelon
|
|
|
164 |
* v0.09
|
|
|
165 |
*
|
|
|
166 |
* Revision 1.3 2007-05-22 12:54:09 ddelon
|
|
|
167 |
* Securisation acces utilisateur
|
|
|
168 |
*
|
|
|
169 |
*
|
|
|
170 |
*
|
|
|
171 |
*/
|
|
|
172 |
|
|
|
173 |
?>
|