diff --git a/VERSIONS_HOTLINE/59686 b/VERSIONS_HOTLINE/59686 new file mode 100644 index 0000000000000000000000000000000000000000..1b358c6831769d14e087a45aed0e1cc24b2fc242 --- /dev/null +++ b/VERSIONS_HOTLINE/59686 @@ -0,0 +1 @@ + - ticket #59686 : Force l'extension .epub pour le téléchargement d'EPUBs de la bibliothèques numérique \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/Manager/Album.php b/library/ZendAfi/Controller/Plugin/Manager/Album.php index a758f092aeb66a6a56e4ea8badd5af1fdacd7e3d..b28bda2897620ed562fdbf733595086bca0c46ba 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/Album.php +++ b/library/ZendAfi/Controller/Plugin/Manager/Album.php @@ -660,6 +660,15 @@ class ZendAfi_Controller_Plugin_Manager_Album extends ZendAfi_Controller_Plugin_ protected function _albumCategoryActions($model) { + if ($model->getId() == 0) + return [ + ['url' => ['module' => 'admin', + 'controller' => 'album', + 'action' => 'add_categorie'], + 'icon' => 'add_category', + 'label' => $this->_('Ajouter une catégorie')], + ]; + return [ ['url' => ['module' => 'admin', 'controller' => 'album', diff --git a/library/ZendAfi/View/Helper/MonocleReaderServerSide.php b/library/ZendAfi/View/Helper/MonocleReaderServerSide.php index 8a710caa8a796f11f2f3fdffdeeb67fbfda6f73a..f3d56643cfb197dcdf77100d1460da833960e962 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' => 'listview']); + } - $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/library/ZendAfi/View/Helper/RenderModelActions.php b/library/ZendAfi/View/Helper/RenderModelActions.php index f830401aa5c9d7135bb745cfbd6a01527af1b901..531b78c7189eef5d8a834a163a70ac0fe57f9483 100644 --- a/library/ZendAfi/View/Helper/RenderModelActions.php +++ b/library/ZendAfi/View/Helper/RenderModelActions.php @@ -151,13 +151,12 @@ class ZendAfi_View_Helper_RenderModelAction { if(!$url = $this->_conf[self::URL]) return ''; - $url = is_array($url) - ? $this->_injectIdIn($id, $url) + return is_array($url) + ? Class_Url::assemble($this->_injectIdIn($id, $url), null, false) : $this->_injectId($id, $url); - - return Class_Url::absolute($url); } + protected function _injectIdIn($model_id, $attribs) { $return = []; foreach($attribs as $attrib => $value) diff --git a/public/admin/js/onload_utils.js b/public/admin/js/onload_utils.js index d2ef3bd4f457bf595f4530d7d0a738549435fe87..1248580ad1f1288f0285955feaae994f3fa7d708 100644 --- a/public/admin/js/onload_utils.js +++ b/public/admin/js/onload_utils.js @@ -48,7 +48,7 @@ if (typeof jQuery != "undefined") //Les liens qui référencent des sites externes doivent être ouverts dans un nouvel onglet var setupAnchorsTarget = function() { - var internalLink = new RegExp('/' + window.location.host + '/'); + var internalLink = new RegExp('/' + window.location.host + '(:[0-9]+)?/'); $('a[href^="http"]').each(function() { if (!internalLink.test($(this).attr('href')) && (undefined == this.onclick) diff --git a/tests/application/modules/admin/controllers/AlbumControllerListViewModeTest.php b/tests/application/modules/admin/controllers/AlbumControllerListViewModeTest.php index 4ff485f3c175c161140ac911958a15f40cd070de..39c8d7021cb317216febb9fbc809981dfc6e67ed 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerListViewModeTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerListViewModeTest.php @@ -113,6 +113,13 @@ class Admin_AlbumControllerListViewModeIndexTest extends Admin_AlbumControllerLi } + /** @test */ + public function anchorShouldLinkToaddCategoryAtRoot() { + $this->assertXPath('//div[@class="actions"][preceding-sibling::a[text()="Racine"]]//a[@href="/admin/album/add_categorie"]'); + } + + + /** @test */ public function addCategoryToEmptyCatShouldBePresent() { $this->assertXPath('//div[@class="actions"]//a[contains(@href,"admin/album/add_categorie_to/id/1")]', $this->_response->getBody()); 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'); + } }