2 |
jpm |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This file is part of Integrateur eFlore. |
|
|
|
9 |
// | |
|
|
|
10 |
// | Foobar is free software; you can redistribute it and/or modify |
|
|
|
11 |
// | it under the terms of the GNU General Public License as published by |
|
|
|
12 |
// | the Free Software Foundation; either version 2 of the License, or |
|
|
|
13 |
// | (at your option) any later version. |
|
|
|
14 |
// | |
|
|
|
15 |
// | Foobar is distributed in the hope that it will be useful, |
|
|
|
16 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
17 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
18 |
// | GNU General Public License for more details. |
|
|
|
19 |
// | |
|
|
|
20 |
// | You should have received a copy of the GNU General Public License |
|
|
|
21 |
// | along with Foobar; if not, write to the Free Software |
|
|
|
22 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
23 |
// +------------------------------------------------------------------------------------------------------+
|
9 |
jp_milcent |
24 |
// CVS : $Id: eflore_transfo_xslt.inc.php,v 1.3 2005-11-18 15:14:39 jp_milcent Exp $
|
2 |
jpm |
25 |
/**
|
|
|
26 |
* Réalisation de la transfo XSL du XML d'eFlore.
|
|
|
27 |
*
|
|
|
28 |
*@package eFlore
|
|
|
29 |
*@subpackage Ancien
|
|
|
30 |
//Auteur original :
|
|
|
31 |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
32 |
//Autres auteurs :
|
|
|
33 |
*@author Aucun
|
|
|
34 |
*@copyright Tela-Botanica 2000-2005
|
9 |
jp_milcent |
35 |
*@version $Revision: 1.3 $ $Date: 2005-11-18 15:14:39 $
|
2 |
jpm |
36 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
37 |
*/
|
|
|
38 |
|
|
|
39 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
40 |
// | ENTETE du PROGRAMME |
|
|
|
41 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
42 |
// Récupération des valeurs du formulaire
|
|
|
43 |
switch ($flore) {
|
|
|
44 |
case 'FRA':
|
|
|
45 |
$services = 'servicesxml/';
|
|
|
46 |
$baseURL .= '&flore=FRA&';
|
|
|
47 |
$tab_champ['esd_nom_index'] = 'France metropole';
|
|
|
48 |
break;
|
|
|
49 |
case 'REU':
|
|
|
50 |
$services = 'services_xml_mascareignes/';
|
|
|
51 |
$baseURL .= '&flore=REU&';
|
|
|
52 |
$tab_champ['esd_nom_index'] = 'France mascareignes';
|
|
|
53 |
break;
|
|
|
54 |
case 'ANT':
|
|
|
55 |
$services = 'services_xml_antilles/';
|
|
|
56 |
$baseURL .= '&flore=ANT&';
|
|
|
57 |
$tab_champ['esd_nom_index'] = 'France antilles';
|
|
|
58 |
break;
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
$numclass = (isset($_POST['numclass'])) ? $_POST['numclass'] : 1;
|
|
|
62 |
switch ($recherche) {
|
|
|
63 |
case 'LATIN':
|
|
|
64 |
$xml = 'donnelistetaxons.php';
|
|
|
65 |
$xslt = 'listetaxons.xsl';
|
|
|
66 |
break;
|
|
|
67 |
case 'VERNA':
|
|
|
68 |
$xml = 'donnelistenomsvernaculaires.php';
|
|
|
69 |
$xslt = 'listenomsvernaculaires.xsl';
|
|
|
70 |
break;
|
|
|
71 |
}
|
|
|
72 |
(isset($_GET['servicexml'])) ? $xml = $_GET['servicexml'] : '';
|
|
|
73 |
(isset($_GET['xslt'])) ? $xslt = $_GET['xslt'] : '';
|
|
|
74 |
|
|
|
75 |
$radical = rawurlencode($radical);
|
|
|
76 |
$param = '?radical='.$radical;
|
|
|
77 |
if (!empty($numclass)) $param .= '&numclass='.$numclass;
|
|
|
78 |
if (!empty($numnom)) $param .= '&numnom='.$numnom;
|
|
|
79 |
if (!empty($paramxslt)) $param .= '¶mxslt='.$paramxslt;
|
|
|
80 |
if (!empty($profondeur)) $param .= '&profondeur='.$profondeur;
|
|
|
81 |
if (!empty($numtaxo)) $param .= '&numtaxo='.$numtaxo;
|
|
|
82 |
|
|
|
83 |
if (empty($eFlore_rangtaxomin)) $eFlore_rangtaxomin = '';
|
|
|
84 |
if (empty($eFlore_rangtaxomax)) $eFlore_rangtaxomax = '';
|
|
|
85 |
if (empty($eFlore_nommin)) $eFlore_nommin = '';
|
|
|
86 |
if (empty($eFlore_nommax)) $eFlore_nommax = '';
|
|
|
87 |
|
|
|
88 |
if ($eFlore_rangtaxomin == -1) { $eFlore_rangtaxomin = 0; }
|
|
|
89 |
if ($eFlore_rangtaxomax == -1) { $eFlore_rangtaxomax = 100000000; }
|
|
|
90 |
if ($eFlore_nommin == '') { $eFlore_nommin = 'aaaa'; }
|
|
|
91 |
if ($eFlore_nommax == '') { $eFlore_nommax = 'zzzz'; }
|
|
|
92 |
|
|
|
93 |
//$chemin_service_XML = "http://test.tela-botanica.org/modules/client/eflore/servicesxml/".$xml.$param;
|
|
|
94 |
$chemin_service_XML = 'http://eflore.tela-botanica.org/'.$services.$xml.$param;
|
|
|
95 |
|
|
|
96 |
//$chemin_service_XML = "http://".$HTTP_HOST."/".EF_PATH_SERVICES.$xml.$param;
|
|
|
97 |
|
|
|
98 |
$xsl = join('', file(EF_PATH_XSLT.$xslt));
|
|
|
99 |
$xml = join ('', file($chemin_service_XML));
|
|
|
100 |
|
|
|
101 |
$arguments = array(
|
|
|
102 |
'/_xml' => $xml,
|
|
|
103 |
'/_xsl' => $xsl
|
|
|
104 |
);
|
|
|
105 |
|
|
|
106 |
// Nom du fichier temporaire pdf
|
|
|
107 |
//include ("php/lib/lib.divers.php") ;
|
|
|
108 |
//$tmp_pdf = "eflore_pdf".create_new_random(5) ;
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
// Début pour PHP 4 avec utilisation de Sablotron
|
9 |
jp_milcent |
112 |
/*
|
2 |
jpm |
113 |
$xh = xslt_create();//Crée un nouvel analyseur XSLT.
|
|
|
114 |
xslt_set_encoding($xh,'ISO-8859-1');
|
|
|
115 |
$result = xslt_process($xh,'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
|
9 |
jp_milcent |
116 |
*/
|
2 |
jpm |
117 |
// Fin pour PHP 4
|
|
|
118 |
|
9 |
jp_milcent |
119 |
|
2 |
jpm |
120 |
// Début pour PHP 5
|
|
|
121 |
$inputDom = new DomDocument(); //Crée un nouvel analyseur XSLT.
|
|
|
122 |
$inputDom->load($chemin_service_XML);
|
|
|
123 |
|
|
|
124 |
$xsl = new DomDocument();
|
|
|
125 |
$xsl->load(EF_PATH_XSLT.$xslt);
|
|
|
126 |
|
|
|
127 |
$proc = new xsltprocessor();
|
|
|
128 |
$xsl = $proc->importStylesheet($xsl);
|
|
|
129 |
|
|
|
130 |
$result = $proc->transformToXML($inputDom);
|
|
|
131 |
// Fin PHP 5
|
9 |
jp_milcent |
132 |
|
2 |
jpm |
133 |
$result = ereg_replace ('transformer.php\?', $baseURL, $result) ;
|
|
|
134 |
//$result = ereg_replace ("pdf.php", $tmp_pdf.".php", $result) ;
|
|
|
135 |
if ($result) {
|
|
|
136 |
$res = $result;
|
|
|
137 |
$tab_champ['ESD_RESULTAT'] = 'ok';
|
|
|
138 |
} else {
|
|
|
139 |
// Début pour PHP 4 avec utilisation de Sablotron
|
9 |
jp_milcent |
140 |
//print 'Message d\'erreur XSLT: ' . xslt_error($xh) .//xslt_error -- Retourne le message d'erreur courant
|
|
|
141 |
//print ' avec le code : ' . xslt_errno($xh);//xslt_errno -- Retourne le numéro d'erreur courant
|
2 |
jpm |
142 |
// Fin pour PHP 4
|
|
|
143 |
$tab_champ['ESD_RESULTAT'] = 'ERREUR';
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
// Début pour PHP 4 avec utilisation de Sablotron
|
9 |
jp_milcent |
147 |
/*
|
2 |
jpm |
148 |
xslt_free($xh);//Détruit l'analyseur XSLT
|
9 |
jp_milcent |
149 |
*/
|
2 |
jpm |
150 |
// Fin pour PHP 4
|
|
|
151 |
|
|
|
152 |
// Début pour PHP 5
|
9 |
jp_milcent |
153 |
unset($xsl);//Détruit l'analyseur XSLT
|
|
|
154 |
unset($inputDom);
|
2 |
jpm |
155 |
// Fin pour PHP 5
|
|
|
156 |
|
|
|
157 |
//if ($servicexml == "donneidentitestaxons.php") {
|
|
|
158 |
// $xsl = join('', file(EF_PATH_XSLT.'identitetaxon_pdf.xsl'));
|
|
|
159 |
// $xml = join ('', file($chemin_service_XML));
|
|
|
160 |
// $xh = xslt_create() ;
|
|
|
161 |
// $arguments = array(
|
|
|
162 |
// '/_xml' => $xml,
|
|
|
163 |
// '/_xsl' => $xsl
|
|
|
164 |
// );
|
|
|
165 |
// $result = xslt_process($xh,'arg:/_xml', 'arg:/_xsl', NULL, $arguments) ;
|
|
|
166 |
// $result = ereg_replace("<", "<", $result) ;
|
|
|
167 |
// $result = ereg_replace(">", ">" , $result) ;
|
|
|
168 |
//$file_php = fopen("tmp/$tmp_pdf.php","w") ;
|
|
|
169 |
//fputs($file_php, $result) ;
|
|
|
170 |
// xslt_free($xh) ;
|
|
|
171 |
//}
|
|
|
172 |
|
|
|
173 |
?>
|
|
|
174 |
|