id=$id+0; // id de la notice $this->fetch_data(); } public function fetch_data() { $this->onglets_auth_list=array(); if(!$this->id) return; // pour chaque autorités existantes récupérér les autorités affectés à la notice $req="select * from authperso, notices_authperso,authperso_authorities where id_authperso=authperso_authority_authperso_num and notice_authperso_authority_num=id_authperso_authority and notice_authperso_notice_num=".$this->id." order by notice_authperso_order"; $res = pmb_mysql_query($req); while(($r=pmb_mysql_fetch_object($res))) { // get isbd ... $this->auth_info[$r->notice_authperso_authority_num]['onglet_num']=$r->authperso_notice_onglet_num; $this->auth_info[$r->notice_authperso_authority_num]['authperso_name']=$r->authperso_name; $this->auth_info[$r->notice_authperso_authority_num]['infos_global']=$r->authperso_infos_global; $this->auth_info[$r->notice_authperso_authority_num]['index_infos_global']=$r->authperso_index_infos_global; $isbd = authperso::get_isbd($r->notice_authperso_authority_num); $this->onglets_auth_list[$r->authperso_notice_onglet_num][$r->id_authperso][$r->notice_authperso_authority_num]['id']=$r->notice_authperso_authority_num; $this->onglets_auth_list[$r->authperso_notice_onglet_num][$r->id_authperso][$r->notice_authperso_authority_num]['isbd']=$isbd; $this->onglets_auth_list[$r->authperso_notice_onglet_num][$r->id_authperso][$r->notice_authperso_authority_num]['authperso_name']=$r->authperso_name; $authperso = $this->get_authperso_class($r->id_authperso); $info_fields=$authperso->get_info_fields($r->notice_authperso_authority_num); $this->auth_info[$r->notice_authperso_authority_num]['isbd']=$isbd; $this->auth_info[$r->notice_authperso_authority_num]['info_fields']=$info_fields; } } public function get_notice_display(){ global $base_path; $aff=""; foreach($this->onglets_auth_list as $onglet_num => $onglet){ $authperso_name=""; foreach($onglet as $authperso_num => $auth_perso){ foreach($auth_perso as $auth_num => $auth){ if($authperso_name!=$auth['authperso_name']){ $authperso_name=$auth['authperso_name']; $aff.="
".$authperso_name." : "; $new=1; } if(!$new) $aff.=", "; $aff.= ''.$auth['isbd'].''; $new=0; } } } return $aff; } public function get_notice_display_list(){ $aff_list=array(); foreach($this->onglets_auth_list as $onglet_num => $onglet){ $authperso_name=""; foreach($onglet as $authperso_num => $auth_perso){ $aff_list[$authperso_num]['isbd']=""; $aff_list[$authperso_num]['name']=""; foreach($auth_perso as $auth_num => $auth){ $aff_list[$authperso_num]['name']=$auth['authperso_name']; if($aff_list[$authperso_num]['isbd'])$aff_list[$authperso_num]['isbd'].=", "; $aff_list[$authperso_num]['isbd'].=$auth['isbd']; } } } return $aff_list; } public function get_index_fields(){ $index_fields=array(); foreach($this->auth_info as $auth){ foreach($auth['info_fields'] as $field){ if(!isset($index_fields[$field['code_champ']]['ss_champ'][0][0])) { $index_fields[$field['code_champ']]['ss_champ'][0][0] = $auth['isbd']; } if($field['search'] ){ $index_fields[$field['code_champ']]['pond']=$field['pond']; if($field['all_format_values']) { $index_fields[$field['code_champ']]['ss_champ'][][$field['code_ss_champ']] = $field['all_format_values']; } } } } return $index_fields; } public function get_index_fields_to_delete(){ return authpersos::get_all_index_fields(); } public function get_form(){ global $msg,$charset,$base_path; $onglet_all_tpl=" "; $authperso_notice_onglet_tpl="

!!onglet_name!!

!!authperso_list!!

"; $authperso_notice_onglet_empty="

!!onglet_name!!


"; $authperso_notice_elt_tpl= "
!!authlist!!
"; $authperso_notice_elt_tpl_num="
"; $onglet_used=array(); // infos des autorités existantes $authpersos = authpersos::get_instance(); $this->onglets_info=$authpersos->get_onglet_list(); foreach($this->onglets_info as $onglet_num => $onglet){ $onglet_contens=""; foreach($onglet as $elt){ // Pour chaque type d'autorité dans l'onglet //printr($elt); $tpl_elt=$authperso_notice_elt_tpl; $iauthperso=0; $auth_list_tpl=""; $tab_authperso_order=array(); if(!isset($this->onglets_auth_list[$onglet_num][$elt['id']]) || !count($this->onglets_auth_list[$onglet_num][$elt['id']])){ // pas d'autorité $auth_list_tpl=$authperso_notice_elt_tpl_num; $auth_list_tpl=str_replace('!!authperso_libelle!!',"", $auth_list_tpl); $auth_list_tpl=str_replace('!!iauthperso!!',$iauthperso, $auth_list_tpl); $auth_list_tpl=str_replace('!!auth_id!!',"", $auth_list_tpl); $max_authperso=1; $tab_authperso_order[]="authperso_".$elt['id']."_0"; }else{ foreach ($this->onglets_auth_list[$onglet_num][$elt['id']] as $auth_id =>$auth){ // Pour chaque autorité répétée $auth_tpl=$authperso_notice_elt_tpl_num; $auth_tpl=str_replace('!!authperso_libelle!!',$auth['isbd'], $auth_tpl); $auth_tpl=str_replace('!!iauthperso!!',$iauthperso, $auth_tpl); $auth_tpl=str_replace('!!auth_id!!',$auth_id, $auth_tpl); $auth_list_tpl.=$auth_tpl; $tab_authperso_order[]="authperso_".$elt['id']."_".$iauthperso; $iauthperso++; $max_authperso=$iauthperso; } } $tpl_elt=str_replace('!!authlist!!',$auth_list_tpl, $tpl_elt); $tpl_elt=str_replace('!!auth_name!!',htmlentities($elt['name'], ENT_QUOTES, $charset), $tpl_elt); $tpl_elt=str_replace('!!authperso_id!!',$elt['id'], $tpl_elt); $tpl_elt=str_replace('!!iauthperso!!',0, $tpl_elt); $tpl_elt=str_replace('!!max_authperso!!',$max_authperso, $tpl_elt); $tpl_elt=str_replace('!!tab_authperso_order!!',implode(",",$tab_authperso_order), $tpl_elt); $onglet_contens.=$tpl_elt; } $onglet_tpl=$authperso_notice_onglet_tpl; $onglet_tpl=str_replace('!!authperso_list!!',$onglet_contens, $onglet_tpl); if(!$elt['onglet_name']) $elt['onglet_name']=$msg['authperso_multi_search_title']; $onglet_tpl=str_replace('!!onglet_name!!',$elt['onglet_name'], $onglet_tpl); $onglet_tpl=str_replace('!!onglet_name_title!!',htmlentities($elt['onglet_name'],ENT_QUOTES, $charset), $onglet_tpl); $onglet_tpl=str_replace('!!ongletnum!!',$onglet_num, $onglet_tpl); $onglet_used[]=$onglet_num; $onglet_all_tpl.=$onglet_tpl; } if (count($onglet_used)) { $req = 'SELECT * FROM notice_onglet where id_onglet not in(' . implode(',', $onglet_used) . ') order by onglet_name'; } else { $req = 'SELECT * FROM notice_onglet order by onglet_name'; } $resultat = pmb_mysql_query($req); if (pmb_mysql_num_rows($resultat)) { while($r_onglet = pmb_mysql_fetch_object($resultat)) { $onglet_tpl = $authperso_notice_onglet_empty; $onglet_tpl = str_replace('!!onglet_name!!', $r_onglet->onglet_name, $onglet_tpl); $onglet_tpl = str_replace('!!onglet_name_title!!',htmlentities($r_onglet->onglet_name, ENT_QUOTES, $charset), $onglet_tpl); $onglet_tpl = str_replace('!!ongletnum!!', $r_onglet->id_onglet, $onglet_tpl); $onglet_all_tpl.= $onglet_tpl; } } return $onglet_all_tpl; } public function delete(){ $req="delete from notices_authperso where notice_authperso_notice_num=".$this->id; pmb_mysql_query($req); } public function save_form(){ $authpersos = authpersos::get_instance(); $infos=$authpersos->get_data(); if(!count($infos)) return; $this->delete(); foreach ($infos as $authperso){ $authperso_id=$authperso['id']; $max_authperso="max_authperso_".$authperso_id; global ${$max_authperso}; $max_authperso=${$max_authperso}; $order=0; $final_ordre=array(); $tab_authperso_order="tab_authperso_order_".$authperso_id; global ${$tab_authperso_order}; $tab_authperso_order=${$tab_authperso_order}; // value="authperso_1_2,authperso_1_0,authperso_1_1" .... $tab_order=explode(',',$tab_authperso_order); foreach($tab_order as $string_order){ $tab_string_order=explode("_",$string_order); $final_ordre[]=$tab_string_order[2]; } if($final_ordre){ $order=0; foreach($final_ordre as $old_order){ $auth_id="f_authperso_id_".$authperso_id."_".$old_order; global ${$auth_id}; $auth_id=${$auth_id}; if($auth_id){ $req="insert into notices_authperso set notice_authperso_notice_num=".$this->id.", notice_authperso_authority_num= $auth_id, notice_authperso_order=".$order; $result = pmb_mysql_query($req); $order++; } } }else{ $order=0; for($i=0;$i<$max_authperso; $i++ ){ $auth_id="f_authperso_id_".$authperso_id."_".$i; global ${$auth_id}; $auth_id=${$auth_id}; if($auth_id){ $req="insert into notices_authperso set notice_authperso_notice_num=".$this->id.", notice_authperso_authority_num= $auth_id, notice_authperso_order=".$order; $result = pmb_mysql_query($req); $order++; } } } } } public function get_fields_search(){ $mots=""; foreach($this->auth_info as $auth){ if($mots)$mots.=" "; $mots.=$auth["infos_global"]; } return $mots; } private function get_authperso_class($id_type_authperso){ if(!isset(self::$authpersos[$id_type_authperso])){ self::$authpersos[$id_type_authperso] = new authperso($id_type_authperso); } return self::$authpersos[$id_type_authperso]; } } // authperso_notice class end