id_import ;
$nb_notices++;
//on la traite comme une notice d'autorités...
$notice_authority = new notice_authority($notobj->notice);
if($notice_authority->error){
//en cas d'erreur à la lecture d'un format unimarc A, on a peut être un format unimarc B et une notice de collection
$notice_authority = new notice_authority_serie($notobj->notice,"UNI","iso-8859-1",$type_link['subcollection']);
if($notice_authority->error){
$fp = fopen ("../../temp/err_import_authorities".SESSid.".unimarc","a+");
fwrite ($fp, $notobj->notice);
fclose ($fp);
$nb_notices_rejetees++;
}
}
//on a une notice correcte, on regarde si on doit la traitée...
if(!$notice_authority->error && ($authorities_type == 'all' || $notice_authority->type == $authorities_type)){
//on y va...
$authority_import = new $pmb_import_modele_authorities($notice_authority,$create_link,$create_link_spec,$force_update,$id_thesaurus,$type_link['rejected'],$type_link['associated']);
//on récupère les infos classiques...
$authority_import->get_informations();
//on donne la possibilité d'agir sur les données avant l'import...
$authority_import->get_informations_callback();
//si la notice est d'un type connu et donc importable dans PMB
if($authority_import->notice->type != ""){
// on importe
$authority_import->import();
// et on donne la possibilité d'un traitement post-import
$authority_import->import_callback();
if(isset($nb_notices_import) && is_array($nb_notices_import) && $nb_notices_import[$authority_import->notice->type]){
$nb_notices_import[$authority_import->notice->type]++;
}else{
$nb_notices_import[$authority_import->notice->type]=1;
}
}elseif(!$notice_authority->error){
$sql_log = mysql_query("insert into error_log (error_origin, error_text) values ('iimport_authorities".addslashes(SESSid).".php', '".addslashes($msg[import_authorite_bad_type].($notice_authority->type != "" ? $msg["import_authorities_type_".$notice_authority->type] : $msg["52"]))."') ") ;
}
}elseif(!$notice_authority->error){
$sql_log = mysql_query("insert into error_log (error_origin, error_text) values ('iimport_authorities".addslashes(SESSid).".php', '".addslashes($msg[import_authorite_bad_type].($notice_authority->type != "" ? $msg["import_authorities_type_".$notice_authority->type] : $msg["52"]))."') ") ;
}
// la notice à été traitée, on la supprime de la table d'import...
$query = "delete from import_marc where id_import = ".$idnotice_import;
mysql_query($query);
}
}
//on regarde si besoin d'une autre passe...
if($nb_notices_remanning>$pmb_import_limit_record_load){
$form = str_replace("!!file_submit!!",$file_submit,$authorities_import_afterupload_form);
$form = str_replace("!!from_file!!",$from_file,$form);
$form = str_replace("!!create_link!!",$create_link,$form);
$form = str_replace("!!create_link_spec!!",$create_link_spec,$form);
$form = str_replace("!!force_update!!",$force_update,$form);
$form = str_replace("!!authorities_type!!",$authorities_type,$form);
$form = str_replace("!!total!!",$total,$form);
$form = str_replace("!!nb_notices!!",$nb_notices,$form);
$form = str_replace("!!nb_notices_import!!",serialize($nb_notices_import),$form);
$form = str_replace("!!nb_notices_rejetees!!",$nb_notices_rejetees,$form);
$form = str_replace("!!type_link!!",serialize($type_link),$form);
$form = str_replace("!!id_thesaurus!!",$id_thesaurus,$form);
print $form;
printf($msg['nb_authorities_already_imported'],$nb_notices,$total);
}else{
//c'est fini !
printf($msg['end_authorities_import'],$nb_notices);
print "
";
if(isset($nb_notices_import) && is_array($nb_notices_import)){
foreach ( $nb_notices_import as $key => $value ) {
print $value." ".htmlentities($msg["import_authorities_type_".$key]." ".$msg["import_authorities_import_success"],ENT_QUOTES,$charset)."
";
}
}
if($nb_notices_rejetees){
printf($msg['import_authorities_error'],$nb_notices_rejetees);
if(file_exists("../../temp/err_import_authorities".SESSid.".unimarc")){
print " ".$msg['download']."
";
}
}
$gen_liste_log="";
$resultat_liste=mysql_query("SELECT error_origin, error_text, count(*) as nb_error FROM error_log where error_origin in ('iimport_authorities".addslashes(SESSid).".php') group by error_origin, error_text ORDER BY error_origin, error_text" );
$nb_liste=mysql_num_rows($resultat_liste);
if ($nb_liste>0) {
$gen_liste_log = "
".$msg[538]."
".$msg[539]." | ".$msg[540]." | ".$msg[541]." |
---|---|---|
".htmlentities(mysql_result($resultat_liste,$i_log,"error_origin"),ENT_QUOTES,$charset)." | " ; $gen_liste_log.="".htmlentities(mysql_result($resultat_liste,$i_log,"error_text"),ENT_QUOTES,$charset)." | " ; $gen_liste_log.="".htmlentities(mysql_result($resultat_liste,$i_log,"nb_error"),ENT_QUOTES,$charset)." | " ; $gen_liste_log.="