From 733165feb693a9fae81a14fbf29fe2516823a4c4 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@afi-sa.fr> Date: Fri, 4 Mar 2016 10:41:56 +0100 Subject: [PATCH] hotline #36324 : digital resources display on phone refactoring --- library/Class/Album/Renderer.php | 3 +- .../Helper/Telephone/TagAlbumMediaList.php | 28 +++++++++---------- .../BibNumeriqueControllerTest.php | 12 ++++---- ...hercheControllerRessourceNumeriqueTest.php | 2 +- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/library/Class/Album/Renderer.php b/library/Class/Album/Renderer.php index c0b9229dbf7..c1487b92300 100644 --- a/library/Class/Album/Renderer.php +++ b/library/Class/Album/Renderer.php @@ -49,8 +49,9 @@ class Class_Album_Renderer { 'tagAlbumMediaList' => function($album) { return true; }]; foreach($mapping as $helper => $closure) - if ($closure($this->_album)) + if ($closure($this->_album)) { return call_user_func_array([$view, $helper], [$this->_album]); + } } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Telephone/TagAlbumMediaList.php b/library/ZendAfi/View/Helper/Telephone/TagAlbumMediaList.php index 0fac2742e95..46508d1ca19 100644 --- a/library/ZendAfi/View/Helper/Telephone/TagAlbumMediaList.php +++ b/library/ZendAfi/View/Helper/Telephone/TagAlbumMediaList.php @@ -16,40 +16,40 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_Telephone_TagAlbumMediaList extends ZendAfi_View_Helper_TagAlbumMediaList { - protected $_builder; + protected $_builder; public function tagAlbumMediaList($album) { $ressources = $album->getRessources(); - $xspf_url = $this->view->url(['module' => 'telephone', + $xspf_url = $this->view->url(['module' => 'telephone', 'controller' => 'bib-numerique', - 'action' => 'album-xspf-playlist', + 'action' => 'album-xspf-playlist', 'id' => $album->getId()]); - $podcast_url = $this->view->url(['module' => 'telephone', + $podcast_url = $this->view->url(['module' => 'telephone', 'controller' => 'bib-numerique', - 'action' => 'Album-rss-feed', + 'action' => 'Album-rss-feed', 'id' => $album->getId()]); $html=''; foreach($ressources as $ressource) { - $html .= sprintf('<li data-role="list-divider"><a href=%s data-ajax="false"><img src=%s><h3>%s</h3></a></li>', - $this->view->absoluteUrl($ressource->getOriginalUrl()), - $this->view->absoluteurl($ressource->getThumbnailUrl()), - $ressource->getTitre() ? $ressource->getTitre() : $ressource->getFichier());} + $html .= sprintf('<li data-role="list-divider"><a href=%s data-ajax="false"><img src=%s><h3>%s</h3></a></li>', + $this->view->absoluteUrl($ressource->getOriginalUrl()), + $this->view->absoluteurl($ressource->getThumbnailUrl()), + $ressource->getTitre() ? $ressource->getTitre() : $ressource->getFichier());} $playlist = sprintf('<a href="%s" data-role="button" data-mini="true" data-ajax="false" data-icon="list-alt">%s</a>', - $this->view->absoluteUrl($xspf_url.'.xspf'), + $this->view->absoluteUrl($xspf_url.'.xspf'), $this->view->_('Playlist'), ['data-ajax' => 'false']); $rss = sprintf('<a href="%s" data-role="button" data-mini="true" data-icon="rss" data-ajax="false">%s</a>', - $this->view->absoluteUrl($podcast_url.'.xml'), - $this->view->_('RSS')); - + $this->view->absoluteUrl($podcast_url.'.xml'), + $this->view->_('RSS')); + return '<ul data-role="listview">' . $html . '</ul><fieldset class="ui-grid-a"><div class="ui-block-a">' .$playlist.'</div><div class="ui-block-b">' .$rss . '</div></fieldset>' ; } diff --git a/tests/application/modules/telephone/controllers/BibNumeriqueControllerTest.php b/tests/application/modules/telephone/controllers/BibNumeriqueControllerTest.php index d0367869ad7..bb3b1c787d9 100644 --- a/tests/application/modules/telephone/controllers/BibNumeriqueControllerTest.php +++ b/tests/application/modules/telephone/controllers/BibNumeriqueControllerTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'TelephoneAbstractControllerTestCase.php'; @@ -101,7 +101,7 @@ class BibNumeriqueControllerTelephoneViewAlbumMultiMedia extends TelephoneAbstra parent::setUp(); Class_Album::newInstanceWithId(999) - ->beDiaporama() + ->setTypeDocId(Class_TypeDoc::AUDIO_RECORD) ->setTitre('Antigone') ->setDateMaj('2012-02-17 10:00:00') ->setAuteur('Sophocle') @@ -128,13 +128,13 @@ class BibNumeriqueControllerTelephoneViewAlbumMultiMedia extends TelephoneAbstra /** @test */ public function pageShouldContainsLinkToRSSPodcast() { - $this->assertXPath('//a[contains(@href, "bib-numerique/Album-rss-feed/id/999.xml")][@data-ajax="false"]'); + $this->assertXPath('//a[contains(@href, "bib-numerique/album-rss-feed/id/999.xml")][@data-ajax="false"]'); } - + /** @test */ - public function pageShouldContainLinkIntroductionMp3() { - $this->assertXPath('//a[contains(@href, "media/introduction.mp3")]'); + public function pageShouldContainLinkToIntroductionMp3PlayResource12() { + $this->assertXPath('//a[contains(@data-src, "bib-numerique/play-ressource/id/12.mp3")]'); } } diff --git a/tests/application/modules/telephone/controllers/RechercheControllerRessourceNumeriqueTest.php b/tests/application/modules/telephone/controllers/RechercheControllerRessourceNumeriqueTest.php index d85d0bf2de4..a8755da909a 100644 --- a/tests/application/modules/telephone/controllers/RechercheControllerRessourceNumeriqueTest.php +++ b/tests/application/modules/telephone/controllers/RechercheControllerRessourceNumeriqueTest.php @@ -183,7 +183,7 @@ class Telephone_RechercheControllerRessourceNumeriqueViewNoticePNBTest extends T /** @test */ - public function consultBookActionShouldBeConsultBookNotAjax() { + public function consultBookActionShouldNotBeVisiable() { $this->dispatch('/telephone/recherche/ressourcesnumeriques/id/1', true); $this->assertXPath('//a[contains(@href, "bib-numerique/consult-book/id/1")]'); } -- GitLab