Subversion Repositories eFlore/Applications.bibliobota

Rev

Rev 2 | Rev 17 | Go to most recent revision | 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) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
3 jp_milcent 22
// CVS : $Id: bbc_recherche.inc.php,v 1.2 2005-11-24 09:02:09 jp_milcent Exp $
2 jp_milcent 23
/**
24
* Appli bb_consultation : gestion des moteurs de recherche de Biblio Bota
25
*
26
* Cette application permet de gérer les moteurs de recherches de l'ensemble des données comprise
27
* dans le modèle de Biblio Bota :
28
* - articles botaniques
29
* - livres et média botaniques
30
* - sites web
31
* - organismes liés à la botanique
32
*
33
*@package BiblioBota-Consultation
34
//Auteur original :
35
*@author        Jean-Charles GRANGER <tela@vecteur.org>
36
//Autres auteurs :
37
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
38
*@copyright     Tela-Botanica 2000-2004
3 jp_milcent 39
*@version       $Revision: 1.2 $ $Date: 2005-11-24 09:02:09 $
2 jp_milcent 40
// +------------------------------------------------------------------------------------------------------+
41
*/
42
 
43
// +------------------------------------------------------------------------------------------------------+
44
// |                                            ENTETE du PROGRAMME                                       |
45
// +------------------------------------------------------------------------------------------------------+
46
 
47
/** Inclusion de la bibliothèque de réaliser les statistiques spécifiques à l'application consultation de BiblioBota.*/
48
require_once BBC_CHEMIN_BIBLIO.'bbc_statistique.fonct.php';
49
 
50
// Globalisation des variables
51
global $TabFinder, $TransTab, $plugin, $tbl;
52
if (isset($TransTab)) {
53
    $TabFinder = FRAG_decoupageChaine($TransTab);
54
}
55
 
56
// Vérification de l'utilisation de BiblioBota comme service web
57
if (empty($TabFinder['plugin'])) {
58
    $TabFinder['plugin'] = '';
59
}
60
if (BB_ARGUMENT_SERVICE != '' && $TabFinder['plugin'] == '') {
61
    $TabFinder['plugin'] = BB_ARGUMENT_SERVICE;
62
}
63
// Limitation au domaine ?
64
if (BB_ARGUMENT_DOMAINE != 1) {
65
    $var_biblio['limit_domain'] = 1;
66
} else {
67
    $var_biblio['limit_domain'] = 0;
68
}
69
 
70
// Gestion du mode du moteur: nomal ou avancé ( = plus d'options)
71
if (empty($TabFinder['finder_mode'])) {
72
    $TabFinder['finder_mode'] = 'normal';
73
}
74
 
75
// Initialisation de TabFinder au cas ou cela n'aurait pas été fait
76
if (!isset($TabFinder['plugin'])) $TabFinder['plugin'] = '';
77
if (!isset($TabFinder['geo'])) $TabFinder['geo'] = '';
78
if (!isset($TabFinder['chaine'])) $TabFinder['chaine'] = '';
79
if (!isset($TabFinder['sort'])) $TabFinder['sort'] = $GLOBALS['moteur_biblio']['defaut_sort'];
80
if (!isset($TabFinder['auteur'])) $TabFinder['auteur'] = '';
81
if (!isset($TabFinder['categ'])) $TabFinder['categ'] = '';
82
if (!isset($TabFinder['pstart'])) $TabFinder['pstart'] = '0';
83
if (!isset($TabFinder['step'])) $TabFinder['step'] = '20';
84
if (!isset($TabFinder['valid'])) $TabFinder['valid'] = '0';
85
if (!isset($TabFinder['typque'])) $TabFinder['typque'] = '1';
86
if (!isset($TabFinder['categ_2'])) $TabFinder['categ_2'] = '';
87
if (!isset($TabFinder['categ_3'])) $TabFinder['categ_3'] = '';
88
if (!isset($TabFinder['since'])) $TabFinder['since'] = '';
89
if (!isset($TabFinder['finder_mode'])) $TabFinder['finder_mode'] = 'normal';
90
// +------------------------------------------------------------------------------------------------------+
91
// |                                            CORPS du PROGRAMME                                        |
92
// +------------------------------------------------------------------------------------------------------+
93
 
94
// no_help est une variable qui est passée par un PlugIn s'il n'y a pas besoin d'aide
95
global $no_help;
96
 
97
// +------------------------------------------------------------------------------------------------------+
98
// Début de gestion des services Web (plugin)
99
if ($TabFinder['plugin'] != '') {
100
    // Séparation des éléments du PlugIn
101
    $plugin_exp = explode('-', $TabFinder['plugin']);
102
 
103
    // Mise en global des variables utilisées ailleurs
104
    global $plugin_store;
105
 
106
    // Création des arguments pour les onglets
107
    $TabFinder['args'] = '&amp;arg_0=plugin%3D'.$TabFinder['plugin'].'&amp;arg_1=plugin%3D'.$TabFinder['plugin'];
108
 
109
    // L'argument 0 de plugin_exp peut avoir les valeurs :
110
    // str (réduction à une structure), coll (réduction à une collection), aut (réduction à des auteurs)
111
    switch ($plugin_exp[0]) {
112
        case 'str':
113
            // On récupère ici dans plugin l'identifiant d'une structure,
114
            // il faut donc réduire à cette structure dans la requête
115
            if (BB_ARGUMENT_REGROUPEMENT == 'article') {
116
                $plugin_store['count_add_table'] = ', '.$tbl['article'].', '.$tbl['fascicule'].', '.$tbl['serie'].', '.$tbl['collection'];
117
                $plugin_store['count_add_query'] =  ' AND B_C_LKSTR = '.$plugin_exp[1].' '.
118
                                                    'AND B_C_CRAI = B_SER_CRAICOLL '.
119
                                                    'AND B_SER_CRAICOLL = B_F_CRAICOLL '.
120
                                                    'AND B_SER_IDSERIE = B_F_CRAISERIE '.
121
                                                    'AND B_F_CRAICOLL = B_A_CRAICOLL '.
122
                                                    'AND B_F_CRAISERIE = B_A_CRAISERIE '.
123
                                                    'AND B_F_NUMERO = B_A_CRAIFASC '.
124
                                                    'AND B_I_IDITEM = B_A_IDART ';
125
 
126
                $plugin_store['categ_add_table'] = ', '.$tbl['article'].', '.$tbl['fascicule'].', '.$tbl['item'];
127
                $plugin_store['categ_add_query'] =  ' AND B_C_LKSTR = '.$plugin_exp[1].' '.
128
                                                    'AND B_SER_IDSERIE = B_F_CRAISERIE '.
129
                                                    'AND B_F_CRAICOLL = B_A_CRAICOLL '.
130
                                                    'AND B_F_CRAISERIE = B_A_CRAISERIE '.
131
                                                    'AND B_F_NUMERO = B_A_CRAIFASC '.
132
                                                    'AND B_I_IDITEM = B_A_IDART ';
133
            } else if (BB_ARGUMENT_REGROUPEMENT == 'media') {
134
                $plugin_store['count_add_table'] = ', '.$tbl['media'];
135
                $plugin_store['count_add_query'] =  ' AND B_M_LKSTR = '.$plugin_exp[1].' '.
136
                                                    'AND B_I_IDITEM = B_M_IDMEDIA ';
137
                $plugin_store['categ_add_table'] = '';
138
                $plugin_store['categ_add_query'] = ' AND B_M_LKSTR = '.$plugin_exp[1].' ';
139
                $plugin_store['query_add_query'] = ' AND B_M_LKSTR = '.$plugin_exp[1].' ';
140
            }
141
        break;
142
 
143
        case 'coll':
144
            // On récupère ici dans plugin l'identifiant d'une collection,
145
            // il faut donc réduire à cette collection dans la requête
146
            // cette option n'existe que pour le regroupement ARTICLE
147
 
148
            if (BB_ARGUMENT_REGROUPEMENT == 'article') {
149
                $plugin_store['count_add_table'] = ', '.$tbl['article'];
150
                $plugin_store['count_add_query'] = ' AND B_A_CRAICOLL = "'.$plugin_exp[1].'" AND B_I_IDITEM = B_A_IDART ';
151
                $plugin_store['categ_add_table'] = '';
152
                $plugin_store['categ_add_query'] = ' AND B_C_CRAI = "'.$plugin_exp[1].'" ';
153
                $plugin_store['query_add_query'] = ' AND B_C_CRAI = "'.$plugin_exp[1].'" ';
154
            } else if (BB_ARGUMENT_REGROUPEMENT == 'media') {
155
                // leurre pour finir proporement le script
156
                $plugin_store['count_add_table'] = '';
157
                $plugin_store['count_add_query'] = ' AND B_I_IDITEM = "aeiouy"';
158
                $plugin_store['categ_add_table'] = '';
159
                $plugin_store['categ_add_query'] = '';
160
                $plugin_store['query_add_query'] = '';
161
            }
162
        break;
163
 
164
        case 'aut':
165
            // On récupère ici dans plugin des identifiants d'auteurs
166
            // il faut donc réduire à ces auteurs dans la requête
167
            // les noms d'auteurs sont séparés par des "!"
168
 
169
            $plugin_auteurs = explode('@',$plugin_exp[1]);
170
 
171
            $plugin_i = 0;
172
            $plugin_action = ' AND (';
173
 
174
            while ($plugin_i < count($plugin_auteurs)) {
175
                if ($plugin_i != 0) {
176
                    $plugin_action .= ' OR ';
177
                }
178
                $plugin_action .= 'B_I_AUTEURSAISIE LIKE "%'.$plugin_auteurs[$plugin_i].'%" ';
179
                $plugin_i++;
180
            }
181
 
182
            $plugin_action .= ') ';
183
 
184
            $plugin_store['count_add_table'] = '';
185
            $plugin_store['count_add_query'] = $plugin_action;
186
 
187
            if (BB_ARGUMENT_REGROUPEMENT == 'article') {
188
                $plugin_store['categ_add_table'] = ", ".$tbl['article'].", ".$tbl['fascicule'].", ".$tbl['item'];
189
                $plugin_store['categ_add_query'] =  ' '.$plugin_action.' '.
190
                                                    'AND B_C_CRAI = B_SER_CRAICOLL '.
191
                                                    'AND B_SER_CRAICOLL = B_F_CRAICOLL '.
192
                                                    'AND B_SER_IDSERIE = B_F_CRAISERIE '.
193
                                                    'AND B_F_CRAICOLL = B_A_CRAICOLL '.
194
                                                    'AND B_F_CRAISERIE = B_A_CRAISERIE '.
195
                                                    'AND B_F_NUMERO = B_A_CRAIFASC '.
196
                                                    'AND B_I_IDITEM = B_A_IDART ';
197
                $plugin_store['query_add_query'] = ' '.$plugin_action.' ';
198
            } else if (BB_ARGUMENT_REGROUPEMENT == 'media') {
199
                $plugin_store['categ_add_table'] = '';
200
                $plugin_store['categ_add_query'] = ' '.$plugin_action.' ';
201
                $plugin_store['query_add_query'] = ' '.$plugin_action.' ';
202
            }
203
        break;
204
 
205
        default:
206
            die('Regroupement PLUGIN impossible... Méthode Plugin par défaut inexistante (méthodes disponibles : str, coll et aut).');
207
        break;
208
    }
209
} // Fin de gestion des services Web
210
 
211
// +------------------------------------------------------------------------------------------------------+
212
// Création de l'interface du moteur de recherche
213
require_once BBC_CHEMIN_BIBLIO.'bbc_moteur_'.BB_ARGUMENT_OBJET.'.fonct.php';
214
$sortie .= mkengine();
215
// Affichage des résultats d'une recherche
216
if ((isset($TabFinder)) && ($TabFinder['valid'] == 1)) {
217
    global $nbr_total;
218
    if ($nbr_total > 1) {
219
        $pluriel_tot = 's';
220
    }
221
 
222
    // Création de la requête
223
    include_once BBC_CHEMIN_BIBLIO.'bbc_requete_'.BB_ARGUMENT_OBJET.'.fonct.php';
224
    $requete = mkquery();
225
    // DEBOGAGE : pour voir la requete finale
226
    //$GLOBALS['_DEBOGAGE_'] .= $requete.'<br>';
227
 
228
    //Requete de calcul du nombre total d'enregistrements de la table
229
    $result_local = mysql_query($requete) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete));
230
    $nbr_local = mysql_num_rows($result_local);
231
    mysql_free_result($result_local);
232
 
233
    if ($nbr_local > 1) {
234
        $pluriel_loc = 's';
235
    }
236
 
237
    // Requete de sélection sur la quantité de données demandées par l'utilisateur (avec bornes LIMIT)
238
    if ($TabFinder['pstart'] == '') {
239
        $TabFinder['pstart'] = 0;
240
    }
241
    $query_final = ' LIMIT '.$TabFinder['pstart'].', '.$TabFinder['step'];
242
 
243
    global $result_final;
244
    $result_final = mysql_query($requete.$query_final) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete.$query_final));
245
    global $nbr_final;
246
    $nbr_final = mysql_num_rows($result_final);
247
 
248
    $sortie .= '<p class="insTitle1">';
249
    $TabFinder['pend'] = $nbr_local;
250
    $sortie .= FRAG_afficherTxtNbreResultat('', $TabFinder, $nbr_local, $nbr_total);
251
    $sortie .= '</p>';
252
 
253
    if (($nbr_local > 0) && ($TabFinder['step'] < $nbr_local)) {
254
        $sortie .= '<p id="fragmenteur_tete" class="fragmenteur">';
255
        $frag = new fragmenteur();
256
        $sortie .= $frag->fragmente($TabFinder, $nbr_local);
257
        $sortie .= '</p>';
258
    }
259
 
260
    include_once BBC_CHEMIN_BIBLIO.'bbc_affichage_'.BB_ARGUMENT_OBJET.'.fonct.php';
261
    $sortie .= mkresu();
262
    mysql_free_result($result_final);
263
 
264
    if (($TabFinder['step'] >= 20) && ($nbr_local - $TabFinder['pstart'] >= (20 + $TabFinder['step']))) {
265
        $sortie .= '<p id="fragmenteur_pied" class="fragmenteur">';
266
        $sortie .= $frag->fragmente($TabFinder, $nbr_local);
267
        $sortie .= '</p>'."\n\n";
268
    }
269
}
270
 
271
// Création de l'aide
272
if ((!isset($TabFinder)) || ($TabFinder['valid'] != 1)) {
273
    if (((!empty($no_help)) && ($no_help == 1))) {
274
        $sortie .= '';
275
    } else {
3 jp_milcent 276
        $sortie .= presa_mk_title('Élargir votre recherche : ', 3);
277
        // Aide : liste complète
278
        $sortie .= '<p>'."\n";
279
        $sortie .=  'Si vous souhaitez élargir votre recherhe à l\'ensemble des ressources documentaires de l\'enseignement supérieur et de la recherche de la région Languedoc-Roussillon, allez sur le <a href="http://www.bomlr.info/askonce.jsp?locale=FR" class="lien_ext">site de la Bibliothèque Ouverte Montpellier Languedoc-Roussillon </a>   '."\n";
280
        $sortie .= '</p>'."\n";
281
 
2 jp_milcent 282
        $sortie .= presa_mk_title('Aide à la recherche : ', 3);
283
        $sortie .= '<p class="texte_tb">'."\n";
284
 
285
        // Aide commune
286
        $sortie .= '- Attention aux fautes de frappe : le moteur recherche EXACTEMENT les termes saisis.'."\n";
287
 
288
        // Aide switchée sur chaine mot précis ou chaque terme
289
        switch (BB_ARGUMENT_OBJET) {
290
            case 'structure':
291
                $exp_exacte = 'Tela Botanica';
292
                $exp_separe = 'association botanique';
293
            break;
294
 
295
            case 'lien':
296
                $exp_exacte = 'Société Botanique du Vaucluse';
297
                $exp_separe = 'botanique Vaucluse';
298
            break;
299
 
300
            case 'media':
301
                $exp_exacte = 'écologie végétale';
302
                $exp_separe = 'écologie environnement';
303
            break;
304
        }
305
        $sortie .= '<br /><br />'."\n";
306
        $sortie .= '- Pour rechercher une <strong>chaine de mots précise</strong>, sélectionnez "<strong>Expression Exacte</strong>" ';
307
        $sortie .= '(ex. : <i>'.$exp_exacte.'</i> recherchera la correspondance exacte). ';
308
        $sortie .= 'Pour rechercher <strong>chacun des mots</strong> saisis, sélectionnez "<strong>Mots séparés</strong>" ';
309
        $sortie .= '(ex. : <i>'.$exp_separe.'</i>). ';
310
        $sortie .= 'Attention ! Le moteur ne comprend ni les symboles + ou -, ni les termes logiques ET, OU, AND, OR...'."\n";
311
 
312
        // Aide sur les moteurs utilisant les index Full Text
313
        if (BB_ARGUMENT_OBJET == 'media') {
314
            $sortie .= '<br /><br />'."\n";
315
            $sortie .=  '- Recherche intelligente : si vous saisissez "ortie", le moteur vous retournera toutes les données contenant cette chaîne de caractères : '.
316
                        '"ortie, sortie, ...". Pour rechercher un terme <strong>exact</strong>, vous pouvez le mettre entre crochets : "[ortie]".'."\n";
317
        }
318
        $sortie .= '<br /><br />'."\n";
319
        $sortie .= '- Seule la zone de saisie "Rechercher" peut contenir plusieurs termes ; les autres champs ne doivent contenir qu\'une seule information.'."\n";
320
 
321
        // Aide sur les moteurs faisant appel à GEO
322
        if ((BB_ARGUMENT_OBJET == 'structure') || (BB_ARGUMENT_OBJET == 'media')) {
323
            $sortie .= '<br /><br />'."\n";
324
            $sortie .=  '- Zone géographique : précisez ici une zone géographique (Pays, nom de département, ville...), '.
325
                        'ou un code de département Français (34, 29...).'."\n";
326
        }
327
 
328
        // Aide : liste complète
329
        $sortie .= '<br /><br />'."\n";
330
        $sortie .=  '- Pour obtenir la liste complète des  données : n\'entrez aucune information dans les champs de saisie, '.
331
                    'choisissez "Tous" dans les listes déroulantes, puis cliquez sur "Chercher". Pour obtenir toutes les données d\'une '.
332
                    'catégorie spécifique, vous pouvez affiner la recherche en sélectionnant une catégorie.'."\n";
3 jp_milcent 333
 
334
 
335
 
2 jp_milcent 336
    }
337
}
338
 
339
// Réalisation des statistiques sur la recherche effectuée
340
if ($TabFinder['valid'] == 1) {
341
    spy_validated_finder(BB_ARGUMENT_APPLI, $nbr_total);
342
}
343
 
344
/* +--Fin du code ----------------------------------------------------------------------------------------+
345
*
346
* $Log: not supported by cvs2svn $
347
* Revision 1.6  2005/02/24 18:32:40  jpm
348
* Mise en global d'une variable.
349
*
350
* Revision 1.5  2005/01/04 16:23:25  jpm
351
* Affichage de la requête sql.
352
*
353
* Revision 1.4  2004/09/16 12:06:39  jpm
354
* Décomposition du fichier information en plusieurs fichiers.
355
*
356
* Revision 1.3  2004/09/15 12:15:55  jpm
357
* Suppresion du code spécifique au moteur annuaire.
358
*
359
* Revision 1.2  2004/09/14 10:18:31  jpm
360
* Mise en forme et amélioration du code.
361
* Passage au XHTML strict.
362
*
363
* Revision 1.1  2004/09/10 18:41:48  jpm
364
* Transformations des ancien pop-up de Bilblio Bota en consultation avancée...
365
* Ajout d'un fichier fournissant les moteurs de recherche et d'un fichier gérant la consultation avancée.
366
*
367
*
368
* +-- Fin du code ----------------------------------------------------------------------------------------+
369
*/
370
?>