From 8f636db50bd7fb8fef6f093590b6e9cb4196f1cb Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Tue, 30 Oct 2018 12:18:09 +0100 Subject: [PATCH] dev #78660 implement viewer --- .../View/Helper/Album.php | 25 ++++++++++++++++++- .../tests/EntrepotNumeriqueMelunTest.php | 11 ++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/library/digital_resources/EntrepotNumeriqueMelun/View/Helper/Album.php b/library/digital_resources/EntrepotNumeriqueMelun/View/Helper/Album.php index 4b6e6611e15..7a408d68a4a 100644 --- a/library/digital_resources/EntrepotNumeriqueMelun/View/Helper/Album.php +++ b/library/digital_resources/EntrepotNumeriqueMelun/View/Helper/Album.php @@ -20,4 +20,27 @@ */ -class EntrepotNumeriqueMelun_View_Helper_Album extends Class_DigitalResource_AlbumViewHelper {} \ No newline at end of file +class EntrepotNumeriqueMelun_View_Helper_Album extends Class_DigitalResource_AlbumViewHelper { + public function album($album) { + if (!$album) + return ''; + + if (!$viewer = $album->getExternalUri()) + return ''; + + $class = $this->_config->getName(). '_viewer'; + + Class_ScriptLoader::getInstance() + ->addInlineStyle(sprintf('iframe.%s { height: %dpx; width: %dpx }', + $class, + 900, + 600)); + + return + $this->_tagAnchor($viewer, $viewer, ['target' => '_blank']) + . $this->_tag('iframe', + null, + ['src' => $viewer, + 'class' => $class]); + } +} \ No newline at end of file diff --git a/library/digital_resources/EntrepotNumeriqueMelun/tests/EntrepotNumeriqueMelunTest.php b/library/digital_resources/EntrepotNumeriqueMelun/tests/EntrepotNumeriqueMelunTest.php index d31ccb4beb1..3eaa695d21a 100644 --- a/library/digital_resources/EntrepotNumeriqueMelun/tests/EntrepotNumeriqueMelunTest.php +++ b/library/digital_resources/EntrepotNumeriqueMelun/tests/EntrepotNumeriqueMelunTest.php @@ -205,4 +205,15 @@ class EntrepotNumeriqueMelunHarvestTests extends EntrepotNumeriqueMelunActivated public function origineDocTypeShouldBeTexteManuscrit() { $this->assertEquals('texte manuscrit', $this->_album->getNote('915$a')); } + + + /** @test */ + public function dispatchResnumeriquesOnIndexedAlbumShouldRenderViewer() { + $this->_album->index(); + $id = $this->_album->getNotice()->getId(); + $this->dispatch('/opac/noticeajax/resnumeriques/id/' . $id, true); + $this->assertXPath('//iframe[@src="http://melun.preprod-osiros.decalog.net//viewer.php?docId=100"]'); + + $this->assertXPathContentContains('//style', 'height: 900px', $this->_response->getBody()); + } } \ No newline at end of file -- GitLab