Subversion Repositories eFlore/Archives.eflore-consultation-v1

Rev

Rev 8 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1                                                                                      |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org)                                         |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of Integrateur eFlore.                                                             |
// |                                                                                                      |
// | Foobar is free software; you can redistribute it and/or modify                                       |
// | it under the terms of the GNU General Public License as published by                                 |
// | the Free Software Foundation; either version 2 of the License, or                                    |
// | (at your option) any later version.                                                                  |
// |                                                                                                      |
// | Foobar is distributed in the hope that it will be useful,                                            |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
// | GNU General Public License for more details.                                                         |
// |                                                                                                      |
// | You should have received a copy of the GNU General Public License                                    |
// | along with Foobar; if not, write to the Free Software                                                |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: eflore_transfo_xslt.inc.php,v 1.3 2005-11-18 15:14:39 jp_milcent Exp $
/**
* Réalisation de la transfo XSL du XML d'eFlore.
*
*@package eFlore
*@subpackage Ancien
//Auteur original :
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author        Aucun
*@copyright     Tela-Botanica 2000-2005
*@version       $Revision: 1.3 $ $Date: 2005-11-18 15:14:39 $
// +------------------------------------------------------------------------------------------------------+
*/

// +------------------------------------------------------------------------------------------------------+
// |                                            ENTETE du PROGRAMME                                       |
// +------------------------------------------------------------------------------------------------------+
// Récupération des valeurs du formulaire
switch ($flore) {
    case 'FRA':
        $services = 'servicesxml/';
        $baseURL .= '&amp;flore=FRA&amp;';
        $tab_champ['esd_nom_index'] = 'France metropole';
        break;
    case 'REU':
        $services = 'services_xml_mascareignes/';
        $baseURL .= '&amp;flore=REU&amp;';
        $tab_champ['esd_nom_index'] = 'France mascareignes';
        break;
    case 'ANT':
        $services = 'services_xml_antilles/';
        $baseURL .= '&amp;flore=ANT&amp;';
        $tab_champ['esd_nom_index'] = 'France antilles';
        break;
}

$numclass = (isset($_POST['numclass'])) ? $_POST['numclass'] : 1;
switch ($recherche) {
    case 'LATIN':
        $xml  = 'donnelistetaxons.php';
        $xslt = 'listetaxons.xsl';
        break;
    case 'VERNA':
        $xml  = 'donnelistenomsvernaculaires.php';
        $xslt = 'listenomsvernaculaires.xsl';
        break;
}
(isset($_GET['servicexml'])) ? $xml = $_GET['servicexml'] : '';
(isset($_GET['xslt'])) ? $xslt = $_GET['xslt'] : '';

$radical = rawurlencode($radical);
$param = '?radical='.$radical;
if (!empty($numclass)) $param .= '&numclass='.$numclass;
if (!empty($numnom)) $param .= '&numnom='.$numnom;
if (!empty($paramxslt)) $param .= '&paramxslt='.$paramxslt;
if (!empty($profondeur)) $param .= '&profondeur='.$profondeur;
if (!empty($numtaxo)) $param .= '&numtaxo='.$numtaxo;

if (empty($eFlore_rangtaxomin)) $eFlore_rangtaxomin = '';
if (empty($eFlore_rangtaxomax)) $eFlore_rangtaxomax = '';
if (empty($eFlore_nommin)) $eFlore_nommin = '';
if (empty($eFlore_nommax)) $eFlore_nommax = '';

if ($eFlore_rangtaxomin == -1) { $eFlore_rangtaxomin = 0; }
if ($eFlore_rangtaxomax == -1) { $eFlore_rangtaxomax = 100000000; }
if ($eFlore_nommin == '') { $eFlore_nommin = 'aaaa'; }
if ($eFlore_nommax == '') { $eFlore_nommax = 'zzzz'; }

//$chemin_service_XML = "http://test.tela-botanica.org/modules/client/eflore/servicesxml/".$xml.$param;
$chemin_service_XML = 'http://eflore.tela-botanica.org/'.$services.$xml.$param;

//$chemin_service_XML = "http://".$HTTP_HOST."/".EF_PATH_SERVICES.$xml.$param;

$xsl = join('', file(EF_PATH_XSLT.$xslt));
$xml = join ('', file($chemin_service_XML));

$arguments = array(
     '/_xml' => $xml,
     '/_xsl' => $xsl
    );

// Nom du fichier temporaire pdf
//include ("php/lib/lib.divers.php") ;
//$tmp_pdf = "eflore_pdf".create_new_random(5) ;


// Début pour PHP 4 avec utilisation de Sablotron
/*
$xh = xslt_create();//Crée un nouvel analyseur XSLT.
xslt_set_encoding($xh,'ISO-8859-1');
$result = xslt_process($xh,'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
*/
// Fin pour PHP 4


// Début pour PHP 5
$inputDom = new DomDocument(); //Crée un nouvel analyseur XSLT.
$inputDom->load($chemin_service_XML);

$xsl = new DomDocument();
$xsl->load(EF_PATH_XSLT.$xslt);

$proc = new xsltprocessor();
$xsl = $proc->importStylesheet($xsl);

$result = $proc->transformToXML($inputDom);
// Fin PHP 5

$result = ereg_replace ('transformer.php\?', $baseURL, $result) ;
//$result = ereg_replace ("pdf.php", $tmp_pdf.".php", $result) ;
if ($result) {
    $res = $result;
    $tab_champ['ESD_RESULTAT'] = 'ok';
} else {
    // Début pour PHP 4 avec utilisation de Sablotron
    //print 'Message d\'erreur XSLT: ' . xslt_error($xh) .//xslt_error -- Retourne le message d'erreur courant
    //print ' avec le code : ' . xslt_errno($xh);//xslt_errno -- Retourne le numéro d'erreur courant
    // Fin pour PHP 4
    $tab_champ['ESD_RESULTAT'] = 'ERREUR';
}
 
// Début pour PHP 4 avec utilisation de Sablotron
/*
xslt_free($xh);//Détruit l'analyseur XSLT
*/
// Fin pour PHP 4

// Début pour PHP 5
unset($xsl);//Détruit l'analyseur XSLT
unset($inputDom);
// Fin pour PHP 5

//if ($servicexml == "donneidentitestaxons.php") {
//    $xsl = join('', file(EF_PATH_XSLT.'identitetaxon_pdf.xsl'));
//    $xml = join ('', file($chemin_service_XML));
//    $xh = xslt_create() ;
//    $arguments = array(
//        '/_xml' => $xml,
//        '/_xsl' => $xsl
//    );
//    $result = xslt_process($xh,'arg:/_xml', 'arg:/_xsl', NULL, $arguments) ;
//    $result = ereg_replace("&lt;", "<", $result) ;
//    $result = ereg_replace("&gt;", ">" , $result) ;
//$file_php = fopen("tmp/$tmp_pdf.php","w") ;
//fputs($file_php, $result) ;
//    xslt_free($xh) ;
//}

?>