fields_array = $this->fields_array();
}
//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;
}
//creation de la liste des criteres principaux
function create_list_fields(){
global $msg,$tpl_form_facette;
//recuperation du fichier xml de configuration
$array = $this->array_sort();
$array2 = $this->array_subfields($this->crit);
$post_flag = true;
$post_param = "list_crit";
$post_param2 = "&sub_field";
$script ="
";
$tpl_form_facette = str_replace('!!script!!', $script, $tpl_form_facette);
$select ="";
if($this->crit!=null) $select .= "";
return $select;
}
//liste liee => sous champs
function create_list_subfields($id,$id_ss_champs=0,$suffixe_id=0){
global $msg,$charset;
$array = $this->array_subfields($id);
$tab_ss_champs = array();
$select_ss_champs="";
if($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;
}
}
//formulaire MaJ ou de creation d'une facette
function form_facette(){
global $tpl_form_facette, $msg,$charset;
$list_champs = $this->create_list_fields();
$tpl_form_facette = str_replace('!!name_del_facette!!',sprintf($msg['label_alert_delete_facette'],htmlentities($this->name,ENT_QUOTES,$charset)),$tpl_form_facette);
$tpl_form_facette = str_replace('!!nameF!!',sprintf($msg['name_facette'],htmlentities($this->name,ENT_QUOTES,$charset)),$tpl_form_facette);
if($this->id==null){
$tpl_form_facette = str_replace('!!libelle!!', htmlentities($msg['lib_nelle_facette_form'],ENT_QUOTES,$charset), $tpl_form_facette);
$tpl_form_facette = str_replace('!!val_submit_form!!', htmlentities($msg['submitSendFacette'],ENT_QUOTES,$charset), $tpl_form_facette);
$tpl_form_facette = str_replace('!!valHidden!!', htmlentities("creation",ENT_QUOTES,$charset), $tpl_form_facette);
$input_delete_disable = "";
$tpl_form_facette = str_replace('!!val_submit_suppr!!', $input_delete_disable, $tpl_form_facette);
$val_nb = 0;
$val_nb += 0;
$tpl_form_facette = str_replace('!!val_nb!!', $val_nb, $tpl_form_facette);
$tpl_form_facette = str_replace('!!defaut_check_order!!',$msg['default_check_facette'],$tpl_form_facette);
$tpl_form_facette = str_replace('!!defaut_check_order2!!',"",$tpl_form_facette);
$tpl_form_facette = str_replace('!!defaut_check_type2!!',$msg['default_check_facette'],$tpl_form_facette);
$tpl_form_facette = str_replace('!!defaut_check_type!!',"",$tpl_form_facette);
$tpl_form_facette = str_replace('!!limit_plus!!',"0",$tpl_form_facette);
} else {
$input_delete = "";
$tpl_form_facette = str_replace('!!val_submit_suppr!!',$input_delete, $tpl_form_facette);
$tpl_form_facette = str_replace('!!libelle!!', htmlentities($msg['update_facette'],ENT_QUOTES,$charset), $tpl_form_facette);
$tpl_form_facette = str_replace('!!val_submit_form!!', htmlentities($msg['submitMajFacette'],ENT_QUOTES,$charset), $tpl_form_facette);
$tpl_form_facette = str_replace('!!valHidden!!', htmlentities($this->id,ENT_QUOTES,$charset), $tpl_form_facette);
$tpl_form_facette = str_replace('!!val_nb!!', htmlentities($this->nb_result,ENT_QUOTES,$charset), $tpl_form_facette);
$tpl_form_facette = str_replace('!!limit_plus!!',$this->limit_plus,$tpl_form_facette);
$tpl_form_facette = str_replace('!!id!!', htmlentities($this->id,ENT_QUOTES,$charset), $tpl_form_facette);
if($this->visible==1)$tpl_form_facette = str_replace('!!defaut_check!!', htmlentities($msg['default_check_facette'],ENT_QUOTES,$charset), $tpl_form_facette);
if($this->order_sort)$tpl_form_facette = str_replace('!!defaut_check_order2!!', htmlentities($msg['default_check_facette'],ENT_QUOTES,$charset), $tpl_form_facette);
else $tpl_form_facette = str_replace('!!defaut_check_order!!',htmlentities($msg['default_check_facette'],ENT_QUOTES,$charset),$tpl_form_facette);
if($this->type_sort)$tpl_form_facette = str_replace('!!defaut_check_type2!!', htmlentities($msg['default_check_facette'],ENT_QUOTES,$charset), $tpl_form_facette);
else $tpl_form_facette = str_replace('!!defaut_check_type!!',htmlentities($msg['default_check_facette'],ENT_QUOTES,$charset),$tpl_form_facette);
}
$tpl_form_facette = str_replace('!!liste1!!', $list_champs, $tpl_form_facette);
return $tpl_form_facette;
}
//enregistrement ou MaJ d une facette*
function save_form_facette(){
global $label_facette,$list_crit,$list_nb,$list_ss_champs,$visible,$hidden_form,$dbh,$type_sort,$order_sort,$limit_plus;
$redirect_list = "";
if($visible==true) $visible=1;
else $visible=0;
$requete="select max(facette_order) as ordre from facettes ";
$resultat=mysql_query($requete);
$ordre_max=@mysql_result($resultat,0,0);
$ordre_max++;
$hidden_form+=0;
$list_ss_champs+=0;
$listNb+=0;
$list_crit+=0;
$limit_plus+=0;
if((!empty($hidden_form)&&($hidden_form!="creation"))){
$req="UPDATE facettes
SET facette_name='".$label_facette."',facette_critere='".$list_crit."',
facette_ss_critere='".$list_ss_champs."',facette_nb_result='".$list_nb."',
facette_visible='".$visible."',facette_type_sort='".$type_sort."',facette_order_sort='".$order_sort."',
facette_limit_plus=$limit_plus
WHERE id_facette='".$hidden_form."'";
$rep = mysql_query($req,$dbh) or die(mysql_error()."
$req");
} else {
$req="INSERT INTO facettes
SET facette_name='".$label_facette."',facette_critere='".$list_crit."',
facette_ss_critere='".$list_ss_champs."',facette_nb_result='".$list_nb."',
facette_visible='".$visible."',facette_type_sort='".$type_sort."',facette_order_sort='".$order_sort."',
facette_order=$ordre_max,
facette_limit_plus=$limit_plus
";
$rep = mysql_query($req,$dbh) or die(mysql_error()."
$req");
}
return $redirect_list;
}
//vue des listes deja creees => page d accueil des facettes
function view_list_facette(){
global $tpl_vue_facettes,$msg,$dbh,$charset;
$req = "SELECT * FROM facettes order by facette_order, facette_name";
$rq = mysql_query($req,$dbh) or die("Erreur SQL");
$lst="";
$array = $this->array_sort();
$array_subfields = array();
$i = 0;
while($rslt = mysql_fetch_object($rq)){
$intit_crit = htmlentities($array[$rslt->facette_critere],ENT_QUOTES,$charset);
$array_subfields = $this->array_subfields($rslt->facette_critere);
$idF = $rslt->id_facette+0;
if(sizeof($array_subfields)>1) $intit_subfields = htmlentities($array_subfields[$rslt->facette_ss_critere],ENT_QUOTES,$charset);
else $intit_subfields = $msg["admin_opac_facette_ss_critere"];
$nb_result = $rslt->facette_nb_result+0;
if($nb_result==0)$nb_result = $msg["admin_opac_facette_illimite"];
$visible = $rslt->facette_visible+0;
if($visible==0)$visible="";
else $visible="X";
if ($i % 2) $pair_impair = "even"; else $pair_impair = "odd";
$on_mouse_down="onMouseDown=\"document.location='./admin.php?categ=opac&sub=facette_search_opac§ion=facette&action=edit&idF=$idF'\"";
$td_javascript=" ";
$tr_surbrillance = "onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='".$pair_impair."'\" ";
$on_mouse_down="onMouseDown=\"document.location='./admin.php?categ=opac&sub=facette_search_opac§ion=facette&action=edit&idF=".$idF."'\"";
$sort_gestion="";
if($rslt->facette_type_sort) $sort_gestion .= $msg['intit_gest_tri2'];
else $sort_gestion .= $msg['intit_gest_tri1'];
$sort_gestion .= " ".$msg['quotas_and']." ";
if($rslt->facette_order_sort) $sort_gestion .= $msg['intit_gest_tri4'];
else $sort_gestion .= $msg['intit_gest_tri3'];
$lst .= "