Subversion Repositories eFlore/Archives.eflore-consultation-v1

Rev

Rev 8 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: eflore_transfo_xslt.inc.php,v 1.1 2005-05-24 15:57:48 jpm Exp $
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
35
*@version       $Revision: 1.1 $ $Date: 2005-05-24 15:57:48 $
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 .= '&amp;flore=FRA&amp;';
47
        $tab_champ['esd_nom_index'] = 'France metropole';
48
        break;
49
    case 'REU':
50
        $services = 'services_xml_mascareignes/';
51
        $baseURL .= '&amp;flore=REU&amp;';
52
        $tab_champ['esd_nom_index'] = 'France mascareignes';
53
        break;
54
    case 'ANT':
55
        $services = 'services_xml_antilles/';
56
        $baseURL .= '&amp;flore=ANT&amp;';
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
//Nous recherchons le navigateur utilisé par le client. S'il s'agit de Netscape 4.x nous
75
//lui attribuons une nouvelle feuille xslt pour la fiche identité taxon.
76
$navigateur = get_browser($_SERVER['HTTP_USER_AGENT']);
77
if ( is_object($navigateur) && $navigateur->browser == 'Netscape' && $navigateur->majorver == '4' && $xslt == 'identitetaxon.xsl') {
78
    $xslt = 'identitetaxon_nn4.xsl';
79
}
80
 
81
$radical = rawurlencode($radical);
82
$param = '?radical='.$radical;
83
if (!empty($numclass)) $param .= '&numclass='.$numclass;
84
if (!empty($numnom)) $param .= '&numnom='.$numnom;
85
if (!empty($paramxslt)) $param .= '&paramxslt='.$paramxslt;
86
if (!empty($profondeur)) $param .= '&profondeur='.$profondeur;
87
if (!empty($numtaxo)) $param .= '&numtaxo='.$numtaxo;
88
 
89
if (empty($eFlore_rangtaxomin)) $eFlore_rangtaxomin = '';
90
if (empty($eFlore_rangtaxomax)) $eFlore_rangtaxomax = '';
91
if (empty($eFlore_nommin)) $eFlore_nommin = '';
92
if (empty($eFlore_nommax)) $eFlore_nommax = '';
93
 
94
if ($eFlore_rangtaxomin == -1) { $eFlore_rangtaxomin = 0; }
95
if ($eFlore_rangtaxomax == -1) { $eFlore_rangtaxomax = 100000000; }
96
if ($eFlore_nommin == '') { $eFlore_nommin = 'aaaa'; }
97
if ($eFlore_nommax == '') { $eFlore_nommax = 'zzzz'; }
98
 
99
//$chemin_service_XML = "http://test.tela-botanica.org/modules/client/eflore/servicesxml/".$xml.$param;
100
$chemin_service_XML = 'http://eflore.tela-botanica.org/'.$services.$xml.$param;
101
 
102
//$chemin_service_XML = "http://".$HTTP_HOST."/".EF_PATH_SERVICES.$xml.$param;
103
 
104
$xsl = join('', file(EF_PATH_XSLT.$xslt));
105
$xml = join ('', file($chemin_service_XML));
106
 
107
$arguments = array(
108
     '/_xml' => $xml,
109
     '/_xsl' => $xsl
110
    );
111
 
112
// Nom du fichier temporaire pdf
113
//include ("php/lib/lib.divers.php") ;
114
//$tmp_pdf = "eflore_pdf".create_new_random(5) ;
115
 
116
 
117
// Début pour PHP 4 avec utilisation de Sablotron
118
$xh = xslt_create();//Crée un nouvel analyseur XSLT.
119
xslt_set_encoding($xh,'ISO-8859-1');
120
$result = xslt_process($xh,'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
121
// Fin pour PHP 4
122
 
123
/*
124
// Début pour PHP 5
125
$inputDom = new DomDocument(); //Crée un nouvel analyseur XSLT.
126
$inputDom->load($chemin_service_XML);
127
 
128
$xsl = new DomDocument();
129
$xsl->load(EF_PATH_XSLT.$xslt);
130
 
131
$proc = new xsltprocessor();
132
$xsl = $proc->importStylesheet($xsl);
133
 
134
$result = $proc->transformToXML($inputDom);
135
// Fin PHP 5
136
*/
137
$result = ereg_replace ('transformer.php\?', $baseURL, $result) ;
138
//$result = ereg_replace ("pdf.php", $tmp_pdf.".php", $result) ;
139
if ($result) {
140
    $res = $result;
141
    $tab_champ['ESD_RESULTAT'] = 'ok';
142
} else {
143
    // Début pour PHP 4 avec utilisation de Sablotron
144
    print 'Message d\'erreur XSLT: ' . xslt_error($xh) .//xslt_error -- Retourne le message d'erreur courant
145
    print ' avec le code : ' . xslt_errno($xh);//xslt_errno -- Retourne le numéro d'erreur courant
146
    // Fin pour PHP 4
147
    $tab_champ['ESD_RESULTAT'] = 'ERREUR';
148
}
149
 
150
// Début pour PHP 4 avec utilisation de Sablotron
151
xslt_free($xh);//Détruit l'analyseur XSLT
152
// Fin pour PHP 4
153
 
154
// Début pour PHP 5
155
//unset($xsl);//Détruit l'analyseur XSLT
156
//unset($inputDom);
157
// Fin pour PHP 5
158
 
159
//if ($servicexml == "donneidentitestaxons.php") {
160
//    $xsl = join('', file(EF_PATH_XSLT.'identitetaxon_pdf.xsl'));
161
//    $xml = join ('', file($chemin_service_XML));
162
//    $xh = xslt_create() ;
163
//    $arguments = array(
164
//        '/_xml' => $xml,
165
//        '/_xsl' => $xsl
166
//    );
167
//    $result = xslt_process($xh,'arg:/_xml', 'arg:/_xsl', NULL, $arguments) ;
168
//    $result = ereg_replace("&lt;", "<", $result) ;
169
//    $result = ereg_replace("&gt;", ">" , $result) ;
170
//$file_php = fopen("tmp/$tmp_pdf.php","w") ;
171
//fputs($file_php, $result) ;
172
//    xslt_free($xh) ;
173
//}
174
 
175
?>
176