New file |
0,0 → 1,173 |
<?php |
/** |
* PHP Version 5 |
* |
* @category PHP |
* @package jrest |
* @author aurelien <aurelien@tela-botanica.org> |
* @copyright 2009 Tela-Botanica |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL |
* @version SVN: <svn_id> |
* @link /doc/jrest/ |
*/ |
|
class PlantNetRssParEspece extends DBAccessor { |
|
var $config; |
|
function PlantNetRss($config) { |
|
$this->config=$config; |
} |
|
function getElement($uid){ |
|
$rss = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"; |
$rss .= "<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n"; |
$rss .=' |
<channel> |
<title>Carnet en ligne</title> |
<link>http://www.tela-botanica.org/cel/jrest/PlantnetRss</link> |
<description>Derniers scans de feuilles</description> |
<language>fr</language>'; |
|
$motcle = 'plantnet' ; |
|
$DB=$this->connectDB($this->config,'cel_db'); |
|
$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.'")' ; |
|
$res =& $DB->query($query_id_id_img); |
|
if (DB::isError($res)) { |
|
echo $res->getMessage(); |
} |
|
$query='SELECT * FROM cel_images'; |
|
$premier_item = true ; |
while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
|
if($premier_item) { |
$query .= ' WHERE '; |
$premier_item = false ; |
} |
else{ |
$query .= ' OR '; |
} |
|
$query .= '(ci_meta_mots_cles LIKE "%'.$row['cmc_id_mot_cle_utilisateur'].'%" AND ci_ce_utilisateur ="'.$row['cmc_id_proprietaire'].'")' ; |
} |
|
$query .= ' ORDER BY ci_meta_date_ajout DESC LIMIT 0,100' ; |
|
$res =& $DB->query($query); |
|
|
if (DB::isError($res)) { |
print("req partie 2"); |
die($res->getMessage()); |
} |
|
while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
$row['ci_nom_original'] = htmlspecialchars($row['ci_nom_original']); |
$row['ci_id_image'] = htmlspecialchars($row['ci_id_image']); |
$row['ci_meta_date_ajout'] = htmlspecialchars($row['ci_meta_date_ajout']); |
$row['ci_ce_utilisateur'] = htmlspecialchars($row['ci_ce_utilisateur']); |
$row['ci_meta_user_comment'] = htmlspecialchars($row['ci_meta_user_comment']); |
$row['ci_note_image'] = htmlspecialchars($row['ci_note_image']); |
$tailleXY = $this->calculerDimensions(array($row['ci_meta_width'], $row['ci_meta_height'])); |
|
$id = $row['ci_id_image']; |
$chemin_sur_serveur = $this->config['cel_db']['url_images']; |
|
$id = sprintf('%09s', $id) ; |
$id = wordwrap($id, 3 , '_', true) ; |
|
$id_fichier = $id.".jpg" ; |
|
$niveauDossier = split("_", $id) ; |
|
$dossierNiveau1 = $niveauDossier[0] ; |
$dossierNiveau2 = $niveauDossier[1] ; |
|
$chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ; |
|
$chemin_fichier = $chemin_sur_serveur_final.'/L/'.$id."_L.jpg" ; |
$chemin_fichier_m = $chemin_sur_serveur_final.'/M/'.$id."_M.jpg" ; |
|
$rss.= ' <item> |
<title>'.$row['ci_nom_original']." (".$row['ci_id_image'].") ". ' par ' . $row['ci_ce_utilisateur'].'</title> |
<author>'.$row['ci_ce_utilisateur'].'</author> |
<link>'.$chemin_fichier.'</link> |
<description>'. |
' <![CDATA[<img src="'.$chemin_fichier_m.'" alt="'.$row['ci_nom_original'].'" height="'.$tailleXY[1].'px" width="'.$tailleXY[0].'px"></img><br/>]]>'. |
$row['ci_nom_original']. ' ajouté le ' .$row['ci_meta_date_ajout'] . ' par ' . $row['ci_ce_utilisateur'].' |
</description> |
<dc:format>text/html</dc:format> |
</item>'; |
} |
|
$rss.= '</channel> </rss>'; |
|
|
header("Content-Type: text/xml; charset=UTF-8"); |
print $rss; |
exit; |
} |
|
|
function getRessource(){ |
|
$uid[] = array() ; |
$this->getElement($uid); |
} |
|
function calculerDimensions($tailleXY) { |
|
$tailleOr = 300 ; |
|
if($tailleXY[1] == 0) { |
$tailleXY[1] = $tailleOr; |
} |
|
if($tailleXY[0] == 0) { |
$tailleXY[0] = $tailleOr; |
} |
|
$maxTaille = max($tailleXY[1],$tailleXY[0]) ; |
|
if($maxTaille == $tailleXY[1]) { |
|
$rapport = $tailleXY[1]/$tailleXY[0] ; |
$tailleXY[1] = 300 ; |
$tailleXY[0] = round($tailleXY[1]/$rapport,0) ; |
|
}else { |
$rapport = $tailleXY[0]/$tailleXY[1] ; |
$tailleXY[0] = 300 ; |
$tailleXY[1] = round($tailleXY[0]/$rapport,0) ; |
} |
|
return $tailleXY ; |
} |
} |
|
|
/* +--Fin du code ---------------------------------------------------------------------------------------+ |
* $Log$ |
* Revision 1.5 2008-11-13 11:29:12 ddelon |
* Reecriture gwt-ext |
* |
* Revision 1.4 2007-06-06 13:31:16 ddelon |
* v0.09 |
* |
* Revision 1.3 2007-05-22 12:54:09 ddelon |
* Securisation acces utilisateur |
* |
* |
* |
*/ |
|
?> |