diff --git a/library/ZendAfi/View/Helper/Album/Download.php b/library/ZendAfi/View/Helper/Album/Download.php new file mode 100644 index 0000000000000000000000000000000000000000..8e601039c38080316beecd23234068dfbcd2389b --- /dev/null +++ b/library/ZendAfi/View/Helper/Album/Download.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class ZendAfi_View_Helper_Album_Download extends Zend_View_Helper_HtmlElement { + public function album_Download($album){ + + + $podcast_url = $this->view->url(['module' => 'opac', + 'controller' => 'bib-numerique', + 'action' => 'album-rss-feed', + 'id' => $album->getId()],null,true); + return '<ul>' + .'<li>'.$this->view->tagAnchor($this->view->absoluteUrl($this->getXspfUrl($album).'.xspf'), + $this->view->_('Téléchargez la playlist (VLC, WinAmp)'), + ['data-ajax' => 'false']).'</li>' + .'<li>'.$this->view->tagAnchor($this->view->absoluteUrl($podcast_url.'.xml'), + $this->view->_('Podcastez l\'album (iTunes, Lecteur RSS)'), + ['data-ajax' => 'false']).'</li>' + .'</ul>'; + } + + public function getXspfUrl($album) { + return $this->view->url(['module' => 'opac', + 'controller' => 'bib-numerique', + 'action' => 'album-xspf-playlist', + 'id' => $album->getId()],null,true); + } +} + +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Album/OsmPlayer.php b/library/ZendAfi/View/Helper/Album/OsmPlayer.php index c8f6e0a477e340385df2711b58804e8d1ce881d7..faa60ca9319fd1b017eb73b1af896da9befddfd1 100644 --- a/library/ZendAfi/View/Helper/Album/OsmPlayer.php +++ b/library/ZendAfi/View/Helper/Album/OsmPlayer.php @@ -21,30 +21,15 @@ class ZendAfi_View_Helper_Album_OsmPlayer extends Zend_View_Helper_HtmlElement { public function album_osmPlayer($album) { + $download_helper = $this->view->getHelper('Album_Download'); $div_id = 'osmplayer'.$album->getId(); - - $xspf_url = $this->view->url(['module' => 'opac', - 'controller' => 'bib-numerique', - 'action' => 'album-xspf-playlist', - 'id' => $album->getId()]); - - $podcast_url = $this->view->url(['module' => 'opac', - 'controller' => 'bib-numerique', - 'action' => 'album-rss-feed', - 'id' => $album->getId()]); - $this->view->osmPlayer('#'.$div_id, - ['playlist' => $xspf_url.'.xml', + ['playlist' => $download_helper->getXspfUrl($album).'.xml', 'height' => '500px']); - return '<ul>' - .'<li>'.$this->view->tagAnchor($this->view->absoluteUrl($xspf_url.'.xspf'), - $this->view->_('Téléchargez la playlist (VLC, WinAmp)'), - ['data-ajax' => 'false']).'</li>' - .'<li>'.$this->view->tagAnchor($this->view->absoluteUrl($podcast_url.'.xml'), - $this->view->_('Podcastez l\'album (iTunes, Lecteur RSS)'), - ['data-ajax' => 'false']).'</li>' - .'</ul>' - .'<div id="'.$div_id.'"></div>'; + + return + $download_helper->album_download($album). + '<div id="'.$div_id.'"></div>'; } } diff --git a/library/ZendAfi/View/Helper/TagAlbumTrackList.php b/library/ZendAfi/View/Helper/TagAlbumTrackList.php index 5a9bb56014f9739e4acd4a43e65a60a048939477..a0f686aebba07edbf1e790f23f91edd2dfbcff4e 100644 --- a/library/ZendAfi/View/Helper/TagAlbumTrackList.php +++ b/library/ZendAfi/View/Helper/TagAlbumTrackList.php @@ -28,7 +28,8 @@ class ZendAfi_View_Helper_TagAlbumTrackList extends Zend_View_Helper_HtmlElement */ public function tagAlbumTrackList($album) { $audio_tracks = $album->getAudioTracks(); - $html = '<ol>'; + $html = $this->view->album_Download($album); + $html .= '<ol>'; foreach($audio_tracks as $audio_track){ $html.= '<li class="audio_track">'. diff --git a/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php b/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php index 733154168c6f786ad77e796e8dc22d005367c9a2..6840d819637e12d49e0e9bf2842d8704aab7b2cb 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php @@ -225,6 +225,17 @@ class RechercheControllerAlbumAudioRecordViewRessourcesNumeriquesTest extends Re $this->assertXPathContentContains('//ol//li', 'unknown.mp3'); } + + /** @test */ + public function pageShouldContainsLinkToXSPFPlayList() { + $this->assertXPath('//a[contains(@href,"/bib-numerique/album-xspf-playlist/id/4.xspf")]'); + } + + /** @test */ + public function pageShouldContainsLinkToRSSPodcast() { + $this->assertXPath('//a[contains(@href,"/bib-numerique/album-rss-feed/id/4.xml")]'); + } + } @@ -240,7 +251,6 @@ class RechercheControllerAlbumAudioRecordViewRessourceInTelephoneModeTest extend public function pageShouldContainsLinkToOpenRessourcesNumeriques() { $this->assertXPathContentContains('//a[contains(@href,"recherche/ressourcesnumeriques/id/1")]','Ecouter l\'album',$this->_response->getBody()); } - }