From d7e4266a8606c0c00b852d715ada4bddf715614a Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Thu, 24 May 2012 15:20:03 +0000
Subject: [PATCH] =?UTF-8?q?Te=CC=81le=CC=81phone:=20affichage=20nuage=20de?=
 =?UTF-8?q?=20tags=20+=20rebonds?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .gitattributes                                |  1 +
 .../opac/controllers/NoticeajaxController.php |  3 +-
 .../opac/controllers/RechercheController.php  |  3 +-
 .../modules/opac/views/scripts/head.phtml     |  2 +-
 .../controllers/RechercheController.php       |  8 +++++
 .../telephone/views/scripts/head.phtml        |  5 +++
 .../views/scripts/recherche/rebond.phtml      |  1 +
 .../views/scripts/recherche/simple.phtml      |  1 -
 .../views/scripts/recherche/tags.phtml        | 15 ++++----
 library/Class/Notice.php                      |  6 ++--
 library/Class/NoticeHtml.php                  |  3 +-
 library/ZendAfi/View/Helper/NuageTags.php     |  9 ++---
 .../telephone/skins/original/css/global.css   |  5 +++
 .../controllers/IndexControllerTest.php       |  3 +-
 .../RechercheControllerHarryPotterTest.php    | 36 ++++++++++++++++++-
 .../TelephoneAbstractControllerTestCase.php   |  7 +++-
 16 files changed, 84 insertions(+), 24 deletions(-)
 create mode 100644 application/modules/telephone/views/scripts/recherche/rebond.phtml

diff --git a/.gitattributes b/.gitattributes
index ea35ab98c5b..7a386a1bf8a 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -661,6 +661,7 @@ application/modules/telephone/views/scripts/recherche/detail.phtml -text
 application/modules/telephone/views/scripts/recherche/exemplaires.phtml -text
 application/modules/telephone/views/scripts/recherche/grandeimage.phtml -text
 application/modules/telephone/views/scripts/recherche/index.phtml -text
+application/modules/telephone/views/scripts/recherche/rebond.phtml -text
 application/modules/telephone/views/scripts/recherche/resume.phtml -text
 application/modules/telephone/views/scripts/recherche/similaires.phtml -text
 application/modules/telephone/views/scripts/recherche/simple.phtml -text
diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php
index 0d3524c3eb3..07ca4218486 100644
--- a/application/modules/opac/controllers/NoticeajaxController.php
+++ b/application/modules/opac/controllers/NoticeajaxController.php
@@ -81,8 +81,7 @@ class NoticeAjaxController extends Zend_Controller_Action
 //------------------------------------------------------------------------------------------------------
 // Tags utilisateur
 //------------------------------------------------------------------------------------------------------
-	function tagsAction()
-	{
+	function tagsAction()	{
 		$tags=$this->notice->getTags($this->id_notice);
 		$html=$this->notice_html->getTags($tags,$this->id_notice);
 
diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php
index 8941b83b8bd..c27a88fbcd4 100644
--- a/application/modules/opac/controllers/RechercheController.php
+++ b/application/modules/opac/controllers/RechercheController.php
@@ -340,8 +340,7 @@ class RechercheController extends Zend_Controller_Action
 //------------------------------------------------------------------------------------------------------
 // LIEN REBONDISSANT
 //------------------------------------------------------------------------------------------------------
-	function rebondAction()
-	{
+	function rebondAction()	{
 		// Lancer la recherche
  		$code=$_REQUEST["code_rebond"];
  		$_SESSION["recherche"]["selection"]["code_rebond"]=$code;
diff --git a/application/modules/opac/views/scripts/head.phtml b/application/modules/opac/views/scripts/head.phtml
index 4b9190f8989..307f8fc4711 100644
--- a/application/modules/opac/views/scripts/head.phtml
+++ b/application/modules/opac/views/scripts/head.phtml
@@ -17,7 +17,7 @@
 $head_scripts = Class_ScriptLoader::newInstance()
 	->addStyleSheet(URL_ADMIN_JS.'jquery_ui/css/jquery.ui.afi.theme')
 	->addOPACStyleSheet('global')
-	->addSkinStyleSheets(array('global', 'erreur', 'dialog', 'popup', 'nuage_tags'))
+	->addSkinStyleSheets(array('global', 'erreur', 'dialog', 'popup'))
 	->addAdminStyleSheet('subModal')
 	->addOPACStyleSheet('print', array('media' => 'print'))
 	->addInlineScript(sprintf('var baseUrl="%s"; var imagesUrl="%s"; var cssUrl="%s"; var userFilesUrl="%s"',
diff --git a/application/modules/telephone/controllers/RechercheController.php b/application/modules/telephone/controllers/RechercheController.php
index e68cda3289d..c0dc064b244 100644
--- a/application/modules/telephone/controllers/RechercheController.php
+++ b/application/modules/telephone/controllers/RechercheController.php
@@ -58,4 +58,12 @@ class Telephone_RechercheController extends RechercheController {
 	public function resumeAction() {
 		$this->view->notice = Class_Notice::getLoader()->find($this->_getParam('id'));
 	}
+
+
+	public function tagsAction() {
+		$notice = Class_Notice::getLoader()->find($this->_getParam('id'));
+		$notice_html = new Class_NoticeHtml();
+		$this->view->tags = $notice_html->getTags($notice->getTags(), $notice->getId());
+		$this->view->notice = $notice;
+	}
 }
\ No newline at end of file
diff --git a/application/modules/telephone/views/scripts/head.phtml b/application/modules/telephone/views/scripts/head.phtml
index a8c2685dfc7..3f77faaa3ae 100644
--- a/application/modules/telephone/views/scripts/head.phtml
+++ b/application/modules/telephone/views/scripts/head.phtml
@@ -27,4 +27,9 @@
 </script>
 <script src="<?php echo URL_JS?>global.js" type="text/javascript"> </script>
 
+<?php
+Class_ScriptLoader::getInstance()
+	 ->renderStyleSheets()
+	 ->renderJavaScripts();
+?>
 </head>
\ No newline at end of file
diff --git a/application/modules/telephone/views/scripts/recherche/rebond.phtml b/application/modules/telephone/views/scripts/recherche/rebond.phtml
new file mode 100644
index 00000000000..1a136078167
--- /dev/null
+++ b/application/modules/telephone/views/scripts/recherche/rebond.phtml
@@ -0,0 +1 @@
+<?php echo $this->render('recherche/simple.phtml') ?>
\ No newline at end of file
diff --git a/application/modules/telephone/views/scripts/recherche/simple.phtml b/application/modules/telephone/views/scripts/recherche/simple.phtml
index c8bde056026..e11eb8e5bbd 100644
--- a/application/modules/telephone/views/scripts/recherche/simple.phtml
+++ b/application/modules/telephone/views/scripts/recherche/simple.phtml
@@ -11,5 +11,4 @@ echo $this->pager($this->resultat['nombre'],
 									$this->preferences["liste_nb_par_page"],
 									$this->resultat['page_cours'],
 									$this->url_retour);
-echo BR;
 ?>
diff --git a/application/modules/telephone/views/scripts/recherche/tags.phtml b/application/modules/telephone/views/scripts/recherche/tags.phtml
index 564b4ced8f0..e14ed81d205 100644
--- a/application/modules/telephone/views/scripts/recherche/tags.phtml
+++ b/application/modules/telephone/views/scripts/recherche/tags.phtml
@@ -1,8 +1,9 @@
-<link rel="stylesheet" type="text/css" media="screen" href="<?php echo URL_CSS?>nuage_tags.css"/>
-<?php
-echo $this->toolbar("Tags",$this->url_retour,true);
-echo '<h1>'.$this->notice["T"].'</h1>';
-echo '<div class="pave">';
-echo $this->tags;
-echo '</div>'.BR;
+<?php 
+echo $this->toolbar($this->_("Tags"), array('action' => 'viewnotice') ,true); 
+echo '<h1>'.$this->notice->getTitrePrincipal().'</h1>';
 ?>
+
+<div class="pave">
+<?php echo $this->tags; ?>
+</div>
+
diff --git a/library/Class/Notice.php b/library/Class/Notice.php
index cef2fb54aec..eb21c1ca02d 100644
--- a/library/Class/Notice.php
+++ b/library/Class/Notice.php
@@ -574,8 +574,10 @@ class Class_Notice extends Storm_Model_Abstract {
 // ----------------------------------------------------------------
 // Tags
 // ----------------------------------------------------------------
-	public function getTags($id_notice)
-	{
+	public function getTags($id_notice = null)	{
+		if (!$id_notice)
+			$id_notice = $this->getId();
+
 		$ix = new Class_Indexation();
 
 		// Preferences
diff --git a/library/Class/NoticeHtml.php b/library/Class/NoticeHtml.php
index cf45e163b93..b89731318e0 100644
--- a/library/Class/NoticeHtml.php
+++ b/library/Class/NoticeHtml.php
@@ -878,8 +878,7 @@ class Class_NoticeHtml
 //------------------------------------------------------------------------------------------------------	
 // Tags utilisateur
 //------------------------------------------------------------------------------------------------------	
-	public function getTags($tags,$id_notice)
-	{
+	public function getTags($tags,$id_notice)	{
 		// Identité user connecté
 		$user = Zend_Auth::getInstance()->getIdentity();
 		
diff --git a/library/ZendAfi/View/Helper/NuageTags.php b/library/ZendAfi/View/Helper/NuageTags.php
index bfa245e9249..bb38512aa90 100644
--- a/library/ZendAfi/View/Helper/NuageTags.php
+++ b/library/ZendAfi/View/Helper/NuageTags.php
@@ -22,13 +22,14 @@
 // OPAC3 : Nuages de tags
 //////////////////////////////////////////////////////////////////////////////////////////
 
-class ZendAfi_View_Helper_NuageTags extends ZendAfi_View_Helper_BaseHelper
-{
+class ZendAfi_View_Helper_NuageTags extends ZendAfi_View_Helper_BaseHelper {
+
+	function nuageTags($tags,$calcul=3) {
+		Class_ScriptLoader::getInstance()->addSkinStyleSheet('nuage_tags');
 
-	function nuageTags($tags,$calcul=3)
-	{
 		// Parametres
 		if(!$tags) return;
+
 		$url = BASE_URL."/opac/recherche/rebond?facette=reset&amp;code_rebond=";
 		
 		// Déterminer les tranches
diff --git a/public/telephone/skins/original/css/global.css b/public/telephone/skins/original/css/global.css
index 319f446aebc..9325562d987 100644
--- a/public/telephone/skins/original/css/global.css
+++ b/public/telephone/skins/original/css/global.css
@@ -312,3 +312,8 @@ table.notice_detail tr li {
 		padding: 0px;
 		margin: 0px;
 }
+
+
+.pave>.nuage+div {
+		display:none;
+}
\ No newline at end of file
diff --git a/tests/application/modules/telephone/controllers/IndexControllerTest.php b/tests/application/modules/telephone/controllers/IndexControllerTest.php
index 2f398712b98..b81440b58e1 100644
--- a/tests/application/modules/telephone/controllers/IndexControllerTest.php
+++ b/tests/application/modules/telephone/controllers/IndexControllerTest.php
@@ -75,9 +75,10 @@ abstract class AbstractIndexControllerTelephoneWithModulesTest extends Telephone
 
 
 
-class IndexControllerTelephoneWithModulesTest extends AbstractIndexControllerTelephoneWithModulesTest {
+class IndexControllerTelephoneSimulationWithModulesTest extends AbstractIndexControllerTelephoneWithModulesTest {
 	public function setUp() {
 		parent::setUp();
+		unset($_SERVER['HTTP_USER_AGENT']);
 		$this->dispatch('/');
 	}
 
diff --git a/tests/application/modules/telephone/controllers/RechercheControllerHarryPotterTest.php b/tests/application/modules/telephone/controllers/RechercheControllerHarryPotterTest.php
index 396d4beb100..4b7ab53fe0b 100644
--- a/tests/application/modules/telephone/controllers/RechercheControllerHarryPotterTest.php
+++ b/tests/application/modules/telephone/controllers/RechercheControllerHarryPotterTest.php
@@ -170,7 +170,41 @@ class Telephone_RechercheControllerHarryPotterViewResumeTest extends Telephone_R
 	public function titleShouldBeHarryPotter() {
 		$this->assertXPathContentContains('//h1', 'Harry Potter à l\'ecole des sorciers');
 	}
-	
+
+
+	/** @test */
+	public function pageShouldContainsResumeBib() {
+		$this->assertXPathContentContains('//div', 'Apres la mort');
+	}	
+}
+
+
+
+
+class Telephone_RechercheControllerHarryPotterTagsTest extends Telephone_RechercheControllerHarryPotterTestCase {
+	public function setUp() {
+		parent::setUp();
+		$this->dispatch('/telephone/recherche/tags/id/4', true);
+	}
+
+
+	/** @test */
+	public function pageShouldContainsUrlToViewNoticeInToolbar() {
+		$this->assertXPath('//div[@class="toolbar"]//a[contains(@href, "recherche/viewnotice/id/4")]');
+	}
+
+
+	/** @test */
+	public function titleShouldBeHarryPotter() {
+		$this->assertXPathContentContains('//h1', 'Harry Potter à l\'ecole des sorciers');
+	}
+
+
+	/** @test */
+	public function pageShouldContainsNuageTagsCss() {
+		$this->assertXPath('//link[contains(@href, "nuage_tags")]',
+											 $this->_response->getBody());
+	}
 }
 
 
diff --git a/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php b/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php
index ae298cee97b..71dee0cc819 100644
--- a/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php
+++ b/tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php
@@ -24,9 +24,14 @@ require_once 'AbstractControllerTestCase.php';
 abstract class TelephoneAbstractControllerTestCase extends AbstractControllerTestCase {
 	public function setUp() {
 		parent::setUp();
-
+		$_SERVER['HTTP_USER_AGENT'] = 'iPhone';
 		Class_Profil::getCurrentProfil()->beTelephone();
 	}
+
+	public function tearDown() {
+		unset($_SERVER['HTTP_USER_AGENT']);
+		parent::tearDown();
+	}
 }
 
 
-- 
GitLab