New file |
0,0 → 1,461 |
<?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_moteur_media.fonct.php,v 1.1 2005-11-23 10:22:25 jp_milcent Exp $ |
/** |
* Fonctions de création du moteur de recherche des médias. |
* |
* Contient les fonctions permettant de retourner l'affichage du moteur de recherche des média. |
* Valable pour le paramètre "media". |
* |
*@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 | |
// +------------------------------------------------------------------------------------------------------+ |
|
|
|
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE de FONCTIONS | |
// +------------------------------------------------------------------------------------------------------+ |
|
/** Fonction mkengine() - Créé le moteur de recherche en XHTML pour les médias. |
* |
* Fonction créant le moteur de recherche en XHTML pour le |
* paramêtre "media". |
* |
* @return string le XHTML du moteur de recherche permettant de récupérer les média. |
*/ |
function mkengine() |
{ |
// Initialisation des variables globales |
global $label_bbota, $tbl, $TabFinder, $nbr_total, $query_dom, $var_biblio; |
global $arg_0,$arg_1,$arg_2,$arg_3,$arg_4,$arg_5; |
global $plugin_store; |
|
// Initialisation des variables |
$url_courante = BB_URL_COURANTE_CONSULTATION; |
$retour = ''; |
|
$tmp_titre = eregi_replace('_', ' ', BB_ARGUMENT_TITRE); |
|
// Comptage du nombre total de données dans la table (hors CACHER = 1) |
if ($var_biblio['limit_domain'] == 1) { |
$add_domain_fr = ', '.$tbl['domaine_lk']; |
$add_domain_qu = ' AND B_I_IDITEM = B_DL_IDITEM AND B_DL_IDDOM = 1'; |
} else { |
$add_domain_fr = ''; |
$add_domain_qu = ''; |
} |
if (BB_ARGUMENT_REGROUPEMENT == 'article') { |
$requete = 'SELECT DISTINCT COUNT(B_I_IDITEM) AS CPT '. |
'FROM '.$tbl['item'].$add_domain_fr.$plugin_store['count_add_table'].' '. |
'WHERE B_I_CACHER = 0 '. |
'AND B_I_TYPLOG = 1 '. |
'AND B_I_TYPPHY = 2 '. |
$add_domain_qu.' '. |
$plugin_store['count_add_query']; |
} else if (BB_ARGUMENT_REGROUPEMENT == 'media') { |
$requete = 'SELECT DISTINCT COUNT(B_I_IDITEM) AS CPT '. |
'FROM '.$tbl['item'].$add_domain_fr.$plugin_store['count_add_table'].' '. |
'WHERE B_I_CACHER = 0 '. |
'AND B_I_TYPPHY <> 2 '. |
$add_domain_qu.' '. |
$plugin_store['count_add_query']; |
} |
// DEBOGAGE : pour voir la requete de comptage |
//$GLOBALS['_DEBOGAGE_'] .= $requete.'<br>'; |
$resultat = $GLOBALS['db_bb']->query($requete); |
(DB::isError($resultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : ''; |
|
if ($resultat->numRows() == 1) { |
$tmp_nb = $resultat->fetchRow(DB_FETCHMODE_OBJECT); |
$nbr_total = $tmp_nb->CPT; |
if ($nbr_total > 0) { |
$chaine = 'parmi '.$nbr_total; |
} else { |
$retour .= presa_mk_title('Rechercher '.$tmp_titre, 1); |
$retour .= '<p class="information">'.'Ce moteur de recherche ne contient aucune donnée...'.'</p>'; |
// Cette variable sert à éviter l'affichage de l'aide |
global $no_help; |
$no_help = 1; |
return $retour; |
} |
} |
|
// Affichage du titre |
$retour .= presa_mk_title('Rechercher '.$chaine.' '.$tmp_titre.' :', 1); |
|
// Affichage du formulaire du moteur de recherche |
$retour .= '<form id="bb_moteur_media" '. |
'action="'.$url_courante."&arg_0=$arg_0&arg_1=$arg_1&arg_2=$arg_2&arg_3=$arg_3&arg_4=$arg_4&arg_5=$arg_5".'" '. |
'method="post">'."\n"; |
$retour .= '<ul>'."\n"; |
$resultat->free();// Fin comptage |
|
// Construction du moteur |
// Ligne de recherche 1 |
$retour .= '<li id="bb_moteur_media_01">'."\n"; |
$retour .= form_mk_chaine(stripslashes($TabFinder['chaine'])).' '.form_mk_typque($TabFinder['typque']); |
$retour .= '</li>'."\n"; |
|
// Ligne de recherche 2 |
$retour .= '<li id="bb_moteur_media_02">'."\n".form_mk_auteur(stripslashes($TabFinder['auteur'])).'</li>'."\n"; |
|
// Ligne de recherche 3 |
$retour .= '<li id="bb_moteur_media_03">'."\n".form_mk_categ($TabFinder['categ']).'</li>'."\n"; |
|
// Ligne de recherche 4 |
$retour .= '<li id="bb_moteur_media_04">'."\n"; |
$retour .= form_mk_geo(stripslashes($TabFinder['geo'])).' '; |
if (BB_ARGUMENT_REGROUPEMENT == 'media') { |
$retour .= form_mk_categ_3($TabFinder['categ_3']).' '.form_mk_categ_2($TabFinder['categ_2']); |
} |
$retour .= '</li>'."\n"; |
|
// Mode avancée |
if ($TabFinder['finder_mode'] == 'advance') { |
$retour .= '<li id="bb_moteur_media_05">'."\n".form_mk_since($TabFinder['since']).'</li>'."\n"; |
|
// Lignes de regroupement (frequente) |
$retour .= '<li id="bb_moteur_media_06">'."\n".form_mk_step($TabFinder['step']).'</li>'."\n"; |
$retour .= '<li id="bb_moteur_media_07">'."\n".form_mk_sort($TabFinder['sort']).'</li>'."\n"; |
} |
|
$retour .= '<li id="bb_moteur_media_08" class="bb_aligner_droite">'."\n"; |
|
$retour .= form_mk_plugin($TabFinder['plugin']).form_mk_advance().' '.form_mk_submit()."\n"; |
$retour .= '</li>'."\n"; |
|
$retour .= '</ul>'."\n"; |
$retour .= '</form>'."\n"; |
|
// Ajout de liens pour les moteurs de recherche |
// Premier lien... |
$retour .= '<p>'."\n"; |
$link = $url_courante.'&TransTab=typque,1!valid,1!finder_mode,normal!sort,B_I_AUTEURS!'; |
$link .= 'pstart,0!step,20!pend,231!plugin,!geo,!chaine,!auteur,!categ,!categ_2,!categ_3,!since,!nom,!prenom,!ville,!dept,!pays,!cotisant,!mail,!'; |
$retour .= ' <a href="'.$link.'" style="visibility:hidden;">all</a>'."\n"; |
|
// Second lien... |
$link = $url_courante.'&TransTab=typque,1!valid,1!finder_mode,normal!sort,B_I_AUTEURS!'; |
$link .= 'pstart,0!step,20!pend,231!plugin,!geo,!chaine,!auteur,!categ,!categ_2,!categ_3,!since,!nom,!prenom,!ville,!dept,!pays,!cotisant,!mail,!'; |
$retour .= ' <a href="'.$link.'" style="visibility:hidden;">all</a>'."\n"; |
$retour .= '</p>'."\n"; |
|
return $retour; |
} |
|
|
// form_mk_sort($actualsort,$class) : |
// fonction spécifique du moteur MEDIA |
// créé une liste déroulante TabFinder[sort] pour ordonner les pages de résultats |
// Entrée : $actualsort (valeur de TabFinder['sort']), $class (classe CSS) par défaut "insInputForm" |
// Sortie (par retour) : string |
function form_mk_sort($actualsort, $class = 'bb_champ') |
{ |
global $TabFinder; |
$retour = ''; |
$id = 'TabFinder[sort]'; |
|
$retour .= '<label for="'.$id.'">'.'Trier par : '.'</label>'; |
$retour .= '<select id="'.$id.'" name="'.$id.'" class="'.$class.'">'."\n"; |
|
$retour .= ' <option value="B_I_AUTEURS" '; |
if ($actualsort == 'B_I_AUTEURS') { |
$retour .= 'selected="selected"'; |
} |
$retour .= '>'.'auteur(s)'.'</option>'."\n"; |
|
$retour .= ' <option value="B_I_TITRE" '; |
if ($actualsort == 'B_I_TITRE') { |
$retour .= 'selected="selected"'; |
} |
$retour .= '>'.'titre'.'</option>'."\n"; |
|
if (BB_ARGUMENT_REGROUPEMENT == 'media') { |
$retour .= ' <option value="B_I_TYPLOG" '; |
if ($actualsort == 'B_I_TYPLOG') { |
$retour .= 'selected="selected"'; |
} |
$retour .= '>'.'type de contenu'.'</option>'."\n"; |
|
$retour .= ' <option value="B_I_TYPPHY" '; |
if ($actualsort == 'B_I_TYPPHY') { |
$retour .= 'selected="selected"'; |
} |
$retour .= '>'.'type de support'.'</option>'."\n"; |
} |
|
if (BB_ARGUMENT_REGROUPEMENT == 'article') { |
$le_champ = 'B_F_DATE'; |
} else { |
$le_champ = 'B_M_DATE'; |
} |
|
$retour .= ' <option value="'.$le_champ.'" '; |
if ($actualsort == $le_champ) { |
$retour .= 'selected'; |
} |
$retour .= '>'.'date'.'</option>'."\n"; |
|
$retour .= '</select>'."\n\n"; |
|
return $retour; |
} |
|
|
// form_mk_categ($actualsort,$class) : |
// fonction spécifique du moteur LINK |
// créé une liste déroulante TabFinder[categ] pour affiner les résultats |
// Entrée : $actualcateg (valeur de TabFinder['categ']), $class (classe CSS) par défaut "insInputForm" |
// Sortie (par retour) : string |
function form_mk_categ($actualcateg, $class = 'bb_champ') |
{ |
global $tbl, $TabFinder, $plugin_store; |
$retour = ''; |
$id = 'TabFinder[categ]'; |
|
if (BB_ARGUMENT_REGROUPEMENT == 'article') { |
// Affichage du réducteur - collections |
$requete = 'SELECT B_C_CRAI, B_C_NOMCOMPLET, B_C_ABREGE '. |
'FROM '.$tbl['collection'].', '.$tbl['serie'].$plugin_store['categ_add_table'].' '. |
'WHERE B_C_CRAI = B_SER_CRAICOLL '. |
'AND B_SER_INTOBIBLIO = 1 '. |
$plugin_store['categ_add_query']. |
'GROUP BY B_C_CRAI '. |
'ORDER BY B_C_NOMCOMPLET'; |
$result_str = mysql_query($requete) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete)); |
$nb_results = mysql_num_rows($result_str); |
|
$retour .= '<label for="'.$id.'">'.'Dans :'.'</label>'; |
$retour .= '<select name="'.$id.'" class="'.$class.'">'."\n"; |
|
if ($nb_results > 1) { |
$retour .= ' <option value=""'; |
if ($actualcateg == '') { |
$retour .= ' selected="selected"'; |
} |
$retour .= '>Toutes les revues</option>'."\n"; |
} |
|
while ($row = mysql_fetch_object($result_str)) { |
$collection = $row->B_C_NOMCOMPLET; |
$abrege = $row->B_C_ABREGE; |
$crai = $row->B_C_CRAI; |
$retour .= '<option value="'.$crai.'"'; |
if ($actualcateg == $crai) { |
$retour .= ' selected="selected"'; |
} |
$retour .= '>'; |
|
if ($abrege == '') { |
$retour .= $collection; |
} else { |
$retour .= $abrege; |
} |
$retour .= '</option>'."\n"; |
} |
$retour .= ' </select>'."\n\n"; |
mysql_free_result($result_str); |
} else { |
global $var_biblio; |
// on recherche ici les éditeurs de médias |
// si les médias sont autre chose que des livres, on affine |
// la liste en ne proposant que les éditeurs publiant des médias. |
$requete = 'SELECT B_M_EDITEUR '. |
'FROM '.$tbl['media'].', '.$tbl['item'].$plugin_store['categ_add_table'].' '. |
'WHERE B_I_IDITEM = B_M_IDMEDIA '. |
$plugin_store['categ_add_query'].' '. |
'GROUP BY B_M_EDITEUR '. |
'ORDER BY B_M_EDITEUR'; |
$do_editeur_qu = mysql_query($requete) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete)); |
$nb_edresults = mysql_num_rows($do_editeur_qu); |
|
if ($var_biblio['how_editeurs'] >= $nb_edresults) { |
// nb de résultats < $how_editeurs |
// on affiche une liste déroulante |
$retour .= '<label for="'.$id.'">'.'Pour :'.'</label>'; |
$retour .= '<select name="'.$id.'" class="'.$class.'">'."\n"; |
if ($nb_edresults > 1) { |
$retour .= '<option value=""'; |
if ($actualcateg == '') { |
$retour .= ' selected="selected"'; |
} |
$retour .= '>'; |
$retour .= 'tous éditeurs'; |
$retour .= '</option>'."\n"; |
} |
while ($row_ed = mysql_fetch_object($do_editeur_qu)) { |
$tmp_id = $row_ed->B_M_EDITEUR; |
|
if ($tmp_id != '') { |
$retour .= '<option value="'.stripslashes($tmp_id).'"'; |
if (stripslashes(stripslashes($actualcateg)) == $tmp_id) { |
$retour .= ' selected="selected"'; |
} |
$retour .= '>'; |
$retour .= stripslashes($tmp_id); |
} else { |
$retour .= '<option value="VIDE"'; |
if (($actualcateg == 'NULL') && ($actualcateg != '')) { |
$retour .= ' selected="selected"'; |
} |
$retour .= '>'; |
$retour .= 'éditeurs inconnus'; |
} |
$retour .= '</option>'."\n"; |
} |
$retour .= ' </select>'; |
} else { |
// nb de résultats > $how_editeurs |
// on affiche une zone de texte |
$retour .= '<label for="'.$id.'">'.'Éditeur :'.'</label>'; |
$retour .= '<input type="text" id="'.$id.'" name="'.$id.'" class="'.$class.'" value="'.$TabFinder['categ'].'" />'."\n"; |
} |
mysql_free_result($do_editeur_qu); |
} |
return $retour; |
} |
|
|
// form_mk_categ_2($actualcateg_2,$class) : |
// fonction spécifique du moteur MEDIA |
// créé une liste déroulante TabFinder[categ_2] pour affiner les résultats |
// Entrée : $actualcateg_2 (valeur de TabFinder['categ_2']), $class (classe CSS) par défaut "insInputForm" |
// Sortie (par retour) : string |
|
function form_mk_categ_2($actualcateg_2, $class = 'bb_champ') |
{ |
global $tbl; |
$retour = ''; |
$requete = 'SELECT * '. |
'FROM '.$tbl['item_typphy'].' '. |
'WHERE B_IP_ID <> 2 '. |
'ORDER BY B_IP_LABEL DESC'; |
$type_phy_do = mysql_query($requete) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete)); |
$retour .= '<select name="TabFinder[categ_2]" class="'.$class.'">'."\n"; |
|
$retour .= '<option value=""'; |
if ($actualcateg_2 == '') { |
$retour .= ' selected="selected"'; |
} |
$retour .= '>'; |
$retour .= 'tous supports'; |
$retour .= '</option>'."\n"; |
|
while ($row_phy = mysql_fetch_object($type_phy_do)) { |
$tmp_label = $row_phy->B_IP_LABEL; |
$tmp_id = $row_phy->B_IP_ID; |
|
$this_number = (count_num_of_reductor('B_I_TYPPHY', $tmp_id)); |
|
if ($this_number > 0) { |
$retour .= '<option value="'.$tmp_id.'"'; |
if ($actualcateg_2 == $tmp_id) { |
$retour .= ' selected="selected"'; |
} |
$retour .= '>'; |
$retour .= $tmp_label.' ('.$this_number.')'; |
$retour .= '</option>'."\n"; |
} |
} |
$retour .= ' </select>'; |
mysql_free_result($type_phy_do); |
|
return $retour; |
} |
|
|
// form_mk_categ_2($actualcateg_2,$class) : |
// fonction spécifique du moteur MEDIA |
// créé une liste déroulante TabFinder[categ_2] pour affiner les résultats |
// Entrée : $actualcateg_2 (valeur de TabFinder['categ_2']), $class (classe CSS) par défaut "insInputForm" |
// Sortie (par retour) : string |
function form_mk_categ_3($actualcateg_3, $class = 'bb_champ') |
{ |
global $tbl; |
$retour = ''; |
|
$requete = 'SELECT * '. |
'FROM '.$tbl['item_typlog'].' '. |
'ORDER BY B_IL_LABEL'; |
$type_log_do = mysql_query($requete) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete)); |
|
$retour .= '<select name="TabFinder[categ_3]" class="'.$class.'">'."\n"; |
|
$retour .= '<option value=""'; |
if ($actualcateg_3 == '') { |
$retour .= ' selected="selected"'; |
} |
$retour .= '>'; |
$retour .= 'tous contenus'; |
$retour .= '</option>'."\n"; |
|
while ($row_phy = mysql_fetch_object($type_log_do)) { |
$tmp_label = $row_phy->B_IL_LABEL; |
$tmp_id = $row_phy->B_IL_ID; |
|
$this_number = (count_num_of_reductor('B_I_TYPLOG', $tmp_id)); |
|
if ($this_number > 0) { |
$retour .= '<option value="'.$tmp_id.'"'; |
if ($actualcateg_3 == $tmp_id) { |
$retour .= ' selected="selected"'; |
} |
$retour .= '>'; |
$retour .= "$tmp_label ($this_number)"; |
$retour .= '</option>'."\n"; |
} |
} |
|
$retour .= ' </select>'; |
mysql_free_result($type_log_do); |
|
return $retour; |
} |
|
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.5 2005/05/17 10:10:08 jpm |
* Correction des bogues avant mise en ligne du site v4. |
* |
* Revision 1.4 2005/03/03 08:32:26 jpm |
* Suppression de li vide. |
* |
* Revision 1.3 2004/09/14 11:49:28 jpm |
* Ajout de l'info sur les logs cvs en bas de fichier. |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |