diff --git a/VERSIONS_HOTLINE/176160 b/VERSIONS_HOTLINE/176160 new file mode 100644 index 0000000000000000000000000000000000000000..1d1e7db35d44c8f0d361a97b8df6a5d69a2321ab --- /dev/null +++ b/VERSIONS_HOTLINE/176160 @@ -0,0 +1 @@ + - correctif #176160 : Module FRBR : Il est dorénavant possible de renseigner une notice via plusieurs schémas d'URL (url pérenne via l'id_sigb ou via la clef alpha de manière indifferente). \ No newline at end of file diff --git a/library/Class/FRBR/Link.php b/library/Class/FRBR/Link.php index 06a18660dcbacabc7af7f8d39bc7a4ba11a4f3f0..0c07458dc4b8e0ce40a76432215238e2fae91846 100644 --- a/library/Class/FRBR/Link.php +++ b/library/Class/FRBR/Link.php @@ -200,17 +200,19 @@ class Class_FRBR_Link extends Storm_Model_Abstract { return; if ('opac' == $request->getModuleName() - && 'recherche' == $request->getControllerName() - && 'viewnotice' == $request->getActionName()) { - $callback(self::TYPE_NOTICE, $request->getParam('clef')); - ; + && 'bib-numerique' == $request->getControllerName() + && 'notice' == $request->getActionName()) { + $callback(self::TYPE_ALBUM, $request->getParam('id')); return; } + $clef = $this->_detectRecordKeyFromUrl($request); + if ('opac' == $request->getModuleName() - && 'bib-numerique' == $request->getControllerName() - && 'notice' == $request->getActionName()) { - $callback(self::TYPE_ALBUM, $request->getParam('id')); + && 'recherche' == $request->getControllerName() + && 'viewnotice' == $request->getActionName()) { + $callback(self::TYPE_NOTICE, $this->_detectRecordKeyFromUrl($request)); + ; return; } @@ -218,6 +220,21 @@ class Class_FRBR_Link extends Storm_Model_Abstract { } + protected function _detectRecordKeyFromUrl($request) : string { + if ($clef = $request->getParam('clef')) + return $clef; + + $id = $request->getParam('id') ?? Class_MoteurRecherche_RecordRequest::answer($request) + ->recordId(); + + return ($notice = Class_Notice::find($id)) + ? $notice->getClefAlpha() + : ''; + + return ''; + } + + protected function _detectSourceType() { $this->_detectEntityTypeFromUrl( $this->getSource(), diff --git a/scripts/validate_frbr_link.php b/scripts/validate_frbr_link.php new file mode 100644 index 0000000000000000000000000000000000000000..6005886e21dfde577c45e31d6563acbc6d029352 --- /dev/null +++ b/scripts/validate_frbr_link.php @@ -0,0 +1,3 @@ +<?php +require(__DIR__.'/../console.php'); +foreach(Class_FRBR_Link::findAll() as $link) $link->save(); diff --git a/tests/application/modules/admin/controllers/FrbrLinkControllerTest.php b/tests/application/modules/admin/controllers/FrbrLinkControllerTest.php index 34beeddb3f3a0cb0d904c436e45880af62b9f35f..fc8807cfe0d08012ceab19e55b5b8f51bbc6aa68 100644 --- a/tests/application/modules/admin/controllers/FrbrLinkControllerTest.php +++ b/tests/application/modules/admin/controllers/FrbrLinkControllerTest.php @@ -247,4 +247,52 @@ class Admin_FrbrLinkControllerEditSuiteValidWithLocalUrlsPostTest extends Admin_ $this->assertEquals(Class_FRBR_Link::TYPE_NOTICE, $this->_link->getTargetType()); } -} \ No newline at end of file +} + + + + +class Admin_FrbrLinkControllerIndexWithIdSigbUrlsTest extends Admin_FrbrLinkControllerTestCase { + protected $_link; + + public function setUp() { + parent::setUp(); + + $this->fixture(Class_Exemplaire::class, + ['id' => 1, + 'id_notice' => 33, + 'id_origine' => 1, + 'id_bib' => 1, + 'id_int_bib' => 1, + 'type' => 1]); + + $this->fixture(Class_Exemplaire::class, + ['id' => 2, + 'id_notice' => 34, + 'id_origine' => 2, + 'id_bib' => 1, + 'id_int_bib' => 1, + 'type' => 1]); + + $this->_link = Class_FRBR_Link::find(2); + $this->_link->setSource(Class_Url::absolute('/recherche/viewnotice/id_site/*/id_sigb/1')) + ->setTarget(Class_Url::absolute('/recherche/viewnotice/id_site/*/id_sigb/2')) + ->save(); + + $this->dispatch('/admin/frbr-link'); + } + + + /** @test */ + public function sourceKeyShouldBeLESGRANDSTEXTES_1() { + $this->assertEquals('LESGRANDSTEXTESDEDROITINTERNATIONALPUBLIC--DUPUYP--DALLOZ-2010-1', + $this->_link->getSourceKey()); + } + + + /** @test */ + public function sourceKeyShouldBeLESGRANDSTEXTES_2() { + $this->assertEquals('LESGRANDSTEXTESDEDROITINTERNATIONALPUBLIC--DUPUYP--DALLOZ-2010-2', + $this->_link->getTargetKey()); + } +}