Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Rev 168 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
59 jpm 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.3                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This file is part of eFlore-consultation.                                                            |
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
// +------------------------------------------------------------------------------------------------------+
171 jpm 24
// CVS : $Id: eflore_recherche_nomenclature.inc.php,v 1.11 2005-06-09 18:10:25 jpm Exp $
59 jpm 25
/**
26
* Affichage du moteur de recherche nomenclatural et de ses résultats.
27
*
28
* Ce script fournit le code html correspondant aux moteurs de recherche nomenclatural et ses résultats.
29
*
30
*@package eFlore
31
//Auteur original :
32
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
33
//Autres auteurs :
34
*@author        Aucun
35
*@copyright     Tela-Botanica 2000-2004
171 jpm 36
*@version       $Revision: 1.11 $ $Date: 2005-06-09 18:10:25 $
59 jpm 37
// +------------------------------------------------------------------------------------------------------+
38
*/
39
 
40
// +------------------------------------------------------------------------------------------------------+
41
// |                                            ENTÊTE du PROGRAMME                                       |
42
// +------------------------------------------------------------------------------------------------------+
171 jpm 43
// Gestion de la session pour le nom
44
if (isset($_SESSION['eflore_nom']) ) {
45
    if (isset($_REQUEST['eflore_nom']) AND $_SESSION['eflore_nom'] != $_REQUEST['eflore_nom']) {
46
        $_SESSION['eflore_nom'] = $_REQUEST['eflore_nom'];
47
    }
48
} else {
49
    if (isset($_REQUEST['eflore_nom'])) {
50
        $_SESSION['eflore_nom'] = $_REQUEST['eflore_nom'];
51
    } else {
52
        $_SESSION['eflore_nom'] = '';
53
    }
127 jpm 54
}
171 jpm 55
// Gestion de la session pour le référenciel
56
if (isset($_SESSION['eflore_referenciel']) ) {
57
    if (isset($_REQUEST['eflore_referenciel']) AND $_SESSION['eflore_referenciel'] != $_REQUEST['eflore_referenciel']) {
58
        $_SESSION['eflore_referenciel'] = $_REQUEST['eflore_referenciel'];
59
    }
60
} else {
61
    if (isset($_REQUEST['eflore_referenciel'])) {
62
        $_SESSION['eflore_referenciel'] = $_REQUEST['eflore_referenciel'];
63
    } else {
64
        $_SESSION['eflore_referenciel'] = 3;
65
    }
66
}
67
// Gestion de la session pour le type du nom
68
if (isset($_SESSION['eflore_type_nom']) ) {
69
    if (isset($_REQUEST['eflore_type_nom']) AND $_REQUEST['eflore_type_nom'] == 'nom_scientifique') {
70
        $_SESSION['eflore_type_nom_scientifique'] = 'checked="checked"';
71
        $_SESSION['eflore_type_nom_vernaculaire'] = '';
72
    } elseif (isset($_REQUEST['eflore_type_nom']) AND $_REQUEST['eflore_type_nom'] == 'nom_vernaculaire') {
73
        $_SESSION['eflore_type_nom_vernaculaire'] = 'checked="checked"';
74
        $_SESSION['eflore_type_nom_scientifique'] = '';
75
    }
76
} else {
77
    if (isset($_REQUEST['eflore_type_nom']) AND $_REQUEST['eflore_type_nom'] == 'nom_scientifique') {
78
        $_SESSION['eflore_type_nom_scientifique'] = 'checked="checked"';
79
        $_SESSION['eflore_type_nom_vernaculaire'] = '';
80
    } elseif (isset($_REQUEST['eflore_type_nom']) AND $_REQUEST['eflore_type_nom'] == 'nom_vernaculaire') {
81
        $_SESSION['eflore_type_nom_vernaculaire'] = 'checked="checked"';
82
        $_SESSION['eflore_type_nom_scientifique'] = '';
83
    } else {
84
        $_SESSION['eflore_type_nom_scientifique'] = 'checked="checked"';
85
        $_SESSION['eflore_type_nom_vernaculaire'] = '';
86
    }
87
}
59 jpm 88
// +------------------------------------------------------------------------------------------------------+
89
// |                                            CORPS du PROGRAMME                                        |
90
// +------------------------------------------------------------------------------------------------------+
91
// Création du formulaire
60 jpm 92
// Ajout du paramêtre action à l'url courante.
93
$GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_RECH_NOM);
171 jpm 94
$contenu = file_get_contents(EFLORE_URL_FORM_NOM);
59 jpm 95
 
171 jpm 96
//Analyse du squelette
97
require_once 'HTML/Template/ITX.php';
98
$squelette = new HTML_Template_ITX();
99
$squelette->setTemplate($contenu, FALSE, FALSE);
59 jpm 100
 
171 jpm 101
// Indique l'url pour obtenir fiche d'un nom
102
$squelette->setCurrentBlock('corps');
103
// Ajout du paramêtre action à l'url courante.
104
$GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_RECH_NOM);
105
$squelette->setVariable('UrlProjetNom', $GLOBALS['_EFLORE_']['url']->getURL());
106
$GLOBALS['_EFLORE_']['url']->removeQueryString(EFLORE_LG_URL_ACTION);
107
// Valeur du champ nom par défaut
108
$squelette->setVariable('eflore_nom', $_SESSION['eflore_nom']);
109
// Type nom scientifique coché par défaut
110
$squelette->setVariable('eflore_type_nom_scientifique', $_SESSION['eflore_type_nom_scientifique']);
111
// Type nom verna non coché par défaut
112
$squelette->setVariable('eflore_type_nom_vernaculaire', $_SESSION['eflore_type_nom_vernaculaire']);
113
// Référentiel sélectionné par défaut
114
$squelette->setCallbackFunction('selectionnerEfloreRef', 'selectionnerEfloreRef');
115
$squelette->performCallback();
116
$squelette->parseCurrentBlock('corps');
59 jpm 117
 
171 jpm 118
// Récupère le bloc "corps"
119
$sortie .= $squelette->get('corps');
59 jpm 120
 
60 jpm 121
// --------------------------------------------------------------------------------------------------------
122
// Lancement de la recherche
127 jpm 123
if (isset($_REQUEST['eflore_nom']) && $_REQUEST['eflore_nom'] != '' && !eregi("^%{1,}$", $_REQUEST['eflore_nom']) ) {
124
    // Formatage de la chaine à rechercher
125
    $_REQUEST['eflore_nom'] = '%'.str_replace(' ', '%', $_REQUEST['eflore_nom']).'%';
60 jpm 126
    if ($_REQUEST['eflore_type_nom'] == 'nom_scientifique') {
127
        // Recherche sur les noms scientifiques
171 jpm 128
        if ($_REQUEST['eflore_referenciel'] != 0) {
129
            $contenu = file_get_contents(sprintf(EFLORE_URL_LISTE_NOM_LATIN_REF, rawurlencode($_REQUEST['eflore_nom']), rawurlencode($_REQUEST['eflore_referenciel'])));
130
        } else {
131
            $contenu = file_get_contents(sprintf(EFLORE_URL_LISTE_NOM_LATIN, rawurlencode($_REQUEST['eflore_nom'])));
132
        }
60 jpm 133
        //Analyse du squelette
171 jpm 134
        require_once 'HTML/Template/ITX.php';
135
        $squelette = new HTML_Template_ITX();
127 jpm 136
        $squelette->setTemplate($contenu, FALSE, FALSE);
60 jpm 137
 
138
        // Indique l'url pour obtenir fiche d'un nom
139
        $squelette->setCurrentBlock('corps');
140
        // Ajout du paramêtre action à l'url courante.
141
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_FICHE);
142
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ONGLET, EFLORE_LG_URL_ONGLET_SYNTHESE);
143
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NN, '');
144
        $squelette->setVariable('UrlFicheNom', $GLOBALS['_EFLORE_']['url']->getURL());
171 jpm 145
        $squelette->setCallbackFunction('UrlFicheNom', 'remplacerUrlFicheNom');
146
        $squelette->performCallback();
60 jpm 147
        $squelette->parseCurrentBlock('corps');
148
 
149
        // Récupère le bloc "corps"
127 jpm 150
        $sortie .= $squelette->get('corps');
60 jpm 151
    } else if ($_REQUEST['eflore_type_nom'] == 'nom_vernaculaire') {
152
        // Recherche sur les noms vernaculaires
127 jpm 153
        $contenu = file_get_contents(sprintf(EFLORE_URL_LISTE_NOM_VERNA, rawurlencode($_REQUEST['eflore_nom'])));
60 jpm 154
 
127 jpm 155
        //Analyse du squelette
156
        require_once 'HTML/Template/ITX.php';
157
        $squelette = new HTML_Template_ITX();
158
        $squelette->setTemplate($contenu, FALSE, FALSE);
159
 
160
        // Indique l'url pour obtenir fiche d'un nom
161
        $squelette->setCurrentBlock('corps');
162
        $squelette->setCallbackFunction('UrlFicheNom', 'remplacerUrlFicheNom');
163
        $squelette->performCallback();
164
        $squelette->parseCurrentBlock('corps');
165
 
166
        // Récupère le bloc "corps"
167
        $sortie .= $squelette->get('corps');
168
 
60 jpm 169
    }
170
}
171
 
171 jpm 172
// +------------------------------------------------------------------------------------------------------+
173
// |                                            LISTE des FONCTIONS                                       |
174
// +------------------------------------------------------------------------------------------------------+
175
 
176
function remplacerUrlFicheNom($arguments) {
177
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_FICHE);
178
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ONGLET, EFLORE_LG_URL_ONGLET_SYNTHESE);
179
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NN, $arguments[0]);
180
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NVP, $arguments[1]);
181
    return $GLOBALS['_EFLORE_']['url']->getURL();
182
}
183
function selectionnerEfloreRef($arguments) {
184
    $retour = '';
185
    if (isset($arguments[0]) AND $arguments[0] == $_SESSION['eflore_referenciel']) {// N° de la version par défaut de la BDNFF
186
        $retour = 'selected="selected"';
187
    }
188
    return $retour;
189
}
190
 
59 jpm 191
/* +--Fin du code ----------------------------------------------------------------------------------------+
192
*
193
* $Log: not supported by cvs2svn $
171 jpm 194
* Revision 1.10  2005/05/19 07:40:06  jpm
195
* Modification mineure syntaxe.
196
*
168 jpm 197
* Revision 1.9  2005/03/15 12:57:16  jpm
198
* Modification du code XHTML.
199
*
162 jpm 200
* Revision 1.8  2005/02/28 15:38:47  jpm
201
* Correction erreur due à un changement de nom.
202
*
159 jpm 203
* Revision 1.7  2005/02/23 12:39:27  jpm
204
* Correction bogue lié à QuickForm.
205
*
156 jpm 206
* Revision 1.6  2005/02/22 19:27:10  jpm
207
* Changement de nom de variables.
208
* Suppression de l'attribut nam de la balise form via une méthode de HTML_Common.
209
*
155 jpm 210
* Revision 1.5  2005/02/22 17:43:53  jpm
211
* Suppression de référence posant problème.
212
*
154 jpm 213
* Revision 1.4  2005/02/15 13:00:23  jpm
214
* Ajout d'un test pour initialiser une variable.
215
*
149 jpm 216
* Revision 1.3  2005/01/28 19:47:55  jpm
217
* Ajout de la recherche pour les taxons.
218
*
127 jpm 219
* Revision 1.2  2005/01/03 19:44:40  jpm
220
* Ajout de la gestion de l'action "fiche".
221
*
60 jpm 222
* Revision 1.1  2004/12/23 20:05:17  jpm
223
* Début prise en maine eflore-consultation.
59 jpm 224
*
60 jpm 225
*
59 jpm 226
* +-- Fin du code ----------------------------------------------------------------------------------------+
227
*/
228
?>