Skip to content
Snippets Groups Projects

Sandbox improve search page

Closed Ghislain Loas requested to merge sandbox_improve_search_page into WIP
Files
28
@@ -25,6 +25,23 @@ class RechercheController extends ZendAfi_Controller_Action {
$preferences;
public function preDispatch() {
parent::preDispatch();
$dispatcher = $this->getFrontController()->getDispatcher();
$search_term = $this->_request->getActionName();
$action = $dispatcher->formatActionName($search_term);
if (!in_array($action, get_class_methods($this)))
$this->_forward('simple',
'recherche',
'opac',
array_merge($this->_request->getParams(),
['q' => urldecode($search_term)]));
}
public function getPlugins() {
return ['ZendAfi_Controller_Plugin_Printer_ModelFusion'];
}
@@ -119,16 +136,20 @@ class RechercheController extends ZendAfi_Controller_Action {
$this->preferences['liste_format'] = $this->_getParam('liste_format', $this->preferences['liste_format']);
if (!$search_result->isError())
$this->addHistoRecherche(1, $criteres_recherche);
$this->addHistoRecherche($criteres_recherche);
$this->view->titre = $this->getTitreRechercheSimple($criteres_recherche);
if($criteres_recherche->getPertinence())
$this->view->titre .= $this->_(' (recherche élargie triée par pertinence)');
$this->view->search_duration = microtime(true) - $search_start_time;
$this->view->search_result = $search_result
->setDuration(microtime(true) - $search_start_time)
->setDuration($this->view->search_duration)
->setSettings($this->preferences);
$this->addHistoRecherche($criteres_recherche);
}
@@ -400,19 +421,16 @@ class RechercheController extends ZendAfi_Controller_Action {
}
private function addHistoRecherche($type,$criteres_recherche) {
if ($criteres_recherche->getFacettes())
return ;
protected function addHistoRecherche($criteres_recherche) {
$criteres_recherche->setTime(microtime(true));
$criteres_histo = clone $criteres_recherche;
$histo_session = new Zend_Session_Namespace('historiqueRecherche');
if (null == ($criteres = $histo_session->criteres)) {
$criteres=[serialize($criteres_histo)];
}
else {
$criteres[]=serialize($criteres_histo);
}
$histo_session->criteres=array_unique($criteres);
(null == ($criteres = $histo_session->criteres))
? ($criteres = [serialize($criteres_histo)])
: ($criteres[] = serialize($criteres_histo));
return $histo_session->criteres = array_unique($criteres);
}
@@ -540,10 +558,9 @@ class RechercheController extends ZendAfi_Controller_Action {
public function suggestajaxAction() {
if (!$startsWith = trim($this->_getParam('startsWith'))) {
$this->_helper->json([]);
return;
}
if (!$startsWith = trim($this->_getParam('startsWith')))
return $this->_helper->json([]);
$results = Class_Autocomplete_Index::searchAll($startsWith);
$terms = Class_Autocomplete_IndexSearcher::extractTerms($startsWith);
$term_regex = '/('.implode('|', $terms).')/iu';
@@ -788,7 +805,8 @@ class RechercheController extends ZendAfi_Controller_Action {
protected function newCriteresRecherches($params) {
$criteres = (new Class_CriteresRecherche())->setParams($params);
$criteres = (new Class_CriteresRecherche())
->setParams($params);
if (isset($this->preferences['liste_nb_par_page']))
$criteres->setDefaultPageSize($this->preferences['liste_nb_par_page']);