New file |
0,0 → 1,365 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: bbc_recherche.inc.php,v 1.1 2005-11-23 10:22:25 jp_milcent Exp $ |
/** |
* Appli bb_consultation : gestion des moteurs de recherche de Biblio Bota |
* |
* Cette application permet de gérer les moteurs de recherches de l'ensemble des données comprise |
* dans le modèle de Biblio Bota : |
* - articles botaniques |
* - livres et média botaniques |
* - sites web |
* - organismes liés à la botanique |
* |
*@package BiblioBota-Consultation |
//Auteur original : |
*@author Jean-Charles GRANGER <tela@vecteur.org> |
//Autres auteurs : |
*@author Jean-Pascal MILCENT <jpm@clapas.org> |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.1 $ $Date: 2005-11-23 10:22:25 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
/** Inclusion de la bibliothèque de réaliser les statistiques spécifiques à l'application consultation de BiblioBota.*/ |
require_once BBC_CHEMIN_BIBLIO.'bbc_statistique.fonct.php'; |
|
// Globalisation des variables |
global $TabFinder, $TransTab, $plugin, $tbl; |
if (isset($TransTab)) { |
$TabFinder = FRAG_decoupageChaine($TransTab); |
} |
|
// Vérification de l'utilisation de BiblioBota comme service web |
if (empty($TabFinder['plugin'])) { |
$TabFinder['plugin'] = ''; |
} |
if (BB_ARGUMENT_SERVICE != '' && $TabFinder['plugin'] == '') { |
$TabFinder['plugin'] = BB_ARGUMENT_SERVICE; |
} |
// Limitation au domaine ? |
if (BB_ARGUMENT_DOMAINE != 1) { |
$var_biblio['limit_domain'] = 1; |
} else { |
$var_biblio['limit_domain'] = 0; |
} |
|
// Gestion du mode du moteur: nomal ou avancé ( = plus d'options) |
if (empty($TabFinder['finder_mode'])) { |
$TabFinder['finder_mode'] = 'normal'; |
} |
|
// Initialisation de TabFinder au cas ou cela n'aurait pas été fait |
if (!isset($TabFinder['plugin'])) $TabFinder['plugin'] = ''; |
if (!isset($TabFinder['geo'])) $TabFinder['geo'] = ''; |
if (!isset($TabFinder['chaine'])) $TabFinder['chaine'] = ''; |
if (!isset($TabFinder['sort'])) $TabFinder['sort'] = $GLOBALS['moteur_biblio']['defaut_sort']; |
if (!isset($TabFinder['auteur'])) $TabFinder['auteur'] = ''; |
if (!isset($TabFinder['categ'])) $TabFinder['categ'] = ''; |
if (!isset($TabFinder['pstart'])) $TabFinder['pstart'] = '0'; |
if (!isset($TabFinder['step'])) $TabFinder['step'] = '20'; |
if (!isset($TabFinder['valid'])) $TabFinder['valid'] = '0'; |
if (!isset($TabFinder['typque'])) $TabFinder['typque'] = '1'; |
if (!isset($TabFinder['categ_2'])) $TabFinder['categ_2'] = ''; |
if (!isset($TabFinder['categ_3'])) $TabFinder['categ_3'] = ''; |
if (!isset($TabFinder['since'])) $TabFinder['since'] = ''; |
if (!isset($TabFinder['finder_mode'])) $TabFinder['finder_mode'] = 'normal'; |
// +------------------------------------------------------------------------------------------------------+ |
// | CORPS du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
// no_help est une variable qui est passée par un PlugIn s'il n'y a pas besoin d'aide |
global $no_help; |
|
// +------------------------------------------------------------------------------------------------------+ |
// Début de gestion des services Web (plugin) |
if ($TabFinder['plugin'] != '') { |
// Séparation des éléments du PlugIn |
$plugin_exp = explode('-', $TabFinder['plugin']); |
|
// Mise en global des variables utilisées ailleurs |
global $plugin_store; |
|
// Création des arguments pour les onglets |
$TabFinder['args'] = '&arg_0=plugin%3D'.$TabFinder['plugin'].'&arg_1=plugin%3D'.$TabFinder['plugin']; |
|
// L'argument 0 de plugin_exp peut avoir les valeurs : |
// str (réduction à une structure), coll (réduction à une collection), aut (réduction à des auteurs) |
switch ($plugin_exp[0]) { |
case 'str': |
// On récupère ici dans plugin l'identifiant d'une structure, |
// il faut donc réduire à cette structure dans la requête |
if (BB_ARGUMENT_REGROUPEMENT == 'article') { |
$plugin_store['count_add_table'] = ', '.$tbl['article'].', '.$tbl['fascicule'].', '.$tbl['serie'].', '.$tbl['collection']; |
$plugin_store['count_add_query'] = ' AND B_C_LKSTR = '.$plugin_exp[1].' '. |
'AND B_C_CRAI = B_SER_CRAICOLL '. |
'AND B_SER_CRAICOLL = B_F_CRAICOLL '. |
'AND B_SER_IDSERIE = B_F_CRAISERIE '. |
'AND B_F_CRAICOLL = B_A_CRAICOLL '. |
'AND B_F_CRAISERIE = B_A_CRAISERIE '. |
'AND B_F_NUMERO = B_A_CRAIFASC '. |
'AND B_I_IDITEM = B_A_IDART '; |
|
$plugin_store['categ_add_table'] = ', '.$tbl['article'].', '.$tbl['fascicule'].', '.$tbl['item']; |
$plugin_store['categ_add_query'] = ' AND B_C_LKSTR = '.$plugin_exp[1].' '. |
'AND B_SER_IDSERIE = B_F_CRAISERIE '. |
'AND B_F_CRAICOLL = B_A_CRAICOLL '. |
'AND B_F_CRAISERIE = B_A_CRAISERIE '. |
'AND B_F_NUMERO = B_A_CRAIFASC '. |
'AND B_I_IDITEM = B_A_IDART '; |
} else if (BB_ARGUMENT_REGROUPEMENT == 'media') { |
$plugin_store['count_add_table'] = ', '.$tbl['media']; |
$plugin_store['count_add_query'] = ' AND B_M_LKSTR = '.$plugin_exp[1].' '. |
'AND B_I_IDITEM = B_M_IDMEDIA '; |
$plugin_store['categ_add_table'] = ''; |
$plugin_store['categ_add_query'] = ' AND B_M_LKSTR = '.$plugin_exp[1].' '; |
$plugin_store['query_add_query'] = ' AND B_M_LKSTR = '.$plugin_exp[1].' '; |
} |
break; |
|
case 'coll': |
// On récupère ici dans plugin l'identifiant d'une collection, |
// il faut donc réduire à cette collection dans la requête |
// cette option n'existe que pour le regroupement ARTICLE |
|
if (BB_ARGUMENT_REGROUPEMENT == 'article') { |
$plugin_store['count_add_table'] = ', '.$tbl['article']; |
$plugin_store['count_add_query'] = ' AND B_A_CRAICOLL = "'.$plugin_exp[1].'" AND B_I_IDITEM = B_A_IDART '; |
$plugin_store['categ_add_table'] = ''; |
$plugin_store['categ_add_query'] = ' AND B_C_CRAI = "'.$plugin_exp[1].'" '; |
$plugin_store['query_add_query'] = ' AND B_C_CRAI = "'.$plugin_exp[1].'" '; |
} else if (BB_ARGUMENT_REGROUPEMENT == 'media') { |
// leurre pour finir proporement le script |
$plugin_store['count_add_table'] = ''; |
$plugin_store['count_add_query'] = ' AND B_I_IDITEM = "aeiouy"'; |
$plugin_store['categ_add_table'] = ''; |
$plugin_store['categ_add_query'] = ''; |
$plugin_store['query_add_query'] = ''; |
} |
break; |
|
case 'aut': |
// On récupère ici dans plugin des identifiants d'auteurs |
// il faut donc réduire à ces auteurs dans la requête |
// les noms d'auteurs sont séparés par des "!" |
|
$plugin_auteurs = explode('@',$plugin_exp[1]); |
|
$plugin_i = 0; |
$plugin_action = ' AND ('; |
|
while ($plugin_i < count($plugin_auteurs)) { |
if ($plugin_i != 0) { |
$plugin_action .= ' OR '; |
} |
$plugin_action .= 'B_I_AUTEURSAISIE LIKE "%'.$plugin_auteurs[$plugin_i].'%" '; |
$plugin_i++; |
} |
|
$plugin_action .= ') '; |
|
$plugin_store['count_add_table'] = ''; |
$plugin_store['count_add_query'] = $plugin_action; |
|
if (BB_ARGUMENT_REGROUPEMENT == 'article') { |
$plugin_store['categ_add_table'] = ", ".$tbl['article'].", ".$tbl['fascicule'].", ".$tbl['item']; |
$plugin_store['categ_add_query'] = ' '.$plugin_action.' '. |
'AND B_C_CRAI = B_SER_CRAICOLL '. |
'AND B_SER_CRAICOLL = B_F_CRAICOLL '. |
'AND B_SER_IDSERIE = B_F_CRAISERIE '. |
'AND B_F_CRAICOLL = B_A_CRAICOLL '. |
'AND B_F_CRAISERIE = B_A_CRAISERIE '. |
'AND B_F_NUMERO = B_A_CRAIFASC '. |
'AND B_I_IDITEM = B_A_IDART '; |
$plugin_store['query_add_query'] = ' '.$plugin_action.' '; |
} else if (BB_ARGUMENT_REGROUPEMENT == 'media') { |
$plugin_store['categ_add_table'] = ''; |
$plugin_store['categ_add_query'] = ' '.$plugin_action.' '; |
$plugin_store['query_add_query'] = ' '.$plugin_action.' '; |
} |
break; |
|
default: |
die('Regroupement PLUGIN impossible... Méthode Plugin par défaut inexistante (méthodes disponibles : str, coll et aut).'); |
break; |
} |
} // Fin de gestion des services Web |
|
// +------------------------------------------------------------------------------------------------------+ |
// Création de l'interface du moteur de recherche |
require_once BBC_CHEMIN_BIBLIO.'bbc_moteur_'.BB_ARGUMENT_OBJET.'.fonct.php'; |
$sortie .= mkengine(); |
// Affichage des résultats d'une recherche |
if ((isset($TabFinder)) && ($TabFinder['valid'] == 1)) { |
global $nbr_total; |
if ($nbr_total > 1) { |
$pluriel_tot = 's'; |
} |
|
// Création de la requête |
include_once BBC_CHEMIN_BIBLIO.'bbc_requete_'.BB_ARGUMENT_OBJET.'.fonct.php'; |
$requete = mkquery(); |
// DEBOGAGE : pour voir la requete finale |
//$GLOBALS['_DEBOGAGE_'] .= $requete.'<br>'; |
|
//Requete de calcul du nombre total d'enregistrements de la table |
$result_local = mysql_query($requete) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete)); |
$nbr_local = mysql_num_rows($result_local); |
mysql_free_result($result_local); |
|
if ($nbr_local > 1) { |
$pluriel_loc = 's'; |
} |
|
// Requete de sélection sur la quantité de données demandées par l'utilisateur (avec bornes LIMIT) |
if ($TabFinder['pstart'] == '') { |
$TabFinder['pstart'] = 0; |
} |
$query_final = ' LIMIT '.$TabFinder['pstart'].', '.$TabFinder['step']; |
|
global $result_final; |
$result_final = mysql_query($requete.$query_final) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete.$query_final)); |
global $nbr_final; |
$nbr_final = mysql_num_rows($result_final); |
|
$sortie .= '<p class="insTitle1">'; |
$TabFinder['pend'] = $nbr_local; |
$sortie .= FRAG_afficherTxtNbreResultat('', $TabFinder, $nbr_local, $nbr_total); |
$sortie .= '</p>'; |
|
if (($nbr_local > 0) && ($TabFinder['step'] < $nbr_local)) { |
$sortie .= '<p id="fragmenteur_tete" class="fragmenteur">'; |
$frag = new fragmenteur(); |
$sortie .= $frag->fragmente($TabFinder, $nbr_local); |
$sortie .= '</p>'; |
} |
|
include_once BBC_CHEMIN_BIBLIO.'bbc_affichage_'.BB_ARGUMENT_OBJET.'.fonct.php'; |
$sortie .= mkresu(); |
mysql_free_result($result_final); |
|
if (($TabFinder['step'] >= 20) && ($nbr_local - $TabFinder['pstart'] >= (20 + $TabFinder['step']))) { |
$sortie .= '<p id="fragmenteur_pied" class="fragmenteur">'; |
$sortie .= $frag->fragmente($TabFinder, $nbr_local); |
$sortie .= '</p>'."\n\n"; |
} |
} |
|
// Création de l'aide |
if ((!isset($TabFinder)) || ($TabFinder['valid'] != 1)) { |
if (((!empty($no_help)) && ($no_help == 1))) { |
$sortie .= ''; |
} else { |
$sortie .= presa_mk_title('Aide à la recherche : ', 3); |
$sortie .= '<p class="texte_tb">'."\n"; |
|
// Aide commune |
$sortie .= '- Attention aux fautes de frappe : le moteur recherche EXACTEMENT les termes saisis.'."\n"; |
|
// Aide switchée sur chaine mot précis ou chaque terme |
switch (BB_ARGUMENT_OBJET) { |
case 'structure': |
$exp_exacte = 'Tela Botanica'; |
$exp_separe = 'association botanique'; |
break; |
|
case 'lien': |
$exp_exacte = 'Société Botanique du Vaucluse'; |
$exp_separe = 'botanique Vaucluse'; |
break; |
|
case 'media': |
$exp_exacte = 'écologie végétale'; |
$exp_separe = 'écologie environnement'; |
break; |
} |
$sortie .= '<br /><br />'."\n"; |
$sortie .= '- Pour rechercher une <strong>chaine de mots précise</strong>, sélectionnez "<strong>Expression Exacte</strong>" '; |
$sortie .= '(ex. : <i>'.$exp_exacte.'</i> recherchera la correspondance exacte). '; |
$sortie .= 'Pour rechercher <strong>chacun des mots</strong> saisis, sélectionnez "<strong>Mots séparés</strong>" '; |
$sortie .= '(ex. : <i>'.$exp_separe.'</i>). '; |
$sortie .= 'Attention ! Le moteur ne comprend ni les symboles + ou -, ni les termes logiques ET, OU, AND, OR...'."\n"; |
|
// Aide sur les moteurs utilisant les index Full Text |
if (BB_ARGUMENT_OBJET == 'media') { |
$sortie .= '<br /><br />'."\n"; |
$sortie .= '- Recherche intelligente : si vous saisissez "ortie", le moteur vous retournera toutes les données contenant cette chaîne de caractères : '. |
'"ortie, sortie, ...". Pour rechercher un terme <strong>exact</strong>, vous pouvez le mettre entre crochets : "[ortie]".'."\n"; |
} |
$sortie .= '<br /><br />'."\n"; |
$sortie .= '- Seule la zone de saisie "Rechercher" peut contenir plusieurs termes ; les autres champs ne doivent contenir qu\'une seule information.'."\n"; |
|
// Aide sur les moteurs faisant appel à GEO |
if ((BB_ARGUMENT_OBJET == 'structure') || (BB_ARGUMENT_OBJET == 'media')) { |
$sortie .= '<br /><br />'."\n"; |
$sortie .= '- Zone géographique : précisez ici une zone géographique (Pays, nom de département, ville...), '. |
'ou un code de département Français (34, 29...).'."\n"; |
} |
|
// Aide : liste complète |
$sortie .= '<br /><br />'."\n"; |
$sortie .= '- Pour obtenir la liste complète des données : n\'entrez aucune information dans les champs de saisie, '. |
'choisissez "Tous" dans les listes déroulantes, puis cliquez sur "Chercher". Pour obtenir toutes les données d\'une '. |
'catégorie spécifique, vous pouvez affiner la recherche en sélectionnant une catégorie.'."\n"; |
$sortie .= '</p>'."\n"; |
} |
} |
|
// Réalisation des statistiques sur la recherche effectuée |
if ($TabFinder['valid'] == 1) { |
spy_validated_finder(BB_ARGUMENT_APPLI, $nbr_total); |
} |
|
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.7 2005/05/17 10:10:08 jpm |
* Correction des bogues avant mise en ligne du site v4. |
* |
* Revision 1.6 2005/02/24 18:32:40 jpm |
* Mise en global d'une variable. |
* |
* Revision 1.5 2005/01/04 16:23:25 jpm |
* Affichage de la requête sql. |
* |
* Revision 1.4 2004/09/16 12:06:39 jpm |
* Décomposition du fichier information en plusieurs fichiers. |
* |
* Revision 1.3 2004/09/15 12:15:55 jpm |
* Suppresion du code spécifique au moteur annuaire. |
* |
* Revision 1.2 2004/09/14 10:18:31 jpm |
* Mise en forme et amélioration du code. |
* Passage au XHTML strict. |
* |
* Revision 1.1 2004/09/10 18:41:48 jpm |
* Transformations des ancien pop-up de Bilblio Bota en consultation avancée... |
* Ajout d'un fichier fournissant les moteurs de recherche et d'un fichier gérant la consultation avancée. |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |