Subversion Repositories eFlore/Archives.herbiers

Rev

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

Rev Author Line No. Line
2 jp_milcent 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This file is part of Herbier - 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
// +------------------------------------------------------------------------------------------------------+
22 jp_milcent 24
// CVS : $Id: hb_consultation.php,v 1.3 2007-08-27 15:56:50 jp_milcent Exp $
2 jp_milcent 25
/**
26
* Application fournissant un moteur de recherche sur les herbiers
27
*
28
* Fournit la liste des herbiers enregistrés dans la base de données.
29
*
30
*@package Herbier-Consultation
31
//Auteur original :
32
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
33
//Autres auteurs :
34
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
35
*@copyright     Tela-Botanica 2000-2005
22 jp_milcent 36
*@version       $Revision: 1.3 $ $Date: 2007-08-27 15:56:50 $
2 jp_milcent 37
// +------------------------------------------------------------------------------------------------------+
38
*/
39
 
40
// +------------------------------------------------------------------------------------------------------+
41
// |                                            ENTETE du PROGRAMME                                       |
42
// +------------------------------------------------------------------------------------------------------+
43
/** Inclusion du fichier de configuration de l'application Herbier - Consultation. */
8 jp_milcent 44
require_once HB_CHEMIN_MODULE.'hb_consultation'.GEN_SEP.'configuration'.GEN_SEP.'hbc_config.inc.php';
2 jp_milcent 45
/** Inclusion du fichier de configuration de l'application Herbier - Administration. */
8 jp_milcent 46
require_once HB_CHEMIN_MODULE.'hb_admin'.GEN_SEP.'configuration'.GEN_SEP.'hba_config.inc.php';
2 jp_milcent 47
 
48
/** Inclusion de l'API Fragmenteur */
49
require_once HB_CHEMIN_API_FRAGMENTEUR.'FRAG_fragmenteur.fonct.php';
50
/** Inclusion de l'API Formulaire - classe : Form */
51
require_once HB_CHEMIN_API_FORM.'FORM_formulaire.class.php';
52
/** Inclusion de l'API Formulaire - classe : formFromTable */
53
require_once HB_CHEMIN_API_FORM.'FORM_formulaire_table.class.php';
54
 
55
/** Inclusion de la classe principale d'Herbier : herbier */
56
require_once HB_CHEMIN_BIBLIO.'hb_herbier.class.php';
57
/** Inclusion de la classe Herbier : collection */
58
require_once HB_CHEMIN_BIBLIO.'hb_collection.class.php';
59
/** Inclusion de la classe Herbier : indic */
60
require_once HB_CHEMIN_BIBLIO.'hb_indic.class.php';
61
/** Inclusion de la classe Herbier : indic_hist */
62
require_once HB_CHEMIN_BIBLIO.'hb_indic_hist.class.php';
63
/** Inclusion de la classe Herbier : organisation */
64
require_once HB_CHEMIN_BIBLIO.'hb_organisation.class.php';
65
/** Inclusion de la classe Herbier : type */
66
require_once HB_CHEMIN_BIBLIO.'hb_type.class.php';
67
/** Inclusion de la classe Herbier : equipe */
68
require_once HB_CHEMIN_BIBLIO.'hb_equipe.class.php';
69
 
70
// Appel du fichier de traduction des textes de l'application Consultation de Herbier
71
if (file_exists(HBC_CHEMIN_LANGUES.'hbc_langue_'.HB_I18N.'.inc.php')) {
72
    /** Inclusion du fichier de traduction de l'application Consultation de Herbier. */
73
    include_once HBC_CHEMIN_LANGUES.'hbc_langue_'.HB_I18N.'.inc.php';
74
} else {
75
    /** Inclusion du fichier de traduction fr par défaut. */
76
    include_once HBC_CHEMIN_LANGUES.'hbc_langue_fr.inc.php';
77
}
78
 
79
// Initialisation de la variable à retourner
80
$sortie .= '<!-- Herbier - Consultation : DEBUT -->'."\n";
81
 
82
// +------------------------------------------------------------------------------------------------------+
83
// |                                            CORPS du PROGRAMME                                        |
84
// +------------------------------------------------------------------------------------------------------+
85
global $project;
86
global $TransTab;
87
global $RECHERCHE, $INSTITUTION, $T_REPONSE, $TYPE_R;
88
if (!isset($_GET['consultation'])) {
89
    // ici on écrase les valeurs des variables globales précédentes au cas où
90
    // on vient de cliquez sur un chiffre du fragmenteur
91
    if (empty($T_REPONSE)) {
92
        $T_REPONSE = 20;
93
    }
94
    if ($TransTab) {
95
        $values = FRAG_decoupageChaine($TransTab);
96
    }
97
 
98
    if (!empty($values)) {
99
        foreach ($values as $key => $val) {
100
            if ($val != '') {
101
                $GLOBALS[$key] = $val ;
102
            }
103
        }
104
    }
105
 
106
    $sortie .= '<h1>'.'Rechercher un herbier :'.'</h1>'."\n";
107
 
108
    $form_1 = new form($GLOBALS['_HERBIER_']['bdd']);
109
    $sortie .= '<form action="'.$GLOBALS['_HERBIER_']['url']->getURL().'" method="post">'."\n";
110
    $sortie .= '<p>'."\n";
111
    $sortie .= '<label for="RECHERCHE">'.'Recherche : '.'</label>'."\n";
112
    $sortie .= '<input id="RECHERCHE" type="text" name="RECHERCHE" class="insInputForm"';
113
    if (!empty($RECHERCHE)) {
114
        $sortie .= ' value="'.$RECHERCHE.'"';
115
    }
116
    $sortie .= '/>'."\n";
117
    $sortie .= '<label for="">'.'Grouper les résultats : '.'</label>'."\n";
118
    $sortie .= $form_1->selectFromTableau('T_REPONSE',array(10, 'par 10', 20, 'par 20', 50, 'par 50'), $T_REPONSE);
119
    $sortie .= $form_1->submit('rechercher')."\n";
120
    $sortie .= '</p>'."\n";
121
    $sortie .= '</form>'."\n";
122
 
123
 
124
    $sortie .=  '<p>'.'Le moteur recherche dans tous les champs de la de la base :'.'</p>'."\n";
125
                '<ul>'."\n".
126
                '<li>'.'Nom d\'institution, adresse, ville, région'.'</li>'."\n".
127
                '<li>'.'Index herbariorum'.'</li>'."\n".
128
                '<li>'.'Nom de collection, description, collecteurs, notes'.'</li>'."\n".
129
                '<li>'.'Indications taxonomiques, historiques, géographiques'.'</li>'."\n".
130
                '</ul>'."\n";
131
    $sortie .=  '<p>'.'Vous pouvez utiliser le caractère % pour remplacer n\'importe quelle chaine.'.'</p>'."\n";
132
 
133
    if (!empty($T_REPONSE) ) {//&& !empty($RECHERCHE)
22 jp_milcent 134
        $query_data =   'SELECT DISTINCT ID_ORG '.
135
                        'FROM HERBIERS_COLLECTION AS HC LEFT JOIN HERBIERS_INDIC AS HI ON HC.ID = HI.ID, HERBIERS_ORGANISATION AS HO '.
136
                        'WHERE HC.PARENT_ID = HO.ID_ORG '.
137
                        'AND ( '.
138
						'		HI.REM_INDIC LIKE "%'.$RECHERCHE.'%" '.
139
						'	OR 	HI.TXT_INDIC LIKE "%'.$RECHERCHE.'%" '.
140
						'	OR 	HC.DESCRIPTION LIKE "%'.$RECHERCHE.'%" '.
141
						'	OR 	HC.NOTES LIKE "%'.$RECHERCHE.'%" '.
142
						'	OR 	HC.COLLECTION_FOCUS LIKE "%'.$RECHERCHE.'%" '.
143
						'	OR 	HC.PURPOSE LIKE "%'.$RECHERCHE.'%" '.
144
						'	OR 	HC.COLLECTEURS LIKE "%'.$RECHERCHE.'%" '.
145
						'	OR 	HC.STRENGTH LIKE "%'.$RECHERCHE.'%" '.
146
						'	OR 	HC.NOM_COLLECTION LIKE "%'.$RECHERCHE.'%" '.
147
						'	OR 	HC.COLLECTION_CODE LIKE "%'.$RECHERCHE.'%" '.
148
						'	OR 	HO.INSTITUTION_NAME LIKE "%'.$RECHERCHE.'%" '.
28 jpm 149
						'	OR 	HO.ADRESS_LINE LIKE "%'.$RECHERCHE.'%" '.
22 jp_milcent 150
						'	OR 	HO.TOWN LIKE "%'.$RECHERCHE.'%" '.
151
						'	OR 	HO.REGION LIKE "%'.$RECHERCHE.'%" '.
152
						'	OR 	HO.INDEX_HERB LIKE "%'.$RECHERCHE.'%" '.
153
						') '.
2 jp_milcent 154
                        'ORDER BY TOWN';
155
 
156
        if (empty($values['pstart'])) {
157
            $values['pstart'] = 0 ;
158
        }
159
 
160
        // Autre requete pour obtenir le nombre total de réponse
161
        // car la clause limit x,y limite le nombre de résultat
162
        $query_nombre = $query_data;
163
 
164
        // Ajout de la clause limit pour les données à afficher
165
        $query_data .= ' LIMIT '.$values['pstart'].','.$T_REPONSE;
166
 
167
        $result_data = mysql_query($query_data) or die (BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $query_data));
168
 
169
        $result_nombre = mysql_query($query_nombre) or die (BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $query_nombre));
170
        $nombre = mysql_num_rows($result_nombre);
171
        mysql_free_result($result_nombre);
172
 
173
        // Utilisation du fragmentateur
174
        $mon_frag = new fragmenteur();
175
        $tableau = array();
176
        $tableau['pstart'] = $values['pstart'];
177
        $tableau['step'] = $T_REPONSE;
178
        $tableau['pend'] = $nombre;
179
 
180
        // Construction de la variable TransTab
181
        $tableau['TYPE_R'] = $TYPE_R;
182
        $tableau['T_REPONSE'] = $T_REPONSE;
183
 
184
        $sortie .= '<p id="frag_nbre_resultat">'.FRAG_afficherTxtNbreResultat('', $tableau, mysql_num_rows($result_data), $nombre).'</p>'."\n";
185
 
186
        if ((mysql_num_rows($result_data) > 0) && ($tableau['step'] < $nombre)) {
187
            $sortie .= '<p id="frag_navigation">';
188
            $sortie .= $mon_frag->fragmente($tableau, $nombre);
189
            $sortie .= '</p>'."\n";
190
        }
191
 
192
        $sortie .= '<ul>'."\n";
193
        while ($row1 = mysql_fetch_object($result_data)) {
194
            $resultat = new H_organisation() ;
195
            $resultat->getFromSQL($row1->ID_ORG);
196
            $sortie .= '<li>'.$resultat->TOWN.' - ';
197
            $sortie .=  '<a href="'.HB_URL_COURANTE_CONSULTATION_FICHE_HERBIER.'&amp;id_org='.$row1->ID_ORG.'">'.
198
                        $resultat->INSTITUTION_NAME.
199
                        '</a>';
200
            $sortie .= '</li>'."\n";
201
        }
202
        $sortie .= '</ul>'."\n";
203
 
204
        if ((mysql_num_rows($result_data) > 0) && ($tableau['step'] < $nombre)) {
205
            $sortie .= '<p>'.$mon_frag->fragmente($tableau, $nombre).'</p>'."\n";
206
        }
207
    }
208
} elseif (isset($_GET['consultation']) && $_GET['consultation'] == 'herbier') {
209
    include_once 'hbc_info_herbier.inc.php';
210
} elseif (isset($_GET['consultation']) && $_GET['consultation'] == 'collection') {
211
    include_once 'hbc_info_collection.inc.php';
212
}
213
 
214
// +------------------------------------------------------------------------------------------------------+
215
// |                                            PIED du PROGRAMME                                         |
216
// +------------------------------------------------------------------------------------------------------+
217
$sortie .= '<!-- Herbier - Consultation : FIN -->'."\n";
218
 
219
/* +--Fin du code ----------------------------------------------------------------------------------------+
220
*
221
* $Log: not supported by cvs2svn $
22 jp_milcent 222
* Revision 1.2  2006-10-31 10:31:36  jp_milcent
223
* Gestion des chemins rendu compatibles avec une utilisation de l'appli Herbiers hors de Papyrus.
224
*
8 jp_milcent 225
* Revision 1.1  2005/11/23 10:32:32  jp_milcent
226
* Ajout au dépot de l'application Herbiers.
227
* Elle doit à terme migrer dans eFlore.
228
*
2 jp_milcent 229
* Revision 1.3  2005/03/30 09:48:58  jpm
230
* Début gestion des raccourcis vers l'administration.
231
*
232
* Revision 1.2  2005/03/09 15:55:17  jpm
233
* Changement du nom de l'appli.
234
*
235
* Revision 1.1  2005/03/08 13:49:17  jpm
236
* Ajout de l'application de consultation sous forme de moteur de recherche.
237
*
238
*
239
* +-- Fin du code ----------------------------------------------------------------------------------------+
240
*/
241
?>