diff --git a/.gitattributes b/.gitattributes index 3f08122637a5b80d208a4cdbe96151abbd919221..c4bf1a64da4903bdce3d6507802472dbf2d5dbc1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2215,6 +2215,7 @@ library/ZendAfi/View/Helper/Album/BookJsonVisitor.php -text library/ZendAfi/View/Helper/Album/BookJsonVisitorAbstract.php -text library/ZendAfi/View/Helper/Album/BookMonoJsonVisitor.php -text library/ZendAfi/View/Helper/Album/JsonVisitor.php -text +library/ZendAfi/View/Helper/Album/OsmPlayer.php -text library/ZendAfi/View/Helper/Album/RssFeedVisitor.php -text library/ZendAfi/View/Helper/Album/XspfPlaylistVisitor.php -text library/ZendAfi/View/Helper/AlbumRessourceInfos.php -text diff --git a/library/ZendAfi/View/Helper/Album/OsmPlayer.php b/library/ZendAfi/View/Helper/Album/OsmPlayer.php new file mode 100644 index 0000000000000000000000000000000000000000..c8f6e0a477e340385df2711b58804e8d1ce881d7 --- /dev/null +++ b/library/ZendAfi/View/Helper/Album/OsmPlayer.php @@ -0,0 +1,51 @@ +<?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_OsmPlayer extends Zend_View_Helper_HtmlElement { + public function album_osmPlayer($album) { + $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', + '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>'; + } +} + +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/OsmPlayer.php b/library/ZendAfi/View/Helper/OsmPlayer.php index ed810d0c29b6df688c28444a0211c7ef0acd531d..86b18dc9eae7ea00df1023e1ef077899ea6e63db 100644 --- a/library/ZendAfi/View/Helper/OsmPlayer.php +++ b/library/ZendAfi/View/Helper/OsmPlayer.php @@ -20,10 +20,24 @@ */ class ZendAfi_View_Helper_OsmPlayer extends Zend_View_Helper_HtmlElement { - public function osmPlayer($album) { - $loader = Class_ScriptLoader::getInstance(); - $div_id = 'osmplayer'.$album->getId(); + /** + * Exemple: + * $this->osmPlayer("audio.mytag", ['width' => '100%', 'height' => '200px']); + * Voir: http://mediafront.org/osmplayer/index.html + */ + public function osmPlayer($selector, $options) { + $options = array_merge($options, + ['swfplayer' => URL_ADMIN_JS.'osmplayer/minplayer/flash/minplayer.swf', + 'logo' => URL_ADMIN_JS.'osmplayer/logo.png']); + + $this->loadJS()->addJQueryReady(sprintf('$("%s").osmplayer(%s)', + $selector, + json_encode($options))); + } + + public function loadJS() { + $loader = Class_ScriptLoader::getInstance(); foreach(['compatibility', 'flags', 'async', 'plugin', 'display'] as $js) $loader->addAdminScript('osmplayer/minplayer/src/minplayer.'.$js); @@ -45,37 +59,6 @@ class ZendAfi_View_Helper_OsmPlayer extends Zend_View_Helper_HtmlElement { foreach(['controller', 'pager', 'playLoader', 'playlist', 'teaser'] as $template) $loader->addAdminScript('osmplayer/templates/default/js/osmplayer.'.$template.'.default.js'); - - $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()]); - - - $loader - ->addStyleSheet(URL_ADMIN_JS.'osmplayer/templates/default/css/osmplayer_default.css') - ->addJQueryReady(sprintf('$("#%s").osmplayer(%s)', - $div_id, - json_encode(['playlist' => $xspf_url.'.xml', - 'height' => '500px', - 'swfplayer' => URL_ADMIN_JS.'osmplayer/minplayer/flash/minplayer.swf', - 'logo' => URL_ADMIN_JS.'osmplayer/logo.png']) - )); - 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 $loader->addStyleSheet(URL_ADMIN_JS.'osmplayer/templates/default/css/osmplayer_default.css'); } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/RenderAlbum.php b/library/ZendAfi/View/Helper/RenderAlbum.php index 93f8948f49c97f2ac78724b1462d547cd74c195f..d54d65950483580ee7df538808bc59a764674e3a 100644 --- a/library/ZendAfi/View/Helper/RenderAlbum.php +++ b/library/ZendAfi/View/Helper/RenderAlbum.php @@ -37,7 +37,7 @@ class ZendAfi_View_Helper_RenderAlbum extends Zend_View_Helper_HtmlElement { return $this->view->tagSlideshow($album); if ($album->isDiaporama()) - return $this->view->osmPlayer($album); + return $this->view->album_OsmPlayer($album); if ($album->isGallica()) return $this->view->gallicaPlayer($album);