$rslt->id_facette+0,
'name'=>$rslt->facette_name,
'id_critere'=>$rslt->facette_critere+0,
'id_ss_critere'=>$rslt->facette_ss_critere+0,
'nb_result'=>$rslt->facette_nb_result+0,
'limit_plus'=>$rslt->facette_limit_plus+0,
'type_sort'=>$rslt->facette_type_sort+0,
'order_sort'=>$rslt->facette_order_sort+0
);
if($rslt->facette_visible==1) $this->tab_facettes_record[]= $tab_temp;
}
return $this->tab_facettes_record;
}
function nb_results_by_facette($tab_id_notice){
global $dbh;
global $lang;
global $msg;
$size = sizeof($this->tab_facettes_record);
$i = 0;
$array_result = array();
$_SESSION['facette_plus']=array();
for($i;$i<$size;$i++){
$limit = "";
$order_sort = "";
$type_sort = "";
$end_req_sql="";
if($this->tab_facettes_record[$i]['type_sort']==0) $type_sort = "nb_result";
else $type_sort = "value";
if($this->tab_facettes_record[$i]['order_sort']==0) $order_sort = "asc";
else $order_sort = "desc";
if($this->tab_facettes_record[$i]['nb_result']>0) $limit = "LIMIT"." ".$this->tab_facettes_record[$i]['nb_result'];
$end_req_sql = "order by ".$type_sort." ".$order_sort." ".$limit;
//AND (lang = '' OR lang = ".$lang.")
$req = "select distinct value ,count(id_notice) as nb_result from (SELECT value,id_notice FROM notices_fields_global_index
WHERE id_notice IN (".$tab_id_notice.")
AND code_champ = ".($this->tab_facettes_record[$i]['id_critere']+0)."
AND code_ss_champ = ".($this->tab_facettes_record[$i]['id_ss_critere']+0)."
AND lang in ('','".$lang."')) as sub
GROUP BY value ".$end_req_sql;
$res = @mysql_query($req,$dbh);
$j=0;
$array_tmp = array();
$array_value = array();
$flag_see_more=0;
while($rslt = mysql_fetch_object($res)){
if($this->tab_facettes_record[$i]['limit_plus'] && $j > $this->tab_facettes_record[$i]['limit_plus']){
$flag_see_more=1;
$_SESSION['facette_plus'][$this->tab_facettes_record[$i]['id']] ['facette'][]=$rslt->value." "."(".($rslt->nb_result+0).")";
$_SESSION['facette_plus'][$this->tab_facettes_record[$i]['id']] ['value'][]=$rslt->value;
}
$array_tmp[$j] = $rslt->value." "."(".($rslt->nb_result+0).")";
$array_value[$j] = $rslt->value;
$j++;
}
$_SESSION['facette_plus'][$this->tab_facettes_record[$i]['id']] ['code_champ']=$this->tab_facettes_record[$i]['id_critere'];
$_SESSION['facette_plus'][$this->tab_facettes_record[$i]['id']] ['code_ss_champ']=$this->tab_facettes_record[$i]['id_ss_critere'];
$array_result[] = array(
'name'=>$this->tab_facettes_record[$i]['name'],
'facette'=>$array_tmp,
'code_champ'=>$this->tab_facettes_record[$i]['id_critere'],
'code_ss_champ'=>$this->tab_facettes_record[$i]['id_ss_critere'],
'value'=>$array_value,
'flag_see_more'=>$flag_see_more,
'size_to_display'=>$this->tab_facettes_record[$i]['limit_plus']
);
}
$this->tab_facettes_opac = $array_result;
}
function create_table_facettes(){
global $charset;
global $mode;
global $msg;
$size = sizeof($this->tab_facettes_opac);
$table_facette = "
";
$table_facette .= "
";
$table_facette_clicked = "";// onclick='javascript:test(this);'
$facette_list_view = 0;
$n = 0;//iterateur de style $pair_impair
for($i=0;$i<$size;$i++){
$facette_view = 1;
//test pour savoir si la facette a deja ete cliquee
if($_SESSION['facette']){
for($x=0;$xtab_facettes_opac[$i]['code_champ'])&&($_SESSION['facette'][$x][2]==$this->tab_facettes_opac[$i]['code_ss_champ'])){
if(($x==0)&&(count($_SESSION['facette'])==1)) $table_facette_clicked .= "".$this->tab_facettes_opac[$i]['name'].": ".stripslashes($_SESSION['facette'][$x][0])." | |
";
else $table_facette_clicked .= "".$this->tab_facettes_opac[$i]['name'].": ".stripslashes($_SESSION['facette'][$x][0])." | |
";
$facette_view = 0;
$n++;
}
}
}
//si elle n'a pas ete cliquee
if($facette_view && (sizeof($this->tab_facettes_opac[$i]['facette'])!=0)){
$facette_list_view++;
$table_facette .= "".htmlentities($this->tab_facettes_opac[$i]['name'],ENT_QUOTES,$charset)." |
";
$size2 = sizeof($this->tab_facettes_opac[$i]['facette']);
for($j=0;$j<$size2;$j++){
$new_value_search = $this->tab_facettes_opac[$i]['value'][$j];
$id_last_query = $_SESSION['last_query']+0;
$fields_search = "&facette_test=1&value=".rawurlencode($new_value_search)."&champ=".$this->tab_facettes_opac[$i]['code_champ']."&ss_champ=".$this->tab_facettes_opac[$i]['code_ss_champ']."";
if($this->tab_facettes_opac[$i]['size_to_display'] && $j > $this->tab_facettes_opac[$i]['size_to_display']){
}else{
$table_facette .= "".htmlentities($this->tab_facettes_opac[$i]['facette'][$j],ENT_QUOTES,$charset)." |
";
}
}
}
$link_plus="";
if($this->tab_facettes_opac[$i]['flag_see_more'])$link_plus="
".$msg["facette_plus_link"]."
|
";
$table_facette .=$link_plus;
}
$table_facette_clicked .= "
";
$table_facette .="
";
if($_SESSION['facette'] && $facette_list_view>0) $table = "".$msg['facette_active']."
".$table_facette_clicked."
".$msg['facette_list']."
".$table_facette."";
elseif(!$_SESSION['facette'] && $facette_list_view>0) $table = "".$msg['facette_list']."
".$table_facette."";
elseif($_SESSION['facette'] && $facette_list_view==0) $table = "".$msg['facette_active']."
".$table_facette_clicked."
";
return $table;
}
function see_more($id){
global $charset;
global $mode;
global $msg;
$facette_opac=$_SESSION['facette_plus'][$id];
//print_r($facette_opac);
$table_facette="";
for($j=0;$j".htmlentities($facette_opac['facette'][$j],ENT_QUOTES,$charset)."";
}
return $table_facette;
}
public static function do_level1() {
global $msg,$mode,$autolevel1,$opac_autolevel2,$tab;
if (($_SESSION["level1"])&&(!$autolevel1)&&($tab!="affiliate")) {
$table="Recherche
\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;
}
if ($n % 2) $pair_impair = "odd"; else $pair_impair = "even";
$td_javascript=" ";
$tr_surbrillance = "onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='".$pair_impair."'\" ";
$table.="".$level["form"].($current?"":"")."$lvl_msg (".$level["count"].")".($current?"":"")." |
";
$n++;
}
$table.="
";
} else {
if (($opac_autolevel2)&&($autolevel1)&&($tab!="affiliate")) {
//Génération du post et du get...
$table="";
$table.="Recherche
\n" .
"";
}
}
return $table;
}
public static function make_facette_search_env() {
global $search;
global $op_0_s_1;
global $field_0_s_1;
//historique des recherches
$search[]="s_1";
$op_0_s_1 ="EQ";
$field_0_s_1[] = $_SESSION['last_query']+0;
//creation des globales => parametres de recherche
if($_SESSION['facette']){
for($i=0;$ifacette_existing();
$face->nb_results_by_facette($id_notice_array);
return $face->create_table_facettes();
}
public static function expl_voisin($id_notice=0){
global $charset,$msg;
$data=array();
$notices_list = facettes::get_expl_voisin($id_notice);
$display=facettes::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;
}
function get_expl_voisin($id_notice=0){
global $dbh;
$id_notice+=0;
$notice_list=array();
$req = "select expl_cote from exemplaires where expl_notice=$id_notice";
$res = @mysql_query($req,$dbh);
if($r=mysql_fetch_object($res)){
$cote=$r->expl_cote;
$query = "
(select distinct expl_notice,expl_cote from exemplaires where expl_notice!=0 and expl_bulletin = 0 and expl_cote >= '".$cote."' and expl_notice!=$id_notice order by expl_cote asc limit 3)
union
(select distinct expl_notice,expl_cote from exemplaires where expl_notice!=0 and expl_bulletin = 0 and expl_cote < '".$cote."' and expl_notice!=$id_notice order by expl_cote desc limit 3)" ;
$result = mysql_query($query,$dbh);
if(mysql_num_rows($result) > 0){
while($row = 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= facettes::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;
}
function get_similitude_notice($id_notice=0){
global $dbh;
$id_notice+=0;
$req="select distinct code_champ, code_ss_champ, num_word from notices_mots_global_index where (
code_champ in(1,17,19,20,25)
)and
id_notice=$id_notice";
/*27,28,29
or (code_champ=90 and code_ss_champ=2)
or (code_champ=90 and code_ss_champ=3)
or (code_champ=90 and code_ss_champ=4)
*/
// 7337 43421
$res=mysql_query($req,$dbh);
$i=0;
while($r=mysql_fetch_object($res)){
$tab[]="SELECT distinct id_notice, pond from notices_mots_global_index where code_champ=".$r->code_champ." AND code_ss_champ =".$r->code_ss_champ." AND num_word =".$r->num_word." and id_notice != ".$id_notice;
$i++;
}
$fields=implode(" union ",$tab);
$req = "select id_notice, sum(pond)as s from(
$fields
) as f group by id_notice order by s desc limit 6";
$res = @mysql_query($req,$dbh);
$notice_list=array();
while($r=mysql_fetch_object($res)){
if($r->s >80)
$notice_list[] = $r->id_notice;
}
return $notice_list;
}
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;
$img_list = "";
$title_list = "";
if ($gestion_acces_active==1 && $gestion_acces_empr_notice==1) {
$ac= new acces();
$dom_2= $ac->setDomain(2);
}
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 = mysql_query($requete, $dbh);
if(mysql_num_rows($myQuery)) {
$statut_temp = 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 = @mysql_query($req,$dbh);
if($r=mysql_fetch_object($res)){
$image="";
if ($r->code || $r->thumbnail_url) {
if ($opac_show_book_pics=='1' && ($opac_book_pics_url || $r->thumbnail_url)) {
$code_chiffre = pmb_preg_replace('/-|\.| /', '', $r->code);
$url_image = $opac_url_base."getimage.php?url_image=".urlencode($opac_book_pics_url)."¬icecode=!!noticecode!!&vigurl=".urlencode($r->thumbnail_url);
if ($r->thumbnail_url) {
$url_image_ok=$r->thumbnail_url;
$title_image_ok="";
} else {
$url_image_ok = str_replace("!!noticecode!!", $code_chiffre, $url_image);
$title_image_ok = htmlentities($opac_book_pics_msg, ENT_QUOTES, $charset);
}
$image = "";
} else{
$image="";
}
}
$notice = new $opac_notice_affichage_class($notice_id, "", 0,0,1);
$notice->do_header();
$notice_header= "".$notice->notice_header."";
$i++;
}
$img_list.="".$image." | ";
$title_list.="".$notice_header." | ";
}
if(!$i)return"";
$display="".$img_list."
".$title_list."
";
return $display;
}
}// end class