Subversion Repositories eFlore/Archives.herbiers

Compare Revisions

Ignore whitespace Rev 1 → Rev 2

/trunk/applications/hb_consultation/hb_consultation.php
New file
0,0 → 1,233
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of Herbier - Consultation. |
// | |
// | Foobar is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation; either version 2 of the License, or |
// | (at your option) any later version. |
// | |
// | Foobar 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 General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with Foobar; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: hb_consultation.php,v 1.1 2005-11-23 10:32:32 jp_milcent Exp $
/**
* Application fournissant un moteur de recherche sur les herbiers
*
* Fournit la liste des herbiers enregistrés dans la base de données.
*
*@package Herbier-Consultation
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@author Jean-Pascal MILCENT <jpm@clapas.org>
*@copyright Tela-Botanica 2000-2005
*@version $Revision: 1.1 $ $Date: 2005-11-23 10:32:32 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
/** Inclusion du fichier de configuration de l'application Herbier - Consultation. */
require_once HB_CHEMIN_APPLI.'hb_consultation'.GEN_SEP.'configuration'.GEN_SEP.'hbc_config.inc.php';
/** Inclusion du fichier de configuration de l'application Herbier - Administration. */
require_once HB_CHEMIN_APPLI.'hb_admin'.GEN_SEP.'configuration'.GEN_SEP.'hba_config.inc.php';
 
/** Inclusion de l'API Fragmenteur */
require_once HB_CHEMIN_API_FRAGMENTEUR.'FRAG_fragmenteur.fonct.php';
/** Inclusion de l'API Formulaire - classe : Form */
require_once HB_CHEMIN_API_FORM.'FORM_formulaire.class.php';
/** Inclusion de l'API Formulaire - classe : formFromTable */
require_once HB_CHEMIN_API_FORM.'FORM_formulaire_table.class.php';
 
/** Inclusion de la classe principale d'Herbier : herbier */
require_once HB_CHEMIN_BIBLIO.'hb_herbier.class.php';
/** Inclusion de la classe Herbier : collection */
require_once HB_CHEMIN_BIBLIO.'hb_collection.class.php';
/** Inclusion de la classe Herbier : indic */
require_once HB_CHEMIN_BIBLIO.'hb_indic.class.php';
/** Inclusion de la classe Herbier : indic_hist */
require_once HB_CHEMIN_BIBLIO.'hb_indic_hist.class.php';
/** Inclusion de la classe Herbier : organisation */
require_once HB_CHEMIN_BIBLIO.'hb_organisation.class.php';
/** Inclusion de la classe Herbier : type */
require_once HB_CHEMIN_BIBLIO.'hb_type.class.php';
/** Inclusion de la classe Herbier : equipe */
require_once HB_CHEMIN_BIBLIO.'hb_equipe.class.php';
 
// Appel du fichier de traduction des textes de l'application Consultation de Herbier
if (file_exists(HBC_CHEMIN_LANGUES.'hbc_langue_'.HB_I18N.'.inc.php')) {
/** Inclusion du fichier de traduction de l'application Consultation de Herbier. */
include_once HBC_CHEMIN_LANGUES.'hbc_langue_'.HB_I18N.'.inc.php';
} else {
/** Inclusion du fichier de traduction fr par défaut. */
include_once HBC_CHEMIN_LANGUES.'hbc_langue_fr.inc.php';
}
 
// Initialisation de la variable à retourner
$sortie .= '<!-- Herbier - Consultation : DEBUT -->'."\n";
 
// +------------------------------------------------------------------------------------------------------+
// | CORPS du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
global $project;
global $TransTab;
global $RECHERCHE, $INSTITUTION, $T_REPONSE, $TYPE_R;
if (!isset($_GET['consultation'])) {
// ici on écrase les valeurs des variables globales précédentes au cas où
// on vient de cliquez sur un chiffre du fragmenteur
if (empty($T_REPONSE)) {
$T_REPONSE = 20;
}
if ($TransTab) {
$values = FRAG_decoupageChaine($TransTab);
}
if (!empty($values)) {
foreach ($values as $key => $val) {
if ($val != '') {
$GLOBALS[$key] = $val ;
}
}
}
$sortie .= '<h1>'.'Rechercher un herbier :'.'</h1>'."\n";
$form_1 = new form($GLOBALS['_HERBIER_']['bdd']);
$sortie .= '<form action="'.$GLOBALS['_HERBIER_']['url']->getURL().'" method="post">'."\n";
$sortie .= '<p>'."\n";
$sortie .= '<label for="RECHERCHE">'.'Recherche : '.'</label>'."\n";
$sortie .= '<input id="RECHERCHE" type="text" name="RECHERCHE" class="insInputForm"';
if (!empty($RECHERCHE)) {
$sortie .= ' value="'.$RECHERCHE.'"';
}
$sortie .= '/>'."\n";
$sortie .= '<label for="">'.'Grouper les résultats : '.'</label>'."\n";
$sortie .= $form_1->selectFromTableau('T_REPONSE',array(10, 'par 10', 20, 'par 20', 50, 'par 50'), $T_REPONSE);
$sortie .= $form_1->submit('rechercher')."\n";
$sortie .= '</p>'."\n";
$sortie .= '</form>'."\n";
$sortie .= '<p>'.'Le moteur recherche dans tous les champs de la de la base :'.'</p>'."\n";
'<ul>'."\n".
'<li>'.'Nom d\'institution, adresse, ville, région'.'</li>'."\n".
'<li>'.'Index herbariorum'.'</li>'."\n".
'<li>'.'Nom de collection, description, collecteurs, notes'.'</li>'."\n".
'<li>'.'Indications taxonomiques, historiques, géographiques'.'</li>'."\n".
'</ul>'."\n";
$sortie .= '<p>'.'Vous pouvez utiliser le caractère % pour remplacer n\'importe quelle chaine.'.'</p>'."\n";
if (!empty($T_REPONSE) ) {//&& !empty($RECHERCHE)
$query_data = 'SELECT DISTINCT(ID_ORG) '.
'FROM HERBIERS_INDIC LEFT JOIN HERBIERS_COLLECTION ON HERBIERS_INDIC.ID = HERBIERS_COLLECTION.ID, HERBIERS_ORGANISATION '.
'WHERE (HERBIERS_COLLECTION.PARENT_ID = HERBIERS_ORGANISATION.ID_ORG '.
'AND (HERBIERS_INDIC.REM_INDIC LIKE "%'.$RECHERCHE.'%" '.
'OR HERBIERS_INDIC.TXT_INDIC LIKE "%'.$RECHERCHE.'%")) '.
'OR (HERBIERS_ORGANISATION.ID_ORG = HERBIERS_COLLECTION.PARENT_ID '.
'AND (HERBIERS_COLLECTION.DESCRIPTION LIKE "%'.$RECHERCHE.'%" '.
'OR HERBIERS_COLLECTION.NOTES LIKE "%'.$RECHERCHE.'%" '.
'OR HERBIERS_COLLECTION.COLLECTION_FOCUS LIKE "%'.$RECHERCHE.'%" '.
'OR HERBIERS_COLLECTION.PURPOSE LIKE "%'.$RECHERCHE.'%" '.
'OR HERBIERS_COLLECTION.COLLECTEURS LIKE "%'.$RECHERCHE.'%" '.
'OR HERBIERS_COLLECTION.STRENGTH LIKE "%'.$RECHERCHE.'%" '.
'OR HERBIERS_COLLECTION.NOM_COLLECTION LIKE "%'.$RECHERCHE.'%" '.
'OR HERBIERS_COLLECTION.COLLECTION_CODE LIKE "%'.$RECHERCHE.'%")) '.
'OR HERBIERS_ORGANISATION.INSTITUTION_NAME LIKE "%'.$RECHERCHE.'%" '.
'OR ADRESS_TEXT LIKE "%'.$RECHERCHE.'%" '.
'OR TOWN LIKE "%'.$RECHERCHE.'%" '.
'OR REGION LIKE "%'.$RECHERCHE.'%" '.
'OR INDEX_HERB LIKE "%'.$RECHERCHE.'%" '.
'ORDER BY TOWN';
if (empty($values['pstart'])) {
$values['pstart'] = 0 ;
}
// Autre requete pour obtenir le nombre total de réponse
// car la clause limit x,y limite le nombre de résultat
$query_nombre = $query_data;
// Ajout de la clause limit pour les données à afficher
$query_data .= ' LIMIT '.$values['pstart'].','.$T_REPONSE;
$result_data = mysql_query($query_data) or die (BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $query_data));
$result_nombre = mysql_query($query_nombre) or die (BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $query_nombre));
$nombre = mysql_num_rows($result_nombre);
mysql_free_result($result_nombre);
// Utilisation du fragmentateur
$mon_frag = new fragmenteur();
$tableau = array();
$tableau['pstart'] = $values['pstart'];
$tableau['step'] = $T_REPONSE;
$tableau['pend'] = $nombre;
// Construction de la variable TransTab
$tableau['TYPE_R'] = $TYPE_R;
$tableau['T_REPONSE'] = $T_REPONSE;
$sortie .= '<p id="frag_nbre_resultat">'.FRAG_afficherTxtNbreResultat('', $tableau, mysql_num_rows($result_data), $nombre).'</p>'."\n";
if ((mysql_num_rows($result_data) > 0) && ($tableau['step'] < $nombre)) {
$sortie .= '<p id="frag_navigation">';
$sortie .= $mon_frag->fragmente($tableau, $nombre);
$sortie .= '</p>'."\n";
}
$sortie .= '<ul>'."\n";
while ($row1 = mysql_fetch_object($result_data)) {
$resultat = new H_organisation() ;
$resultat->getFromSQL($row1->ID_ORG);
$sortie .= '<li>'.$resultat->TOWN.' - ';
$sortie .= '<a href="'.HB_URL_COURANTE_CONSULTATION_FICHE_HERBIER.'&amp;id_org='.$row1->ID_ORG.'">'.
$resultat->INSTITUTION_NAME.
'</a>';
$sortie .= '</li>'."\n";
}
$sortie .= '</ul>'."\n";
if ((mysql_num_rows($result_data) > 0) && ($tableau['step'] < $nombre)) {
$sortie .= '<p>'.$mon_frag->fragmente($tableau, $nombre).'</p>'."\n";
}
}
} elseif (isset($_GET['consultation']) && $_GET['consultation'] == 'herbier') {
include_once 'hbc_info_herbier.inc.php';
} elseif (isset($_GET['consultation']) && $_GET['consultation'] == 'collection') {
include_once 'hbc_info_collection.inc.php';
}
 
// +------------------------------------------------------------------------------------------------------+
// | PIED du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
$sortie .= '<!-- Herbier - Consultation : FIN -->'."\n";
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.3 2005/03/30 09:48:58 jpm
* Début gestion des raccourcis vers l'administration.
*
* Revision 1.2 2005/03/09 15:55:17 jpm
* Changement du nom de l'appli.
*
* Revision 1.1 2005/03/08 13:49:17 jpm
* Ajout de l'application de consultation sous forme de moteur de recherche.
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>