diff --git a/VERSIONS_HOTLINE/110213 b/VERSIONS_HOTLINE/110213 new file mode 100644 index 0000000000000000000000000000000000000000..c7ff3eb2c6b1b9820f6352379458e6282cdf34f1 --- /dev/null +++ b/VERSIONS_HOTLINE/110213 @@ -0,0 +1 @@ + - ticket #110213 : Correction de la prise en compte d'ISBN multiples à l'intégration et l'export MARCXML \ No newline at end of file diff --git a/cosmogramme/php/classes/classe_unimarc.php b/cosmogramme/php/classes/classe_unimarc.php index aa3a3f46488accf55842b280ffc4d13ef140d5d1..4935e7b0319d25ea5f09c517bd06ff1da7744741 100644 --- a/cosmogramme/php/classes/classe_unimarc.php +++ b/cosmogramme/php/classes/classe_unimarc.php @@ -998,25 +998,14 @@ class notice_unimarc extends iso2709_record { public function getIsbn() { $datas = $this->get_subfield('010', 'a'); - if ($isbn = $this->_detectIsbn($datas)) { - $oIsbn = new Class_Isbn($isbn); - $isbn = $oIsbn->getAll(); - } - - if (count($datas) > 1) { - $isbn['multiple'] = true; - $this->delete_field('010'); - $this->add_zone('010', $datas[0]); - } - - if (!is_array($isbn)) - $isbn = ['statut' => 0, - 'isbn' => '', - 'isbn10' => '', - 'isbn13' => '', - 'ean' => '']; + if ($isbn = $this->_detectIsbn($datas)) + return (new Class_Isbn($isbn))->getAll(); - return $isbn; + return ['statut' => 0, + 'isbn' => '', + 'isbn10' => '', + 'isbn13' => '', + 'ean' => '']; } @@ -1031,8 +1020,9 @@ class notice_unimarc extends iso2709_record { if (!$datas) return ''; - return 1 == count($datas) ? - trim($datas[0]) : $this->_chooseIsbn($datas); + return 1 == count($datas) + ? trim($datas[0]) + : $this->_chooseIsbn($datas); } diff --git a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php index 5944f3bdf3e08de98c1231b24978c2248802a17b..e0c2c17436631008d18c2c2542641d487b56f932 100644 --- a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php +++ b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php @@ -822,3 +822,38 @@ class KohaRecordIntegrationMultipleSECTIntegrationTest extends KohaRecordIntegra $this->assertContains('HSECT0002 HSECT0001 HSECT0003', Class_Notice::find(1)->getFacettes()); } } + + + + +class KohaRecordIntegrationUnimarcWithSeveralISBNTest extends KohaRecordIntegrationTestCase { + public function setUp() { + parent::setUp(); + $this->loadNotice('unimarc_relations_oif_onu'); + } + + + /** + * @see https://en.wikipedia.org/wiki/International_Standard_Book_Number + * @test + * */ + public function isbnShouldBe978_2_8492_4590_3() { + $this->assertEquals('978-2-8492-4590-3', + Class_Notice::find(1)->getIsbn()); + } + + + /** @test */ + public function firstSubfield010DollarAShouldBe978_2_84924_590_3() { + $this->assertEquals('978-2-84924-590-3', + Class_Notice::find(1)->get_subfield('010', 'a')[0]); + } + + + /** @test */ + public function secondSubfield010DollarAShouldBe2_84924_590_3() { + $this->assertEquals('2-84924-590-9', + Class_Notice::find(1)->get_subfield('010', 'a')[1]); + } + +} diff --git a/cosmogramme/tests/php/classes/unimarc_relations_oif_onu.txt b/cosmogramme/tests/php/classes/unimarc_relations_oif_onu.txt new file mode 100644 index 0000000000000000000000000000000000000000..082aac51e711e12ca8dc636325f3e86709e43045 --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_relations_oif_onu.txt @@ -0,0 +1 @@ +02608cam0 2200433 4500001000700000003003000007005001700037009001000054010003500064010002300099090001100122099001800133100004100151101000800192102000700200105001800207106000600225181002500231181002000256182002100276182001100297183002500308200010200333214002900435214001100464215004800475225001700523320002700540330098800567410005301555601008801608601012401696606009201820676001501912680000701927700005501934930003801989995014702027142434http://www.sudoc.fr/24157711X20200710071203.024157711X bbr.d15 EURa978-2-84924-590-3 bbr.a2-84924-590-9 a142434 s0x2touvrage a20191219h20192019k y0frey50 ba0 afre aFR ay a 000yy ar 6z01ctxt2rdacontent 16z01ai#bxxxe## 6z01cn2rdamedia 16z01an 16z01anga2rdacarrier1 aLes relations entre l'OIF et l'ONU en matieÌ€re de paix et seÌcuriteÌfAristide Donald Bilounga 0aPariscEditions du Cygne 4dC 2019 a1 vol. (143 p.)ccouv. ill. en coul.d21 cm0 aFrontieÌ€res aBibliogr. p. 131-[141] aLa 4e de couv. indique : "PreÌvention des conflits, gestion des crises, consolidation de la paix, telles sont les activiteÌs meneÌes par les organisations internationales de nature culturelle ou politique, en reÌponse aux menaces seÌcuritaires actuelles. S'il y a neÌcessiteÌ d'apporter des solutions globales et inclusives aÌ€ cette queÌ‚te de la paix et de la seÌcuriteÌ des peuples du monde, il n'en demeure pas moins que les deÌmarches, les inteÌreÌ‚ts et le positionnement des uns et des autres creÌaient une dynamique interinstitutionnelle. L'auteur montre ainsi que la construction de cette dynamique entre l'Organisation Internationale de la Francophonie et l'Organisation des Nations Unies en faveur de la paix et de la seÌcuriteÌ reÌsulte des rapports de solidariteÌ eÌvoluant vers des liens de rivaliteÌ. Cet ouvrage est un important outil au service des chercheurs, eÌtudiants et professionnels des relations internationales et du maintien de la paix." 0128383291tFrontieÌ€res (Paris. 2008)x1966-818X0230290836997ba0yba0y8frefreaNations UniesbConseil de seÌcuriteÌ2rameau96057490230614129539447617aOrganisation internationale de la francophonie303018634X9210400xEt la politique militaire2rameau 302777591791212812aMaintien de la paix30276031059282248yAfrique francophone2rameau a327.17v23 aJA 1324157824891224135aBiloungabAristide Donald4070 5384212201:653292481b384212201jg 2052019-12-099126455AIEPG 0000065977R1bIEPGcIEPGeLABf621000173893i13.65k327.1 BILm2020-03-13o0rLIVs1ACHATvouvragew2y2020-09-17 \ No newline at end of file diff --git a/library/Class/Isbn.php b/library/Class/Isbn.php index a7fae5901985bbd08c668387b19f59e67a55c559..5eeecf1cc1655c27867a029b8e593ea5ba25cfca 100644 --- a/library/Class/Isbn.php +++ b/library/Class/Isbn.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //////////////////////////////////////////////////////////////////////// // OPAC3 : ISBN formattage @@ -34,7 +34,7 @@ class Class_Isbn private $pays; // Code pays private $editeur; // Code editeur private $numero; // Numéro chez l'éditeur - + // ---------------------------------------------------------------- // Constructeur (formatte le code) // ---------------------------------------------------------------- @@ -43,18 +43,18 @@ class Class_Isbn $this->code_brut=$code; $code=trim($code); if(!$code) return; - + // filtrer $new = ''; - for($i=0;$i < strLen($code); $i++) if($code[$i]>="0" and $code[$i] <="9") $new.= $code[$i]; - + for($i=0;$i < strLen($code); $i++) if($code[$i]>="0" and $code[$i] <="9") $new.= $code[$i]; + // Tester la longueur $len = strlen($new); if($len == 9 or $len == 10) { $this->calculIsbn($new); $this->isbn=$this->isbn10; } elseif($len < 12 ) - { - $this->statut=1; - $this->erreur="longueur incorrecte (".$len.")"; + { + $this->statut=1; + $this->erreur="longueur incorrecte (".$len.")"; } // code ok else @@ -87,7 +87,7 @@ class Class_Isbn $ret["numero"]=$this->numero; return $ret; } - + // ---------------------------------------------------------------- // Calcul l'isbn 10 et 13 // ---------------------------------------------------------------- @@ -104,29 +104,29 @@ class Class_Isbn for($i=0;$i<9; $i++) { $facteur = 10 -$i; - $somme += ((int)$code[$i] * $facteur); + $somme += ((int)$code[$i] * $facteur); } $clef= 11 - $somme % 11; if($clef == 10) $clef="X"; if($clef == 11) $clef = 0; $this->isbn10=$this->decoupeIsbn($code,$clef); - + // isbn 13 if($prefixe13) $code=$prefixe13.$code; else $code="978".$code; $clef=$this->clefEan($code); $this->isbn13=$this->decoupeIsbn(substr($code,3,12),$clef); $this->isbn13=substr($code,0,3)."-".$this->isbn13; } -// ---------------------------------------------------------------- +// ---------------------------------------------------------------- // Calcul clef ean // ---------------------------------------------------------------- private function clefEan($code) - { + { $somme = 0; for($i=0; $i<12; $i++) { if($i & 1) $facteur=3; else $facteur=1; - $somme += (int)$code[$i] * $facteur; + $somme += (int)$code[$i] * $facteur; } $clef=$somme % 10; if($clef > 0)$clef=10-$clef; @@ -137,6 +137,7 @@ class Class_Isbn // ---------------------------------------------------------------- private function decoupeIsbn($code,$clef) { + //see https://en.wikipedia.org/wiki/International_Standard_Book_Number $code=strLeft($code,9); // Pays $pays=strLeft($code,1); @@ -150,7 +151,7 @@ class Class_Isbn else { $pays=strLeft($code,5); $code=strMid($code,5,10);} } $this->pays=$pays; - + // editeur if(strLeft($code,2) < "20") {$editeur=strLeft($code,2); $numero=strMid($code,2,10); } elseif(strLeft($code,3) < "700") {$editeur=strLeft($code,3); $numero=strMid($code,3,10); }