1000 $aut_table_name_list=array( AUT_TABLE_AUTHORS => 'authors', AUT_TABLE_CATEG => 'categ', AUT_TABLE_PUBLISHERS=> 'publishers', AUT_TABLE_COLLECTIONS => 'collection', AUT_TABLE_SUB_COLLECTIONS => 'sub_collections', AUT_TABLE_SERIES => 'series', AUT_TABLE_TITRES_UNIFORMES => 'titres_uniformes', AUT_TABLE_INDEXINT => 'indexint', AUT_TABLE_CONCEPT => 'concept', AUT_TABLE_INDEX_CONCEPT => 'concept', AUT_TABLE_AUTHPERSO => 'authperso' ); // définition de la classe de gestion des liens entre autorités class aut_link { protected $aut_link_xml; public $aut_table; public $id; protected $js_aut_link_table_list = ''; // nécesaire pour les aut perso.. private static $onto_index; public function __construct($aut_table,$id) { $this->aut_table = $aut_table; $this->id = $id; $this->getdata(); } public function getdata() { global $dbh,$msg; global $aut_table_name_list; global $pmb_opac_url; $this->parse_file(); if($this->aut_table > 1000) { $this->aut_table_name = $aut_table_name_list[AUT_TABLE_AUTHPERSO]; } else { $this->aut_table_name = $aut_table_name_list[$this->aut_table]; } $this->aut_list=array(); $rqt="select * from aut_link where (aut_link_from='".$this->aut_table."' and aut_link_from_num='".$this->id."' ) or ( aut_link_to='".$this->aut_table."' and aut_link_to_num='".$this->id."' and aut_link_reciproc=1 ) order by aut_link_type "; $aut_res=pmb_mysql_query($rqt, $dbh); $i=0; while($row = pmb_mysql_fetch_object($aut_res)){ $i++; $this->aut_list[$i]['to']=$row->aut_link_to; $this->aut_list[$i]['to_num']=$row->aut_link_to_num; $this->aut_list[$i]['type']=$row->aut_link_type; $this->aut_list[$i]['reciproc']=$row->aut_link_reciproc; $this->aut_list[$i]['comment']=$row->aut_link_comment; if(($this->aut_table==$row->aut_link_to ) and ($this->id == $row->aut_link_to_num)) { $this->aut_list[$i]['flag_reciproc']=1; $this->aut_list[$i]['to']=$row->aut_link_from; $this->aut_list[$i]['to_num']=$row->aut_link_from_num; } else { $this->aut_list[$i]['flag_reciproc']=0; } switch($this->aut_list[$i]['to']){ case AUT_TABLE_AUTHORS : $auteur = authorities_collection::get_authority($this->aut_list[$i]['to'], $this->aut_list[$i]['to_num']); $this->aut_list[$i]['isbd_entry'] = $auteur->get_isbd(); $this->aut_list[$i]['libelle'] = '['.$msg[133].'] '.$auteur->get_isbd(); break; case AUT_TABLE_CATEG : $categ = authorities_collection::get_authority($this->aut_list[$i]['to'], $this->aut_list[$i]['to_num']); $this->aut_list[$i]['isbd_entry'] = $categ->libelle; $this->aut_list[$i]['libelle'] = '['.$msg[134].'] '.$categ->libelle; break; case AUT_TABLE_PUBLISHERS : $ed = authorities_collection::get_authority($this->aut_list[$i]['to'], $this->aut_list[$i]['to_num']); $this->aut_list[$i]['isbd_entry'] = $ed->get_isbd(); $this->aut_list[$i]['libelle'] = '['.$msg[135].'] '.$ed->get_isbd(); break; case AUT_TABLE_COLLECTIONS : $collection = authorities_collection::get_authority($this->aut_list[$i]['to'], $this->aut_list[$i]['to_num']); $this->aut_list[$i]['isbd_entry'] = $collection->get_isbd(); $this->aut_list[$i]['libelle'] = '['.$msg[136].'] '.$collection->get_isbd(); break; case AUT_TABLE_SUB_COLLECTIONS : $subcollection = authorities_collection::get_authority($this->aut_list[$i]['to'], $this->aut_list[$i]['to_num']); $this->aut_list[$i]['isbd_entry'] = $subcollection->get_isbd(); $this->aut_list[$i]['libelle'] = '['.$msg[137].'] '.$subcollection->get_isbd(); break; case AUT_TABLE_SERIES : $serie = authorities_collection::get_authority($this->aut_list[$i]['to'], $this->aut_list[$i]['to_num']); $this->aut_list[$i]['isbd_entry'] = $serie->get_isbd(); $this->aut_list[$i]['libelle'] = '['.$msg[333].'] '.$serie->get_isbd(); break; case AUT_TABLE_TITRES_UNIFORMES : $tu = authorities_collection::get_authority($this->aut_list[$i]['to'], $this->aut_list[$i]['to_num']); $this->aut_list[$i]['isbd_entry']=$tu->get_isbd(); $this->aut_list[$i]['libelle']='['.$msg['aut_menu_titre_uniforme'].'] '.$tu->get_isbd(); break; case AUT_TABLE_INDEXINT : $indexint = authorities_collection::get_authority($this->aut_list[$i]['to'], $this->aut_list[$i]['to_num']); $this->aut_list[$i]['isbd_entry']=$indexint->get_isbd(); $this->aut_list[$i]['libelle']='['.$msg['indexint_menu'].'] '.$indexint->get_isbd(); break; case AUT_TABLE_CONCEPT : $concept= authorities_collection::get_authority($this->aut_list[$i]['to'], $this->aut_list[$i]['to_num']); $this->aut_list[$i]['isbd_entry']=$concept->get_display_label(); $this->aut_list[$i]['libelle']='['.$msg['concept_menu'].'] '.$concept->get_display_label(); break; default: if($this->aut_list[$i]['to']>1000){ // authperso $authperso = new authperso($this->aut_list[$i]['to']-1000); $isbd = authperso::get_isbd($this->aut_list[$i]['to_num']); $this->aut_list[$i]['isbd_entry']=$isbd; $this->aut_list[$i]['libelle']='['.$authperso->info['name'].'] '.$isbd; $this->aut_list[$i]['url_to_gestion']='./autorites.php?categ=authperso&sub=authperso_form&id_authperso=&id='.$this->aut_list[$i]['to_num']; $this->aut_list[$i]['url_to_opac']=$pmb_opac_url.'index.php?lvl=authperso_see&id='.$this->aut_list[$i]['to_num']; } break; } if($this->aut_list[$i]["flag_reciproc"]){ $type_relation=new marc_select("relationtype_autup","f_aut_link_type$i", $this->aut_list[$i]['type']); }else { $type_relation=new marc_select("relationtype_aut","f_aut_link_type$i", $this->aut_list[$i]['type']); } $this->aut_list[$i]['relation_libelle']=$type_relation->libelle; } } public function get_form($caller="categ_form") { global $msg,$add_aut_link,$aut_link0,$aut_link1,$form_aut_link; global $thesaurus_concepts_active,$charset; $form = $add_aut_link; $this->js_aut_link_table_list=" var aut_link_table_select=Array(); aut_link_table_select[".AUT_TABLE_AUTHORS."]='./select.php?what=auteur&caller=$caller&dyn=2¶m1='; aut_link_table_select[".AUT_TABLE_CATEG."]='./select.php?what=categorie&caller=$caller&dyn=2&parent=1&p1='; aut_link_table_select[".AUT_TABLE_PUBLISHERS."]='./select.php?what=editeur&caller=$caller&dyn=2&p1='; aut_link_table_select[".AUT_TABLE_COLLECTIONS."]='./select.php?what=collection&caller=$caller&dyn=2&p1='; aut_link_table_select[".AUT_TABLE_SUB_COLLECTIONS."]='./select.php?what=subcollection&caller=$caller&dyn=2&p1='; aut_link_table_select[".AUT_TABLE_SERIES."]='./select.php?what=serie&caller=$caller&dyn=2¶m1='; aut_link_table_select[".AUT_TABLE_TITRES_UNIFORMES."]='./select.php?what=titre_uniforme&caller=$caller&dyn=2¶m1='; aut_link_table_select[".AUT_TABLE_INDEXINT."]='./select.php?what=indexint&caller=$caller&dyn=2¶m1='; aut_link_table_select[".AUT_TABLE_CONCEPT."]='./select.php?what=ontology&caller=$caller&element=concept&dyn=2¶m1='; "; $aut_table_list = $this->generate_aut_type_selector($caller); $i=0; if(!count($this->aut_list)){ // pas d'enregistrement $form.=$aut_link0; $liste_type_relation=new marc_select("relationtype_aut","f_aut_link_type$i", "","","","",array(array('name'=>'data-form-name','value'=>'f_aut_link_type'))); $form=str_replace("!!aut_link_type!!",$liste_type_relation->display,$form); $form=str_replace("!!aut_link_reciproc!!","unchecked='unchecked'",$form); $form=str_replace("!!aut_link!!",$i,$form); $form=str_replace("!!aut_link_libelle!!","",$form); $form=str_replace("!!aut_link_table!!","",$form); $form=str_replace("!!aut_link_id!!","",$form); $form=str_replace("!!aut_link_comment!!","",$form); $i++; } else{ foreach ($this->aut_list as $aut) { // Construction de chaque ligne du formulaire if($i) $form_suivant=$aut_link1; else $form_suivant=$aut_link0; if($aut["flag_reciproc"]){ $liste_type_relation=new marc_select("relationtype_autup","f_aut_link_type$i", $aut["type"],"","","",array(array('name'=>'data-form-name','value'=>'f_aut_link_type'))); }else { $liste_type_relation=new marc_select("relationtype_aut","f_aut_link_type$i", $aut["type"],"","","",array(array('name'=>'data-form-name','value'=>'f_aut_link_type'))); } $form_suivant=str_replace("!!aut_link_type!!",$liste_type_relation->display,$form_suivant); if($aut["reciproc"]) $check="checked='checked'"; else $check=""; $form_suivant=str_replace("!!aut_link_reciproc!!",$check,$form_suivant); $form_suivant=str_replace("!!aut_link!!",$i,$form_suivant); $form_suivant=str_replace("!!aut_link_libelle!!",htmlentities($aut["libelle"],ENT_QUOTES, $charset,false),$form_suivant); $form_suivant=str_replace("!!aut_link_table!!",$aut["to"],$form_suivant); $form_suivant=str_replace("!!aut_link_id!!",$aut["to_num"],$form_suivant); $form_suivant=str_replace("!!aut_link_comment!!",$aut["comment"],$form_suivant); $form.=$form_suivant; $i++; } } $form=str_replace("!!max_aut_link!!",$i,$form); $form=str_replace("!!js_aut_link_table_list!!",$this->js_aut_link_table_list,$form); $form=str_replace("!!aut_table_list!!",$aut_table_list,$form); if(!$aut_table_list && !count($this->aut_list)){ return str_replace("!!aut_link_contens!!", $msg['no_aut_link'], $form_aut_link); } return str_replace("!!aut_link_contens!!", $form , $form_aut_link); } public function save_form() { global $dbh; //max_aut_link //f_aut_link_typexxx //f_aut_link_tablexxx //f_aut_link_idxxx global $max_aut_link; if(!$this->aut_table && !$this->id) return; $this->delete_link(); for($i=0;$i<$max_aut_link;$i++){ eval("global \$f_aut_link_table".$i.";\$f_aut_link_table= \$f_aut_link_table$i;"); eval("global \$f_aut_link_id".$i.";\$f_aut_link_id= \$f_aut_link_id$i;"); eval("global \$f_aut_link_type".$i.";\$f_aut_link_type= \$f_aut_link_type$i;"); eval("global \$f_aut_link_reciproc".$i.";\$f_aut_link_reciproc= \$f_aut_link_reciproc$i;"); eval("global \$f_aut_link_comment".$i.";\$f_aut_link_comment= \$f_aut_link_comment$i;"); // Les selecteurs de concept retourne l'uri et non id if($f_aut_link_table==AUT_TABLE_CONCEPT && !is_numeric($f_aut_link_id)){ $f_aut_link_id=onto_common_uri::get_id($f_aut_link_id); } if($f_aut_link_reciproc)$f_aut_link_reciproc=1; if($f_aut_link_id && $f_aut_link_table && $f_aut_link_type && !(($this->aut_table == $f_aut_link_table) && ($this->id == $f_aut_link_id))) { $requete="INSERT INTO aut_link (aut_link_from, aut_link_from_num, aut_link_to,aut_link_to_num , aut_link_type, aut_link_reciproc, aut_link_comment) VALUES ('".$this->aut_table."', '".$this->id."','".$f_aut_link_table."', '".$f_aut_link_id."', '".$f_aut_link_type."', '".$f_aut_link_reciproc."','".$f_aut_link_comment."')"; pmb_mysql_query($requete); } if($f_aut_link_reciproc){ $this->maj_index($f_aut_link_id, $f_aut_link_table > 1000 ? 9 : $f_aut_link_table); } } } // delete tous les liens (from vers to) de cette autorité public function delete_link() { if(!$this->aut_table && !$this->id) return; $query = "SELECT aut_link_to_num, aut_link_to FROM aut_link WHERE aut_link_from_num='".$this->id."' and aut_link_from='".$this->aut_table."'"; $result = pmb_mysql_query($query); pmb_mysql_query("DELETE FROM aut_link WHERE aut_link_from='".$this->aut_table."' and aut_link_from_num='".$this->id."' "); if(pmb_mysql_num_rows($result)) { while($row = pmb_mysql_fetch_object($result)) { $this->maj_index($row->aut_link_to_num, $row->aut_link_to > 1000 ? 9 : $row->aut_link_to); } } $query = "SELECT aut_link_from_num, aut_link_from FROM aut_link WHERE aut_link_to_num='".$this->id."' and aut_link_to='".$this->aut_table."' and aut_link_reciproc=1"; $result = pmb_mysql_query($query); pmb_mysql_query("DELETE FROM aut_link WHERE aut_link_to='".$this->aut_table."' and aut_link_to_num='".$this->id."' and aut_link_reciproc=1 "); if(pmb_mysql_num_rows($result)) { while($row = pmb_mysql_fetch_object($result)) { $this->maj_index($row->aut_link_from_num, $row->aut_link_from > 1000 ? 9 : $row->aut_link_from); } } } // delete tous les liens (from et to) de cette autorité public function delete() { global $dbh; if(!$this->aut_table && !$this->id) return; $query = "SELECT aut_link_to_num, aut_link_to FROM aut_link WHERE aut_link_from_num='".$this->id."' and aut_link_from='".$this->aut_table."'"; $result = pmb_mysql_query($query); pmb_mysql_query("DELETE FROM aut_link WHERE aut_link_from='".$this->aut_table."' and aut_link_from_num='".$this->id."' "); if(pmb_mysql_num_rows($result)) { while($row = pmb_mysql_fetch_object($result)) { $this->maj_index($row->aut_link_to_num, $row->aut_link_to > 1000 ? 9 : $row->aut_link_to); } } $query = "SELECT aut_link_from_num, aut_link_from FROM aut_link WHERE aut_link_to_num='".$this->id."' and aut_link_to='".$this->aut_table."'"; $result = pmb_mysql_query($query); pmb_mysql_query("DELETE FROM aut_link WHERE aut_link_to='".$this->aut_table."' and aut_link_to_num='".$this->id."' "); if(pmb_mysql_num_rows($result)) { while($row = pmb_mysql_fetch_object($result)) { $this->maj_index($row->aut_link_from_num, $row->aut_link_from > 1000 ? 9 : $row->aut_link_from); } } } // copie les liens from et to par une autre autorité public function add_link_to($copy_table,$copy_num) { global $dbh; if(!$this->aut_table && !$this->id && !$copy_link_to && !$copy_link_to_num) return; foreach ($this->aut_list as $aut) { if($aut["flag_reciproc"]){ $requete="INSERT INTO aut_link (aut_link_from, aut_link_from_num, aut_link_to,aut_link_to_num , aut_link_type, aut_link_reciproc, aut_link_comment) VALUES ('".$aut["to"]."', '".$aut["to_num"]."','".$copy_table."', '".$copy_num."', '".$aut["type"]."', '".$aut["reciproc"]."','".$aut["comment"]."')"; }else { $requete="INSERT INTO aut_link (aut_link_from, aut_link_from_num, aut_link_to,aut_link_to_num , aut_link_type, aut_link_reciproc, aut_link_comment) VALUES ('".$copy_table."', '".$copy_num."','".$aut["to"]."', '".$aut["to_num"]."', '".$aut["type"]."', '".$aut["reciproc"]."','".$aut["comment"]."')"; } @pmb_mysql_query($requete); } } public function get_display($caller="categ_form") { global $msg; if(!count($this->aut_list)) return""; $aut_see_link = "./autorites.php?categ=see&sub=!!type!!&id=!!to_num!!"; $marc_table=marc_list_collection::get_instance("relationtype_aut"); $liste_type_relation = $marc_table->table; $marc_tableup=marc_list_collection::get_instance("relationtype_autup"); $liste_type_relationup = $marc_tableup->table; $aff="