From 27e37955665ed47bc81490234a820ec71f54d29c Mon Sep 17 00:00:00 2001
From: ayjuillet <ayjuillet@git-test.afi-sa.fr>
Date: Mon, 24 Sep 2012 07:57:30 +0000
Subject: [PATCH] =?UTF-8?q?T=C3=A9l=C3=A9phone=20:=20Skin=20jquery=20Bibnu?=
 =?UTF-8?q?merique?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .gitattributes                                |  2 +
 .../View/Helper/Telephone/RenderAlbum.php     | 50 ++++++++++++++++
 .../Helper/Telephone/TagAlbumMediaList.php    | 60 +++++++++++++++++++
 .../BibNumeriqueControllerTest.php            | 16 +++--
 4 files changed, 123 insertions(+), 5 deletions(-)
 create mode 100644 library/ZendAfi/View/Helper/Telephone/RenderAlbum.php
 create mode 100644 library/ZendAfi/View/Helper/Telephone/TagAlbumMediaList.php

diff --git a/.gitattributes b/.gitattributes
index f7700e35443..8a9dea454bf 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2150,6 +2150,8 @@ library/ZendAfi/View/Helper/Telephone/Kiosque.php -text
 library/ZendAfi/View/Helper/Telephone/ListeNotices.php -text
 library/ZendAfi/View/Helper/Telephone/News.php -text
 library/ZendAfi/View/Helper/Telephone/Pager.php -text
+library/ZendAfi/View/Helper/Telephone/RenderAlbum.php -text
+library/ZendAfi/View/Helper/Telephone/TagAlbumMediaList.php -text
 library/ZendAfi/View/Helper/Telephone/Tags/NoticeDetaillee.php -text
 library/ZendAfi/View/Helper/Telephone/Tags/ResumeAvis.php -text
 library/ZendAfi/View/Helper/Telephone/Tags/Toolbar.php -text
diff --git a/library/ZendAfi/View/Helper/Telephone/RenderAlbum.php b/library/ZendAfi/View/Helper/Telephone/RenderAlbum.php
new file mode 100644
index 00000000000..1b74c80a4d7
--- /dev/null
+++ b/library/ZendAfi/View/Helper/Telephone/RenderAlbum.php
@@ -0,0 +1,50 @@
+<?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_Telephone_RenderAlbum extends ZendAfi_View_Helper_RenderAlbum {
+	public function renderAlbum($album) {
+		return $album 
+			? sprintf('<div id="resnum">%s</div>', $this->renderAlbumHelper($album))
+			: '';
+	}
+
+
+	public function renderAlbumHelper($album) {
+		if ($album->isLivreNumerique()) {
+			Class_ScriptLoader::getInstance()->loadBooklet($album->getId(), '#resnum');
+			return '';
+		}
+
+		if ($album->isDiaporama() && $album->hasOnlyImages())
+			return $this->view->tagSlideshow($album);
+
+
+		if ($album->isGallica())
+			return  $this->view->gallicaPlayer($album);
+
+		if ($album->isArteVod())
+			return $this->view->tagVideo($album);
+
+		return $this->view->tagAlbumMediaList($album);
+	}
+}
+
+?>
\ No newline at end of file
diff --git a/library/ZendAfi/View/Helper/Telephone/TagAlbumMediaList.php b/library/ZendAfi/View/Helper/Telephone/TagAlbumMediaList.php
new file mode 100644
index 00000000000..4e643dac7ba
--- /dev/null
+++ b/library/ZendAfi/View/Helper/Telephone/TagAlbumMediaList.php
@@ -0,0 +1,60 @@
+<?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_Telephone_TagAlbumMediaList extends ZendAfi_View_Helper_TagAlbumMediaList {
+		protected $_builder;
+
+	public function tagAlbumMediaList($album) {
+	  
+
+			$ressources = $album->getRessources();
+
+		$xspf_url = $this->view->url(['module' => 'telephone', 
+																	'controller' => 'bib-numerique',
+																	'action' => 'album-xspf-playlist', 
+																	'id' => $album->getId()]);
+
+		$podcast_url = $this->view->url(['module' => 'telephone', 
+																		 'controller' => 'bib-numerique',
+																		 'action' => 'Album-rss-feed', 
+																		 'id' => $album->getId()]);
+		$html='';
+		foreach($ressources as $ressource) {
+		$html .=  sprintf('<li data-role="list-divider" ><a href=%s  rel="external"><img src=%s><h3>%s</h3></a></li>', 
+											$this->view->absoluteUrl($ressource->getOriginalUrl()),
+											$this->view->absoluteurl($ressource->getThumbnailUrl()),
+											$ressource->getTitre());}
+
+		$playlist = sprintf('<a href="%s" data-role="button" data-mini="true"  data-icon="list-alt" rel="external">%s</a>',
+										 $this->view->absoluteUrl($xspf_url.'.xspf'), 
+										 $this->view->_('Playlist'),
+										 ['data-ajax' => 'false']);
+
+		$rss = sprintf('<a href="%s"  data-role="button" data-mini="true"  data-icon="rss" rel="external">%s</a>',
+										 $this->view->absoluteUrl($podcast_url.'.xml'), 
+										 $this->view->_('RSS'));
+	  
+		return '<ul data-role="listview">' . $html . '</ul><fieldset class="ui-grid-a"><div class="ui-block-a">' .$playlist.'</div><div class="ui-block-b">' .$rss . '</div></fieldset>'  ;
+
+	}
+}
+
+?>
\ No newline at end of file
diff --git a/tests/application/modules/telephone/controllers/BibNumeriqueControllerTest.php b/tests/application/modules/telephone/controllers/BibNumeriqueControllerTest.php
index b5517739507..f9806c9c6e1 100644
--- a/tests/application/modules/telephone/controllers/BibNumeriqueControllerTest.php
+++ b/tests/application/modules/telephone/controllers/BibNumeriqueControllerTest.php
@@ -73,14 +73,13 @@ class BibNumeriqueControllerTelephoneViewCategorieEPUBTest extends BibNumeriqueC
 class BibNumeriqueControllerTelephoneViewAlbumMonumentsTest extends BibNumeriqueControllerTelephoneTestCase {
 	public function setUp() {
 		parent::setUp();
-		$this->dispatch('/bib-numerique/view-album/id/234');
+		$this->dispatch('/bib-numerique/view-album/id/234', true);
 	}
 
 
 	/** @test */
 	public function pageShouldContainsLinkToDownloadEPub() {
-		$this->assertXPathContentContains('//a[contains(@href, "bib-numerique/download-resource/id/123")][@data-ajax="false"]', 
-																			'versailles.epub');
+		$this->assertXPath('//a[contains(@href, "media/versailles.epub")]');
 	}
 }
 
@@ -112,14 +111,21 @@ class BibNumeriqueControllerTelephoneViewAlbumMultiMedia extends TelephoneAbstra
 
 	/** @test */
 	public function pageShouldContainsLinkToXSPFPlayList() {
-		$this->assertXPath('//a[@href="http://localhost'.BASE_URL.'/bib-numerique/album-xspf-playlist/id/999.xspf"][@data-ajax="false"]', $this->_response->getBody());
+		$this->assertXPath('//a[contains(@href, "bib-numerique/album-xspf-playlist/id/999.xspf")]');
 	}
 
 
 	/** @test */
 	public function pageShouldContainsLinkToRSSPodcast() {
-		$this->assertXPath('//a[@href="http://localhost'.BASE_URL.'/bib-numerique/album-rss-feed/id/999.xml"][@data-ajax="false"]');
+		$this->assertXPath('//a[contains(@href, "bib-numerique/Album-rss-feed/id/999.xml")]');
 	}
+
+	
+	/** @test */
+	public function pageShouldContainLinkIntroductionMp3() {
+	  $this->assertXPath('//a[contains(@href, "media/introduction.mp3")]');
+	}
+
 }
 
 
-- 
GitLab