Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

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

Rev 149 Rev 154
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.4 2005-02-15 13:00:23 jpm Exp $
24
// CVS : $Id: eflore_recherche_nomenclature.inc.php,v 1.5 2005-02-22 17:43:53 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.4 $ $Date: 2005-02-15 13:00:23 $
36
*@version       $Revision: 1.5 $ $Date: 2005-02-22 17:43:53 $
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
$form =& new HTML_QuickForm('eflore_form_nomenclature', 'post', str_replace('&amp;', '&', $GLOBALS['_EFLORE_']['url']->getUrl()));
63
$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
$squelette =& $form->defaultRenderer();
65
$squelette = $form->defaultRenderer();
66
$squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'{content}'."\n".'</form>');
66
$squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'{content}'."\n".'</form>');
67
$squelette->setElementTemplate( '<li>'."\n".
67
$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
//$squelette->setRequiredNoteTemplate("\n".'<p><span class="symbole_obligatoire">'.MORE_LG_FORM_SYMBOLE_OBLIGATOIRE.'</span> {requiredNote}</p>'."\n");
73
//$squelette->setRequiredNoteTemplate("\n".'<p><span class="symbole_obligatoire">'.MORE_LG_FORM_SYMBOLE_OBLIGATOIRE.'</span> {requiredNote}</p>'."\n");
74
 
74
 
75
$partie_menu_debut = '<fieldset>'."\n".'<legend>'.EFLORE_LG_RECH_NOM_FORM_TITRE.'</legend>'."\n";
75
$partie_menu_debut = '<fieldset>'."\n".'<legend>'.EFLORE_LG_RECH_NOM_FORM_TITRE.'</legend>'."\n";
76
$form->addElement('html', $partie_menu_debut);
76
$form->addElement('html', $partie_menu_debut);
77
 
77
 
78
$id = 'eflore_nom';
78
$id = 'eflore_nom';
79
$aso_attributs = array( 'id'=>$id, 'class' => 'champ', 'tabindex' => $tab_index++, 
79
$aso_attributs = array( 'id'=>$id, 'class' => 'champ', 'tabindex' => $tab_index++, 
80
                        'size' => EFLORE_RECH_NOM_FORM_NOM_SIZE, 
80
                        'size' => EFLORE_RECH_NOM_FORM_NOM_SIZE, 
81
                        'maxlength' => EFLORE_RECH_NOM_FORM_NOM_MAXLENGTH,
81
                        'maxlength' => EFLORE_RECH_NOM_FORM_NOM_MAXLENGTH,
82
                        'onclick' => "javascript: this.value='';");
82
                        'onclick' => "javascript: this.value='';");
83
$label = '<label for="'.$id.'">'.EFLORE_LG_RECH_NOM_FORM_NOM.'</label>';
83
$label = '<label for="'.$id.'">'.EFLORE_LG_RECH_NOM_FORM_NOM.'</label>';
84
$form->addElement('text', $id, $label, $aso_attributs);
84
$form->addElement('text', $id, $label, $aso_attributs);
85
 
85
 
86
$liste_type_nom_debut = '<ul>'."\n";
86
$liste_type_nom_debut = '<ul>'."\n";
87
$form->addElement('html', $liste_type_nom_debut);
87
$form->addElement('html', $liste_type_nom_debut);
88
 
88
 
89
$id = 'eflore_type_nom';
89
$id = 'eflore_type_nom';
90
$valeur = 'nom_scientifique';
90
$valeur = 'nom_scientifique';
91
$aso_attributs = array( 'id'=> $id, 'tabindex' => $tab_index++);
91
$aso_attributs = array( 'id'=> $id, 'tabindex' => $tab_index++);
92
$label = '';
92
$label = '';
93
$form->addElement('radio', $id, $label, EFLORE_LG_RECH_NOM_FORM_TYPE_NOM_SCI, $valeur, $aso_attributs);
93
$form->addElement('radio', $id, $label, EFLORE_LG_RECH_NOM_FORM_TYPE_NOM_SCI, $valeur, $aso_attributs);
94
$valeur = 'nom_vernaculaire';
94
$valeur = 'nom_vernaculaire';
95
$aso_attributs = array( 'id'=> $id, 'tabindex' => $tab_index++);
95
$aso_attributs = array( 'id'=> $id, 'tabindex' => $tab_index++);
96
$label = '';
96
$label = '';
97
$form->addElement('radio', $id, $label, EFLORE_LG_RECH_NOM_FORM_TYPE_NOM_VER, $valeur, $aso_attributs);
97
$form->addElement('radio', $id, $label, EFLORE_LG_RECH_NOM_FORM_TYPE_NOM_VER, $valeur, $aso_attributs);
98
if (isset($_REQUEST[$id])) {
98
if (isset($_REQUEST[$id])) {
99
    switch ($_REQUEST[$id]) {
99
    switch ($_REQUEST[$id]) {
100
        case 'nom_scientifique':
100
        case 'nom_scientifique':
101
            $form->setDefaults(array($id => 'nom_scientifique'));
101
            $form->setDefaults(array($id => 'nom_scientifique'));
102
            break;
102
            break;
103
        case 'nom_vernaculaire':
103
        case 'nom_vernaculaire':
104
            $form->setDefaults(array($id => 'nom_vernaculaire'));
104
            $form->setDefaults(array($id => 'nom_vernaculaire'));
105
            break;
105
            break;
106
    }
106
    }
107
} else {
107
} else {
108
    $form->setDefaults(array($id => 'nom_scientifique'));
108
    $form->setDefaults(array($id => 'nom_scientifique'));
109
}
109
}
110
 
110
 
111
$liste_type_nom_fin = '</ul>'."\n";
111
$liste_type_nom_fin = '</ul>'."\n";
112
$form->addElement('html', $liste_type_nom_fin);
112
$form->addElement('html', $liste_type_nom_fin);
113
 
113
 
114
$id = 'eflore_valider_nom';
114
$id = 'eflore_valider_nom';
115
$aso_attributs = array('id'=> $id, 'class' => 'champ', 'tabindex' => $tab_index++);
115
$aso_attributs = array('id'=> $id, 'class' => 'champ', 'tabindex' => $tab_index++);
116
$form->addElement('submit', $id, EFLORE_LG_RECH_NOM_FORM_VALIDER, $aso_attributs);
116
$form->addElement('submit', $id, EFLORE_LG_RECH_NOM_FORM_VALIDER, $aso_attributs);
117
 
117
 
118
$partie_entete_fin = "\n".'</fieldset>';
118
$partie_entete_fin = "\n".'</fieldset>';
119
$form->addElement('html', $partie_entete_fin);
119
$form->addElement('html', $partie_entete_fin);
120
 
120
 
121
// Instanciation avec les valeur par défaut
121
// Instanciation avec les valeur par défaut
122
if (isset($_SESSION['_EFLORE_']['rechercher'])) {
122
if (isset($_SESSION['_EFLORE_']['rechercher'])) {
123
    $form->setDefaults($_SESSION['_EFLORE_']['rechercher']);
123
    $form->setDefaults($_SESSION['_EFLORE_']['rechercher']);
124
}
124
}
125
 
125
 
126
// Transformation en XHTML du formulaire
126
// Transformation en XHTML du formulaire
127
$sortie .= $form->toHTML()."\n";
127
$sortie .= $form->toHTML()."\n";
128
$sortie .= '</ul>'."\n";
128
$sortie .= '</ul>'."\n";
129
 
129
 
130
// --------------------------------------------------------------------------------------------------------
130
// --------------------------------------------------------------------------------------------------------
131
// Lancement de la recherche
131
// Lancement de la recherche
132
if (isset($_REQUEST['eflore_nom']) && $_REQUEST['eflore_nom'] != '' && !eregi("^%{1,}$", $_REQUEST['eflore_nom']) ) {
132
if (isset($_REQUEST['eflore_nom']) && $_REQUEST['eflore_nom'] != '' && !eregi("^%{1,}$", $_REQUEST['eflore_nom']) ) {
133
    // Formatage de la chaine à rechercher
133
    // Formatage de la chaine à rechercher
134
    $_REQUEST['eflore_nom'] = '%'.str_replace(' ', '%', $_REQUEST['eflore_nom']).'%';
134
    $_REQUEST['eflore_nom'] = '%'.str_replace(' ', '%', $_REQUEST['eflore_nom']).'%';
135
    if ($_REQUEST['eflore_type_nom'] == 'nom_scientifique') {
135
    if ($_REQUEST['eflore_type_nom'] == 'nom_scientifique') {
136
        // Recherche sur les noms scientifiques
136
        // Recherche sur les noms scientifiques
137
        $contenu = file_get_contents(sprintf(EFLORE_URL_LISTE_NOM_LATIN, rawurlencode($_REQUEST['eflore_nom'])));
137
        $contenu = file_get_contents(sprintf(EFLORE_URL_LISTE_NOM_LATIN, rawurlencode($_REQUEST['eflore_nom'])));
138
        
138
        
139
        //Analyse du squelette
139
        //Analyse du squelette
140
        require_once 'HTML/Template/IT.php';
140
        require_once 'HTML/Template/IT.php';
141
        $squelette = new HTML_Template_IT();
141
        $squelette = new HTML_Template_IT();
142
        $squelette->setTemplate($contenu, FALSE, FALSE);
142
        $squelette->setTemplate($contenu, FALSE, FALSE);
143
        
143
        
144
        // Indique l'url pour obtenir fiche d'un nom
144
        // Indique l'url pour obtenir fiche d'un nom
145
        $squelette->setCurrentBlock('corps');
145
        $squelette->setCurrentBlock('corps');
146
        // Ajout du paramêtre action à l'url courante.
146
        // Ajout du paramêtre action à l'url courante.
147
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_FICHE);
147
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ACTION, EFLORE_LG_URL_ACTION_FICHE);
148
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ONGLET, EFLORE_LG_URL_ONGLET_SYNTHESE);
148
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_ONGLET, EFLORE_LG_URL_ONGLET_SYNTHESE);
149
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NN, '');
149
        $GLOBALS['_EFLORE_']['url']->addQueryString(EFLORE_LG_URL_NN, '');
150
        $squelette->setVariable('UrlFicheNom', $GLOBALS['_EFLORE_']['url']->getURL());
150
        $squelette->setVariable('UrlFicheNom', $GLOBALS['_EFLORE_']['url']->getURL());
151
        $squelette->parseCurrentBlock('corps');
151
        $squelette->parseCurrentBlock('corps');
152
        
152
        
153
        // Récupère le bloc "corps"
153
        // Récupère le bloc "corps"
154
        $sortie .= $squelette->get('corps');
154
        $sortie .= $squelette->get('corps');
155
    } else if ($_REQUEST['eflore_type_nom'] == 'nom_vernaculaire') {
155
    } else if ($_REQUEST['eflore_type_nom'] == 'nom_vernaculaire') {
156
        // Recherche sur les noms vernaculaires
156
        // Recherche sur les noms vernaculaires
157
        $contenu = file_get_contents(sprintf(EFLORE_URL_LISTE_NOM_VERNA, rawurlencode($_REQUEST['eflore_nom'])));
157
        $contenu = file_get_contents(sprintf(EFLORE_URL_LISTE_NOM_VERNA, rawurlencode($_REQUEST['eflore_nom'])));
158
        
158
        
159
        //Analyse du squelette
159
        //Analyse du squelette
160
        require_once 'HTML/Template/ITX.php';
160
        require_once 'HTML/Template/ITX.php';
161
        $squelette = new HTML_Template_ITX();
161
        $squelette = new HTML_Template_ITX();
162
        $squelette->setTemplate($contenu, FALSE, FALSE);
162
        $squelette->setTemplate($contenu, FALSE, FALSE);
163
        
163
        
164
        // Indique l'url pour obtenir fiche d'un nom
164
        // Indique l'url pour obtenir fiche d'un nom
165
        $squelette->setCurrentBlock('corps');
165
        $squelette->setCurrentBlock('corps');
166
        $squelette->setCallbackFunction('UrlFicheNom', 'remplacerUrlFicheNom');
166
        $squelette->setCallbackFunction('UrlFicheNom', 'remplacerUrlFicheNom');
167
        $squelette->performCallback();
167
        $squelette->performCallback();
168
        $squelette->parseCurrentBlock('corps');
168
        $squelette->parseCurrentBlock('corps');
169
        
169
        
170
        // Récupère le bloc "corps"
170
        // Récupère le bloc "corps"
171
        $sortie .= $squelette->get('corps');
171
        $sortie .= $squelette->get('corps');
172
        
172
        
173
    }
173
    }
174
}
174
}
175
 
175
 
176
/* +--Fin du code ----------------------------------------------------------------------------------------+
176
/* +--Fin du code ----------------------------------------------------------------------------------------+
177
*
177
*
178
* $Log: not supported by cvs2svn $
178
* $Log: not supported by cvs2svn $
-
 
179
* Revision 1.4  2005/02/15 13:00:23  jpm
-
 
180
* Ajout d'un test pour initialiser une variable.
-
 
181
*
179
* Revision 1.3  2005/01/28 19:47:55  jpm
182
* Revision 1.3  2005/01/28 19:47:55  jpm
180
* Ajout de la recherche pour les taxons.
183
* Ajout de la recherche pour les taxons.
181
*
184
*
182
* Revision 1.2  2005/01/03 19:44:40  jpm
185
* Revision 1.2  2005/01/03 19:44:40  jpm
183
* Ajout de la gestion de l'action "fiche".
186
* Ajout de la gestion de l'action "fiche".
184
*
187
*
185
* Revision 1.1  2004/12/23 20:05:17  jpm
188
* Revision 1.1  2004/12/23 20:05:17  jpm
186
* Début prise en maine eflore-consultation.
189
* Début prise en maine eflore-consultation.
187
*
190
*
188
*
191
*
189
* +-- Fin du code ----------------------------------------------------------------------------------------+
192
* +-- Fin du code ----------------------------------------------------------------------------------------+
190
*/
193
*/
191
?>
194
?>