id=$id+0;
$this->fetch_data();
}
public function fetch_data() {
global $charset;
$this->info=array();
$this->info['fields']=array();
if(!$this->id) return;
$req="select * from authperso where id_authperso=". $this->id." order by authperso_name";
$resultat=pmb_mysql_query($req);
if (pmb_mysql_num_rows($resultat)) {
$r=pmb_mysql_fetch_object($resultat);
$this->info['id']= $r->id_authperso;
$this->info['name']= $r->authperso_name;
$this->info['onglet_num']= $r->authperso_notice_onglet_num;
$this->info['isbd_script']= $r->authperso_isbd_script;
$this->info['opac_search']= $r->authperso_opac_search;
$this->info['opac_multi_search']= $r->authperso_opac_multi_search;
$this->info['comment']= $r->authperso_comment;
$this->info['event'] = $r->authperso_oeuvre_event;
$this->info['responsability_authperso']= $r->authperso_responsability_authperso;
$this->info['onglet_name']="";
$req="SELECT * FROM notice_onglet where id_onglet=".$r->authperso_notice_onglet_num;
$resultat=pmb_mysql_query($req);
if (pmb_mysql_num_rows($resultat)) {
$r_onglet=pmb_mysql_fetch_object($resultat);
$this->info['onglet_name']= $r_onglet->onglet_name;
}
}
$req = "select * from authperso_custom where num_type=". $this->id." order by ordre";
$resultat = pmb_mysql_query($req);
$i = 0;
if (pmb_mysql_num_rows($resultat)) {
while ($r = pmb_mysql_fetch_object($resultat)) {
$this->info['fields'][$i]['id'] = (int) $r->idchamp;
$this->info['fields'][$i]['custom_prefixe'] = $r->custom_prefixe;
$this->info['fields'][$i]['name'] = $r->name;
$this->info['fields'][$i]['label'] = $r->titre;
$this->info['fields'][$i]['type'] = $r->type;
$this->info['fields'][$i]['datatype'] = $r->datatype;
$this->info['fields'][$i]['ordre'] = (int) $r->ordre;
$this->info['fields'][$i]['search'] = (int) $r->search;
$this->info['fields'][$i]['pond'] = (int) $r->pond;
$this->info['fields'][$i]['obligatoire'] = (int) $r->obligatoire;
$this->info['fields'][$i]['export'] = (int) $r->export;
$this->info['fields'][$i]['multiple'] = (int) $r->multiple;
$this->info['fields'][$i]['opac_sort'] = (int) $r->opac_sort;
$this->info['fields'][$i]['code_champ'] = $this->id;
$this->info['fields'][$i]['code_ss_champ'] = (int) $r->idchamp;
$this->info['fields'][$i]['data'] = array();
$this->info['fields'][$i]['OPTIONS'] = [_parser_text_no_function_("\n".$r->options, "OPTIONS")];
$i++;
}
}
}
public function get_data(){
return $this->info;
}
public function get_info_fields($id=0){
$info= array();
$id += 0;
if($id){
$req="select * from authperso_authorities,authperso where id_authperso=authperso_authority_authperso_num and id_authperso_authority=". $id;
$res = pmb_mysql_query($req);
if(($r=pmb_mysql_fetch_object($res))) {
$p_perso=new custom_parametres_perso("authperso","authperso",$r->authperso_authority_authperso_num,"./autorites.php?categ=authperso&sub=update&id_authperso=".$this->id);
$fields=$p_perso->get_out_values($id);
$authperso_fields=$p_perso->values;
}
}
foreach($this->info['fields'] as $field){
$info[$field['id']]['id']= $field['id'];
$info[$field['id']]['name']= $field['name'];
$info[$field['id']]['label']= $field['label'];
$info[$field['id']]['type']= $field['type'];
$info[$field['id']]['ordre']= $field['ordre'];
$info[$field['id']]['search']=$field['search'];
$info[$field['id']]['pond']=$field['pond'];
$info[$field['id']]['obligatoire']=$field['obligatoire'];
$info[$field['id']]['export']=$field['export'];
$info[$field['id']]['multiple']=$field['multiple'];
$info[$field['id']]['opac_sort']=$field['opac_sort'];
$info[$field['id']]['code_champ']=$this->id;
$info[$field['id']]['code_ss_champ']=$field['id'];
$info[$field['id']]['values']= (isset($authperso_fields[$field['name']]['values']) ? $authperso_fields[$field['name']]['values'] : '');
$info[$field['id']]['all_format_values']= (isset($authperso_fields[$field['name']]['all_format_values']) ? $authperso_fields[$field['name']]['all_format_values'] : '');
}
return $info;
}
public function fetch_data_auth($id) {
$p_perso=new custom_parametres_perso("authperso","authperso",$this->id);
$authperso_fields=$p_perso->get_out_values($id);
$this->info['data_auth'][$id]=$p_perso->values;
//pour ne pas louper les champs vides...
foreach($this->info['fields'] as $i =>$field){
if(isset($this->info['data_auth'][$id][$field['name']])) {
$this->info['fields'][$i]['data'][$id]=$this->info['data_auth'][$id][$field['name']];
} else {
$this->info['fields'][$i]['data'][$id]=array('values' =>
array(
array(
'value' => '',
'format_value' => ''
)
)
);
}
}
return $p_perso->values;
}
// Génération de l'isbd de l'autorité
public static function get_isbd($id){
global $base_path;
$id+= 0;
if(!$id) return '';
$isbd = '';
$req="select * from authperso_authorities,authperso where id_authperso=authperso_authority_authperso_num and id_authperso_authority=". $id;
$res = pmb_mysql_query($req);
if(($r=pmb_mysql_fetch_object($res))) {
$p_perso=new custom_parametres_perso("authperso","authperso",$r->authperso_authority_authperso_num,"./autorites.php?categ=authperso&sub=update&id_authperso=".$id);
$fields=$p_perso->get_out_values($id);
$authperso_fields=$p_perso->values;
if($r->authperso_isbd_script){
$index_concept = new index_concept($id, TYPE_AUTHPERSO);
$authperso_fields['index_concepts'] = $index_concept->get_data();
$template_path = $base_path.'/temp/'.LOCATION.'_authperso_isbd_'.$r->authperso_authority_authperso_num;
if(!file_exists($template_path) || (md5($r->authperso_isbd_script) != md5_file($template_path))){
file_put_contents($template_path, $r->authperso_isbd_script);
}
$h2o = H2o_collection::get_instance($template_path);
$isbd = $h2o->render($authperso_fields);
}else{
$first = true;
foreach ($authperso_fields as $field){
if (!$first){
$isbd.=". ";
}
$isbd.=$field['values'][0]['format_value'];
$first=false;
}
}
}
$isbd = str_replace(array("\n", "\t", "\r"), '', strip_tags($isbd));
return $isbd;
}
// Génération de la notice d'autorité
public function get_view($id){
global $base_path;
$id += 0;
$req="select * from authperso_authorities,authperso where id_authperso=authperso_authority_authperso_num and id_authperso_authority=". $id;
$res = pmb_mysql_query($req);
if(($r=pmb_mysql_fetch_object($res))) {
$p_perso=new custom_parametres_perso("authperso","authperso",$r->authperso_authority_authperso_num,"./autorites.php?categ=authperso&sub=update&id_authperso=".$id);
$fields=$p_perso->get_out_values($id);
$authperso_fields=$p_perso->values;
if (empty(static::$antiloop[$id])) {
static::$antiloop[$id] = true;
$aut_link= new aut_link($r->authperso_authority_authperso_num + 1000,$id);
$authperso_fields['authorities_link']=$aut_link->get_data();
}
if($r->authperso_view_script){
$template_path = $base_path.'/temp/'.LOCATION.'_authperso_isbd_'.$r->authperso_authority_authperso_num;
if(!file_exists($template_path) || (md5($r->authperso_view_script) != md5_file($template_path))){
file_put_contents($template_path, $r->authperso_view_script);
}
$h2o = H2o_collection::get_instance($template_path);
$view = $h2o->render($authperso_fields);
}else{
$view='';
foreach ($authperso_fields as $field){
$view.= (!empty($field['values'][0]['format_value']) ? $field['values'][0]['format_value'].". " : "");
}
}
}
return $view;
}
public function get_ajax_list($user_input){
$values=array();
$search_word = str_replace('*','%',$user_input);
$req = "select * from authperso_authorities where ( authperso_infos_global like '".addslashes($search_word)."%' or authperso_index_infos_global like ' ".addslashes($user_input)."%' ) and authperso_authority_authperso_num= ".$this->id;
$req .= " order by authperso_index_infos_global limit 20";
$res = pmb_mysql_query($req);
while(($r=pmb_mysql_fetch_object($res))) {
$values[$r->id_authperso_authority]=strip_tags(static::get_isbd($r->id_authperso_authority));
}
return($values);
}
public function get_name() {
return $this->info['name'];
}
public function get_list_selector($id_to_view=0,$url = '',$nb_per_page=10) {
global $msg,$charset,$dbh;
global $user_query, $user_input, $f_user_input, $page,$nbr_lignes,$last_param;
global $callback;
global $caller;
global $base_url;
if(!$url){
$url = $base_url;
}
if($id_to_view){
$isbd=strip_tags(static::get_isbd($id_to_view));
$authority = new authority(0, $id_to_view, AUT_TABLE_AUTHPERSO);
return "
".$authority->get_display_statut_class_html()."".
htmlentities($isbd,ENT_QUOTES, $charset)."
";
}
$auth_lines='';
if(!$page) $page=1;
$debut =($page-1)*$nb_per_page;
if (!$user_input && $f_user_input) {
$user_input = $f_user_input;
}
$search_word = str_replace('*','%',$user_input);
if(!($nb_per_page*1)){
$nb_per_page=$nb_per_page_search;
}
if(!$page) $page=1;
if(!$last_param){
$debut =($page-1)*$nb_per_page;
$requete = "SELECT count(1) FROM authperso_authorities where ( authperso_infos_global like '%".$search_word."%' or authperso_index_infos_global like '%".$user_input."%' ) and authperso_authority_authperso_num= ".$this->id;
$res = pmb_mysql_query($requete, $dbh);
$nbr_lignes = pmb_mysql_result($res, 0, 0);
$nbepages = ceil($nbr_lignes/$nb_per_page);
if($page>$nbepages){
$debut=0;
$page=1;
}
$req = "select * from authperso_authorities where ( authperso_infos_global like '%".$search_word."%' or authperso_index_infos_global like '%".$user_input."%' ) and authperso_authority_authperso_num= ".$this->id;
$req .= " order by authperso_index_infos_global LIMIT ".$debut.",".$nb_per_page." ";
}else{ // les derniers créés
$req = "select * from authperso_authorities where authperso_authority_authperso_num= ".$this->id;
$req .= " order by id_authperso_authority DESC LIMIT $nb_per_page";
}
$res = pmb_mysql_query($req,$dbh);
while(($r=pmb_mysql_fetch_object($res))) {
$id=$r->id_authperso_authority;
$isbd=strip_tags(static::get_isbd($id));
$authority = new authority(0, $id, AUT_TABLE_AUTHPERSO);
$auth_lines.=$authority->get_display_statut_class_html()."".
htmlentities($isbd,ENT_QUOTES, $charset)."
";
}
//$url_base = $base_url."&user_input=".rawurlencode(stripslashes($user_input));
$nav_bar = aff_pagination ($url, $nbr_lignes, $nb_per_page, $page, 10, false, true) ;
$authperso_list_tpl= "
$auth_lines