From 81bb8bf923fe456d3ae871d1851c18289d71b8f5 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Thu, 13 Sep 2012 15:26:22 +0000 Subject: [PATCH] =?UTF-8?q?Compatibilit=C3=A9=20Bib=20num=20avec=20VLC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/Class/AlbumRessource.php | 2 +- library/Class/Xml/Builder.php | 2 +- .../View/Helper/Album/XspfPlaylistVisitor.php | 11 ++++-- .../BibNumeriqueControllerTest.php | 34 +++++++++++++++---- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/library/Class/AlbumRessource.php b/library/Class/AlbumRessource.php index c77960cfaba..6b47016d437 100644 --- a/library/Class/AlbumRessource.php +++ b/library/Class/AlbumRessource.php @@ -515,7 +515,7 @@ class Class_AlbumRessource extends Storm_Model_Abstract { if ($this->hasUrl()) return $this->getUrl(); - return $this->getLocatedFile($this->getOriginalsUrl()); + return $this->getOriginalsUrl() . rawurlencode($this->getFichier()); } diff --git a/library/Class/Xml/Builder.php b/library/Class/Xml/Builder.php index 9fb3cf9dbcb..faed36f8b67 100644 --- a/library/Class/Xml/Builder.php +++ b/library/Class/Xml/Builder.php @@ -42,7 +42,7 @@ class Class_Xml_Builder { public function _xmlString($name, $content, $attributes = '') { - return '<'.htmlentities($name, ENT_XML1).$attributes.'>'.$content.'</'.$name.'>'; + return '<'.$name.$attributes.'>'.$content.'</'.$name.'>'; } diff --git a/library/ZendAfi/View/Helper/Album/XspfPlaylistVisitor.php b/library/ZendAfi/View/Helper/Album/XspfPlaylistVisitor.php index 77742bb52a9..63f863b7da1 100644 --- a/library/ZendAfi/View/Helper/Album/XspfPlaylistVisitor.php +++ b/library/ZendAfi/View/Helper/Album/XspfPlaylistVisitor.php @@ -41,10 +41,17 @@ class ZendAfi_View_Helper_Album_XspfPlaylistVisitor extends Zend_View_Helper_Ab public function visitRessource($ressource, $index) { $this->_tracks []= $this->_builder->track( $this->_builder->title($ressource->getTitre()) - .$this->_builder->image('http://' . $_SERVER['SERVER_NAME'] . $ressource->getThumbnailUrl()) - .$this->_builder->location('http://' . $_SERVER['SERVER_NAME'] . $ressource->getOriginalUrl()) + .$this->_builder->image($this->absoluteUrl($ressource->getThumbnailUrl())) + .$this->_builder->location($this->absoluteUrl($ressource->getOriginalUrl())) ); } + + + public function absoluteUrl($url) { + if (preg_match('/http[s]?:\/\//', $url)) + return $url; + return 'http://' . $_SERVER['SERVER_NAME'] . $url; + } } diff --git a/tests/application/modules/opac/controllers/BibNumeriqueControllerTest.php b/tests/application/modules/opac/controllers/BibNumeriqueControllerTest.php index fedfe047924..fab2c0642e1 100644 --- a/tests/application/modules/opac/controllers/BibNumeriqueControllerTest.php +++ b/tests/application/modules/opac/controllers/BibNumeriqueControllerTest.php @@ -511,7 +511,8 @@ class BibNumeriqueControllerViewCategorieActionLaBibleDeSouvignyTest extends Bib -class BibNumeriqueControllerAlbumMultiMediasTest extends AbstractControllerTestCase { + +abstract class BibNumeriqueControllerAlbumMultiMediasTestCase extends AbstractControllerTestCase { protected $_xpath; public function setUp() { @@ -533,12 +534,26 @@ class BibNumeriqueControllerAlbumMultiMediasTest extends AbstractControllerTestC ->setTitre('Batman Dark Knight') ->setVignette('batman.jpg'), - - Class_AlbumRessource::newInstanceWithId(4) + Class_AlbumRessource::newInstanceWithId(5) ->setUrl('http://progressive.totaleclips.com.edgesuite.net/107/e107950_227.mp4') ->setTitre('Hunger Games') - ->setVignette('hunger.jpg')]); + ->setVignette('hunger.jpg'), + + Class_AlbumRessource::newInstanceWithId(6) + ->setFichier('Monsieur l\'escargot.mp3') + ->setTitre('Monsieur l\'escargot') + ->setVignette('l\'escargot.jpg')]); + } +} + + + +class BibNumeriqueControllerAlbumMultiMediasXSPFTest extends BibNumeriqueControllerAlbumMultiMediasTestCase { + protected $_xpath; + + public function setUp() { + parent::setUp(); $this->dispatch('/opac/bib-numerique/album-xspf-playlist/id/999.xspf', true); } @@ -601,10 +616,17 @@ class BibNumeriqueControllerAlbumMultiMediasTest extends AbstractControllerTestC /** @test */ - public function thirsTrackLocationShouldBeTotaleClipsDotCom() { + public function thirdTrackLocationShouldBeTotaleClipsDotCom() { + $this->_xpath->assertXPath($this->_response->getBody(), + '//xspf:playlist/xspf:trackList/xspf:track/xspf:location[text()="http://progressive.totaleclips.com.edgesuite.net/107/e107950_227.mp4"]'); + } + + + /** @test */ + public function fourthTrackLocationShouldBeUrlEncoded() { $this->_xpath->assertXPathContentContains($this->_response->getBody(), '//xspf:playlist/xspf:trackList/xspf:track/xspf:location', - 'http://progressive.totaleclips.com.edgesuite.net/107/e107950_227.mp4'); + 'Monsieur%20l%27escargot.mp3'); } } -- GitLab