Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Rev 156 | Rev 162 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 159
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.3                                                                                      |
4
// | PHP version 4.3                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This file is part of eFlore-consultation.                                                            |
8
// | This file is part of eFlore-consultation.                                                            |
9
// |                                                                                                      |
9
// |                                                                                                      |
10
// | Foobar is free software; you can redistribute it and/or modify                                       |
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                                 |
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                                    |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
13
// | (at your option) any later version.                                                                  |
13
// | (at your option) any later version.                                                                  |
14
// |                                                                                                      |
14
// |                                                                                                      |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
18
// | GNU General Public License for more details.                                                         |
18
// | GNU General Public License for more details.                                                         |
19
// |                                                                                                      |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: eflore_recherche_nomenclature.inc.php,v 1.7 2005-02-23 12:39:27 jpm Exp $
24
// CVS : $Id: eflore_recherche_nomenclature.inc.php,v 1.8 2005-02-28 15:38:47 jpm Exp $
25
/**
25
/**
26
* Affichage du moteur de recherche nomenclatural et de ses résultats.
26
* Affichage du moteur de recherche nomenclatural et de ses résultats.
27
*
27
*
28
* Ce script fournit le code html correspondant aux moteurs de recherche nomenclatural et ses résultats.
28
* Ce script fournit le code html correspondant aux moteurs de recherche nomenclatural et ses résultats.
29
*
29
*
30
*@package eFlore
30
*@package eFlore
31
//Auteur original :
31
//Auteur original :
32
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
32
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
33
//Autres auteurs :
33
//Autres auteurs :
34
*@author        Aucun
34
*@author        Aucun
35
*@copyright     Tela-Botanica 2000-2004
35
*@copyright     Tela-Botanica 2000-2004
36
*@version       $Revision: 1.7 $ $Date: 2005-02-23 12:39:27 $
36
*@version       $Revision: 1.8 $ $Date: 2005-02-28 15:38:47 $
37
// +------------------------------------------------------------------------------------------------------+
37
// +------------------------------------------------------------------------------------------------------+
38
*/
38
*/
39
 
39
 
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
41
// |                                            ENTÊTE du PROGRAMME                                       |
41
// |                                            ENTÊTE du PROGRAMME                                       |
42
// +------------------------------------------------------------------------------------------------------+
42
// +------------------------------------------------------------------------------------------------------+
43
 
43
 
44
function remplacerUrlFicheNom($arguments) {
44
function remplacerUrlFicheNom($arguments) {
45
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_FICHE);
45
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_FICHE);
46
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ONGLET, EFLORE_LG_URL_ONGLET_SYNTHESE);
46
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ONGLET, EFLORE_LG_URL_ONGLET_SYNTHESE);
47
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NN, $arguments[0]);
47
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NN, $arguments[0]);
48
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NVP, $arguments[1]);
48
    $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NVP, $arguments[1]);
49
    return $GLOBALS['_EFLORE_']['url']->getURL();
49
    return $GLOBALS['_EFLORE_']['url']->getURL();
50
}
50
}
51
 
51
 
52
// +------------------------------------------------------------------------------------------------------+
52
// +------------------------------------------------------------------------------------------------------+
53
// |                                            CORPS du PROGRAMME                                        |
53
// |                                            CORPS du PROGRAMME                                        |
54
// +------------------------------------------------------------------------------------------------------+
54
// +------------------------------------------------------------------------------------------------------+
55
$sortie .= '<h2>'.EFLORE_LG_RECH_NOM_TITRE.'</h2>';
55
$sortie .= '<h2>'.EFLORE_LG_RECH_NOM_TITRE.'</h2>';
56
 
56
 
57
// --------------------------------------------------------------------------------------------------------
57
// --------------------------------------------------------------------------------------------------------
58
// Création du formulaire
58
// Création du formulaire
59
$sortie .= '<ul>';
59
$sortie .= '<ul>';
60
// Ajout du paramêtre action à l'url courante.
60
// Ajout du paramêtre action à l'url courante.
61
$GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_RECH_NOM);
61
$GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_RECH_NOM);
62
// Notes : Quickform semble remplacer les & des &amp; à nouveau par des &amp; solution utiliser str_replace()...
62
// Notes : Quickform semble remplacer les & des &amp; à nouveau par des &amp; solution utiliser str_replace()...
63
$eflore_form = new HTML_QuickForm('eflore_form_nomenclature', 'post', str_replace('&amp;', '&', $GLOBALS['_EFLORE_']['url']->getUrl()));
63
$eflore_form = new HTML_QuickForm('eflore_form_nomenclature', 'post', str_replace('&amp;', '&', $GLOBALS['_EFLORE_']['url']->getUrl()));
64
$tab_index = EFLORE_RECH_NOM_FORM_TAB;
64
$tab_index = EFLORE_RECH_NOM_FORM_TAB;
65
$eflore_squelette =& $eflore_form->defaultRenderer();
65
$eflore_squelette =& $eflore_form->defaultRenderer();
66
$eflore_squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'{content}'."\n".'</form>');
66
$eflore_squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'{content}'."\n".'</form>');
67
$eflore_squelette->setElementTemplate( '<li>'."\n".
67
$eflore_squelette->setElementTemplate( '<li>'."\n".
68
                                '{label}'."\n".
68
                                '{label}'."\n".
69
                                '{element}'."\n".
69
                                '{element}'."\n".
70
                                '<!-- BEGIN required --><span class="symbole_obligatoire">'.EFLORE_LG_FORM_SYMBOLE_OBLIGATOIRE.'</span><!-- END required -->'."\n".
70
                                '<!-- BEGIN required --><span class="symbole_obligatoire">'.EFLORE_LG_FORM_SYMBOLE_OBLIGATOIRE.'</span><!-- END required -->'."\n".
71
                                '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
71
                                '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
72
                                '</li>'."\n");
72
                                '</li>'."\n");
73
$eflore_form->accept($eflore_squelette);
73
$eflore_form->accept($eflore_squelette);
74
$eflore_form->removeAttribute('name');
74
$eflore_form->removeAttribute('name');
75
 
75
 
76
$partie_menu_debut = '<fieldset>'."\n".'<legend>'.EFLORE_LG_RECH_NOM_FORM_TITRE.'</legend>'."\n";
76
$partie_menu_debut = '<fieldset>'."\n".'<legend>'.EFLORE_LG_RECH_NOM_FORM_TITRE.'</legend>'."\n";
77
$eflore_form->addElement('html', $partie_menu_debut);
77
$eflore_form->addElement('html', $partie_menu_debut);
78
 
78
 
79
$id = 'eflore_nom';
79
$id = 'eflore_nom';
80
$aso_attributs = array( 'id'=>$id, 'class' => 'champ', 'tabindex' => $tab_index++, 
80
$aso_attributs = array( 'id'=>$id, 'class' => 'champ', 'tabindex' => $tab_index++, 
81
                        'size' => EFLORE_RECH_NOM_FORM_NOM_SIZE, 
81
                        'size' => EFLORE_RECH_NOM_FORM_NOM_SIZE, 
82
                        'maxlength' => EFLORE_RECH_NOM_FORM_NOM_MAXLENGTH,
82
                        'maxlength' => EFLORE_RECH_NOM_FORM_NOM_MAXLENGTH,
83
                        'onclick' => "javascript: this.value='';");
83
                        'onclick' => "javascript: this.value='';");
84
$label = '<label for="'.$id.'">'.EFLORE_LG_RECH_NOM_FORM_NOM.'</label>';
84
$label = '<label for="'.$id.'">'.EFLORE_LG_RECH_NOM_FORM_NOM.'</label>';
85
$eflore_form->addElement('text', $id, $label, $aso_attributs);
85
$eflore_form->addElement('text', $id, $label, $aso_attributs);
86
 
86
 
87
$liste_type_nom_debut = '<ul>'."\n";
87
$liste_type_nom_debut = '<ul>'."\n";
88
$eflore_form->addElement('html', $liste_type_nom_debut);
88
$eflore_form->addElement('html', $liste_type_nom_debut);
89
 
89
 
90
$id = 'eflore_type_nom';
90
$id = 'eflore_type_nom';
91
$valeur = 'nom_scientifique';
91
$valeur = 'nom_scientifique';
92
$aso_attributs = array( 'id'=> $id, 'tabindex' => $tab_index++);
92
$aso_attributs = array( 'id'=> $id, 'tabindex' => $tab_index++);
93
$label = '';
93
$label = '';
94
$eflore_form->addElement('radio', $id, $label, EFLORE_LG_RECH_NOM_FORM_TYPE_NOM_SCI, $valeur, $aso_attributs);
94
$eflore_form->addElement('radio', $id, $label, EFLORE_LG_RECH_NOM_FORM_TYPE_NOM_SCI, $valeur, $aso_attributs);
95
 
95
 
96
$valeur = 'nom_vernaculaire';
96
$valeur = 'nom_vernaculaire';
97
$aso_attributs = array( 'id'=> $id, 'tabindex' => $tab_index++);
97
$aso_attributs = array( 'id'=> $id, 'tabindex' => $tab_index++);
98
$label = '';
98
$label = '';
99
$eflore_form->addElement('radio', $id, $label, EFLORE_LG_RECH_NOM_FORM_TYPE_NOM_VER, $valeur, $aso_attributs);
99
$eflore_form->addElement('radio', $id, $label, EFLORE_LG_RECH_NOM_FORM_TYPE_NOM_VER, $valeur, $aso_attributs);
100
if (isset($_REQUEST[$id])) {
100
if (isset($_REQUEST[$id])) {
101
    switch ($_REQUEST[$id]) {
101
    switch ($_REQUEST[$id]) {
102
        case 'nom_scientifique':
102
        case 'nom_scientifique':
103
            $form->setDefaults(array($id => 'nom_scientifique'));
103
            $eflore_form->setDefaults(array($id => 'nom_scientifique'));
104
            break;
104
            break;
105
        case 'nom_vernaculaire':
105
        case 'nom_vernaculaire':
106
            $form->setDefaults(array($id => 'nom_vernaculaire'));
106
            $eflore_form->setDefaults(array($id => 'nom_vernaculaire'));
107
            break;
107
            break;
108
    }
108
    }
109
} else {
109
} else {
110
    $eflore_form->setDefaults(array($id => 'nom_scientifique'));
110
    $eflore_form->setDefaults(array($id => 'nom_scientifique'));
111
}
111
}
112
 
112
 
113
$liste_type_nom_fin = '</ul>'."\n";
113
$liste_type_nom_fin = '</ul>'."\n";
114
$eflore_form->addElement('html', $liste_type_nom_fin);
114
$eflore_form->addElement('html', $liste_type_nom_fin);
115
 
115
 
116
$id = 'eflore_valider_nom';
116
$id = 'eflore_valider_nom';
117
$aso_attributs = array('id'=> $id, 'class' => 'champ', 'tabindex' => $tab_index++);
117
$aso_attributs = array('id'=> $id, 'class' => 'champ', 'tabindex' => $tab_index++);
118
$eflore_form->addElement('submit', $id, EFLORE_LG_RECH_NOM_FORM_VALIDER, $aso_attributs);
118
$eflore_form->addElement('submit', $id, EFLORE_LG_RECH_NOM_FORM_VALIDER, $aso_attributs);
119
 
119
 
120
$partie_entete_fin = "\n".'</fieldset>';
120
$partie_entete_fin = "\n".'</fieldset>';
121
$eflore_form->addElement('html', $partie_entete_fin);
121
$eflore_form->addElement('html', $partie_entete_fin);
122
 
122
 
123
// Instanciation avec les valeur par défaut
123
// Instanciation avec les valeur par défaut
124
if (isset($_SESSION['_EFLORE_']['rechercher'])) {
124
if (isset($_SESSION['_EFLORE_']['rechercher'])) {
125
    $eflore_form->setDefaults($_SESSION['_EFLORE_']['rechercher']);
125
    $eflore_form->setDefaults($_SESSION['_EFLORE_']['rechercher']);
126
}
126
}
127
 
127
 
128
// Transformation en XHTML du formulaire
128
// Transformation en XHTML du formulaire
129
$sortie .= $eflore_form->toHTML()."\n";
129
$sortie .= $eflore_form->toHTML()."\n";
130
$sortie .= '</ul>'."\n";
130
$sortie .= '</ul>'."\n";
131
 
131
 
132
// --------------------------------------------------------------------------------------------------------
132
// --------------------------------------------------------------------------------------------------------
133
// Lancement de la recherche
133
// Lancement de la recherche
134
if (isset($_REQUEST['eflore_nom']) && $_REQUEST['eflore_nom'] != '' && !eregi("^%{1,}$", $_REQUEST['eflore_nom']) ) {
134
if (isset($_REQUEST['eflore_nom']) && $_REQUEST['eflore_nom'] != '' && !eregi("^%{1,}$", $_REQUEST['eflore_nom']) ) {
135
    // Formatage de la chaine à rechercher
135
    // Formatage de la chaine à rechercher
136
    $_REQUEST['eflore_nom'] = '%'.str_replace(' ', '%', $_REQUEST['eflore_nom']).'%';
136
    $_REQUEST['eflore_nom'] = '%'.str_replace(' ', '%', $_REQUEST['eflore_nom']).'%';
137
    if ($_REQUEST['eflore_type_nom'] == 'nom_scientifique') {
137
    if ($_REQUEST['eflore_type_nom'] == 'nom_scientifique') {
138
        // Recherche sur les noms scientifiques
138
        // Recherche sur les noms scientifiques
139
        $contenu = file_get_contents(sprintf(EFLORE_URL_LISTE_NOM_LATIN, rawurlencode($_REQUEST['eflore_nom'])));
139
        $contenu = file_get_contents(sprintf(EFLORE_URL_LISTE_NOM_LATIN, rawurlencode($_REQUEST['eflore_nom'])));
140
        
140
        
141
        //Analyse du squelette
141
        //Analyse du squelette
142
        require_once 'HTML/Template/IT.php';
142
        require_once 'HTML/Template/IT.php';
143
        $squelette = new HTML_Template_IT();
143
        $squelette = new HTML_Template_IT();
144
        $squelette->setTemplate($contenu, FALSE, FALSE);
144
        $squelette->setTemplate($contenu, FALSE, FALSE);
145
        
145
        
146
        // Indique l'url pour obtenir fiche d'un nom
146
        // Indique l'url pour obtenir fiche d'un nom
147
        $squelette->setCurrentBlock('corps');
147
        $squelette->setCurrentBlock('corps');
148
        // Ajout du paramêtre action à l'url courante.
148
        // Ajout du paramêtre action à l'url courante.
149
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_FICHE);
149
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_FICHE);
150
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ONGLET, EFLORE_LG_URL_ONGLET_SYNTHESE);
150
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ONGLET, EFLORE_LG_URL_ONGLET_SYNTHESE);
151
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NN, '');
151
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NN, '');
152
        $squelette->setVariable('UrlFicheNom', $GLOBALS['_EFLORE_']['url']->getURL());
152
        $squelette->setVariable('UrlFicheNom', $GLOBALS['_EFLORE_']['url']->getURL());
153
        $squelette->parseCurrentBlock('corps');
153
        $squelette->parseCurrentBlock('corps');
154
        
154
        
155
        // Récupère le bloc "corps"
155
        // Récupère le bloc "corps"
156
        $sortie .= $squelette->get('corps');
156
        $sortie .= $squelette->get('corps');
157
    } else if ($_REQUEST['eflore_type_nom'] == 'nom_vernaculaire') {
157
    } else if ($_REQUEST['eflore_type_nom'] == 'nom_vernaculaire') {
158
        // Recherche sur les noms vernaculaires
158
        // Recherche sur les noms vernaculaires
159
        $contenu = file_get_contents(sprintf(EFLORE_URL_LISTE_NOM_VERNA, rawurlencode($_REQUEST['eflore_nom'])));
159
        $contenu = file_get_contents(sprintf(EFLORE_URL_LISTE_NOM_VERNA, rawurlencode($_REQUEST['eflore_nom'])));
160
        
160
        
161
        //Analyse du squelette
161
        //Analyse du squelette
162
        require_once 'HTML/Template/ITX.php';
162
        require_once 'HTML/Template/ITX.php';
163
        $squelette = new HTML_Template_ITX();
163
        $squelette = new HTML_Template_ITX();
164
        $squelette->setTemplate($contenu, FALSE, FALSE);
164
        $squelette->setTemplate($contenu, FALSE, FALSE);
165
        
165
        
166
        // Indique l'url pour obtenir fiche d'un nom
166
        // Indique l'url pour obtenir fiche d'un nom
167
        $squelette->setCurrentBlock('corps');
167
        $squelette->setCurrentBlock('corps');
168
        $squelette->setCallbackFunction('UrlFicheNom', 'remplacerUrlFicheNom');
168
        $squelette->setCallbackFunction('UrlFicheNom', 'remplacerUrlFicheNom');
169
        $squelette->performCallback();
169
        $squelette->performCallback();
170
        $squelette->parseCurrentBlock('corps');
170
        $squelette->parseCurrentBlock('corps');
171
        
171
        
172
        // Récupère le bloc "corps"
172
        // Récupère le bloc "corps"
173
        $sortie .= $squelette->get('corps');
173
        $sortie .= $squelette->get('corps');
174
        
174
        
175
    }
175
    }
176
}
176
}
177
 
177
 
178
/* +--Fin du code ----------------------------------------------------------------------------------------+
178
/* +--Fin du code ----------------------------------------------------------------------------------------+
179
*
179
*
180
* $Log: not supported by cvs2svn $
180
* $Log: not supported by cvs2svn $
-
 
181
* Revision 1.7  2005/02/23 12:39:27  jpm
-
 
182
* Correction bogue lié à QuickForm.
-
 
183
*
181
* Revision 1.6  2005/02/22 19:27:10  jpm
184
* Revision 1.6  2005/02/22 19:27:10  jpm
182
* Changement de nom de variables.
185
* Changement de nom de variables.
183
* Suppression de l'attribut nam de la balise form via une méthode de HTML_Common.
186
* Suppression de l'attribut nam de la balise form via une méthode de HTML_Common.
184
*
187
*
185
* Revision 1.5  2005/02/22 17:43:53  jpm
188
* Revision 1.5  2005/02/22 17:43:53  jpm
186
* Suppression de référence posant problème.
189
* Suppression de référence posant problème.
187
*
190
*
188
* Revision 1.4  2005/02/15 13:00:23  jpm
191
* Revision 1.4  2005/02/15 13:00:23  jpm
189
* Ajout d'un test pour initialiser une variable.
192
* Ajout d'un test pour initialiser une variable.
190
*
193
*
191
* Revision 1.3  2005/01/28 19:47:55  jpm
194
* Revision 1.3  2005/01/28 19:47:55  jpm
192
* Ajout de la recherche pour les taxons.
195
* Ajout de la recherche pour les taxons.
193
*
196
*
194
* Revision 1.2  2005/01/03 19:44:40  jpm
197
* Revision 1.2  2005/01/03 19:44:40  jpm
195
* Ajout de la gestion de l'action "fiche".
198
* Ajout de la gestion de l'action "fiche".
196
*
199
*
197
* Revision 1.1  2004/12/23 20:05:17  jpm
200
* Revision 1.1  2004/12/23 20:05:17  jpm
198
* Début prise en maine eflore-consultation.
201
* Début prise en maine eflore-consultation.
199
*
202
*
200
*
203
*
201
* +-- Fin du code ----------------------------------------------------------------------------------------+
204
* +-- Fin du code ----------------------------------------------------------------------------------------+
202
*/
205
*/
203
?>
206
?>