1 |
<?php
|
1 |
<?php
|
2 |
/**
|
2 |
/**
|
3 |
|
- |
|
4 |
David Delon david.delon@clapas.net 2007
|
3 |
* PHP Version 5
|
5 |
|
4 |
*
|
6 |
Ce logiciel est r�gi par la licence CeCILL soumise au droit fran�ais et
|
- |
|
7 |
respectant les principes de diffusion des logiciels libres. Vous pouvez
|
- |
|
8 |
utiliser, modifier et/ou redistribuer ce programme sous les conditions
|
- |
|
9 |
de la licence CeCILL telle que diffus�e par le CEA, le CNRS et l'INRIA
|
- |
|
10 |
sur le site "http://www.cecill.info".
|
5 |
* @category PHP
|
11 |
En contrepartie de l'accessibilit� au code source et des droits de copie,
|
6 |
* @package jrest
|
12 |
de modification et de redistribution accord�s par cette licence, il n'est
|
7 |
* @author David Delon <david.delon@clapas.net>
|
13 |
offert aux utilisateurs qu'une garantie limit�e. Pour les m�mes raisons,
|
- |
|
14 |
seule une responsabilit� restreinte p�se sur l'auteur du programme, le
|
- |
|
15 |
titulaire des droits patrimoniaux et les conc�dants successifs.
|
8 |
* @copyright 2010 Tela-Botanica
|
16 |
|
- |
|
17 |
A cet �gard l'attention de l'utilisateur est attir�e sur les risques
|
- |
|
18 |
associ�s au chargement, � l'utilisation, � la modification et/ou au
|
- |
|
19 |
d�veloppement et � la reproduction du logiciel par l'utilisateur �tant
|
- |
|
20 |
donn� sa sp�cificit� de logiciel libre, qui peut le rendre complexe �
|
- |
|
21 |
manipuler et qui le r�serve donc � des d�veloppeurs et des professionnels
|
- |
|
22 |
avertis poss�dant des connaissances informatiques approfondies. Les
|
9 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
23 |
utilisateurs sont donc invit�s � charger et tester l'ad�quation du
|
- |
|
24 |
logiciel � leurs besoins dans des conditions permettant d'assurer la
|
10 |
* @version SVN: <svn_id>
|
25 |
s�curit� de leurs syst�mes et ou de leurs donn�es et, plus g�n�ralement,
|
- |
|
26 |
� l'utiliser et l'exploiter dans les m�mes conditions de s�curit�.
|
- |
|
27 |
|
- |
|
28 |
Le fait que vous puissiez acc�der � cet en-t�te signifie que vous avez
|
- |
|
29 |
pris connaissance de la licence CeCILL, et que vous en avez accept� les
|
- |
|
30 |
termes.
|
11 |
* @link /doc/jrest/
|
31 |
|
- |
|
32 |
*/
|
12 |
*/
|
33 |
|
- |
|
34 |
// in : utf8
|
- |
|
35 |
// out : 8859
|
13 |
|
36 |
/*
|
14 |
/**
|
37 |
* NameImage.php
|
15 |
* NameImage.php
|
- |
|
16 |
*
|
- |
|
17 |
* in : utf8
|
- |
|
18 |
* out : 8859
|
38 |
*
|
19 |
*
|
39 |
* Cas d'utilisation :
|
20 |
* Cas d'utilisation :
|
40 |
* Service recherche d'image a partir d'un numero nomenclatural
|
21 |
* Service recherche d'image a partir d'un numero nomenclatural
|
41 |
*
|
22 |
*
|
42 |
* 1: Le service recoit un numero nomenclatural
|
23 |
* 1: Le service recoit un numero nomenclatural
|
43 |
* 2: Le service calcul le numero taxonomique associe
|
24 |
* 2: Le service calcul le numero taxonomique associe
|
44 |
* 3: Le service recherche une image disponible pour ce numero taxonomique
|
25 |
* 3: Le service recherche une image disponible pour ce numero taxonomique
|
45 |
* 4: Le service redimensionne l'image et la renvoie
|
26 |
* 4: Le service redimensionne l'image et la renvoie
|
46 |
*/
|
27 |
*/
|
47 |
|
28 |
|
48 |
/** Constante stockant l'URL de la page d'accueil de Photoflora.*/
|
29 |
/** Constante stockant l'URL de la page d'accueil de Photoflora.*/
|
49 |
define('EF_URL_PHOTOFLORA', 'http://photoflora.free.fr/');
|
30 |
define('EF_URL_PHOTOFLORA', 'http://photoflora.free.fr/');
|
50 |
/** Constante stockant l'URL de la page de Photoflora affichant toutes les images d'un taxon donné.*/
|
31 |
/** Constante stockant l'URL de la page de Photoflora affichant toutes les images d'un taxon donné.*/
|
51 |
define('EF_URL_PHOTOFLORA_TAXON', EF_URL_PHOTOFLORA.'FiTax.php?NumTaxon=%s');
|
32 |
define('EF_URL_PHOTOFLORA_TAXON', EF_URL_PHOTOFLORA.'FiTax.php?NumTaxon=%s');
|
52 |
/** Constante stockant l'URL du dossier de photoflora contenant les images miniatures.*/
|
33 |
/** Constante stockant l'URL du dossier de photoflora contenant les images miniatures.*/
|
53 |
define('EF_URL_PHOTOFLORA_IMG_MIN', 'http://photoflora.free.fr/photos/%s/min/%s');
|
34 |
define('EF_URL_PHOTOFLORA_IMG_MIN', 'http://photoflora.free.fr/photos/%s/min/%s');
|
54 |
/** Constante stockant l'URL du service XML de Photoflora.*/
|
35 |
/** Constante stockant l'URL du service XML de Photoflora.*/
|
55 |
define('EF_URL_PHOTOFLORA_SERVICE', EF_URL_PHOTOFLORA.'ef_photoflora.php?nt=%s');
|
36 |
define('EF_URL_PHOTOFLORA_SERVICE', EF_URL_PHOTOFLORA.'ef_photoflora.php?nt=%s');
|
56 |
|
37 |
|
57 |
define('EF_URL_PHOTOFLORA_REGEXP_01', '/\/photos\/([^\/]+)\/max\/(.+)$/');
|
38 |
define('EF_URL_PHOTOFLORA_REGEXP_01', '/\/photos\/([^\/]+)\/max\/(.+)$/');
|
58 |
define('EF_URL_PHOTOFLORA_REGEXP_02', '/photoflora([^.]+)\.free\.fr\/max\/(.+)$/');
|
39 |
define('EF_URL_PHOTOFLORA_REGEXP_02', '/photoflora([^.]+)\.free\.fr\/max\/(.+)$/');
|
59 |
|
40 |
|
60 |
class NameImage extends Cel {
|
41 |
class NameImage extends Cel {
|
61 |
|
42 |
|
62 |
function getElement($uid){
|
43 |
function getElement($uid){
|
63 |
|
- |
|
64 |
// Num nomenclatural
|
- |
|
65 |
$requete_num_nom = "SELECT DISTINCT b.esn_id_taxon FROM eflore_nom, eflore_nom_rang," .
|
- |
|
66 |
" eflore_selection_nom a, eflore_selection_nom b".
|
- |
|
67 |
" WHERE a.esn_id_nom= ".$this->proteger($uid[0]).
|
- |
|
68 |
" AND a.esn_id_version_projet_taxon = 25 ".
|
- |
|
69 |
" AND a.esn_id_taxon=b.esn_id_taxon ".
|
- |
|
70 |
" AND b.esn_ce_statut=3 ".
|
- |
|
71 |
" AND a.esn_id_version_projet_taxon=b.esn_id_version_projet_taxon" .
|
- |
|
72 |
" AND en_ce_rang = enrg_id_rang" .
|
- |
|
73 |
" AND en_id_nom = b.esn_id_nom" .
|
- |
|
74 |
" AND a.esn_id_version_projet_taxon=en_id_version_projet_nom ";
|
- |
|
75 |
|
- |
|
76 |
$res_num_nom = $this->requeter($requete_num_nom);
|
- |
|
77 |
|
44 |
|
- |
|
45 |
$nt = null;
|
- |
|
46 |
|
78 |
$nt = null;
|
47 |
if(isset($uid[0])) {
|
79 |
if(is_array($res_num_nom) && count($res_num_nom) > 0) {
|
48 |
$recherche_infos_taxon = new RechercheInfosTaxon($this->config);
|
80 |
$nt=$res_num_nom[0]['esn_id_taxon'];
|
49 |
$nt = $recherche_infos_taxon->rechercherNumTaxSurNumNom($uid[0]);
|
81 |
}
|
50 |
}
|
82 |
|
51 |
|
83 |
$projet_photo = 'photoflora';
|
52 |
$projet_photo = 'photoflora';
|
84 |
|
53 |
|
85 |
$tab_retour[$projet_photo]=chercherIllustrationsServiceXml(sprintf(EF_URL_PHOTOFLORA_SERVICE, $nt));
|
54 |
$tab_retour[$projet_photo]=chercherIllustrationsServiceXml(sprintf(EF_URL_PHOTOFLORA_SERVICE, $nt));
|
86 |
|
55 |
|
87 |
$value=array('null','null');
|
56 |
$value=array('null','null');
|
88 |
|
57 |
|
89 |
foreach ($tab_retour[$projet_photo] as $cle => $illustration) {
|
58 |
foreach ($tab_retour[$projet_photo] as $cle => $illustration) {
|
90 |
|
- |
|
91 |
|
59 |
|
92 |
if (preg_match(EF_URL_PHOTOFLORA_REGEXP_01, $illustration['about'], $match)) {
|
60 |
if (preg_match(EF_URL_PHOTOFLORA_REGEXP_01, $illustration['about'], $match)) {
|
93 |
$abreviation = $match[1];
|
61 |
$abreviation = $match[1];
|
94 |
$fichier = $match[2];
|
62 |
$fichier = $match[2];
|
95 |
}
|
63 |
}
|
96 |
else {
|
64 |
else {
|
97 |
|
65 |
|
98 |
if (preg_match(EF_URL_PHOTOFLORA_REGEXP_02, $illustration['about'], $match)) {
|
66 |
if (preg_match(EF_URL_PHOTOFLORA_REGEXP_02, $illustration['about'], $match)) {
|
99 |
$abreviation = $match[1];
|
67 |
$abreviation = $match[1];
|
100 |
$fichier = $match[2];
|
68 |
$fichier = $match[2];
|
101 |
}
|
69 |
}
|
102 |
}
|
70 |
}
|
103 |
|
71 |
|
104 |
if (isset($abreviation)) {
|
72 |
if (isset($abreviation)) {
|
105 |
|
- |
|
106 |
$url_miniature = sprintf(EF_URL_PHOTOFLORA_IMG_MIN, $abreviation, $fichier);;
|
73 |
$url_miniature = sprintf(EF_URL_PHOTOFLORA_IMG_MIN, $abreviation, $fichier);;
|
107 |
$url_max = $illustration['about'];
|
74 |
$url_max = $illustration['about'];
|
108 |
|
75 |
|
109 |
$value=array($url_miniature,$url_max);
|
76 |
$value=array($url_miniature,$url_max);
|
110 |
|
77 |
|
111 |
// Priorite aux images en png
|
78 |
// Priorite aux images en png
|
112 |
if (strstr($fichier, '.png')) {
|
79 |
if (strstr($fichier, '.png')) {
|
113 |
break;
|
80 |
break;
|
114 |
}
|
81 |
}
|
115 |
}
|
82 |
}
|
116 |
|
- |
|
117 |
}
|
83 |
}
|
118 |
|
84 |
|
119 |
$output = json_encode($value);
|
85 |
$output = json_encode($value);
|
- |
|
86 |
header("content-type: application/json");
|
120 |
print($output);
|
87 |
print($output);
|
- |
|
88 |
return true;
|
121 |
}
|
89 |
}
|
122 |
|
90 |
|
123 |
}
|
91 |
}
|
124 |
|
92 |
|
125 |
function chercherIllustrationsServiceXml($url)
|
93 |
function chercherIllustrationsServiceXml($url)
|
126 |
{
|
94 |
{
|
127 |
return analyserFichierRdf($url);
|
95 |
return analyserFichierRdf($url);
|
128 |
}
|
96 |
}
|
129 |
|
97 |
|
130 |
function analyserFichierRdf($chemin)
|
98 |
function analyserFichierRdf($chemin)
|
131 |
{
|
99 |
{
|
132 |
$aso_info = array();
|
100 |
$aso_info = array();
|
133 |
$dom = new DOMDocument();
|
101 |
$dom = new DOMDocument();
|
134 |
$dom->validateOnParse = true;
|
102 |
$dom->validateOnParse = true;
|
135 |
if (preg_match('/^http:\/\//', $chemin)) {
|
103 |
if (preg_match('/^http:\/\//', $chemin)) {
|
136 |
@$dom->loadXML(file_get_contents($chemin));
|
104 |
@$dom->loadXML(file_get_contents($chemin));
|
137 |
} else {
|
105 |
} else {
|
138 |
@$dom->load($chemin);
|
106 |
@$dom->load($chemin);
|
139 |
}
|
107 |
}
|
140 |
|
- |
|
141 |
|
108 |
|
142 |
$tab_infos = array();
|
109 |
$tab_infos = array();
|
143 |
foreach ($dom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description') as $rdf_description) {
|
110 |
foreach ($dom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description') as $rdf_description) {
|
144 |
$aso_info['about'] = $rdf_description->getAttribute('about');
|
111 |
$aso_info['about'] = $rdf_description->getAttribute('about');
|
145 |
$aso_info['dc:identifier'] = $rdf_description->getAttribute('identifier');
|
112 |
$aso_info['dc:identifier'] = $rdf_description->getAttribute('identifier');
|
146 |
$aso_info['dc:title'] = utf8_decode($rdf_description->getAttribute('title'));
|
113 |
$aso_info['dc:title'] = utf8_decode($rdf_description->getAttribute('title'));
|
147 |
$aso_info['dc:creator'] = utf8_decode($rdf_description->getAttribute('creator'));
|
114 |
$aso_info['dc:creator'] = utf8_decode($rdf_description->getAttribute('creator'));
|
148 |
$aso_info['dc:contributor'] = utf8_decode($rdf_description->getAttribute('contributor'));
|
115 |
$aso_info['dc:contributor'] = utf8_decode($rdf_description->getAttribute('contributor'));
|
149 |
$aso_info['dc:publisher'] = utf8_decode($rdf_description->getAttribute('publisher'));
|
116 |
$aso_info['dc:publisher'] = utf8_decode($rdf_description->getAttribute('publisher'));
|
150 |
$aso_info['dc:type'] = utf8_decode($rdf_description->getAttribute('type'));
|
117 |
$aso_info['dc:type'] = utf8_decode($rdf_description->getAttribute('type'));
|
151 |
$aso_info['dc:format'] = utf8_decode($rdf_description->getAttribute('format'));
|
118 |
$aso_info['dc:format'] = utf8_decode($rdf_description->getAttribute('format'));
|
152 |
if (function_exists('date_default_timezone_set')) {
|
119 |
if (function_exists('date_default_timezone_set')) {
|
153 |
date_default_timezone_set('Europe/Paris');
|
120 |
date_default_timezone_set('Europe/Paris');
|
154 |
}
|
121 |
}
|
155 |
if (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $rdf_description->getAttribute('created'))) {
|
122 |
if (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $rdf_description->getAttribute('created'))) {
|
156 |
$aso_info['dcterms:created'] = date('j-m-Y à H:i:s', strtotime($rdf_description->getAttribute('created')));
|
123 |
$aso_info['dcterms:created'] = date('j-m-Y à H:i:s', strtotime($rdf_description->getAttribute('created')));
|
157 |
} else {
|
124 |
} else {
|
158 |
$aso_info['dcterms:created'] = $rdf_description->getAttribute('created');
|
125 |
$aso_info['dcterms:created'] = $rdf_description->getAttribute('created');
|
159 |
}
|
126 |
}
|
160 |
$aso_info['dcterms:dateSubmitted'] = utf8_decode($rdf_description->getAttribute('dateSubmitted'));
|
127 |
$aso_info['dcterms:dateSubmitted'] = utf8_decode($rdf_description->getAttribute('dateSubmitted'));
|
161 |
$aso_info['dcterms:spatial'] = utf8_decode($rdf_description->getAttribute('spatial'));
|
128 |
$aso_info['dcterms:spatial'] = utf8_decode($rdf_description->getAttribute('spatial'));
|
162 |
$aso_info['dcterms:licence'] = utf8_decode($rdf_description->getAttribute('licence'));
|
129 |
$aso_info['dcterms:licence'] = utf8_decode($rdf_description->getAttribute('licence'));
|
163 |
$tab_infos[$rdf_description->getAttribute('identifier')] = $aso_info;
|
130 |
$tab_infos[$rdf_description->getAttribute('identifier')] = $aso_info;
|
164 |
}
|
131 |
}
|
165 |
|
132 |
|
166 |
return $tab_infos;
|
133 |
return $tab_infos;
|
167 |
}
|
134 |
}
|
168 |
|
- |
|
169 |
|
- |
|
170 |
/* +--Fin du code ---------------------------------------------------------------------------------------+
|
135 |
/* +--Fin du code ---------------------------------------------------------------------------------------+
|
171 |
* $Log$
|
136 |
* $Log$
|
172 |
* Revision 1.4 2008-11-13 11:29:12 ddelon
|
137 |
* Revision 1.4 2008-11-13 11:29:12 ddelon
|
173 |
* Reecriture gwt-ext
|
138 |
* Reecriture gwt-ext
|
174 |
*
|
139 |
*
|
175 |
* Revision 1.2 2008-01-30 08:57:28 ddelon
|
140 |
* Revision 1.2 2008-01-30 08:57:28 ddelon
|
176 |
* fin mise en place mygwt
|
141 |
* fin mise en place mygwt
|
177 |
*
|
142 |
*
|
178 |
* Revision 1.1 2007-06-06 13:31:16 ddelon
|
143 |
* Revision 1.1 2007-06-06 13:31:16 ddelon
|
179 |
* v0.09
|
144 |
* v0.09
|
180 |
*
|
145 |
*
|
181 |
*/
|
146 |
*/
|
182 |
?>
|
147 |
?>
|