From 06f071d64f01f2a7b28e45c052582c75701b152d Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Fri, 8 Jun 2012 09:01:15 +0000 Subject: [PATCH] Visu player gallica dans les notices --- library/Class/Album.php | 14 ++++++- library/ZendAfi/View/Helper/GallicaPlayer.php | 7 +++- library/ZendAfi/View/Helper/RenderAlbum.php | 2 + .../ZendAfi/View/Helper/RenderAlbumTest.php | 41 ++++++++++++++++++- 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/library/Class/Album.php b/library/Class/Album.php index 3970e78b624..45f0f7339f3 100644 --- a/library/Class/Album.php +++ b/library/Class/Album.php @@ -329,6 +329,11 @@ class Class_Album extends Storm_Model_Abstract { } + public function isOAI() { + return $this->getTypeDocId() == Class_TypeDoc::OAI; + } + + /** * @param Zend_Controller_Request_Http $request * @return array @@ -968,7 +973,14 @@ class Class_Album extends Storm_Model_Abstract { public function isGallica() { - return false !== strpos($this->getIdOrigine(), 'gallica'); + return ($this->isOAI() && (false !== strpos($this->getIdOrigine(), 'gallica'))); + } + + + public function getGallicaArkId() { + if (!$this->isGallica()) + return ''; + return array_last(explode('/', $this->getIdOrigine())); } } diff --git a/library/ZendAfi/View/Helper/GallicaPlayer.php b/library/ZendAfi/View/Helper/GallicaPlayer.php index 7d41c71b1a6..cb9b4bd61c3 100644 --- a/library/ZendAfi/View/Helper/GallicaPlayer.php +++ b/library/ZendAfi/View/Helper/GallicaPlayer.php @@ -20,7 +20,12 @@ */ class ZendAfi_View_Helper_GallicaPlayer extends Zend_View_Helper_HtmlElement { - public function gallicaPlayer($id_ark) { + public function gallicaPlayer($album_or_id_ark) { + if (is_int($album_or_id_ark)) + $id_ark = $album_or_id_ark; + else + $id_ark = $album_or_id_ark->getGallicaArkId(); + return sprintf( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" diff --git a/library/ZendAfi/View/Helper/RenderAlbum.php b/library/ZendAfi/View/Helper/RenderAlbum.php index 1b7f8e3a966..f1297602232 100644 --- a/library/ZendAfi/View/Helper/RenderAlbum.php +++ b/library/ZendAfi/View/Helper/RenderAlbum.php @@ -29,6 +29,8 @@ class ZendAfi_View_Helper_RenderAlbum extends Zend_View_Helper_HtmlElement { Class_ScriptLoader::getInstance()->loadBooklet($album->getId(), '#resnum'); else if ($album->isDiaporama()) $content = $this->view->tagSlideshow($album); + else if ($album->isGallica()) + $content = $this->view->gallicaPlayer($album); else $content = $this->view->tagAlbumMediaList($album); diff --git a/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php b/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php index 1d8aefee303..0ecaf077462 100644 --- a/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php +++ b/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class ZendAfi_View_Helper_RenderAlbumEPUBTest extends ViewHelperTestCase { +abstract class ZendAfi_View_Helper_RenderAlbumTestCase extends ViewHelperTestCase { /** @var ZendAfi_View_Helper_RenderForm */ protected $_helper; @@ -32,6 +32,14 @@ class ZendAfi_View_Helper_RenderAlbumEPUBTest extends ViewHelperTestCase { $view = new ZendAfi_Controller_Action_Helper_View(); $this->_helper = new ZendAfi_View_Helper_RenderAlbum(); $this->_helper->setView($view); + } +} + + + +class ZendAfi_View_Helper_RenderAlbumEPUBTest extends ZendAfi_View_Helper_RenderAlbumTestCase { + public function setUp() { + parent::setUp(); $this->_album_epub = Class_Album::getLoader() ->newInstanceWithId(999) @@ -58,4 +66,33 @@ class ZendAfi_View_Helper_RenderAlbumEPUBTest extends ViewHelperTestCase { '//a[contains(@href, "bib-numerique/download-resource/id/123")]', 'versailles.epub'); } -} \ No newline at end of file +} + + + + +class ZendAfi_View_Helper_RenderAlbumGallicaTest extends ZendAfi_View_Helper_RenderAlbumTestCase { + public function setUp() { + parent::setUp(); + + $this->_album_gallica = Class_Album::getLoader() + ->newInstanceWithId(999) + ->setLibelle('Fleurs de nice') + ->beOAI() + ->setIdOrigine('http://gallica.bnf.fr/ark:/1234'); + + $this->html = $this->_helper->renderAlbum($this->_album_gallica); + } + + + /** @test */ + public function pageShouldContainsGallicaPlayer() { + $this->assertXPath($this->html, + '//object//param[@name="FlashVars"][contains(@value, "1234")]', + $this->html); + } + +} + + +?> \ No newline at end of file -- GitLab