objects_ids).' AND code_champ = '.($id_critere+0).' AND code_ss_champ = '.($id_ss_critere+0).' AND lang in ("","'.$lang.'","'.substr($lang,0,2).'")) as sub GROUP BY value ORDER BY '; return $query; } public static function do_level1() { global $msg,$mode,$autolevel1,$opac_autolevel2,$tab,$charset; global $lvl, $id; $table=""; if (($_SESSION["level1"])&&(!$autolevel1)&&($tab!="affiliate")) { $table.="

".htmlentities($msg['autolevel1_search'],ENT_QUOTES,$charset)."

\n"; $n=0; foreach($_SESSION["level1"] as $mod_search=>$level) { $current=false; switch ($mod_search) { case "abstract": $form_name="search_abstract"; $lvl_msg=$msg["abstract"]; if ($mode=="abstract") $current=true; break; case "author": $form_name="search_authors"; $lvl_msg=$msg["authors"]; if ($mode=="auteur") $current=true; break; case "category": $form_name="search_categorie"; $lvl_msg=$msg["categories"]; if ($mode=="categorie") $current=true; break; case "collection": $form_name="search_collection"; $lvl_msg=$msg["collections"]; if ($mode=="collection") $current=true; break; case "docnum": $form_name="search_docnum"; $lvl_msg=$msg["docnum"]; if ($mode=="docnum") $current=true; break; case "indexint": $form_name="search_indexint"; $lvl_msg=$msg["indexint"]; if ($mode=="indexint") $current=true; break; case "keywords": $form_name="search_keywords"; $lvl_msg=$msg["keywords"]; if ($mode=="keyword") $current=true; break; case "publisher": $form_name="search_publishers"; $lvl_msg=$msg["publishers"]; if ($mode=="editeur") $current=true; break; case "subcollection": $form_name="search_sub_collection"; $lvl_msg=$msg["subcollections"]; if ($mode=="souscollection") $current=true; break; case "title": $form_name="search_objects"; $lvl_msg=$msg["titles"]; if (($mode=="titre")||($mode=="title")) $current=true; break; case "titre_uniforme": $form_name="search_titres_uniformes"; $lvl_msg=$msg["titres_uniformes"]; if ($mode=="titre_uniforme") $current=true; break; case "tous": $form_name="search_tous"; $lvl_msg=$msg["tous"]; if ($mode=="tous") $current=true; break; case "concept": $form_name="search_concepts"; $lvl_msg=$msg["concepts_search"]; if ($mode=="concept") $current=true; break; default: if(substr($mod_search, 0,10) == "authperso_"){ $form_name="search_".$mod_search; $lvl_msg=$level['name']; if ($mode==$mod_search) $current=true; } break; } if ($n % 2) $pair_impair = "odd"; else $pair_impair = "even"; $td_javascript=" "; $tr_surbrillance = "onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='".$pair_impair."'\" "; $table.=""; $n++; } $table.="
".$level["form"].($current?"":"")."$lvl_msg (".$level["count"].")".($current?"":"")."
"; } else { if (($opac_autolevel2)&&($autolevel1)&&($tab!="affiliate")) { //Génération du post et du get... //Attention tous ce qui passe par ajax.php doit être en utf-8 $table=""; $table.="

".htmlentities($msg['autolevel1_search'],ENT_QUOTES,$charset)."

\n" . ""; } } return $table; } public static function get_facette_wrapper(){ $script = parent::get_facette_wrapper(); $script .= " "; return $script; } public static function make_facette_search_env() { global $search; global $op_0_s_1; global $field_0_s_1; //historique des recherches if(empty($search)) { $search = array(); } $search[] = "s_1"; $op_0_s_1 = "EQ"; $field_0_s_1[] = intval($_SESSION['last_query']); //creation des globales => parametres de recherche if ($_SESSION['facette']) { for ($i=0;$i$lookflag) { $action.="&".$looktype."=1"; } $table_facette_suggest =""; //on recrée un tableau pour regrouper les éventuels doublons $tmpArray = array(); $tmpArray = $suggestion->listUniqueSimilars(); if (count($tmpArray)) { foreach($tmpArray as $word){ $table_facette_suggest.=""; } } $table_facette_suggest.="
".$word."
"; if (count($tmpArray)) { $table = "

".$msg['facette_suggest']."

".$table_facette_suggest."
"; } else { $table = ""; } return $table; } public static function expl_voisin($id_notice=0){ global $charset,$msg; $data=array(); $notices_list = facettes::get_expl_voisin($id_notice); $display=static::aff_notices_list($notices_list); $data['aff']=""; if($display)$data['aff']= "

".$msg['expl_voisin_search']."

".$display; if ($charset!="utf-8") $data['aff']= utf8_encode($data['aff']); $data['id']=$id_notice; return $data; } public static function get_expl_voisin($id_notice=0){ global $dbh; global $opac_nb_notices_similaires; $id_notice = intval($id_notice); $notice_list=array(); $req = "select expl_cote, expl_section from exemplaires where expl_notice=$id_notice"; $res = @pmb_mysql_query($req,$dbh); $nb_result = $opac_nb_notices_similaires; if($nb_result>6 || $nb_result<0 || !(isset($opac_nb_notices_similaires))){ $nb_result=6; } $nb_asc=""; $nb_desc=""; if(($nb_result%2)==0){ $nb_asc = $nb_result/2; $nb_desc = $nb_asc; } else { $nb_desc = $nb_result%2; $nb_asc = $nb_result-$nb_desc; } if($res && pmb_mysql_num_rows($res)){ $r=pmb_mysql_fetch_object($res); $cote=$r->expl_cote; $section=$r->expl_section; $query = " (select distinct expl_notice from exemplaires where expl_notice!=0 and expl_cote >= '".$cote."' and expl_section = '".$section."' and expl_notice!=$id_notice order by expl_cote asc limit ".$nb_asc.") union (select distinct expl_notice from exemplaires where expl_notice!=0 and expl_cote < '".$cote."' and expl_section = '".$section."' and expl_notice!=$id_notice order by expl_cote desc limit ".$nb_desc.")" ; $result = pmb_mysql_query($query,$dbh); if(pmb_mysql_num_rows($result) > 0){ while($row = pmb_mysql_fetch_object($result)){ $notice_list[] = $row->expl_notice; } } } return $notice_list; } public static function similitude($id_notice=0){ global $charset,$msg; $data=array(); $notices_list = facettes::get_similitude_notice($id_notice); $display= static::aff_notices_list($notices_list); $data['aff']=""; if($display)$data['aff']= "

".$msg['simili_search']."

".$display; if ($charset!="utf-8") $data['aff']= utf8_encode($data['aff']); $data['id']=$id_notice; return $data; } public static function get_similitude_notice($id_notice=0){ global $dbh; global $opac_nb_notices_similaires; global $gestion_acces_active,$gestion_acces_empr_notice; $id_notice = intval($id_notice); $req="select distinct code_champ, code_ss_champ, num_word from notices_mots_global_index ".gen_where_in('code_champ', '1,17,19,20,25')." and id_notice=".$id_notice; $res=pmb_mysql_query($req,$dbh); $where_mots=""; $notice_list=array(); if($res && pmb_mysql_num_rows($res)){ while($r=pmb_mysql_fetch_object($res)){ if($where_mots)$where_mots.=" or "; $where_mots.="(code_champ =".$r->code_champ." AND code_ss_champ =".$r->code_ss_champ." AND num_word =".$r->num_word." and id_notice != ".$id_notice.")"; } } if($where_mots){ if ($gestion_acces_active==1 && $gestion_acces_empr_notice==1) { $ac= new acces(); $dom_2= $ac->setDomain(2); } $nb_result = $opac_nb_notices_similaires; if($nb_result>6 || $nb_result<0 || !(isset($opac_nb_notices_similaires))){ $nb_result=6; } $req = "select id_notice, sum(pond) as s from notices_mots_global_index where $where_mots group by id_notice order by s desc limit ".$nb_result; $res = @pmb_mysql_query($req,$dbh); if($res && pmb_mysql_num_rows($res)){ while($r=pmb_mysql_fetch_object($res)){ if($r->s >80){ $acces_v=TRUE; if ($gestion_acces_active==1 && $gestion_acces_empr_notice==1) { $acces_v = $dom_2->getRights($_SESSION['id_empr_session'],$r->id_notice,4); } else { $requete = "SELECT notice_visible_opac, expl_visible_opac, notice_visible_opac_abon, expl_visible_opac_abon, explnum_visible_opac, explnum_visible_opac_abon FROM notices, notice_statut WHERE notice_id ='".$r->id_notice."' and id_notice_statut=statut "; $myQuery = pmb_mysql_query($requete, $dbh); if($myQuery && pmb_mysql_num_rows($myQuery)) { $statut_temp = pmb_mysql_fetch_object($myQuery); if(!$statut_temp->notice_visible_opac) $acces_v=FALSE; if($statut_temp->notice_visible_opac_abon && !$_SESSION['id_empr_session']) $acces_v=FALSE; } else $acces_v=FALSE; } if($acces_v){ $notice_list[] = $r->id_notice; } } } } } return $notice_list; } protected static function aff_notices_list($notices_list){ global $dbh,$charset; global $opac_show_book_pics,$opac_book_pics_url,$opac_book_pics_msg,$opac_url_base; global $opac_notice_affichage_class,$gestion_acces_active,$gestion_acces_empr_notice; global $opac_notice_reduit_format_similaire ; $img_list = ""; $title_list = ""; $tabNotice = array(); if ($gestion_acces_active==1 && $gestion_acces_empr_notice==1) { $ac= new acces(); $dom_2= $ac->setDomain(2); } $i = 0; foreach($notices_list as $notice_id){ $acces_v=TRUE; if ($gestion_acces_active==1 && $gestion_acces_empr_notice==1) { $acces_v = $dom_2->getRights($_SESSION['id_empr_session'],$notice_id,4); } else { $requete = "SELECT notice_visible_opac, expl_visible_opac, notice_visible_opac_abon, expl_visible_opac_abon, explnum_visible_opac, explnum_visible_opac_abon FROM notices, notice_statut WHERE notice_id ='".$notice_id."' and id_notice_statut=statut "; $myQuery = pmb_mysql_query($requete, $dbh); if($myQuery && pmb_mysql_num_rows($myQuery)) { $statut_temp = pmb_mysql_fetch_object($myQuery); if(!$statut_temp->notice_visible_opac) $acces_v=FALSE; if($statut_temp->notice_visible_opac_abon && !$_SESSION['id_empr_session']) $acces_v=FALSE; } else $acces_v=FALSE; } if(!$acces_v) continue; $req = "select * from notices where notice_id=$notice_id"; $res = @pmb_mysql_query($req,$dbh); $image = ""; if($r=pmb_mysql_fetch_object($res)){ if (substr($opac_notice_reduit_format_similaire,0,1)!="H" && $opac_show_book_pics=='1') { if (($r->code && $opac_book_pics_url) || $r->thumbnail_url) { $url_image_ok = getimage_url($r->code, $r->thumbnail_url); $title_image_ok = ""; if(!$r->thumbnail_url) { $title_image_ok = htmlentities($opac_book_pics_msg, ENT_QUOTES, $charset); } if(!trim($title_image_ok)){ $title_image_ok = htmlentities($r->tit1, ENT_QUOTES, $charset); } $image = ""."".""; } else { $image = "".""; } } $notice = new $opac_notice_affichage_class($notice_id, "", 0,0,1); $notice->do_header_similaire(); $notice_header= "".$notice->notice_header.""; $i++; } // affichage du titre et de l'image dans la même cellule if($image!=""){ $img_list.="".$image."
".$notice_header.""; } else { $img_list.="".$notice_header.""; } } if(!$i)return""; $display="".$img_list."
"; return $display; } /** * Retourne le template de facettes * @param string $query */ public static function get_display_list_from_query($query) { global $opac_facettes_ajax; $display = ''; $objects = ''; $result = pmb_mysql_query($query); if($result) { while($row = pmb_mysql_fetch_object($result)){ if($objects){ $objects.=","; } $objects.= $row->notice_id; } } if(!$opac_facettes_ajax){ $display .= facettes::make_facette($objects); }else{ $_SESSION['tab_result']=$objects; $display .= static::call_ajax_facettes(); } //Formulaire "FACTICE" pour l'application du comparateur et du filtre multiple... if($display) { $display.= '
'.facette_search_compare::form_write_facette_compare().'
'; } return $display; } public static function get_formatted_value($id_critere, $id_ss_critere, $value) { //Aucun formatage nécessaire pour les facettes PMB (non externes). return get_msg_to_display($value); } public function get_query_expl($notices_ids) { global $opac_view_filter_class; $opac_view_filter_where = ''; if($opac_view_filter_class){ if(sizeof($opac_view_filter_class->params["nav_sections"])){ $opac_view_filter_where=" AND idlocation in (". implode(",",$opac_view_filter_class->params["nav_sections"]).")"; }else{ return ""; } } $commons_select = " SELECT exemplaires.expl_location AS id_location, notices.notice_id AS id_notice FROM exemplaires "; $commons_join = " JOIN docs_section ON exemplaires.expl_section=docs_section.idsection AND docs_section.section_visible_opac=1 JOIN docs_statut ON exemplaires.expl_statut=docs_statut.idstatut AND statut_visible_opac=1 JOIN docs_location ON exemplaires.expl_location=docs_location.idlocation AND docs_location.location_visible_opac=1 JOIN notice_statut on notice_statut.id_notice_statut=notices.statut and notice_statut.expl_visible_opac=1 ".(!$_SESSION["user_code"] ? " and notice_statut.expl_visible_opac_abon=0 " : "")." "; $query = $commons_select." JOIN notices ON exemplaires.expl_notice = notices.notice_id and exemplaires.expl_bulletin= 0 ".$commons_join." ".gen_where_in('notices.notice_id', $notices_ids). $opac_view_filter_where." UNION ".$commons_select." JOIN bulletins ON exemplaires.expl_bulletin = bulletins.bulletin_id and exemplaires.expl_notice= 0 JOIN notices ON bulletins.bulletin_notice = notices.notice_id ".$commons_join." ".gen_where_in('notices.notice_id', $notices_ids). $opac_view_filter_where." UNION ".$commons_select." JOIN bulletins ON exemplaires.expl_bulletin = bulletins.bulletin_id and exemplaires.expl_notice= 0 JOIN notices ON bulletins.num_notice = notices.notice_id ".$commons_join." ".gen_where_in('notices.notice_id', $notices_ids). $opac_view_filter_where; return $query; } public function get_query_explnum($notices_ids) { global $gestion_acces_active,$gestion_acces_empr_docnum; if ($gestion_acces_active==1 && $gestion_acces_empr_docnum==1) { $ac= new acces(); $dom_3= $ac->setDomain(3); $acces_j = $dom_3->getJoin($_SESSION['id_empr_session'],16,'explnum_id'); } else { $acces_j = " JOIN explnum_statut ON explnum_docnum_statut=id_explnum_statut AND ( (explnum_statut.explnum_visible_opac=1 AND explnum_statut.explnum_visible_opac_abon=0)" .($_SESSION["user_code"]?" or (explnum_statut.explnum_visible_opac_abon=1 and explnum_statut.explnum_visible_opac=1)":"") .")"; } $query = " SELECT explnum_location.num_location AS id_location, explnum.explnum_notice AS id_notice FROM explnum_location JOIN explnum ON explnum_location.num_explnum = explnum.explnum_id AND explnum.explnum_bulletin = 0 JOIN docs_location ON explnum_location.num_location = docs_location.idlocation AND docs_location.location_visible_opac=1 " . $acces_j . gen_where_in('explnum.explnum_notice', $notices_ids)." UNION SELECT explnum_location.num_location AS id_location, bulletins.bulletin_notice AS id_notice FROM explnum_location JOIN explnum ON explnum_location.num_explnum = explnum.explnum_id AND explnum.explnum_notice = 0 JOIN bulletins ON explnum.explnum_bulletin = bulletins.bulletin_id JOIN docs_location ON explnum_location.num_location = docs_location.idlocation AND docs_location.location_visible_opac=1 " . $acces_j . gen_where_in('bulletins.bulletin_notice', $notices_ids)." UNION SELECT explnum_location.num_location AS id_location, bulletins.num_notice AS id_notice FROM explnum_location JOIN explnum ON explnum_location.num_explnum = explnum.explnum_id AND explnum.explnum_notice = 0 JOIN bulletins ON explnum.explnum_bulletin = bulletins.bulletin_id JOIN docs_location ON explnum_location.num_location = docs_location.idlocation AND docs_location.location_visible_opac=1 " . $acces_j . gen_where_in('bulletins.num_notice', $notices_ids); return $query; } }// end class