From 8ec1eefb72763c4fffe1b731429890c759e916ae Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@git-test.afi-sa.fr>
Date: Wed, 3 Apr 2013 17:43:52 +0000
Subject: [PATCH] page notice: les urls pour ouvrir blocs et onglets sont au
 format zend pour garder le contexte

---
 .../opac/controllers/NoticeajaxController.php |  3 +-
 public/opac/js/recherche.js                   | 18 +++++++++---
 .../controllers/NoticeAjaxControllerTest.php  | 29 +++++++++++++------
 3 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php
index 2b491f8da4c..62ad7ffd743 100644
--- a/application/modules/opac/controllers/NoticeajaxController.php
+++ b/application/modules/opac/controllers/NoticeajaxController.php
@@ -168,7 +168,8 @@ class NoticeAjaxController extends Zend_Controller_Action {
 			$notice=$this->notice->getArticlesPeriodique($this->id_notice);
 			$html=$this->notice_html->getArticlesPeriodique($notice);
 		}
-		else $html=$this->notice_html->getNoticeDetaillee($notice,$_REQUEST["onglet"]);
+		else 
+			$html=$this->notice_html->getNoticeDetaillee($notice,$_REQUEST["onglet"]);
 
 		$this->_sendResponse($html);
 	}
diff --git a/public/opac/js/recherche.js b/public/opac/js/recherche.js
index 0e5d0ae38e7..6aaea947fc3 100644
--- a/public/opac/js/recherche.js
+++ b/public/opac/js/recherche.js
@@ -48,7 +48,7 @@ function getNoticeAjax(sIdNotice,sContainer,sTypeDoc)
 ////////////////////////////////////////////////////////////////////////////////////
 // Onglets et blocs ajax
 ///////////////////////////////////////////////////////////////////////////////////
-function infos_onglet(sIdOngletCourant,sIsbn,sType,sCherche,nNiveau,nPage)
+function infos_onglet(sIdOngletCourant,sIsbn,sType,sCherche,nNiveau,nPage,sUrl)
 {
 
 	$('.onglet_select').attr('className','onglet').removeClass('onglet_select');
@@ -59,8 +59,14 @@ function infos_onglet(sIdOngletCourant,sIsbn,sType,sCherche,nNiveau,nPage)
 	nPos=sIdRoot.lastIndexOf("_");
 	sIdRoot=sIdRoot.substr(0,nPos + 1);
 	nIdNotice=sIdRoot.substr(3,nPos-1).replace("_onglet_","");
-	sUrl=baseUrl + '/opac/noticeajax/'+ sType + '?isbn=' + sIsbn + '&onglet=' + sIdOngletCourant + '&page=' + nPage +'&id_notice='+ nIdNotice;
+
+	if (sUrl == undefined)
+		sUrl=baseUrl + '/opac/noticeajax/'+ sType;
+
+	sUrl = sUrl + '?isbn=' + sIsbn + '&onglet=' + sIdOngletCourant + '&page=' + nPage +'&id_notice='+ nIdNotice;
+
 	if(sCherche) sUrl = sUrl + '&cherche=' + sCherche;
+
 	var onglet = $('#' + sIdOngletCourant +'_contenu');
 	onglet
 		.css('display','block')
@@ -74,7 +80,7 @@ if (undefined == window.blocNoticeAfterLoad)
 	window.blocNoticeAfterLoad = function (info, isbn, target) {};
 
 
-function infos_bloc(sIdBloc,sIsbn,sType,sCherche,nNiveau,nPage)
+function infos_bloc(sIdBloc,sIsbn,sType,sCherche,nNiveau,nPage, sUrl)
 {
 	if(sIdBloc.substr(0,1) == "I" ) sIdBloc=sIdBloc.substr(1,sIdBloc.length);
 	oImg=document.getElementById("I" + sIdBloc);
@@ -90,7 +96,11 @@ function infos_bloc(sIdBloc,sIsbn,sType,sCherche,nNiveau,nPage)
 	oContenu.style.display="block";
 	nPos=sIdBloc.lastIndexOf("_");
 	nIdNotice=sIdBloc.substr(5,nPos-5);
-	sUrl=baseUrl + '/opac/noticeajax/'+ sType + '?isbn=' + sIsbn + '&onglet=' + sIdBloc + '&page=' + nPage +'&id_notice=N'+ nIdNotice;
+
+	if (sUrl == undefined)
+		sUrl=baseUrl + '/opac/noticeajax/'+ sType;
+	sUrl = sUrl + '?isbn=' + sIsbn + '&onglet=' + sIdBloc + '&page=' + nPage +'&id_notice=N'+ nIdNotice;
+
 	if(sCherche) sUrl = sUrl + '&cherche=' + sCherche;
 	
 	var bloc = $('#'+sIdBloc + '_contenu');
diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php
index 4977c83cb2a..99a097972b5 100644
--- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php
+++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php
@@ -56,35 +56,36 @@ class NoticeAjaxControllerNonRegressionTest extends AbstractControllerTestCase {
 		$this->dispatch('/opac/noticeajax/similaires?isbn=&onglet=set197143_onglet_0&page=0&id_notice=197143', true);
 		$this->assertXPathContentContains('//td', utf8_encode("Aucune information n'a été trouvée"));
 	}
+}
 
 
 
-	/** @test */
-	function detailShouldRenderOneNoticeTrouvee() {
+
+class NoticeAjaxControllerNoticeSimilairesSouleymaneTest extends AbstractControllerTestCase {
+	public function setUp() {
+		parent::setUp();
+		Class_Notice::getLoader()->newInstanceWithId('197143');
+
 		$mock_sql = Storm_Test_ObjectWrapper::on(Zend_Registry::get('sql'));
 		Zend_Registry::set('sql', $mock_sql);
 
 		$mock_sql
 			->whenCalled('fetchOne')
 			->with('select count(*) from exemplaires')
-			->answers(123);
+			->answers(123)
 
-		$mock_sql
 			->whenCalled('fetchOne')
 			->with("select valeur from variables where clef ='url_services'")
-			->answers('http://localhost');
+			->answers('http://localhost')
 
-			
-		$mock_sql
 			->whenCalled('fetchEnreg')
 			->with('select titres,auteurs,collection,matieres,dewey from notices where id_notice=197143', false)
 			->answers(array('titres' => 'IRM',
 											'auteurs' => '',
 											'collection' => '',
 											'matieres' => '',
-											'dewey' => ''));
+											'dewey' => ''))
 
-		$mock_sql
 			->whenCalled('fetchAll')
 			->with("select id_notice from notices where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST(' (IRM IRMS )') and id_notice !=197143 LIMIT 0,10", false)
 			->answers(array(array('id_notice' => 1)))
@@ -115,7 +116,17 @@ class NoticeAjaxControllerNonRegressionTest extends AbstractControllerTestCase {
 
 
 		$this->dispatch('/opac/noticeajax/similaires?isbn=&onglet=set197143_onglet_0&page=0&id_notice=197143', true);
+	}
+
+
+	/** @test */
+	function aTDShouldContainsAuteurSouleymaneCissé() {
 		$this->assertXPathContentContains('//td', utf8_encode('Auteur : Souleymane Cissé'), $this->_response->getBody());
+	}
+
+
+	/** @test */
+	public function supportShouldBeDisplayed() {
 		$this->assertContains("images/supports", $this->_response->getBody());
 	}
 }
-- 
GitLab