Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?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_requete_lien.fonct.php,v 1.1 2005-11-23 10:22:25 jp_milcent Exp $/*** Fonctions de création de la requête sur un lien.** Contient une fonction créant la requête d'intérogation de la base de données.* Valable pour le paramètre "lien".**@package BiblioBota-Consultation*@subpackage Fonctions//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 |// +------------------------------------------------------------------------------------------------------+/*Mettre ici les inclusions de fichiers*/// +------------------------------------------------------------------------------------------------------+// | LISTE de FONCTIONS |// +------------------------------------------------------------------------------------------------------+/*Mettre ici la liste de fonctions.*/function mkquery(){global $TabFinder, $tbl;// Initialisation$order_query = '';// Si la variable de catégorie vaut 0, il n'y a pas affinage de la requête par catégorie. Sinon, on affine.if ($TabFinder['categ'] != 0) {$add_to_from = $tbl['cat'].', '.$tbl['categlien'].', ';$add_to_query = ' AND ('.$tbl['cat'].'.B_CAT_IDCAT = '.$TabFinder['categ'].')';if ($TabFinder['chaine'] != '') {$join_categ = ' AND ';} else {$join_categ = '';}$join_categ .= ' AND ('.$tbl['link'].'.B_L_IDLINK = '.$tbl['categlien'].'.B_LC_IDLINK) AND ('.$tbl['cat'].'.B_CAT_IDCAT = '.$tbl['categlien'].'.B_LC_IDCAT)';} else {$add_to_from = '';$add_to_query = '';$join_categ = '';}// Création du SELECT$normal_query = 'SELECT '.$tbl['link'].'.*, '.$tbl['str'].'.B_S_NOM ';// si le raffinement de catégorie vaut autre chose que 0, il faut ajouter les tables de catégoriesif ($TabFinder['categ'] != 0) {$normal_query .= ', '.$tbl['categlien'].'.*, '.$tbl['cat'].'.B_CAT_LABEL, '.$tbl['cat'].'.B_CAT_IDCAT ';}// Création du FROM$normal_query .= 'FROM '.$add_to_from.$tbl['link'].' LEFT JOIN '.$tbl['str'].' ON '.$tbl['link'].'.B_L_LKSTR = '.$tbl['str'].'.B_S_IDSTR ';// Création du WHERE$normal_query .= 'WHERE B_L_CACHER = 0 ';if (($TabFinder['typque'] == 0) && ($TabFinder['chaine'] != '')) {$normal_query .= ' AND (';$normal_query .= $tbl['link'].'.B_L_TITRE like "%'.$TabFinder['chaine'].'%" '.'OR '.$tbl['link'].'.B_L_URL like "%'.$TabFinder['chaine'].'%" '.'OR '.$tbl['link'].'.B_L_RESUMCLE like "%'.$TabFinder['chaine'].'%" ';$normal_query .= ') ';} else if ($TabFinder['chaine'] != '') {$normal_query .= ' AND (';// Si la variable de type de recherche vaut 1, il faut que le moteur recherche chaque motifif ($TabFinder['typque'] == 1) {$result_from_ex = explode (' ', $TabFinder['chaine']);}$i_ex = 0;while ($i_ex < count($result_from_ex)) {$normal_query .= $tbl['link'].'.B_L_TITRE LIKE "%';if ($result_from_ex[$i_ex] != '') {$normal_query .= $result_from_ex[$i_ex];}$normal_query .= '%" OR ';$normal_query .= $tbl['link'].'.B_L_URL LIKE "%';if ($result_from_ex[$i_ex] != '') {$normal_query .= $result_from_ex[$i_ex];}$normal_query .= '%" OR ';$normal_query .= $tbl['link'].'.B_L_RESUMCLE LIKE "%';if ($result_from_ex[$i_ex] != '') {$normal_query .= $result_from_ex[$i_ex];}$normal_query .= '%"';if ($i_ex < (count($result_from_ex) - 1)) {$normal_query .= ') AND (';}$i_ex++;}$normal_query .= ')';}// traitement du réducteur SINCE (fonction de la date)if ($TabFinder['since'] != '') {$since_var = explode('/', $TabFinder['since']);if (empty($since_var[0])) {$since_var[0] = '';}if (empty($since_var[1])) {$since_var[1] = '';}if (empty($since_var[2])) {$since_var[2] = '';}$timestamp = mktime(NULL, NULL, NULL, $since_var[1], $since_var[0], $since_var[2]);if (!ereg('WHERE', $normal_query)) {$normal_query .= ' WHERE ';} else {$normal_query .= ' AND ';}$normal_query .= 'B_L_MAJFICHE > '.$timestamp;}// Création de l'ordre de tri$order_query = ' ORDER BY '.$TabFinder['sort'];// Affectation de la requête à la variable qui va l'envoyer au moteur$unreq = $normal_query.' '.$join_categ.' '.$add_to_query.' '.$order_query;return $unreq;}/* +--Fin du code ----------------------------------------------------------------------------------------+** $Log: not supported by cvs2svn $* Revision 1.4 2005/06/20 17:32:14 jpm* Correction erreur de construction de la requête sql.** Revision 1.3 2005/05/17 10:10:08 jpm* Correction des bogues avant mise en ligne du site v4.** Revision 1.2 2004/09/14 11:49:52 jpm* Ajout de l'entête au fichier.*** +-- Fin du code ----------------------------------------------------------------------------------------+*/?>