From 6edec6d2323eaf71ab860cb9c7df138125227916 Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@git-test.afi-sa.fr>
Date: Wed, 3 Apr 2013 17:45:30 +0000
Subject: [PATCH] Historique de la recherche : utilisation de la session Zend

---
 .gitattributes                                |   2 +
 .../opac/controllers/RechercheController.php  |  25 +-
 .../views/scripts/recherche/avancee.phtml     |   6 +-
 .../opac/views/scripts/recherche/guidee.phtml |   2 +-
 .../scripts/recherche/resultatRecherche.phtml | 278 +++++++++---------
 .../opac/views/scripts/recherche/saisie.phtml |   2 +-
 library/Class/MoteurRecherche.php             |   4 +-
 .../View/Helper/HistoriqueRecherche.php       | 111 +------
 .../View/Helper/TagCriteresRecherche.php      |  18 +-
 .../View/Helper/TagHistoriqueRecherche.php    |  88 ++++++
 library/ZendAfi/View/Helper/UrlNotice.php     |   1 -
 tests/library/Class/CommSigbTest.php          |   2 +-
 .../View/Helper/HistoriqueRechercheTest.php   |  69 +++++
 13 files changed, 349 insertions(+), 259 deletions(-)
 create mode 100644 library/ZendAfi/View/Helper/TagHistoriqueRecherche.php
 create mode 100644 tests/library/ZendAfi/View/Helper/HistoriqueRechercheTest.php

diff --git a/.gitattributes b/.gitattributes
index bd210395c3e..97b7c66556f 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2692,6 +2692,7 @@ library/ZendAfi/View/Helper/TagArticleEvent.php -text
 library/ZendAfi/View/Helper/TagBanniere.php -text
 library/ZendAfi/View/Helper/TagCriteresRecherche.php -text
 library/ZendAfi/View/Helper/TagEditArticle.php -text
+library/ZendAfi/View/Helper/TagHistoriqueRecherche.php -text
 library/ZendAfi/View/Helper/TagImg.php -text
 library/ZendAfi/View/Helper/TagModelTable.php -text
 library/ZendAfi/View/Helper/TagObjetsImgProperties.php -text
@@ -5194,6 +5195,7 @@ tests/library/ZendAfi/View/Helper/AvisTest.php -text
 tests/library/ZendAfi/View/Helper/CkEditorTest.php -text
 tests/library/ZendAfi/View/Helper/ComboCodificationTest.php -text
 tests/library/ZendAfi/View/Helper/FicheAbonneLinksTest.php -text
+tests/library/ZendAfi/View/Helper/HistoriqueRechercheTest.php -text
 tests/library/ZendAfi/View/Helper/IconeSupportTest.php -text
 tests/library/ZendAfi/View/Helper/IframeContainerTest.php -text
 tests/library/ZendAfi/View/Helper/Java/MenuImageTest.php -text
diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php
index 0150aaa4c28..ad0bef1310d 100644
--- a/application/modules/opac/controllers/RechercheController.php
+++ b/application/modules/opac/controllers/RechercheController.php
@@ -136,6 +136,9 @@ class RechercheController extends Zend_Controller_Action
 		
 		if ($titre=$this->_request->getParam('titre'))
 			$this->view->titre=$titre;
+		else if ($this->_request->getParam('rubrique'))
+			$this->view->titre="Recherche guidée";
+
 		else if ($catalogue = $criteres_recherche->getCatalogue())
 			$this->view->titre=$catalogue->getLibelle();
 		else if ($panier = $criteres_recherche->getPanier())
@@ -159,7 +162,7 @@ class RechercheController extends Zend_Controller_Action
 		// Moteur de recherche
 		$moteur=new Class_MoteurRecherche();
 		$catalogue = Class_Catalogue::find($this->_getParam('id_catalogue'));
-		xdebug_break();
+		
 		if (!$catalogue)
 			return;
 		$criteres_recherche = new Class_CriteresRecherche();
@@ -190,7 +193,7 @@ class RechercheController extends Zend_Controller_Action
 				$this->view->liste = $ret;
 				$this->view->resultat = $ret;
 		} else {
-//			$this->addHistoRecherche(1, $_SESSION["recherche"]["selection"]);
+			$this->addHistoRecherche(1,$criteres_recherche);
 
 			$this->view->liste = $this->_getListNotices($ret['req_liste']);
 
@@ -338,16 +341,18 @@ class RechercheController extends Zend_Controller_Action
 //------------------------------------------------------------------------------------------------------
 // Memo historique de recherche dans la session
 //------------------------------------------------------------------------------------------------------
-	private function addHistoRecherche($type,$criteres)
+	private function addHistoRecherche($type,$criteres_recherche)
 	{
-		$ligne["type"]=$type;
-		$ligne["selection"]=$criteres;
-		// controle si existe deja
-		if(isset($_SESSION["histo_recherche"]))
-		{
-			for($i=0; $i < count($_SESSION["histo_recherche"]); $i++) if($_SESSION["histo_recherche"][$i] == $ligne) return;
+
+		$histo_session = new Zend_Session_Namespace('historiqueRecherche');
+		if (null == ($criteres = $histo_session->criteres)) {
+			$criteres=[serialize($criteres_recherche)];
+		}
+		else 	{
+			$criteres[]=serialize($criteres_recherche);
 		}
-		$_SESSION["histo_recherche"][]=$ligne;
+		$histo_session->criteres=array_unique($criteres);		
+
 	}
 
 
diff --git a/application/modules/opac/views/scripts/recherche/avancee.phtml b/application/modules/opac/views/scripts/recherche/avancee.phtml
index fb98adbe4b0..8decbee73a9 100644
--- a/application/modules/opac/views/scripts/recherche/avancee.phtml
+++ b/application/modules/opac/views/scripts/recherche/avancee.phtml
@@ -150,11 +150,11 @@ if ($this->statut == "saisie") {
 	$this->closeBoite();
 
 	// Historique des recherches
-	if (array_key_exists("histo_recherche", $_SESSION)) {
+
 		echo '<div class="conteneur_simple">';
-		$this->historiqueRecherche();
+		echo $this->historiqueRecherche();
 		echo '</div>';
-	}
+
 } else {
 	echo $this->render("recherche/resultatRecherche.phtml");
 }
diff --git a/application/modules/opac/views/scripts/recherche/guidee.phtml b/application/modules/opac/views/scripts/recherche/guidee.phtml
index 3a55309d89d..1db449c809f 100644
--- a/application/modules/opac/views/scripts/recherche/guidee.phtml
+++ b/application/modules/opac/views/scripts/recherche/guidee.phtml
@@ -2,7 +2,7 @@
 <?php
 
 // Fil d'ariane
-echo "Recherche guidée<br>";
+//echo "Recherche guidée<br>";
 
 if($this->fil_ariane["liens"])
 {
diff --git a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml
index a74f7cc29ba..444ca1929f5 100644
--- a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml
+++ b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml
@@ -1,140 +1,140 @@
-<?php
-$preferences = $this->current_module["preferences"];
-
-$hasFacettes	= (1 == $preferences["facettes_actif"]);
-$hasTags			= (1 == $preferences["tags_actif"]);
-$tagsPosition	= $preferences["tags_position"];
-extract($this->resultat);
-
-
-$this->openBoite($this->titre);
-
-if ($this->is_pertinence) {
-	$this->titre .= $this->_(" (recherche élargie triée par pertinence)");
-}
-
-
-if ($this->rubriques || $this->fil_ariane) {
-	echo $this->render('recherche/guidee.phtml');
-}
-echo $this->tagCriteresRecherche($this->criteres_recherche);
-
-?>
-
-<div class="criteres_recherche"><?php echo $this->texte_selection ?></div>
-
-
-<div class="recherche_actions">
-	<span>
-	<?php 
-	echo $this->tagAnchor($this->url($this->criteres_recherche->getUrlRetourRechercheInitiale(), null, true), 
-												sprintf('&raquo; %s', 
-																$this->_('Retour à la recherche initiale')));?>
-  </span> 
-	<?php if ($this->url_retour_notice) { ?>
-		<span>
-		<?php 
-		echo $this->tagAnchor($this->url_retour_notice, 
-													sprintf('&raquo; %s', 
-																	$this->_('Retour à la notice'))); ?>
-		</span>
-	<?php } ?>
-
-	<span>
-  <?php echo $this->tagAnchor($this->url($this->criteres_recherche->getUrlNouvelleRecherche(), null, true), 
-															'&raquo; '.$this->_('Nouvelle recherche')); ?>
-  </span>
-
-  
-	<span>
-	<?php if ((int)$preferences['suggestion_achat'] == 1)
-           echo $this->tagAnchor(['controller' => 'abonne', 'action' => 'suggestion-achat'], 
-																 '&raquo; '.$this->_('Suggérer un achat'));?>
-  </span> 
-</div>
-
-
-<?php
-$this->closeBoite();
-
-
-if (!isset($tags)) $tags=[];
-?>
-
-<div style="width:100%" class="conteneur_simple">
-	<?php
-	// Si facettes ou tags on ouvre un tableau a 2 colonnes
-	if ($hasFacettes	or ($hasTags and (2 == $tagsPosition))) 
-	{
-		?>
-		<table class="resultat_recherche" style="width:100%">
-			<tr>
-				<td style="vertical-align:top" style="width: 65%">
-		<?php
-	}
-
-	// Liste notices
-	echo $this->listeNotices($this->liste, 
-													 $nombre, 
-													 $page_cours, 
-													 $preferences, 
-													 $this->criteres_recherche);
-	?>
-	<br/>
-	<div style="width:100%;text-align:center;">
-	<?php 
-	echo $this->pager($nombre, 
-										$preferences["liste_nb_par_page"], 
-										$page_cours, 
-										$this->url_retour);?>
-  </div>
-	<?php
-	// Container notice pour listes d'images
-	if (3 < $preferences["liste_format"]) {
-		$notice_html= new Class_NoticeHtml();
-		print($notice_html->getConteneurNotice("notice"));
-	}
-
-	// Tags sous la liste
-	if ($hasTags and (1 == $tagsPosition)) {
-		print(BR . $this->nuageTags($tags, $preferences["tags_codes"]));
-	}
-
-	// Facettes et tags sous les facettes
-	if ($hasFacettes or $hasTags) { ?>
-		</td>
-		<td style="vertical-align:top;width: 35%">
-		<?php
-		if ($nombre) {
-			if ($hasFacettes) { ?>
-				<div class="facette_outer" style="margin-left:10px;margin-top:17px">
-					<?php if ($preferences["facettes_message"]) { ?>
-						<strong><?php echo $preferences["facettes_message"];?></strong><br/>
-					<?php } ?>
-					<?php 
-											
-													echo $this->facettes($facettes, $preferences, $this->url_facette); ?>
-				</div>
-			<?php
-			}
-
-			if ($hasTags and (2 == $tagsPosition)) { ?>
-				<div class="nuage_outer" style="margin-left:10px"><br/>
-					<?php if ($preferences["tags_message"]) { ?>
-						<strong><?php echo $preferences["tags_message"];?></strong>
-					<?php } ?>
-					<?php echo $this->nuageTags($tags, $preferences["tags_calcul"]); ?>
-				</div>
-			<?php
-			}
-		}
-		?>
-		</td>
-		</tr>
-	</table>
-	<?php } ?>
-
-</div>
-
-<script src="<?php echo URL_JS?>recherche.js" type="text/javascript"> </script>
+<?php
+$preferences = $this->current_module["preferences"];
+
+$hasFacettes	= (1 == $preferences["facettes_actif"]);
+$hasTags			= (1 == $preferences["tags_actif"]);
+$tagsPosition	= $preferences["tags_position"];
+extract($this->resultat);
+
+
+$this->openBoite($this->titre);
+
+if ($this->is_pertinence) {
+	$this->titre .= $this->_(" (recherche élargie triée par pertinence)");
+}
+
+
+if ($this->rubriques || $this->fil_ariane) {
+	echo $this->render('recherche/guidee.phtml');
+}
+echo $this->tagCriteresRecherche($this->criteres_recherche);
+
+?>
+
+<div class="criteres_recherche"><?php echo $this->texte_selection ?></div>
+
+
+<div class="recherche_actions">
+	<span>
+	<?php 
+	echo $this->tagAnchor($this->url($this->criteres_recherche->getUrlRetourRechercheInitiale(), null, true), 
+												sprintf('&raquo; %s', 
+																$this->_('Retour à la recherche initiale')));?>
+  </span> 
+	<?php if ($this->url_retour_notice) { ?>
+		<span>
+		<?php 
+		echo $this->tagAnchor($this->url_retour_notice, 
+													sprintf('&raquo; %s', 
+																	$this->_('Retour à la notice'))); ?>
+		</span>
+	<?php } ?>
+
+	<span>
+  <?php echo $this->tagAnchor($this->url($this->criteres_recherche->getUrlNouvelleRecherche(), null, true), 
+															'&raquo; '.$this->_('Nouvelle recherche')); ?>
+  </span>
+
+  
+	<span>
+	<?php if ((int)$preferences['suggestion_achat'] == 1)
+           echo $this->tagAnchor(['controller' => 'abonne', 'action' => 'suggestion-achat'], 
+																 '&raquo; '.$this->_('Suggérer un achat'));?>
+  </span> 
+</div>
+
+
+<?php
+$this->closeBoite();
+
+
+if (!isset($tags)) $tags=[];
+?>
+
+<div style="width:100%" class="conteneur_simple">
+	<?php
+	// Si facettes ou tags on ouvre un tableau a 2 colonnes
+	if ($hasFacettes	or ($hasTags and (2 == $tagsPosition))) 
+	{
+		?>
+		<table class="resultat_recherche" style="width:100%">
+			<tr>
+				<td style="vertical-align:top" style="width: 65%">
+		<?php
+	}
+
+	// Liste notices
+	echo $this->listeNotices($this->liste, 
+													 $nombre, 
+													 $page_cours, 
+													 $preferences, 
+													 $this->criteres_recherche);
+	?>
+	<br/>
+	<div style="width:100%;text-align:center;">
+	<?php 
+	echo $this->pager($nombre, 
+										$preferences["liste_nb_par_page"], 
+										$page_cours, 
+										$this->url_retour);?>
+  </div>
+	<?php
+	// Container notice pour listes d'images
+	if (3 < $preferences["liste_format"]) {
+		$notice_html= new Class_NoticeHtml();
+		print($notice_html->getConteneurNotice("notice"));
+	}
+
+	// Tags sous la liste
+	if ($hasTags and (1 == $tagsPosition)) {
+		print(BR . $this->nuageTags($tags, $preferences["tags_codes"]));
+	}
+
+	// Facettes et tags sous les facettes
+	if ($hasFacettes or $hasTags) { ?>
+		</td>
+		<td style="vertical-align:top;width: 35%">
+		<?php
+		if ($nombre) {
+			if ($hasFacettes) { ?>
+				<div class="facette_outer" style="margin-left:10px;margin-top:17px">
+					<?php if ($preferences["facettes_message"]) { ?>
+						<strong><?php echo $preferences["facettes_message"];?></strong><br/>
+					<?php } ?>
+					<?php 
+											
+													echo $this->facettes($facettes, $preferences, $this->url_facette); ?>
+				</div>
+			<?php
+			}
+
+			if ($hasTags and (2 == $tagsPosition)) { ?>
+				<div class="nuage_outer" style="margin-left:10px"><br/>
+					<?php if ($preferences["tags_message"]) { ?>
+						<strong><?php echo $preferences["tags_message"];?></strong>
+					<?php } ?>
+					<?php echo $this->nuageTags($tags, $preferences["tags_calcul"]); ?>
+				</div>
+			<?php
+			}
+		}
+		?>
+		</td>
+		</tr>
+	</table>
+	<?php } ?>
+
+</div>
+
+<script src="<?php echo URL_JS?>recherche.js" type="text/javascript"> </script>
 <link rel="stylesheet" type="text/css" media="screen" href="<?php echo URL_CSS?>recherche.css" />
\ No newline at end of file
diff --git a/application/modules/opac/views/scripts/recherche/saisie.phtml b/application/modules/opac/views/scripts/recherche/saisie.phtml
index 19a9bba7e41..49824352139 100644
--- a/application/modules/opac/views/scripts/recherche/saisie.phtml
+++ b/application/modules/opac/views/scripts/recherche/saisie.phtml
@@ -32,7 +32,7 @@ $this->closeBoite();
 	
 echo '<div class="conteneur_simple">';
 // Historique des recherches
-if($_SESSION["histo_recherche"]) $this->historiqueRecherche();
+$this->historiqueRecherche();
 
 echo '</div>';
 
diff --git a/library/Class/MoteurRecherche.php b/library/Class/MoteurRecherche.php
index e7ddfb5558c..030c167a016 100644
--- a/library/Class/MoteurRecherche.php
+++ b/library/Class/MoteurRecherche.php
@@ -295,7 +295,7 @@ class Class_MoteurRecherche {
 		$this->all_facettes .= ' +'.$indice.'*';
 		
 		$this->fil_ariane=$this->getFilAriane($fil,$indice);
-		xdebug_break();
+		
 // Tableau des rubriques
 		if($rubriques_tmp)
 			{
@@ -502,7 +502,7 @@ class Class_MoteurRecherche {
 // ----------------------------------------------------------------
 	private function addStatEchec($type_recherche,$criteres)
 	{
-		xdebug_break();
+		
 		$criteres=addslashes(serialize($criteres));
 		sqlExecute("insert into stats_recherche_echec(type_recherche,criteres) values($type_recherche,'$criteres')");
 	}
diff --git a/library/ZendAfi/View/Helper/HistoriqueRecherche.php b/library/ZendAfi/View/Helper/HistoriqueRecherche.php
index 11cb844f814..c0915dca010 100644
--- a/library/ZendAfi/View/Helper/HistoriqueRecherche.php
+++ b/library/ZendAfi/View/Helper/HistoriqueRecherche.php
@@ -20,111 +20,26 @@
  */
 class ZendAfi_View_Helper_HistoriqueRecherche extends ZendAfi_View_Helper_BaseHelper
 {
+	
+
 	public function historiqueRecherche()
 	{
+	$html='';
 		// Entete
-		printf('<h4>%s :</h4>', $this->translate()->_('Vos dernières recherches'));
-		print('<table style="width:100%">');
-		print('<tr>');
-		print('<th width="5%">&nbsp;</th>');
-		printf('<th width="10%%" align="left">%s</th>',$this->translate()->_('Type'));
-		printf('<th width="45%%" align="left">%s</th>', $this->translate()->_('Expression recherchée'));
-		printf('<th width="40%%" align="left">%s</th>', $this->translate()->_('Critères de sélection'));
-		print('</tr>');
-		print('<tr><td colspan="4" style="background: transparent url(\'../images/separ.gif) repeat-x scroll center top\'">&nbsp;</td></tr>');
+		$html .= '<h4>'.$this->view->_('Vos dernières recherches').'</h4>';
+		$html .= '<table style="width:100%"><tr>		<th width="5%">&nbsp;</th>';
+		$html .= '<th width="45%%" align="left">'.$this->view->_('Expression recherchée').'</th></tr>
+		<tr><td colspan="4" style="background: transparent url(\'../images/separ.gif) repeat-x scroll center top\'">&nbsp;</td></tr>';
 
-		// Lignes
-		for($i=count($_SESSION["histo_recherche"])-1; $i>=0; $i--)
-		{
-			$id_histo=$i;
-			$ligne=$_SESSION["histo_recherche"][$i];
-			$expression="";	$this->addCritere("RESET","","");
-			$criteres="";	$this->addSelection("RESET","","");
-			$crit=$ligne["selection"];
-			switch($ligne["type"])
+		$this->_session = new Zend_Session_Namespace('historiqueRecherche');
+		$criteres_recherche = $this->_session->criteres;
+	
+		foreach($criteres_recherche as $critere)
 			{
-				case 1: // recherche simple
-					$type="simple";
-					$expression=$crit["expressionRecherche"];
-					break;
-				case 2: // recherche avancée
-					$type="avancée";
-					// expression recherche
-					$expression=$this->addCritere($this->translate()->_("Titre"),$crit["operateur_titres"],$crit["rech_titres"]);
-					$expression=$this->addCritere($this->translate()->_("Auteur"),$crit["operateur_auteurs"],$crit["rech_auteurs"]);
-					$expression=$this->addCritere($this->translate()->_("Sujet"),$crit["operateur_matieres"],$crit["rech_matieres"]);
-					$expression=$this->addCritere($this->translate()->_("Dewey"),$crit["operateur_dewey"],$crit["rech_dewey"]);
-					$expression=$this->addCritere($this->translate()->_("Editeur"),$crit["operateur_editeur"],$crit["rech_editeur"]);
-					$expression=$this->addCritere($this->translate()->_("Collection"),$crit["operateur_collection"],$crit["rech_collection"]);
-					$expression=$this->addCritere($this->translate()->_("Dewey"),$crit["operateur_dewey"],$crit["rech_dewey"]);
-					// criteres de selection
-					$criteres=$this->addSelection($this->translate()->_("Année début"),$crit["annee_debut"]);
-					$criteres=$this->addSelection($this->translate()->_("Année fin"),$crit["annee_fin"]);
-					$criteres=$this->addSelection($this->translate()->_("Nouveautés"),$crit["nouveaute"]);
-					$criteres=$this->addSelection($this->translate()->_("année début"),$crit["annee_debut"]);
-					break;
+				$html.=$this->view->tagHistoriqueRecherche(unserialize($critere));
 			}
-			// Criteres de selection communs
-			$criteres=$this->addSelection($this->translate()->_("Type de doc."),$crit["type_doc"]);
-			$criteres=$this->addSelection($this->translate()->_("Bibliothèques"),$crit["selection_bib"]);
-			
-			// Url pour relancer la recherche
-			$url=BASE_URL."/recherche/histo?id_histo=".$id_histo;
-			
-			printf('<tr style="cursor:pointer" onclick="document.location=\''.$url.'\'" title="%s">', $this->translate()->_('Relancer cette recherche'));
-			printf('<td valign="top" style="text-align:center"><img src="'.URL_IMG.'bouton/loupe.gif" border="0" title="%s"></td>', $this->translate()->_('Relancer cette recherche'));
-			print('<td valign="top">'.$type.'</td>');
-			print('<td valign="top">'.$expression.'</td>');
-			print('<td valign="top">'.$criteres.'</td>');
-			print('</tr>');
-		}
-		print('</table>'.BR.BR);
+		return "<div class='criteres_recherche'>".$html."</table></div>";
 	}
 
-//------------------------------------------------------------------------------------------------------	
-// Fonctions privees
-//------------------------------------------------------------------------------------------------------
-	private function addCritere($libelle,$operateur,$texte)
-	{
-		global $expression;
-		if($libelle == "RESET"){ $expression=""; return; }
-		if(!$texte) return $expression;
-		if($expression) $expression.=BR;
 
-		switch($operateur)	{
-  		case "or": $expression.=$this->translate()->_("%s ", 'ou'); break;
-	  	case "not": $expression.=$this->translate()->_("%s ", 'sauf'); break;
-		}
-		$expression.=$libelle;
-		$expression.="=".$texte;
-		return $expression;
-	}
-	
-	private function addSelection($libelle,$valeur)
-	{
-		global $criteres;
-		if($libelle == "RESET"){ $criteres=""; return; }
-		if(!trim($valeur)) return $criteres;
-		if($libelle == $this->translate()->_("Type de doc."))
-		{
-			if(!$valeur or $valeur == "0") return $criteres;
-			$valeur=Class_Codification::getInstance()->getLibelleFacette("T".$valeur);
-		}
-		if($libelle == $this->translate()->_("Bibliothèques") and trim($valeur) > "" )
-		{
-			$bibs=explode(" ",$valeur);
-			$valeur="";
-			foreach($bibs as $bib)
-			{
-				if(!trim($bib)) continue;
-				$id_bib=(int)substr($bib,1);
-				$lib=fetchOne("select nom_court from int_bib where id_bib=$id_bib");
-				if($valeur) $valeur.=", ";
-				$valeur.=$lib;
-			}
-		}
-		if($criteres) $criteres.=BR;
-		$criteres.=$libelle."=".$valeur;
-		return $criteres;
-	}
 }
\ No newline at end of file
diff --git a/library/ZendAfi/View/Helper/TagCriteresRecherche.php b/library/ZendAfi/View/Helper/TagCriteresRecherche.php
index 75eea13e91b..29df8c6a64a 100644
--- a/library/ZendAfi/View/Helper/TagCriteresRecherche.php
+++ b/library/ZendAfi/View/Helper/TagCriteresRecherche.php
@@ -25,6 +25,11 @@ class ZendAfi_View_Helper_TagCriteresRecherche extends Zend_View_Helper_HtmlElem
 	protected $_current_facettes = [];
 	
 	public function tagCriteresRecherche($criteres_recherche) {
+		$this->visitCriteresRecherche($criteres_recherche);
+		return '<div class="criteres_recherche">'.$this->_html.'</div>';
+	}
+
+	public function visitCriteresRecherche($criteres_recherche) {
 		if (!isset($criteres_recherche))
 			return '';
 		$this->_criteres_recherche=$criteres_recherche;
@@ -45,13 +50,18 @@ class ZendAfi_View_Helper_TagCriteresRecherche extends Zend_View_Helper_HtmlElem
 		if (isset($criteres_recherche)) 
 			$criteres_recherche->acceptVisitor($this);
 
-		return '<div class="criteres_recherche">'.$this->_html.'</div>';
+	
 	}
 
-
 	public function visitTextInput($name, $operateur, $type_recherche, $value) {
+	
+		if (!$operateur) 
+			$libelle_operateur = " et ";
+		else $libelle_operateur = $this->_libelles_operateur[$operateur];
+
+					
 		$this->htmlAppend(
-			$this->_libelles_operateur[$operateur] .
+			$libelle_operateur.
 			$this->_libelles_criteres[$name].
 			' '.$this->_($type_recherche == 'contient' ? 'contient' : 'commence par').' '.
 			$value);
@@ -109,6 +119,8 @@ class ZendAfi_View_Helper_TagCriteresRecherche extends Zend_View_Helper_HtmlElem
 
 	public function visitCatalogue($catalogue) {
 	}
+
+
 	public function htmlAppend($text) {
 		$this->_html .= '<div>'.$text.'</div>';
 		return $this;
diff --git a/library/ZendAfi/View/Helper/TagHistoriqueRecherche.php b/library/ZendAfi/View/Helper/TagHistoriqueRecherche.php
new file mode 100644
index 00000000000..880cfb07dc0
--- /dev/null
+++ b/library/ZendAfi/View/Helper/TagHistoriqueRecherche.php
@@ -0,0 +1,88 @@
+<?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_TagHistoriqueRecherche extends ZendAfi_View_Helper_TagCriteresRecherche {
+
+	protected $_html = '';
+	protected $_current_facettes = [];
+	
+	public function tagHistoriqueRecherche($criteres_recherche) {
+		$this->_html='';
+		parent::visitCriteresRecherche($criteres_recherche);
+		$url=$this->view->url($this->_criteres_recherche->getUrlCriteresWithFacettes(),null,true);
+	
+		$this->_html='<tr style="cursor:pointer" onclick="document.location=\''.$url.'\'" title="'.$this->view->_(' cette recherche').'">'.'<td valign="top" style="text-align:center"><img src="'.URL_IMG.'bouton/loupe.gif" border="0" title="'.$this->view->_('Relancer cette recherche').'"></td><td>'.$this->_html;
+					
+		return $this->_html."</td></tr>";
+	}
+
+
+	public function visitTextInput($name, $operateur, $type_recherche, $value) {
+	
+		if (!$operateur) 
+			$libelle_operateur = " et ";
+		else $libelle_operateur = $this->_libelles_operateur[$operateur];
+
+					
+		$this->htmlAppend(
+			$libelle_operateur.
+			$this->_libelles_criteres[$name].
+			' '.$this->_($type_recherche == 'contient' ? 'contient' : 'commence par').' '.
+			$value);
+	}
+
+	public function visitNouveaute($nouveaute) {
+	$this->_html='<div>'.$this->view->_('Nouveauté de moins de : ').$nouveaute.' mois</div>';
+	}
+
+
+	public function visitAnneeDebutFin($annee_debut, $annee_fin) {
+		$texte = $this->view->_("Documents parus ");
+		$texte .= ($annee_debut == $annee_fin) 
+			? "en " . $annee_debut 
+			: $this->view->_("entre %s et %s", $annee_debut, $annee_fin);
+		$this->htmlAppend($texte);
+	}
+
+
+	public function visitFacette($facette) {
+		$libelle = Class_Codification::getInstance()->getNomFacette($facette).': '.Class_Codification::getInstance()->getLibelleFacette($facette);
+		$facettes = array_diff($this->_current_facettes, [$facette] );
+		$url=$this->_criteres_recherche->getUrlRetourListe();
+		$url['facettes']=implode('-', $facettes);
+		$url = array_filter($url);
+		$this->htmlAppend($libelle);
+	}
+
+
+	public function htmlAppend($text) {
+		$this->_html .= '<div>'.$text."</div>";
+		return $this;
+	}
+
+
+	public function visitExpression($expression) {
+		$this->htmlAppend($expression);
+	}
+
+
+}
+
+?>
\ No newline at end of file
diff --git a/library/ZendAfi/View/Helper/UrlNotice.php b/library/ZendAfi/View/Helper/UrlNotice.php
index 35dbde7beac..b2dbaca42af 100644
--- a/library/ZendAfi/View/Helper/UrlNotice.php
+++ b/library/ZendAfi/View/Helper/UrlNotice.php
@@ -24,7 +24,6 @@ class ZendAfi_View_Helper_UrlNotice extends Zend_View_Helper_HtmlElement {
 	 * @param mixed $notice array or Class_Notice
 	 */
 	public function urlNotice($notice, $id_panier = null) {
-		xdebug_break();
 		if (!$notice)
 			return $this->view->url(['controller'=>'recherche',
 															 'action' => 'simple']);
diff --git a/tests/library/Class/CommSigbTest.php b/tests/library/Class/CommSigbTest.php
index 6f57b288a59..0f255b9b2e3 100644
--- a/tests/library/Class/CommSigbTest.php
+++ b/tests/library/Class/CommSigbTest.php
@@ -193,7 +193,7 @@ abstract class CommSigbTestCase extends Storm_Test_ModelTestCase {
 						 'ABC')
 			->will($this->returnValue(array('statut' => 1,
 																			'erreur' => '')));
-		xdebug_break();
+		
 		$this->assertEquals(array('statut' => 1,
 															'erreur' => ''),
 												$this->comm_sigb->reserverExemplaire(5, '123', 'ABC'));
diff --git a/tests/library/ZendAfi/View/Helper/HistoriqueRechercheTest.php b/tests/library/ZendAfi/View/Helper/HistoriqueRechercheTest.php
new file mode 100644
index 00000000000..580945fb23c
--- /dev/null
+++ b/tests/library/ZendAfi/View/Helper/HistoriqueRechercheTest.php
@@ -0,0 +1,69 @@
+<?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_HistoriqueRechercheTest extends ViewHelperTestCase {
+
+	public function setUp() {
+		parent::setUp();
+		$this->_session = new Zend_Session_Namespace('historiqueRecherche');
+		$criteres =  new Class_CriteresRecherche();
+		$criteres->setParams(['expressionRecherche' => 'Millenium']);
+		$criteres_auteur = new Class_CriteresRecherche();
+		$criteres_auteur->setParams(['rech_auteurs' => 'Larsson',
+																 	 'operateur_auteurs'=>'and',
+																	'rech_titres' => 'Les hommes qui n\'aimaient pas les femmes']);
+		
+		$this->_session->criteres=[serialize($criteres),serialize($criteres_auteur)];
+		$view = new ZendAfi_Controller_Action_Helper_View();
+		$this->_helper = new ZendAfi_View_Helper_HistoriqueRecherche();
+		$this->_helper->setView($view);
+	
+	}
+
+
+
+	/** @test */
+	public function milleniumShouldBeDisplayed() {
+		$this->assertXPathContentContains($this->_helper->historiqueRecherche(), 
+																			'//div',
+																			'Millenium');
+	}
+
+	/** @test */
+	public function milleniumAndLarssonShouldBeDisplayed() {
+		$this->assertXPathContentContains($this->_helper->historiqueRecherche(), 
+																			'//div',
+																			'Larsson');
+	}
+
+	/** @test */
+	public function URLRechercheSimpleShouldBeDisplay(){
+		$this->assertXPath($this->_helper->historiqueRecherche(), 
+											 '//tr[contains(@onclick, "/recherche/simple/expressionRecherche/Millenium")]');
+	}
+
+	/** @test */
+	public function URLRechercheAvanceShouldBeDisplay(){
+		$this->assertXPath($this->_helper->historiqueRecherche(), 
+											 '//tr[contains(@onclick, "/recherche/simple/rech_titres/Les+hommes+qui+n%27aimaient+pas+les+femmes/rech_auteurs/Larsson")]',$this->_helper->historiqueRecherche());
+	}
+	
+}
-- 
GitLab