From 1923fcc990745b278b9cfb9022033da74921fc40 Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@git-test.afi-sa.fr>
Date: Wed, 3 Apr 2013 17:43:58 +0000
Subject: [PATCH] =?UTF-8?q?Recherche:=20Les=20liens=20code=20rebond=20noti?=
 =?UTF-8?q?ce=20d=C3=A9taill=C3=A9e=20+=20liens=20notices=20similaires=20g?=
 =?UTF-8?q?ardent=20le=20contexte?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../opac/controllers/NoticeajaxController.php | 14 ++++----
 library/Class/Codification.php                |  2 ++
 library/Class/Notice.php                      | 15 ++++++---
 library/Class/NoticeHtml.php                  | 32 ++++---------------
 library/ZendAfi/View/Helper/Notice/Entete.php |  2 +-
 5 files changed, 25 insertions(+), 40 deletions(-)

diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php
index 62ad7ffd743..224392666f4 100644
--- a/application/modules/opac/controllers/NoticeajaxController.php
+++ b/application/modules/opac/controllers/NoticeajaxController.php
@@ -37,9 +37,6 @@ class NoticeAjaxController extends Zend_Controller_Action {
 		if($this->_request->getParam("action") != "notice") {
 			$viewRenderer = $this->getHelper('ViewRenderer');
 			$viewRenderer->setNoRender();
-			$onglet = $this->_getParam("onglet");
-			if (strPos($onglet,"_onglet_") !== false) 
-				$this->notice_html->initHautOnglet($onglet);
 		}
 
 		// Test services afi
@@ -163,13 +160,14 @@ class NoticeAjaxController extends Zend_Controller_Action {
 
 
 	public function detailAction() {
-		$notice=$this->notice->getTousChamps($this->id_notice);
-		if($notice["type_doc"]==2) {
-			$notice=$this->notice->getArticlesPeriodique($this->id_notice);
-			$html=$this->notice_html->getArticlesPeriodique($notice);
+		$notice = Class_Notice::find($this->id_notice);
+
+		if ($notice->isPeriodique()) {
+			$periodiques = $this->notice->getArticlesPeriodique($this->id_notice);
+			$html=$this->notice_html->getArticlesPeriodique($periodiques);
 		}
 		else 
-			$html=$this->notice_html->getNoticeDetaillee($notice,$_REQUEST["onglet"]);
+			$html=$this->view->notice_Entete($notice, ['entete' => Class_Codification::CHAMPS]);
 
 		$this->_sendResponse($html);
 	}
diff --git a/library/Class/Codification.php b/library/Class/Codification.php
index 542c6f0427d..6e6e885d2dd 100644
--- a/library/Class/Codification.php
+++ b/library/Class/Codification.php
@@ -23,6 +23,8 @@
 //////////////////////////////////////////////////////////////////////////////////////////
 
 class Class_Codification {
+	const CHAMPS = "TAKEFCNMDGPILOR8";
+
 	protected static $_nom_champs, $_nom_onglets;
 
 //------------------------------------------------------------------------------------------------------
diff --git a/library/Class/Notice.php b/library/Class/Notice.php
index 760b739481d..f0c631d47ad 100644
--- a/library/Class/Notice.php
+++ b/library/Class/Notice.php
@@ -461,7 +461,7 @@ class Class_Notice extends Storm_Model_Abstract {
 		if (!$notice) return false;
 
 		// Champs
-		$champs = "TAKEFCNMDGPILOR8";
+		$champs = Class_Codification::CHAMPS;
 		for ($i = 0; $i < strlen($champs); $i++) 
 		{
 			$clef = $champs[$i];
@@ -558,10 +558,15 @@ class Class_Notice extends Storm_Model_Abstract {
 				$type = $item[0];
 				if ($type != $champ)
 					continue;
-				$id = substr($item, 1);
-				$libelle = Class_Codification::getLibelleFacette($item);
-				$url = BASE_URL . "/recherche/rebond?facette=reset&amp;code_rebond=" . $item;
-				$ret[] = compact("id", "libelle", "url");
+
+				$ret[] = ['id' => substr($item, 1),
+									'libelle' => Class_Codification::getLibelleFacette($item), 
+									'url' => ['controller' => 'recherche',
+														'action' => 'rebond',
+														'code_rebond' => $item,
+														'facettes' => null,
+														'facette' => null,
+														'page' => null]];
 			}
 		}
 		// Champ texte
diff --git a/library/Class/NoticeHtml.php b/library/Class/NoticeHtml.php
index 6277be7112d..6e41fca9eb5 100644
--- a/library/Class/NoticeHtml.php
+++ b/library/Class/NoticeHtml.php
@@ -24,15 +24,14 @@
 
 class Class_NoticeHtml {
 	public $notice;								// Structure complete de la notice
-	public $haut_onglet;					// Html ligne du haut avec image fermer pour les onglets
+	public $haut_onglet = '';					// Html ligne du haut avec image fermer pour les onglets
 	public $preferences;					// Préférences d'affichage pour les blocs et les onglets
 	private $_translate;
 	
 //------------------------------------------------------------------------------------------------------
 // Constructeur initialise la notice
 //------------------------------------------------------------------------------------------------------
-	function __construct($notice="")
-	{
+	function __construct($notice="") {
 		$this->notice=$notice;
 		$this->preferences = Class_Profil::getCurrentProfil()->getCfgNoticeAsArray();
 		$this->_translate = Zend_Registry::get('translate');
@@ -41,8 +40,7 @@ class Class_NoticeHtml {
 //------------------------------------------------------------------------------------------------------
 // Champs d'Entete (selon preferences)
 //------------------------------------------------------------------------------------------------------
-	public function getEntete()
-	{
+	public function getEntete()	{
 		if(!$this->notice["entete"]) return false;
 		$html='<table id="entete_notice">';
 		foreach($this->notice["entete"] as $libelle => $valeurs)
@@ -56,7 +54,8 @@ class Class_NoticeHtml {
 			else	{
 				foreach($valeurs as $item) {
 					if (gettype($item) == "array"){ 
-						if($item["url"]) $html.='<a href="'.$item["url"].'" class="notice">'.$item["libelle"].'</a>.';
+						if($item["url"]) 
+							$html.='<a href="'.$item["url"].'" class="notice">'.$item["libelle"].'</a>.';
 					} else {
 						$html.=$item;
 					}
@@ -84,17 +83,6 @@ class Class_NoticeHtml {
 		return $template;
 	}
 	
-//------------------------------------------------------------------------------------------------------
-// 1ere ligne pour les onglets
-//------------------------------------------------------------------------------------------------------
-	public function initHautOnglet($id_onglet)	{
-		$this->haut_onglet = '';
-		return;
-		$this->haut_onglet='<table width="100%"><tr><td style="text-align:right">';
-		$this->haut_onglet.='<img src="'.URL_IMG.'bouton/contracter.gif" border="0" title="'.$this->_translate->_('Fermer les onglets').'"';
-		$this->haut_onglet.=' onclick="javascript:fermer_infos_notice(\''.$id_onglet.'\')" style="cursor:pointer" alt="'.$this->_translate->_('Refermer').'" />';
-		$this->haut_onglet.='</td></tr></table>';
-	}
 	
 //------------------------------------------------------------------------------------------------------
 // Ligne de message : pas d'info trouvée
@@ -110,15 +98,7 @@ class Class_NoticeHtml {
 		return $html;
 	}
 
-//------------------------------------------------------------------------------------------------------
-// Notice détaillée
-//------------------------------------------------------------------------------------------------------
-	public function getNoticeDetaillee($notice,$id_onglet)
-	{
-		$this->notice=$notice;
-		return $this->haut_onglet.$this->getEntete();
-	}
-
+	
 //------------------------------------------------------------------------------------------------------
 // Notice détaillée : articles de périodique
 //------------------------------------------------------------------------------------------------------
diff --git a/library/ZendAfi/View/Helper/Notice/Entete.php b/library/ZendAfi/View/Helper/Notice/Entete.php
index ab7e4b7e8fc..d2d6a49037c 100644
--- a/library/ZendAfi/View/Helper/Notice/Entete.php
+++ b/library/ZendAfi/View/Helper/Notice/Entete.php
@@ -40,7 +40,7 @@ class ZendAfi_View_Helper_Notice_Entete extends Zend_View_Helper_HtmlElement {
 			else	{
 				foreach($valeurs as $item) {
 					if (gettype($item) == "array"){ 
-						if($item["url"]) $html.='<a href="'.$item["url"].'" class="notice">'.$item["libelle"].'</a>.';
+						if($item["url"]) $html.='<a href="'.$this->view->url($item["url"]).'" class="notice">'.$item["libelle"].'</a>.';
 					} else {
 						$html.=$item;
 					}
-- 
GitLab