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
 
$nav_bar
"; return $authperso_list_tpl; } } //authperso class end class authpersos { public $info=array(); protected static $instance; public static function get_name($id_authperso){ $id_authperso+=0; $query = "select authperso_name from authperso where id_authperso = ".$id_authperso; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)){ return pmb_mysql_result($result, 0); } } public function __construct() { $this->fetch_data(); } public function fetch_data() { global $PMBuserid; $this->info=array(); $i=0; $req="select * from authperso order by authperso_name"; $resultat=pmb_mysql_query($req); if (pmb_mysql_num_rows($resultat)) { while($r=pmb_mysql_fetch_object($resultat)){ $authperso= new authperso($r->id_authperso); $this->info[$r->id_authperso]=$authperso->get_data(); $i++; } } } public function get_data(){ return($this->info); } public function get_simple_seach_list_tpl() { global $look_FIRSTACCESS ; // si 0 alors premier Acces : la rech par defaut est cochee global $get_query; $ou_chercher_tab=array(); foreach($this->info as $authperso){ if (!$authperso['opac_search']) continue; $look_name="look_AUTHPERSO_".$authperso['id']."#"; global ${$look_name}; $look=${$look_name}; if (!$look_FIRSTACCESS && !$get_query ) { if ($authperso['opac_search']==2) $look = 1 ; } if($look){ $checked_AUTHPERSO= " checked='' " ; $this->simple_seach_list_checked=1; }else $checked_AUTHPERSO=""; $ou_chercher_tab[]= "\n"; } return $ou_chercher_tab; } public function get_simple_seach_list_tpl_hiden() { $tpl=""; foreach($this->info as $authperso){ if (!$authperso['opac_search']) continue; $look_name="look_AUTHPERSO_".$authperso['id']."#"; global ${$look_name}; $look=${$look_name}; if($look)$tpl.=""; } return $tpl; } public function make_search_test() { $tpl=""; foreach($this->info as $authperso){ if (!$authperso['opac_search']) continue; $look_name="look_AUTHPERSO_".$authperso['id']."#"; global ${$look_name}; $look=${$look_name}; if($look)$tpl.=""; } return $tpl; } public function get_field_text($id) { // BT : fonction probablement plus/pas utilisée $auth = new authperso_data($id); return array('valeur_champ' => $auth->get_isbd(), "look_AUTHPERSO_typ_search" => $auth->get_authperso_num()); } public function search_authperso($user_query) { global $opac_search_other_function,$typdoc,$charset,$dbh; global $opac_stemming_active; $total_results=0; foreach($this->info as $authperso){ if (!$authperso['opac_search']) continue; $look_name="look_AUTHPERSO_".$authperso['id']."#"; global ${$look_name}; $look=${$look_name}; if(!$look) continue; $clause = ''; $add_notice = ''; $aq=new analyse_query(stripslashes($user_query),0,0,1,1,$opac_stemming_active); $members=$aq->get_query_members("authperso_authorities","authperso_infos_global","authperso_index_infos_global","id_authperso_authority"); $clause.= "where ".$members["where"] ." and authperso_authority_authperso_num=".$authperso['id']; if ($opac_search_other_function) $add_notice=search_other_function_clause(); if ($typdoc || $add_notice) $clause = ', notices, notices_authperso '.$clause; if ($typdoc) $clause.=" and notice_authperso_notice_num=notice_id and typdoc='".$typdoc."' "; if ($add_notice) $clause.= ' and notice_id in ('.$add_notice.')'; $tri = 'order by pert desc, authperso_index_infos_global'; $pert=$members["select"]." as pert"; $auth_res = pmb_mysql_query("SELECT COUNT(distinct id_authperso_authority) FROM authperso_authorities $clause", $dbh); $nb_result = pmb_mysql_result($auth_res, 0 , 0); if ($nb_result) { $total_results+=$nb_result; //définition du formulaire $form = "
"; $form .= "\n"; if (function_exists("search_other_function_post_values")){ $form .=search_other_function_post_values(); } $form .= "\n"; $form .= "\n"; $form .= "\n"; $form .= "\n"; $form .= "\n"; $form .= ""; $form .= "\n"; $form .= "
\n"; $form .= "
"; $_SESSION["level1"]["authperso_".$authperso['id']]["form"]=$form; $_SESSION["level1"]["authperso_".$authperso['id']]["count"]=$nb_result; $_SESSION["level1"]["authperso_".$authperso['id']]["name"]=$authperso["name"]; } } return $total_results; } public function rec_history($n) { foreach($this->info as $authperso){ if (!$authperso['opac_search']) continue; $look_name="look_AUTHPERSO_".$authperso['id']."#"; global ${$look_name}; $look=${$look_name}; if($look)$_SESSION[$look_name.$n]=$look; } } public function get_history($n) { foreach($this->info as $authperso){ if (!$authperso['opac_search']) continue; $look_name="look_AUTHPERSO_".$authperso['id']."#"; global ${$look_name}; ${$look_name}=(isset($_SESSION[$look_name.$n]) ? $_SESSION[$look_name.$n] : ''); } } public function get_human_query($n) { $r1 = ''; foreach($this->info as $authperso){ if (!$authperso['opac_search']) continue; $look_name="look_AUTHPERSO_".$authperso['id']."#"; global ${$look_name}; if (isset($_SESSION["$look_name".$n]) && $_SESSION["$look_name".$n]) $r1.=$authperso['name']." "; } return $r1; } public static function get_instance() { if(!isset(static::$instance)) { static::$instance = new authpersos(); } return static::$instance; } public function is_responsability_authperso() { $req = "select authperso_responsability_authperso from authperso where id_authperso=". $this->id; $res = pmb_mysql_query($req); if(($r=pmb_mysql_fetch_object($res))) { return $r->authperso_responsability_authperso; } return 0; } } // authpersos class end