id=$id+0; $this->fields_array = $this->fields_array(); $this->fetch_data(); } //recuperation de champs_base.xml function fields_array(){ global $include_path,$msg; global $dbh, $champ_base; if(!count($champ_base)) { $file = $include_path."/indexation/notices/champs_base_subst.xml"; if(!file_exists($file)){ $file = $include_path."/indexation/notices/champs_base.xml"; } $fp=fopen($file,"r"); if ($fp) { $xml=fread($fp,filesize($file)); } fclose($fp); $champ_base=_parser_text_no_function_($xml,"INDEXATION"); } return $champ_base; } function fetch_data() { global $msg,$dbh,$charset; $this->facettes=array(); $req="select * from bannette_facettes where num_ban_facette=". $this->id." order by ban_facette_order"; $res = mysql_query($req,$dbh); $i=0; if (mysql_num_rows($res)) { while($r=mysql_fetch_object($res)){ $this->facettes[$i] = new stdClass(); $this->facettes[$i]->critere=$r->ban_facette_critere; $this->facettes[$i]->ss_critere= $r->ban_facette_ss_critere; $this->facettes[$i]->order_sort= $r->ban_facette_order; $i++; } } } function array_sort(){ global $msg; $array_sort = array(); $nb = count($this->fields_array['FIELD']); for($i=0;$i<$nb;$i++){ if($tmp= $msg[$this->fields_array['FIELD'][$i]['NAME']]){ $lib = $tmp; }else{ $lib = $this->fields_array['FIELD'][$i]['NAME']; } $id2 = $this->fields_array['FIELD'][$i]['ID'] + 0; $array_sort[$id2] = $lib; } asort($array_sort); return $array_sort; } function array_subfields($id){ global $msg,$charset; $array = $this->fields_array; $array_subfields = array(); $bool_search = 0; $i = 0; if($id!=100){ while($bool_search==0){ if($array['FIELD'][$i]['ID']==$id){ $isbd=$array['FIELD'][$i]['ISBD']; $array = $array['FIELD'][$i]['TABLE'][0]['TABLEFIELD']; $bool_search = 1; } $i++; } $size = count($array); for($i=0;$i<$size;$i++){ if ($array[$i]['NAME']) $array_subfields[$array[$i]['ID']+0] = $msg[$array[$i]['NAME']]; } if($isbd){ $array_subfields[$isbd[0]['ID']+0]=$msg['facette_isbd']; } }else{ $req= mysql_query("select idchamp,titre from notices_custom order by titre asc"); $j=0; while($rslt=mysql_fetch_object($req)){ $array_subfields[$rslt->idchamp+0] = $rslt->titre; $j++; } } return $array_subfields; } function delete(){ $del = "delete from bannette_facettes where num_ban_facette = '".$this->id."'"; mysql_query($del); } function save(){ global $max_facette; $this->delete(); $order=0; for($i=0;$i<$max_facette;$i++){ $critere = 'list_crit_'.$i; global $$critere; if($$critere > 0){ $ss_critere = 'list_ss_champs_'.$i; global $$ss_critere; $rqt = "insert into bannette_facettes set num_ban_facette = '".$this->id."', ban_facette_critere = '".$$critere."', ban_facette_ss_critere='".$$ss_critere."', ban_facette_order='".$order."' "; mysql_query($rqt); $order++; } } } function add_ss_crit($suffixe_id,$id,$id_ss_champs=0){ global $msg,$charset; $id+=0; $id_ss_champs+=0; $array = $this->array_subfields($id); $tab_ss_champs = array(); if(isset($suffixe_id)){ $name_ss_champs="list_ss_champs_".$suffixe_id; }else{ $name_ss_champs="list_ss_champs"; } $select_ss_champs.=""; return $select_ss_champs; }elseif(count($array)==1){ foreach($array as $j=>$val2){ $select_ss_champs = ""; } return $select_ss_champs; } } function add_facette($i_field){ global $tpl_facette_elt_ajax; $array = $this->array_sort(); $tpl = $tpl_facette_elt_ajax; $i=0; foreach ($array as $id => $value) { if(!$i){ $select.=""; } else { $select.=""; } } $tpl = str_replace('!!i_field!!', $i_field, $tpl); $tpl = str_replace("!!liste1!!",$select,$tpl); $tpl = str_replace("!!id_bannette!!",$this->id,$tpl); return $tpl; } function gen_facette_selection(){ global $dsi_facette_tpl; global $tpl_facette_elt; $array = $this->array_sort(); $tpls=$dsi_facette_tpl; $nb=count($this->facettes); if(!$nb)$nb++; for ($i=0 ; $i<$nb; $i++){ $tpl = $tpl_facette_elt; $tpl = str_replace('!!i_field!!', $i, $tpl); $tpl = str_replace('!!ss_crit!!', $this->facettes[$i]->ss_critere, $tpl); $select=""; foreach ($array as $id => $value) { if( $id==$this->facettes[$i]->critere){ $select.=""; } else { $select.=""; } } $tpl = str_replace("!!liste1!!",$select,$tpl); $facettes_tpl.=$tpl; } $tpls = str_replace("!!facettes!!",$facettes_tpl,$tpls); $tpls = str_replace("!!max_facette!!",$nb,$tpls); $tpls = str_replace("!!id_bannette!!",$this->id,$tpls); return $tpls; } function build_document($notice_ids,$notice_tpl="",$gen_summary=0){ if($notice_tpl){ $this->noti_tpl_document=new notice_tpl_gen($notice_tpl); } else $this->noti_tpl_document=""; // paramétrage : $this->environement["short"] = 6 ; $this->environement["ex"] = 0 ; $this->environement["exnum"] = 1 ; $facettes_list=$this->facettes; $this->gen_summary=$gen_summary; $this->summary=""; $this->index=0; $res_notice_ids=$this->filter_facettes_search($facettes_list,$notice_ids); $resultat_aff=$this->filter_facettes_print($res_notice_ids); if($this->gen_summary) $resultat_aff="
";
foreach($res_notice_ids["notfound"] as $notice_id){
if( !in_array($notice_id, $notfound) )
$tpl.="".$this->build_notice($notice_id)."
" ;
$notfound[]=$notice_id;
}
$tpl.="
";
}else{
$tpl.="
";
}
foreach($contens["values"] as $notice_id){
$tpl.=$this->build_notice($notice_id)."
" ;
}
if(count($contens["notfound"]))
foreach($contens["notfound"] as $notice_id){
if( !in_array($notice_id, $notfound) )
$tpl.=$this->build_notice($notice_id)."
" ;
$notfound[]=$notice_id;
}
$tpl.="