From eeaac923ca226e7111a266ef067868c599ab5e77 Mon Sep 17 00:00:00 2001 From: Alex Arnaud <alex.arnaud@biblibre.com> Date: Tue, 4 Feb 2025 14:00:41 +0100 Subject: [PATCH 1/2] hotline#213660 : fix marc file checking page --- cosmogramme/php/classes/classe_buffer.php | 3 ++- cosmogramme/php/classes/classe_unimarc.php | 5 +++++ cosmogramme/php/integre_analyse_fichier_unimarc.php | 1 - 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cosmogramme/php/classes/classe_buffer.php b/cosmogramme/php/classes/classe_buffer.php index b8f8e44c818..dc104f38c42 100644 --- a/cosmogramme/php/classes/classe_buffer.php +++ b/cosmogramme/php/classes/classe_buffer.php @@ -61,7 +61,8 @@ class buffer closedir($dir); if (!$page) $page = 1; $this->page = $page; - @$this->fic = fopen($this->nomFic.'.'.$page, 'a') || afficherErreur("Impossible d'ouvrir le fichier de bufferisation"); + if (! @$this->fic = fopen($this->nomFic.'.'.$page, 'a')) + afficherErreur("Impossible d'ouvrir le fichier de bufferisation"); } // Ecrire diff --git a/cosmogramme/php/classes/classe_unimarc.php b/cosmogramme/php/classes/classe_unimarc.php index e3ec07847a5..529352a30ed 100644 --- a/cosmogramme/php/classes/classe_unimarc.php +++ b/cosmogramme/php/classes/classe_unimarc.php @@ -1356,6 +1356,11 @@ class notice_unimarc extends iso2709_record return (new Class_Notice_Authors($this))->getFirstAuthorAlphaKey(); } + public function getAuteurs(): array + { + return (new Class_Notice_Authors($this))->getAllAuthors(); + } + public function getDewey() : array { return array_filter( diff --git a/cosmogramme/php/integre_analyse_fichier_unimarc.php b/cosmogramme/php/integre_analyse_fichier_unimarc.php index 526c9e44925..6e23817884a 100644 --- a/cosmogramme/php/integre_analyse_fichier_unimarc.php +++ b/cosmogramme/php/integre_analyse_fichier_unimarc.php @@ -250,7 +250,6 @@ if ($ret["statut"]=="erreur") { } if($nb_notices > 0 ) { - if(!$nb_suppr > 0) $nb_suppr="aucune"; $buffer->ecrire("Notices à supprimer : " . $nb_suppr.BR); $buffer->ecrire("Notices à mettre à jour : " . ($nb_notices - ($nb_rejets + $nb_suppr)).BR); $buffer->ecrire("Exemplaires à insérer : " . $nb_ex.BR); -- GitLab From 211d02f2e256f0c1784512fd73c5a9ec33663a11 Mon Sep 17 00:00:00 2001 From: Alex Arnaud <alex.arnaud@biblibre.com> Date: Mon, 24 Feb 2025 17:19:35 +0100 Subject: [PATCH 2/2] hotline#213660 : follow up --- .../php/classes/classe_notice_integration.php | 15 ------------- cosmogramme/php/classes/classe_unimarc.php | 21 +++++++++++++++---- .../php/integre_analyse_fichier_synthese.php | 4 ++-- ...gre_analyse_fichier_valeurs_distinctes.php | 4 ++-- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/cosmogramme/php/classes/classe_notice_integration.php b/cosmogramme/php/classes/classe_notice_integration.php index 6a98fb6f655..b210257afe6 100644 --- a/cosmogramme/php/classes/classe_notice_integration.php +++ b/cosmogramme/php/classes/classe_notice_integration.php @@ -1107,21 +1107,6 @@ class notice_integration { } } - -// -------------------------------------------------------------------------------- -// Recupere titre, auteurs, matieres pour 1 article de périodique -// -------------------------------------------------------------------------------- - public function getDataArticlePeriodique($unimarc) - { - if(!$unimarc) { $this->erreur="notice sans unimarc"; return false; } - if(!$this->analyseur->ouvrirNotice($unimarc,$this->id_profil,0,"")) { $this->erreur=$this->analyseur->getLastError(); return false; } - - $ret["titres"]=$this->analyseur->getTitres(); - $ret["auteurs"]=$this->analyseur->getAuteurs(); - $ret["matieres"]=$this->analyseur->getMatieresLabels(); - return $ret; - } - // -------------------------------------------------------------------------------- // Rend la derniere erreur et les derniers warnings // -------------------------------------------------------------------------------- diff --git a/cosmogramme/php/classes/classe_unimarc.php b/cosmogramme/php/classes/classe_unimarc.php index 529352a30ed..8a8e9992578 100644 --- a/cosmogramme/php/classes/classe_unimarc.php +++ b/cosmogramme/php/classes/classe_unimarc.php @@ -58,6 +58,7 @@ class notice_unimarc extends iso2709_record protected $_id_bib; // Bibliotheque d'intégration protected $_fluent; // Class_NoticeUnimarc_Fluent protected $_type_doc; //type do document + protected $_notice_authors; public function __construct($id_bib=null) { $this->_id_bib = $id_bib; @@ -204,7 +205,10 @@ class notice_unimarc extends iso2709_record $notice["alpha_titre"] = $this->indexation->codeAlphaTitre($notice["titre_princ"]." ".$notice["tome_alpha"]); $notice["id_commerciale"] = $this->getIdCommerciale($notice["alpha_titre"]); - $auteurs = new Class_Notice_Authors($this); + if (!$this->_notice_authors) + $this->_notice_authors = new Class_Notice_Authors($this); + + $auteurs = $this->_notice_authors; $notice["auteurs"] = $auteurs->getAllAuthors(); $notice["auteurs_raw"] = $auteurs->getAllAuthorsAndIds(); $notice["alpha_auteur"] = $this->indexation->alphaMaj($notice["auteurs"][0] ?? ''); @@ -1348,17 +1352,26 @@ class notice_unimarc extends iso2709_record public function getAuteurPrincipal() : string { - return (new Class_Notice_Authors($this))->getFirstAuthorNames(); + if (!$this->_notice_authors) + $this->_notice_authors = new Class_Notice_Authors($this); + + return $this->_notice_authors->getFirstAuthorNames(); } public function getAuteurClefAlpha() : string { - return (new Class_Notice_Authors($this))->getFirstAuthorAlphaKey(); + if (!$this->_notice_authors) + $this->_notice_authors = new Class_Notice_Authors($this); + + return $this->_notice_authors->getFirstAuthorAlphaKey(); } public function getAuteurs(): array { - return (new Class_Notice_Authors($this))->getAllAuthors(); + if (!$this->_notice_authors) + $this->_notice_authors = new Class_Notice_Authors($this); + + return $this->_notice_authors->getAllAuthors(); } diff --git a/cosmogramme/php/integre_analyse_fichier_synthese.php b/cosmogramme/php/integre_analyse_fichier_synthese.php index 98ed757a2d2..f2270690206 100644 --- a/cosmogramme/php/integre_analyse_fichier_synthese.php +++ b/cosmogramme/php/integre_analyse_fichier_synthese.php @@ -209,8 +209,8 @@ if ($ret["statut"]=="erreur") { else $texte_statut .= "aucune notice n'a pu être analysée.".BR; } elseif ($nb_notices == 0) { $texte_statut = '<span class="rouge">Le fichier ne contenait aucune notice</span><br>'; -} else $texte_statut = '<b><span class="vert">Le fichier respecte la norme unimarc</span></b>'.BR; -sauveContexte(); +} else $texte_statut = '<b><span class="vert">Le fichier respecte la norme unimarc</span></b>'.BR; +sauveContexte(true); // ---------------------------------------------------------------- // Fonctions diff --git a/cosmogramme/php/integre_analyse_fichier_valeurs_distinctes.php b/cosmogramme/php/integre_analyse_fichier_valeurs_distinctes.php index 581ff2980df..9799b08c02e 100644 --- a/cosmogramme/php/integre_analyse_fichier_valeurs_distinctes.php +++ b/cosmogramme/php/integre_analyse_fichier_valeurs_distinctes.php @@ -194,8 +194,8 @@ if ($ret["statut"]=="erreur") { else $texte_statut .= "aucune notice n'a pu être analysée.".BR; } elseif ($nb_notices == 0) { $texte_statut = '<span class="rouge">Le fichier ne contenait aucune notice</span><br>'; -} else $texte_statut = '<b><span class="vert">Le fichier respecte la norme unimarc</span></b>'.BR; -sauveContexte(); +} else $texte_statut = '<b><span class="vert">Le fichier respecte la norme unimarc</span></b>'.BR; +sauveContexte(true); // ---------------------------------------------------------------- // Fonctions -- GitLab