Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

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

<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.3                                                                                      |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of eFlore-consultation.                                                            |
// |                                                                                                      |
// | 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_recherche_taxonomie.inc.php,v 1.4 2005-06-30 15:24:26 jpm Exp $
/**
* Affichage du moteur de recherche taxonomique et de ses résultats.
*
* Ce script fournit le code html correspondant aux moteurs de recherche taxonomique (par projet) et ses 
* résultats.
*
*@package eFlore
//Auteur original :
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author        Aucun
*@copyright     Tela-Botanica 2000-2004
*@version       $Revision: 1.4 $ $Date: 2005-06-30 15:24:26 $
// +------------------------------------------------------------------------------------------------------+
*/

// +------------------------------------------------------------------------------------------------------+
// |                                            ENTÊTE du PROGRAMME                                       |
// +------------------------------------------------------------------------------------------------------+

function ajouterArboressenceClassif($arguments) {
    if (isset($GLOBALS['_EFLORE_']['classif'][$arguments[0]])) {
        $retour = $GLOBALS['_EFLORE_']['classif'][$arguments[0]];
        return $retour;
    }
    return '';
}

function remplacerUrlClassif($arguments) {
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_RECH_TAX);
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NT, $arguments[0]);
    $retour = $GLOBALS['_EFLORE_']['url']->getURL().'#eflore_taxon_'.$arguments[0];
    $GLOBALS['_EFLORE_']['url']->removeQueryString(EFLORE_LG_URL_ACTION);
    $GLOBALS['_EFLORE_']['url']->removeQueryString(EFLORE_LG_URL_NT);
    return $retour;
}

function remplacerInfoCommune(&$squelette) {
    $squelette->setCallbackFunction('ajouterArboressenceClassif', 'ajouterArboressenceClassif');
    $squelette->setCallbackFunction('remplacerUrlClassif', 'remplacerUrlClassif');
    $squelette->performCallback();
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_FICHE);
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ONGLET, EFLORE_LG_URL_ONGLET_SYNTHESE);
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NVP, $_REQUEST['eflore_projet']);
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NN, '');
    $squelette->setVariable('UrlFicheNom', $GLOBALS['_EFLORE_']['url']->getURL());
    $GLOBALS['_EFLORE_']['url']->removeQueryString(EFLORE_LG_URL_ACTION);
    $GLOBALS['_EFLORE_']['url']->removeQueryString(EFLORE_LG_URL_ONGLET);
    $GLOBALS['_EFLORE_']['url']->removeQueryString(EFLORE_LG_URL_NVP);
    $GLOBALS['_EFLORE_']['url']->removeQueryString(EFLORE_LG_URL_NN);
    return $squelette;
}

// +------------------------------------------------------------------------------------------------------+
// |                                            CORPS du PROGRAMME                                        |
// +------------------------------------------------------------------------------------------------------+
// Recherche sur les noms scientifiques
//$GLOBALS['_DEBOGAGE_'] .= '<pre>'.print_r($GLOBALS, true).'</pre>';
if (isset($_REQUEST['eflore_projet']) AND isset($_REQUEST['eflore_rang']) AND isset($_REQUEST['eflore_ordre'])) {
    if (!isset($_REQUEST['eflore_lettre'])) {
        $_REQUEST['eflore_lettre'] = 'A';
    }
    $url = sprintf(EFLORE_URL_FORM_TAXON_ALPHABET, rawurlencode($_REQUEST['eflore_projet']), rawurlencode($_REQUEST['eflore_rang']), rawurlencode($_REQUEST['eflore_ordre']), rawurlencode($_REQUEST['eflore_lettre']));
    $_SESSION['eflore_projet'] = $_REQUEST['eflore_projet'];
    $_SESSION['eflore_rang'] = $_REQUEST['eflore_rang'];
    $_SESSION['eflore_ordre'] = $_REQUEST['eflore_ordre'];
    $_SESSION['eflore_lettre'] = $_REQUEST['eflore_lettre'];
    $_SESSION['eflore_classif'] = array();
    $_SESSION['eflore_classif_chemin'] = '';
} else if (isset($_REQUEST[EFLORE_LG_URL_NT])) {
    $_REQUEST['eflore_projet'] = $_SESSION['eflore_projet'];
    $_REQUEST['eflore_rang'] = $_SESSION['eflore_rang'];
    $_REQUEST['eflore_ordre'] = $_SESSION['eflore_ordre'];
    $_REQUEST['eflore_lettre'] = $_SESSION['eflore_lettre'];
    $url = sprintf(EFLORE_URL_FORM_TAXON_ALPHABET, rawurlencode($_REQUEST['eflore_projet']), rawurlencode($_REQUEST['eflore_rang']), rawurlencode($_REQUEST['eflore_ordre']), rawurlencode($_REQUEST['eflore_lettre']));
} else {
    $url = EFLORE_URL_FORM_TAXON;
}

$contenu = file_get_contents($url);

//Analyse du squelette
require_once 'HTML/Template/IT.php';
$squelette = new HTML_Template_IT();
$squelette->setTemplate($contenu, FALSE, FALSE);

// Indique l'url pour obtenir fiche d'un nom
$squelette->setCurrentBlock('corps');
// Ajout du paramêtre action à l'url courante.
$GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_RECH_TAX);
$squelette->setVariable('UrlProjetTaxon', $GLOBALS['_EFLORE_']['url']->getURL());
$GLOBALS['_EFLORE_']['url']->removeQueryString(EFLORE_LG_URL_ACTION);
$squelette->parseCurrentBlock('corps');

// Récupère le bloc "corps"
$sortie .= $squelette->get('corps');

// --------------------------------------------------------------------------------------------------------
// Lancement de la recherche
if (isset($_REQUEST['eflore_taxonomie_submit'])) {
    //Constitution du chemin de navigation dans la classification
    if (isset($_REQUEST[EFLORE_LG_URL_NT])) {
        if (!isset($_SESSION['eflore_classif'][$_REQUEST[EFLORE_LG_URL_NT]])) {
            $_SESSION['eflore_classif_chemin'] .= $_REQUEST[EFLORE_LG_URL_NT].'>';
            $_SESSION['eflore_classif'][$_REQUEST[EFLORE_LG_URL_NT]] = $_REQUEST['eflore_projet'];
        }
    }
    if (!empty($_SESSION['eflore_classif_chemin'])) {
        $GLOBALS['_DEBOGAGE_'] .= $_SESSION['eflore_classif_chemin'].'<br/>';
        $tab_classif_chemin = array_reverse(explode('>', substr($_SESSION['eflore_classif_chemin'], 0, -1)));
        
        $GLOBALS['_EFLORE_']['classif'] = array();
        $GLOBALS['_DEBOGAGE_'] .= $tab_classif_chemin[0].'<br />';
        for ($i = 0; $i < count($tab_classif_chemin); $i++) {
            $url = sprintf(EFLORE_URL_LISTE_CLASSIF, rawurlencode($_SESSION['eflore_classif'][$tab_classif_chemin[$i]]), rawurlencode($tab_classif_chemin[$i]));
            $GLOBALS['_DEBOGAGE_'] .= $url.'<br />';
            $contenu = file_get_contents($url);
            //Analyse du squelette
            require_once 'HTML/Template/ITX.php';
            $squelette = new HTML_Template_ITX();
            $squelette->setTemplate($contenu, FALSE, FALSE);
            $squelette->setCurrentBlock('liste');
            $squelette =& remplacerInfoCommune($squelette);
            $squelette->parseCurrentBlock('liste');
            $GLOBALS['_EFLORE_']['classif'][$tab_classif_chemin[$i]] = $squelette->get('liste');
        }
    }
    
    // Recherche sur les taxons
    $url = sprintf(EFLORE_URL_LISTE_TAXON, rawurlencode($_REQUEST['eflore_projet']), rawurlencode($_REQUEST['eflore_rang']), rawurlencode($_REQUEST['eflore_ordre']), rawurlencode($_REQUEST['eflore_lettre']));
    $contenu = file_get_contents($url);
    
    //Analyse du squelette
    require_once 'HTML/Template/ITX.php';
    $squelette = new HTML_Template_ITX();
    $squelette->setTemplate($contenu, FALSE, FALSE);
    
    // Analyse du corps de la recherche
    $squelette->setCurrentBlock('corps');
    $squelette =& remplacerInfoCommune($squelette);
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NVP, $_REQUEST['eflore_projet']);
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_RG, $_REQUEST['eflore_rang']);
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_OD, $_REQUEST['eflore_ordre']);
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_LE, '');
    $squelette->setVariable('UrlRechercheTaxonAlphabet', $GLOBALS['_EFLORE_']['url']->getURL());
    $squelette->parseCurrentBlock('corps');
    
    // Récupère le bloc "corps"
    $sortie .= $squelette->get('corps');
}

/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.3  2005/02/15 13:00:51  jpm
* Ajout de la possibilité de naviguer dans la classification.
*
* Revision 1.2  2005/01/28 19:47:55  jpm
* Ajout de la recherche pour les taxons.
*
* Revision 1.1  2004/12/23 20:05:17  jpm
* Début prise en maine eflore-consultation.
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>