diff --git a/library/ZendAfi/View/Helper/MonocleReaderServerSide.php b/library/ZendAfi/View/Helper/MonocleReaderServerSide.php index 8a710caa8a796f11f2f3fdffdeeb67fbfda6f73a..b502f280bce432aa5bdf29f792fe94a068490a67 100644 --- a/library/ZendAfi/View/Helper/MonocleReaderServerSide.php +++ b/library/ZendAfi/View/Helper/MonocleReaderServerSide.php @@ -90,35 +90,42 @@ class ZendAfi_View_Helper_MonocleReaderServerSide extends Zend_View_Helper_HtmlE public function showUrls($album) { - $html = '<ul data-role="listview">'; - - $ressources = $album->getRessources(); - foreach($ressources as $ressource) { - $libelle = $ressource->getTitre() ? $ressource->getTitre() : $ressource->getFichier(); - $html .= '<li data-role="list-divider">'. - $this->view->tagAnchor($this->view->absoluteUrl($ressource->getOriginalUrl()), - $this->view->tagImg($this->view->absoluteurl($ressource->getThumbnailUrl()), - ['alt' => $this->view->_('Télécharger')]) - . $libelle, - ['data-ajax' => 'false', - 'download' => $libelle]); - - if ($ressource->getFileExtension()=='epub') { - $html .= $this->view->tagAnchor(['module' => 'opac', - 'controller' => 'bib-numerique', - 'action' => 'full-screen', - 'id' => $ressource->getId()], - $this->view->tagImg(URL_ADMIN_IMG . 'picto/show.gif', - ['alt' => $this->view->_('Plein écran')]), - ['data-ajax' => 'false'] - ); - } + return $this->view + ->tag('ul', + implode('', array_map([$this, '_renderListItem'], + $album->getRessources())), + ['data-role' => 'listiew']); + } - $html .= '</li>'; - } - $html .= '</ul>'; - return $html; + protected function _renderListItem($ressource) { + $libelle = $ressource->getTitre() + ? $ressource->getTitre() + : $ressource->getFichier(); + + $download_filename = $ressource->getTitre() + ? ($ressource->getTitre() . '.' . $ressource->getFileExtension()) + : $ressource->getFichier(); + + $html = $this->view->tagAnchor($this->view->absoluteUrl($ressource->getOriginalUrl()), + $this->view->tagImg($this->view->absoluteurl($ressource->getThumbnailUrl()), + ['alt' => $this->view->_('Télécharger')]) + . $libelle, + ['data-ajax' => 'false', + 'download' => $download_filename]); + + if ($ressource->getFileExtension()=='epub') + $html .= $this->view->tagAnchor(['module' => 'opac', + 'controller' => 'bib-numerique', + 'action' => 'full-screen', + 'id' => $ressource->getId()], + $this->view->tagImg(URL_ADMIN_IMG . 'picto/show.gif', + ['alt' => $this->view->_('Plein écran')]), + ['data-ajax' => 'false']); + + return $this->view->tag('li', + $html, + ['data-role' => 'list-divider']); } } diff --git a/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php b/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php index 0f914fed16fa88f28f999ff30e1a071f96b53d48..3d3c2e665efb1e46abf06f3cc386e1ac843eb128 100644 --- a/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php +++ b/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php @@ -79,7 +79,14 @@ class ZendAfi_View_Helper_RenderAlbumEPUBTest extends ZendAfi_View_Helper_Render } - + /** @test */ + public function withTitleToVisitVersaillesDownloadLinkShouldBeVisitVersaillesDotEPub() { + Class_AlbumRessource::find(123)->setTitre('Visit Versailles')->assertSave(); + $html = $this->_helper->renderAlbum($this->_album_epub); + $this->assertXPathContentContains($html, + '//a[@download="Visit Versailles.epub"]', + 'Visit Versailles'); + } }