Skip to content
Snippets Groups Projects
Commit 72f59a12 authored by efalcy's avatar efalcy
Browse files

Historique & Recherche vide

Historique : optimise le stockage en session
Recherche vide : considere la recherche vide comme une recherche '*' (et la recheche '*' recherche sur tout le catalogue)
parent 633ea8da
Branches
Tags
No related merge requests found
......@@ -22,7 +22,6 @@
class Class_CriteresRecherche {
use Trait_Translator;
protected $_expression;
protected $_params;
protected $_profil;
public static $criteres = [
......@@ -53,6 +52,20 @@ class Class_CriteresRecherche {
public function __construct() {
$this->_profil = Class_Profil::getCurrentProfil();
}
public function __wakeup() {
$this->_profil = Class_Profil::getCurrentProfil();
}
public function __sleep() {
return [
'_params'
];
}
public function getValidParameters() {
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']);
}
......@@ -319,14 +332,24 @@ class Class_CriteresRecherche {
}
public function replaceEmptyRechercheByStar($params) {
if (isset( $params['expressionRecherche']) && $params['expressionRecherche']==='')
$params['expressionRecherche']='*';
return $params;
}
public function filterParams($params) {
$valid_parameters = $this->getValidParameters();
$filtered_params = [];
$params= $this->replaceEmptyRechercheByStar($params);
foreach($valid_parameters as $key) {
if (array_isset($key, $params)) {
if (preg_match('/^operateur_/', $key) && (!array_key_exists(str_replace('operateur_','rech_',$key),$params) || $params[str_replace('operateur_','rech_',$key)]=='')) {
continue;
}
......
......@@ -66,7 +66,9 @@ class Class_MoteurRecherche {
public function visitExpression($expression,$pertinence,$tri) {
// Analyse de l'expression
$expression = trim($expression);
if ($expression == '*') {
return;
}
// Recherche par isbn (1 seul mot et isbn ou ean valide)
$recherche = '';
if (!$mode_isbn = $this->createReqForIsbn($expression)) {
......@@ -79,6 +81,7 @@ class Class_MoteurRecherche {
$recherche .= ' ';
$recherche .= ($pertinence ? ' ' : '+') . $mot;
}
}
......@@ -89,7 +92,7 @@ class Class_MoteurRecherche {
$this->setErreur(("Il n'y aucun mot assez significatif pour la recherche"));
return ;
}
if ($pertinence == true)
$against=" AGAINST('".$recherche."')";
else
......
......@@ -41,7 +41,7 @@ class ZendAfi_View_Helper_Accueil_RechSimple extends ZendAfi_View_Helper_Accueil
$arg_filtre = '';
if(array_isset("type_doc", $this->preferences)) $arg_filtre="?facette=T".$this->preferences["type_doc"];
$this->contenu.='<form name="form" action="'.BASE_URL.'/opac/recherche/simple'.$arg_filtre.'" method="post" class="rechSimpleForm">';
$this->contenu.='<form name="form" action="'.BASE_URL.'/opac/recherche/simple'.$arg_filtre.'" method="get" class="rechSimpleForm">';
$this->contenu.= '<div>';
$this->contenu.='<div'.$float.'><label for="expressionRecherche_'.$this->id_module.'">'.$this->preferences["message"].'&nbsp;</label></div>';
......
......@@ -43,6 +43,15 @@ class CriteresRerchercheRetourTest extends AbstractControllerTestCase {
'facettes' => 'B1-T1'
]],
[['expressionRecherche' => '',
'facettes' => 'V1',
'facette' => 'U1'], ['controller' => 'recherche',
'action' => 'simple',
'expressionRecherche' => '*',
'facettes' => 'V1-U1'
]],
[['rech_titres' => 'metropolitan',
'rech_auteurs' =>'',
'facettes' => 'T1-YMET'], ['controller' => 'recherche',
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment