diff --git a/library/Class/Album.php b/library/Class/Album.php index 3970e78b62491485ae0d421bad492514b1cec7d7..45f0f7339f3f5522be2d77446bb0153619b96c9a 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 7d41c71b1a6a4997ee48585dafde26aba17226f6..cb9b4bd61c3b2f2b656d531a12ccf35be7175f2e 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 1b7f8e3a966c7fee7e18196b30d51f5546a85ef1..f12976022323591fc00afd699ce274a807f9a5e0 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 1d8aefee3032fa0cc3d48e01f5075d0b515a54de..0ecaf077462b3c296172241272f9a201618f79d3 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