From 4ffeb0b4beecf3e2c850e4084b60d996b6addfd3 Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@git-test.afi-sa.fr>
Date: Wed, 3 Apr 2013 17:59:45 +0000
Subject: [PATCH] recherche avancee : prise en compte des operateurs dans les
 valeurs par defaut lors d'un retour a la recherche initiale

---
 .../views/scripts/recherche/avancee.phtml     | 36 +++++++++----------
 library/Class/CriteresRecherche.php           | 12 +++++--
 .../View/Helper/HistoriqueRecherche.php       |  2 +-
 3 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/application/modules/opac/views/scripts/recherche/avancee.phtml b/application/modules/opac/views/scripts/recherche/avancee.phtml
index 693a862ac68..c335ba0ed65 100644
--- a/application/modules/opac/views/scripts/recherche/avancee.phtml
+++ b/application/modules/opac/views/scripts/recherche/avancee.phtml
@@ -11,9 +11,9 @@ if ($this->statut == "saisie") {
 							<tr>
 								<td>
 									<select name="operateur_titres" style="width:50px">
-										<option value="and" <?php if ($this->operateur_titres == "and") print('selected="selected"'); ?>><?php echo $this->_('et'); ?></option>
-										<option value="or" <?php if ($this->operateur_titres == "or") print('selected="selected"'); ?>><?php echo $this->_('ou'); ?></option>
-										<option value="and not" <?php if ($this->operateur_titres == "and not") print('selected="selected"'); ?>><?php echo $this->_('sauf'); ?></option>
+										<option value="and" <?php if ($this->criteres_recherche->getParam('operateur_titres') == "and") print('selected="selected"'); ?>><?php echo $this->_('et'); ?></option>
+										<option value="or" <?php if ($this->criteres_recherche->getParam('operateur_titres') == "or") print('selected="selected"'); ?>><?php echo $this->_('ou'); ?></option>
+										<option value="and not" <?php if ($this->criteres_recherche->getParam('operateur_titres') == "and not") print('selected="selected"'); ?>><?php echo $this->_('sauf'); ?></option>
 									</select>
 								</td>
 								<td><?php echo $this->_('Titres') ?></td>
@@ -22,9 +22,9 @@ if ($this->statut == "saisie") {
 							<tr>
 								<td>
 									<select name="operateur_auteurs" style="width:50px">
-										<option value="and" <?php if ($this->operateur_auteurs == "and") print('selected="selected"'); ?>><?php echo $this->_('et'); ?></option>
-										<option value="or" <?php if ($this->operateur_auteurs == "or") print('selected="selected"'); ?>><?php echo $this->_('ou'); ?></option>
-										<option value="and not" <?php if ($this->operateur_auteurs == "and not") print('selected="selected"'); ?>><?php echo $this->_('sauf'); ?></option>
+										<option value="and" <?php if ($this->criteres_recherche->getParam('operateur_auteurs') == "and") print('selected="selected"'); ?>><?php echo $this->_('et'); ?></option>
+										<option value="or" <?php if ($this->criteres_recherche->getParam('operateur_auteurs') == "or") print('selected="selected"'); ?>><?php echo $this->_('ou'); ?></option>
+										<option value="and not" <?php if ($this->criteres_recherche->getParam('operateur_auteurs') == "and not") print('selected="selected"'); ?>><?php echo $this->_('sauf'); ?></option>
 									</select>
 								</td>
 								<td><?php echo $this->_('Auteurs'); ?></td>
@@ -33,9 +33,9 @@ if ($this->statut == "saisie") {
 							<tr>
 								<td>
 									<select name="operateur_matieres" style="width:50px">
-										<option value="and" <?php if ($this->operateur_matieres == "and") print('selected="selected"'); ?>><?php echo $this->_('et'); ?></option>
-										<option value="or" <?php if ($this->operateur_matieres == "or") print('selected="selected"'); ?>><?php echo $this->_('ou'); ?></option>
-										<option value="and not" <?php if ($this->operateur_matieres == "and not") print('selected="selected"'); ?>><?php echo $this->_('sauf'); ?></option>
+										<option value="and" <?php if ($this->criteres_recherche->getParam('operateur_matieres') == "and") print('selected="selected"'); ?>><?php echo $this->_('et'); ?></option>
+										<option value="or" <?php if ($this->criteres_recherche->getParam('operateur_matieres') == "or") print('selected="selected"'); ?>><?php echo $this->_('ou'); ?></option>
+										<option value="and not" <?php if ($this->criteres_recherche->getParam('operateur_matieres') == "and not") print('selected="selected"'); ?>><?php echo $this->_('sauf'); ?></option>
 									</select>
 								</td>
 								<td><?php echo $this->_('Sujets'); ?></td>
@@ -44,9 +44,9 @@ if ($this->statut == "saisie") {
 							<tr>
 								<td>
 									<select name="operateur_dewey" style="width:50px">
-										<option value="and" <?php if ($this->operateur_dewey == "and") print('selected="selected"'); ?>><?php echo $this->_('et'); ?></option>
-										<option value="or" <?php if ($this->operateur_dewey == "or") print('selected="selected"'); ?>><?php echo $this->_('ou'); ?></option>
-										<option value="and not" <?php if ($this->operateur_dewey == "and not") print('selected="selected"'); ?>><?php echo $this->_('sauf'); ?></option>
+										<option value="and" <?php if ($this->criteres_recherche->getParam('operateur_dewey') == "and") print('selected="selected"'); ?>><?php echo $this->_('et'); ?></option>
+										<option value="or" <?php if ($this->criteres_recherche->getParam('operateur_dewey') == "or") print('selected="selected"'); ?>><?php echo $this->_('ou'); ?></option>
+										<option value="and not" <?php if ($this->criteres_recherche->getParam('operateur_dewey') == "and not") print('selected="selected"'); ?>><?php echo $this->_('sauf'); ?></option>
 									</select>
 								</td>
 								<td><?php echo $this->_("Centres d'intérêt"); ?></td>
@@ -55,9 +55,9 @@ if ($this->statut == "saisie") {
 							<tr>
 								<td>
 									<select name="operateur_editeur" style="width:50px">
-										<option value="and" <?php if ($this->operateur_editeur == "and") print('selected="selected"'); ?>><?php echo $this->_('et'); ?></option>
-										<option value="or" <?php if ($this->operateur_editeur == "or") print('selected="selected"'); ?>><?php echo $this->_('ou'); ?></option>
-										<option value="and not" <?php if ($this->operateur_editeur == "and not") print('selected="selected"'); ?>><?php echo $this->_('sauf'); ?></option>
+	<option value="and" <?php if ($this->criteres_recherche->getParam('operateur_editeur') == "and") print('selected="selected"'); ?>><?php echo $this->_('et'); ?></option>
+										<option value="or"  <?php if ($this->criteres_recherche->getParam('operateur_editeur') == "or") print('selected="selected"'); ?>><?php echo $this->_('ou'); ?></option>
+										<option value="and not" <?php if ($this->criteres_recherche->getParam('operateur_editeur') == "and not") print('selected="selected"'); ?>><?php echo $this->_('sauf'); ?></option>
 									</select>
 								</td>
 								<td><?php echo $this->_('Editeur'); ?></td>
@@ -66,9 +66,9 @@ if ($this->statut == "saisie") {
 							<tr>
 								<td>
 									<select name="operateur_collection" style="width:50px">
-										<option value="and" <?php if ($this->operateur_collection == "and") print('selected="selected"'); ?>><?php echo $this->_('et'); ?></option>
-										<option value="or" <?php if ($this->operateur_collection == "or") print('selected="selected"'); ?>><?php echo $this->_('ou'); ?></option>
-										<option value="and not" <?php if ($this->operateur_collection == "and not") print('selected="selected"'); ?>><?php echo $this->_('sauf'); ?></option>
+										<option value="and" <?php if ($this->criteres_recherche->getParam('operateur_collection') == "and") print('selected="selected"'); ?>><?php echo $this->_('et'); ?></option>
+										<option value="or" <?php if ($this->criteres_recherche->getParam('operateur_collection') == "or") print('selected="selected"'); ?>><?php echo $this->_('ou'); ?></option>
+										<option value="and not" <?php if ($this->criteres_recherche->getParam('operateur_collection') == "and not") print('selected="selected"'); ?>><?php echo $this->_('sauf'); ?></option>
 									</select>
 								</td>
 								<td><?php echo $this->_('Collection'); ?></td>
diff --git a/library/Class/CriteresRecherche.php b/library/Class/CriteresRecherche.php
index d16b5c2e617..281d2f5f132 100644
--- a/library/Class/CriteresRecherche.php
+++ b/library/Class/CriteresRecherche.php
@@ -41,14 +41,20 @@ class Class_CriteresRecherche {
 		'tri' => 'Trié par',
 		'id_catalogue' => "Catalogue",
 		'id_panier' => "Panier",
-		'retour_panier' => "Panier"
-
+		'retour_panier' => "Panier",
+		'operateur_editeur'=> "op editeur",
+		'operateur_titres'=> '',
+		'operateur_auteurs'=> '',
+		'operateur_matieres' => '',
+		'operateur_dewey'=>'',
+		'operateur_editeur'=>'',
+		'operateur_collection'=>''
 	];
 	public function __construct()	{
 		$this->_profil = Class_Profil::getCurrentProfil();
 	}
 	public function getValidParameters() {
-		return array_merge(array_keys(self::$criteres), [ 'filtres','id_user','id_module', 'facette','facettes', 'operateur_titres','operateur_auteurs','operateur_matieres','operateur_dewey','operateur_editeur','operateur_collection','code_rebond','pertinence','type_recherche','section','annexe','geo_zone','fil','bib_select']);
+		return array_merge(array_keys(self::$criteres), [ 'filtres','id_user','id_module', 'facette','facettes','code_rebond','pertinence','type_recherche','section','annexe','geo_zone','fil','bib_select']);
 	}
 
 	public function getListeTris() {
diff --git a/library/ZendAfi/View/Helper/HistoriqueRecherche.php b/library/ZendAfi/View/Helper/HistoriqueRecherche.php
index c0915dca010..c7b3ee376a4 100644
--- a/library/ZendAfi/View/Helper/HistoriqueRecherche.php
+++ b/library/ZendAfi/View/Helper/HistoriqueRecherche.php
@@ -32,7 +32,7 @@ class ZendAfi_View_Helper_HistoriqueRecherche extends ZendAfi_View_Helper_BaseHe
 		<tr><td colspan="4" style="background: transparent url(\'../images/separ.gif) repeat-x scroll center top\'">&nbsp;</td></tr>';
 
 		$this->_session = new Zend_Session_Namespace('historiqueRecherche');
-		$criteres_recherche = $this->_session->criteres;
+		$criteres_recherche = array_reverse($this->_session->criteres);
 	
 		foreach($criteres_recherche as $critere)
 			{
-- 
GitLab