Skip to content
Snippets Groups Projects
Commit ca276156 authored by llaffont's avatar llaffont
Browse files

Bib numérique compatible iTunes Podcast

parent ddc75409
Branches
Tags
No related merge requests found
......@@ -21,32 +21,60 @@
class ZendAfi_View_Helper_Album_RssFeedVisitor extends Zend_View_Helper_Abstract {
protected $_data_rss;
protected $_channel;
protected $_doc;
public function album_rssFeedVisitor($album) {
$this->_doc = new DOMDocument('1.0', 'utf-8');
$root = $this->appendTag($this->_doc, 'rss');
$root->setAttribute('version', '2.0');
$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:content', 'http://purl.org/rss/1.0/modules/content/');
$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
$this->_channel = $this->appendTag($root, 'channel');
$album->acceptVisitor($this);
$feed = Zend_Feed::importArray($this->_data_rss, 'rss');
return $feed->saveXML();
return $this->_doc->saveXML();
}
public function appendTag($parent, $name, $content = '') {
$parent->appendChild($element = $this->_doc->createElement($name, $content));
return $element;
}
public function appendTags($parent, $tags) {
foreach ($tags as $name => $content)
$this->appendTag($parent, $name, $content);
}
public function visitAlbum($album) {
$this->_data_rss = [
'title' => $album->getTitre(),
'link' => $this->view->absoluteUrl($album->getPermalink()),
'charset' => 'utf-8',
'description' => $album->getDescription(),
'lastUpdate' => strtotime($album->getDateMaj()),
'entries' => []];
$description = $album->getDescription();
$this->appendTags($this->_channel,
['title' => $album->getTitre(),
'link' => $this->view->absoluteUrl($album->getPermalink()),
'charset' => 'utf-8',
'itunes:image' => $this->view->absoluteUrl($album->getPermalinkThumbnail()),
'description' => $description,
'itunes:summary' => $description,
'pubDate' => gmdate('r', strtotime($album->getDateMaj()))]);
}
public function visitRessource($ressource, $index) {
$this->_data_rss['entries'] []= [
'title' => $ressource->getTitre(),
'link' => $this->view->absoluteUrl($ressource->getOriginalUrl()),
'description' => $ressource->getDescription()
];
$media_url = $this->view->absoluteUrl($ressource->getOriginalUrl());
$this->appendTags($item = $this->appendTag($this->_channel, 'item'),
['title' => $ressource->getTitre(),
'link' => $media_url,
'description' => $ressource->getDescription(),
'itunes:order' => $ressource->getOrdre(),
'guid' => $media_url]);
$enclosure = $item->appendChild($this->_doc->createElement('enclosure'));
$enclosure->setAttribute('url', $media_url);
$enclosure->setAttribute('type', Class_File_Mime::getType($ressource->getFileExtension()));
}
}
......
......@@ -519,8 +519,7 @@ abstract class BibNumeriqueControllerAlbumMultiMediasTestCase extends AbstractCo
parent::setUp();
$this->_xpath = new Storm_Test_XPathXML();
$this->_xpath->registerNameSpace('xspf', 'http://xspf.org/ns/0/');
$album = Class_Album::newInstanceWithId(999)
->beDiaporama()
->setTitre('Plein de medias')
......@@ -529,22 +528,26 @@ abstract class BibNumeriqueControllerAlbumMultiMediasTestCase extends AbstractCo
->setRessources([Class_AlbumRessource::newInstanceWithId(2)
->setFichier('mimi_jolie.mp3')
->setTitre('Emilie jolie')
->setOrdre(1)
->setVignette('mimi_jolie.png'),
Class_AlbumRessource::newInstanceWithId(4)
->setFichier('dark_night.mp4')
->setTitre('Batman Dark Knight')
->setVignette('batman.jpg')
->setOrdre(2)
->setDescription('Une nouvelle aventure du justicier noir'),
Class_AlbumRessource::newInstanceWithId(5)
->setUrl('http://progressive.totaleclips.com.edgesuite.net/107/e107950_227.mp4')
->setTitre('Hunger Games')
->setOrdre(3)
->setVignette('hunger.jpg'),
Class_AlbumRessource::newInstanceWithId(6)
->setFichier('Monsieur l\'escargot.mp3')
->setTitre('Monsieur l\'escargot')
->setOrdre(4)
->setVignette('l\'escargot.jpg')]);
}
}
......@@ -555,6 +558,7 @@ abstract class BibNumeriqueControllerAlbumMultiMediasTestCase extends AbstractCo
class BibNumeriqueControllerAlbumMultiMediasXSPFTest extends BibNumeriqueControllerAlbumMultiMediasTestCase {
public function setUp() {
parent::setUp();
$this->_xpath->registerNameSpace('xspf', 'http://xspf.org/ns/0/');
$this->dispatch('/opac/bib-numerique/album-xspf-playlist/id/999.xspf', true);
}
......@@ -636,6 +640,9 @@ class BibNumeriqueControllerAlbumMultiMediasXSPFTest extends BibNumeriqueControl
class BibNumeriqueControllerAlbumMultiMediasRSSTest extends BibNumeriqueControllerAlbumMultiMediasTestCase {
public function setUp() {
parent::setUp();
$this->_xpath->registerNameSpace('itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
$this->dispatch('/opac/bib-numerique/album-rss-feed/id/999.xml', true);
}
......@@ -666,6 +673,14 @@ class BibNumeriqueControllerAlbumMultiMediasRSSTest extends BibNumeriqueControll
}
/** @test */
public function itunesImageShouldBeNoticeThumbnail() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/itunes:image',
'http://localhost'.BASE_URL.'/bib-numerique/notice-thumbnail/id/999');
}
/** @test */
public function descriptionShouldBePourPasserLaSoiree() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
......@@ -674,6 +689,14 @@ class BibNumeriqueControllerAlbumMultiMediasRSSTest extends BibNumeriqueControll
}
/** @test */
public function itunesSummaryShouldBePourPasserLaSoiree() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/itunes:summary',
'<p>pour passer la soirée</p>');
}
/** @test */
public function linkShouldBeBibNumeriqueNoticeId999() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
......@@ -681,6 +704,7 @@ class BibNumeriqueControllerAlbumMultiMediasRSSTest extends BibNumeriqueControll
'http://localhost'.BASE_URL.'/bib-numerique/notice/id/999');
}
/** @test */
public function pubDateShouldBeFri17Feb2012() {
......@@ -691,7 +715,7 @@ class BibNumeriqueControllerAlbumMultiMediasRSSTest extends BibNumeriqueControll
/** @test */
public function firstItemTibleShouldBeEmilieJolie() {
public function firstItemTitleShouldBeEmilieJolie() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/item[1]/title',
'Emilie jolie');
......@@ -706,6 +730,28 @@ class BibNumeriqueControllerAlbumMultiMediasRSSTest extends BibNumeriqueControll
}
/** @test */
public function firstItemEnclosureShouldBeMediaMimiJolieMp3() {
$this->_xpath->assertXPath($this->_response->getBody(),
'//channel/item[1]/enclosure[@url="http://localhost'.BASE_URL.'/userfiles/album/999/big/media/mimi_jolie.mp3"][@type="audio/mpeg"]');
}
/** @test */
public function firstItemITunesOrderShouldBeOne() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/item[1]/itunes:order',
'1');
}
/** @test */
public function firstItemGUIDShouldBeMediaMimiJolieMp3() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/item[1]/guid',
'http://localhost'.BASE_URL.'/userfiles/album/999/big/media/mimi_jolie.mp3');
}
/** @test */
public function secondItemTitleShouldBeDarkKnight() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
......@@ -720,6 +766,14 @@ class BibNumeriqueControllerAlbumMultiMediasRSSTest extends BibNumeriqueControll
'//channel/item[2]/description',
'Une nouvelle aventure du justicier noir');
}
/** @test */
public function firstItemITunesOrderShouldBeTwo() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//channel/item[2]/itunes:order',
'2');
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment