416 |
aurelien |
1 |
<?php
|
871 |
aurelien |
2 |
// ATTENTION ! Classe compatible uniquement avec nouveau format de bdd du cel //
|
|
|
3 |
|
416 |
aurelien |
4 |
/**
|
|
|
5 |
* PHP Version 5
|
|
|
6 |
*
|
|
|
7 |
* Retourne un RDF des images pour eflore
|
|
|
8 |
*
|
|
|
9 |
* @category PHP
|
|
|
10 |
* @package jrest
|
881 |
aurelien |
11 |
* @author david <david@tela-botanica.org>
|
416 |
aurelien |
12 |
* @copyright 2010 Tela-Botanica
|
|
|
13 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
|
|
14 |
* @version SVN: <svn_id>
|
|
|
15 |
* @link /doc/jrest/
|
|
|
16 |
*/
|
871 |
aurelien |
17 |
class ImageRDF extends Cel {
|
416 |
aurelien |
18 |
|
|
|
19 |
/**
|
|
|
20 |
* Recherche des images associee au numero nomenclatural
|
|
|
21 |
* @param numeric $uid [0] : numero nomenclatural obligatoire , $uid[1] (optionnel) : taille image : S , M, L (default)
|
871 |
aurelien |
22 |
*/
|
416 |
aurelien |
23 |
function getElement($uid){
|
|
|
24 |
|
871 |
aurelien |
25 |
// TODO : recherche taxon ?
|
416 |
aurelien |
26 |
// Taille
|
|
|
27 |
if (isset($uid[1])) {
|
628 |
jpm |
28 |
$taille = $uid[1]; // S , M ou L
|
416 |
aurelien |
29 |
}
|
|
|
30 |
else {
|
628 |
jpm |
31 |
$taille = 'L';
|
416 |
aurelien |
32 |
}
|
|
|
33 |
|
871 |
aurelien |
34 |
// Recherche de toutes les observations transmises du taxon pour lesquelles une photo est associee.
|
|
|
35 |
$requete_obs_publiques_images_taxon = 'SELECT * FROM cel_obs, cel_obs_images, cel_images '.
|
1765 |
raphael |
36 |
' WHERE cel_obs.nom_sel_nn = '.Cel::db()->proteger($uid[0]).
|
871 |
aurelien |
37 |
' AND cel_obs_images.id_observation = cel_obs.id_observation '.
|
872 |
aurelien |
38 |
' AND cel_obs.transmission = 1 '.
|
871 |
aurelien |
39 |
' AND cel_images.id_image = cel_obs_images.id_image';
|
416 |
aurelien |
40 |
|
1765 |
raphael |
41 |
$resultat_requete_obs_images_taxon = Cel::db()->requeter($requete_obs_publiques_images_taxon);
|
1391 |
aurelien |
42 |
$picture_path = $this->config['cel']['url_images'];
|
871 |
aurelien |
43 |
|
416 |
aurelien |
44 |
// Formatage du xml
|
|
|
45 |
$xml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
|
|
|
46 |
$xml .= '<rdf:RDF'."\n";
|
|
|
47 |
$xml .= ' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n";
|
|
|
48 |
$xml .= ' xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n";
|
|
|
49 |
$xml .= ' xmlns:dcterms="http://purl.org/dc/terms">'."\n";
|
871 |
aurelien |
50 |
|
|
|
51 |
$images_obs_taxon = array();
|
|
|
52 |
if (is_array($resultat_requete_obs_images_taxon)) {
|
|
|
53 |
$images_obs_taxon = $resultat_requete_obs_images_taxon;
|
|
|
54 |
}
|
416 |
aurelien |
55 |
|
871 |
aurelien |
56 |
foreach ($images_obs_taxon as $picture) {
|
416 |
aurelien |
57 |
|
871 |
aurelien |
58 |
// Calcul du chemin sur le serveur en fonction de l'identifiant (id)
|
|
|
59 |
$id = $picture['id_image'];
|
416 |
aurelien |
60 |
$id = sprintf('%09s', $id) ;
|
|
|
61 |
$id = wordwrap($id, 3 , '_', true) ;
|
|
|
62 |
|
|
|
63 |
$id_fichier = $id.".jpg" ;
|
|
|
64 |
|
996 |
aurelien |
65 |
$niveauDossier = explode("_", $id) ;
|
416 |
aurelien |
66 |
|
|
|
67 |
$dossierNiveau1 = $niveauDossier[0] ;
|
|
|
68 |
$dossierNiveau2 = $niveauDossier[1] ;
|
|
|
69 |
|
|
|
70 |
$picture_path_with_level = $picture_path.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
|
871 |
aurelien |
71 |
|
|
|
72 |
// TODO: mettre nom prénom dans créateur ? ou mail ?
|
416 |
aurelien |
73 |
$xml .= ' <rdf:Description about="'.$picture_path_with_level.'/'.$taille.'/'.$id.'_'.$taille.'.jpg'.'"'."\n";
|
871 |
aurelien |
74 |
$xml .= ' dc:identifier="'.'urn:lsid:tela-botanica.org:celpic:'.$picture['id_image'].'"'."\n";
|
416 |
aurelien |
75 |
$xml .= ' dc:title="'.$picture['nom_sel'].'"'."\n";
|
871 |
aurelien |
76 |
$xml .= ' dc:description="'.$picture['nom_sel']." - [fichier_origine:".$picture['nom_original'].'][image_identifiant:'.$picture['id_image'].']';
|
|
|
77 |
$xml .= '[image_ordre:'.$picture['ordre'].']';
|
|
|
78 |
$xml .= '[observation_identifiant:'.$picture['id_observation'].']';
|
416 |
aurelien |
79 |
$xml .= '[observation_ordre:'.$picture['ordre'].']'.'"'."\n";
|
1391 |
aurelien |
80 |
$xml .= ' dc:creator="'.$picture['courriel_utilisateur'].'"'."\n";
|
416 |
aurelien |
81 |
$xml .= ' dc:publisher="CEL"'."\n";
|
871 |
aurelien |
82 |
$xml .= ' dcterms:spatial="'.utf8_decode($picture['zone_geo'])." (".$picture['ce_zone_geo'].")".'"'."\n";
|
416 |
aurelien |
83 |
|
|
|
84 |
if ($picture['date_observation'] != '0000-00-00 00:00:00') {
|
2009 |
mathias |
85 |
$yearMonthDay = explode('-',$picture['date_observation']);
|
|
|
86 |
$year = $yearMonthDay[0];
|
2015 |
mathias |
87 |
$month = 0;
|
|
|
88 |
$day = 0;
|
2009 |
mathias |
89 |
if (count($yearMonthDay) > 1) {
|
|
|
90 |
$month = $yearMonthDay[1];
|
|
|
91 |
}
|
|
|
92 |
if (count($yearMonthDay) > 2) {
|
|
|
93 |
$day = $yearMonthDay[2];
|
|
|
94 |
}
|
996 |
aurelien |
95 |
list($day) = explode(' ',$day);
|
416 |
aurelien |
96 |
$created = $day.'/'.$month.'/'.$year;
|
|
|
97 |
$xml .= ' dcterms:created="'.$created.'"'."\n";
|
|
|
98 |
}
|
|
|
99 |
$xml .= ' dcterms:licence="CC BY-SA"/>'."\n";
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
$xml .= '</rdf:RDF>'."\n";
|
|
|
103 |
|
|
|
104 |
// Envoi du xml au navigateur
|
|
|
105 |
header("Content-Type: text/xml");
|
871 |
aurelien |
106 |
echo utf8_encode(str_replace(' & ', ' & ', $xml));
|
416 |
aurelien |
107 |
|
|
|
108 |
}
|
|
|
109 |
|
617 |
jpm |
110 |
function envoyerRequete($url) {
|
|
|
111 |
$contenu = false;
|
|
|
112 |
$contexte = stream_context_create(array(
|
|
|
113 |
'http' => array(
|
|
|
114 |
'method' => 'GET',
|
|
|
115 |
'header' => "Content-type: application/x-www-form-urlencoded\r\n")));
|
|
|
116 |
|
|
|
117 |
$flux = @fopen($url, 'r', false, $contexte);
|
|
|
118 |
$contenu = json_decode(stream_get_contents($flux));
|
|
|
119 |
fclose($flux);
|
|
|
120 |
return $contenu;
|
|
|
121 |
}
|
416 |
aurelien |
122 |
|
|
|
123 |
}
|
540 |
david |
124 |
?>
|