1,4 → 1,6 |
<?php |
// ATTENTION ! Classe compatible uniquement avec nouveau format de bdd du cel // |
|
/** |
* PHP Version 5 |
* |
12,28 → 14,15 |
* @version SVN: <svn_id> |
* @link /doc/jrest/ |
*/ |
Class ImageRDF extends DBAccessor { |
class ImageRDF extends Cel { |
|
var $config; |
|
function ImageRDF($config) { |
|
$this->config=$config; |
} |
|
|
|
/** |
* Recherche des images associee au numero nomenclatural |
* @param numeric $uid [0] : numero nomenclatural obligatoire , $uid[1] (optionnel) : taille image : S , M, L (default) |
*/ |
|
|
// TODO : recherche taxon ? |
|
*/ |
function getElement($uid){ |
|
|
// TODO : recherche taxon ? |
// Taille |
if (isset($uid[1])) { |
$taille = $uid[1]; // S , M ou L |
41,31 → 30,19 |
else { |
$taille = 'L'; |
} |
|
|
$DB=$this->connectDB($this->config,'cel_db'); |
|
// Recherche de toutes les observations transmises du taxon pour lesquelles une photo est associee. |
|
$query = 'SELECT * FROM cel_inventory, cel_obs_images, cel_images '. |
' WHERE cel_inventory.num_nom_sel = "'.mysql_escape_string($uid[0]).'"'. |
' AND cel_obs_images.coi_ce_utilisateur = cel_inventory.identifiant '. |
' AND cel_obs_images.coi_ce_observation = cel_inventory.ordre '. |
' AND cel_inventory.transmission = 1 '. |
' AND cel_images.ci_ce_utilisateur = cel_obs_images.coi_ce_utilisateur '. |
' AND ci_id_image = cel_obs_images.coi_ce_image'; |
// Recherche de toutes les observations transmises du taxon pour lesquelles une photo est associee. |
$requete_obs_publiques_images_taxon = 'SELECT * FROM cel_obs, cel_obs_images, cel_images '. |
' WHERE cel_obs.nom_sel_nn = '.$this->proteger($uid[0]). |
' AND cel_obs_images.id_utilisateur = cel_obs.ce_utilisateur '. |
' AND cel_obs_images.id_observation = cel_obs.id_observation '. |
' AND cel_obs.transmission = 0 '. |
' AND cel_images.ce_utilisateur = cel_obs_images.id_utilisateur '. |
' AND cel_images.id_image = cel_obs_images.id_image'; |
|
|
$result =& $DB->query($query); |
|
if (DB::isError($result)) { |
die($result->getMessage()); |
} |
|
|
$resultat_requete_obs_images_taxon = $this->requeter($requete_obs_publiques_images_taxon); |
$picture_path = $this->config['cel_db']['url_images']; |
|
|
|
// Formatage du xml |
$xml = '<?xml version="1.0" encoding="utf-8"?>'."\n"; |
$xml .= '<rdf:RDF'."\n"; |
72,12 → 49,16 |
$xml .= ' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n"; |
$xml .= ' xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n"; |
$xml .= ' xmlns:dcterms="http://purl.org/dc/terms">'."\n"; |
|
|
$images_obs_taxon = array(); |
if (is_array($resultat_requete_obs_images_taxon)) { |
$images_obs_taxon = $resultat_requete_obs_images_taxon; |
} |
|
while ($picture =& $result->fetchrow(DB_FETCHMODE_ASSOC)) { |
// Calcul du chemin sur le serveur en fonction de l'identifiant (id) |
foreach ($images_obs_taxon as $picture) { |
|
$id = $picture['ci_id_image']; |
// Calcul du chemin sur le serveur en fonction de l'identifiant (id) |
$id = $picture['id_image']; |
$id = sprintf('%09s', $id) ; |
$id = wordwrap($id, 3 , '_', true) ; |
|
89,19 → 70,18 |
$dossierNiveau2 = $niveauDossier[1] ; |
|
$picture_path_with_level = $picture_path.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ; |
|
|
|
|
// TODO: mettre nom prénom dans créateur ? ou mail ? |
$xml .= ' <rdf:Description about="'.$picture_path_with_level.'/'.$taille.'/'.$id.'_'.$taille.'.jpg'.'"'."\n"; |
$xml .= ' dc:identifier="'.'urn:lsid:tela-botanica.org:celpic:'.$picture['ci_id_image'].'"'."\n"; |
$xml .= ' dc:identifier="'.'urn:lsid:tela-botanica.org:celpic:'.$picture['id_image'].'"'."\n"; |
$xml .= ' dc:title="'.$picture['nom_sel'].'"'."\n"; |
$xml .= ' dc:description="'.$picture['nom_sel']." - [fichier_origine:".$picture['ci_nom_original'].'][image_identifiant:'.$picture['ci_id_image'].']'; |
$xml .= '[image_ordre:'.$picture['ci_ordre'].']'; |
$xml .= '[observation_identifiant:'.$picture['id'].']'; |
$xml .= ' dc:description="'.$picture['nom_sel']." - [fichier_origine:".$picture['nom_original'].'][image_identifiant:'.$picture['id_image'].']'; |
$xml .= '[image_ordre:'.$picture['ordre'].']'; |
$xml .= '[observation_identifiant:'.$picture['id_observation'].']'; |
$xml .= '[observation_ordre:'.$picture['ordre'].']'.'"'."\n"; |
$xml .= ' dc:creator="'.$picture['identifiant'].'"'."\n"; |
$xml .= ' dc:creator="'.$picture['ce_utilisateur'].'"'."\n"; |
$xml .= ' dc:publisher="CEL"'."\n"; |
$xml .= ' dcterms:spatial="'.utf8_decode($picture['location'])." (".$picture['id_location'].")".'"'."\n"; |
$xml .= ' dcterms:spatial="'.utf8_decode($picture['zone_geo'])." (".$picture['ce_zone_geo'].")".'"'."\n"; |
|
if ($picture['date_observation'] != '0000-00-00 00:00:00') { |
list($year,$month,$day) = split ('-',$picture['date_observation']); |
116,8 → 96,7 |
|
// Envoi du xml au navigateur |
header("Content-Type: text/xml"); |
echo utf8_encode(str_replace(' & ', ' & ', $xml)); |
|
echo utf8_encode(str_replace(' & ', ' & ', $xml)); |
|
} |
|