Skip to content
Snippets Groups Projects

Master

Merged Ghislain Loas requested to merge master into dev_#25821_skin_mobile
Compare and
+ 385
107
Preferences
Compare changes
Files
@@ -20,9 +20,10 @@
*/
class RechercheController extends ZendAfi_Controller_Action {
private $moteur;
private $liste;
private $preferences;
protected
$moteur,
$liste,
$preferences;
public function init() {
@@ -41,12 +42,12 @@ class RechercheController extends ZendAfi_Controller_Action {
}
public function _getListNotices($req) {
public function _getListNotices($criteres_recherche, $req) {
if (!$req)
return [];
return Class_Notice::findAllByRequeteRecherche($req,
$this->preferences['liste_nb_par_page'],
$criteres_recherche->getPageSize(),
$this->_getParam('page',1));
}
@@ -80,8 +81,7 @@ class RechercheController extends ZendAfi_Controller_Action {
unset($params['q']);
}
$criteres_recherche = new Class_CriteresRecherche();
$criteres_recherche->setParams($params);
$criteres_recherche = $this->newCriteresRecherches($params);
if ('json' == $this->_getParam('format', '')) {
$this->_renderJsonResult($criteres_recherche);
@@ -109,7 +109,7 @@ class RechercheController extends ZendAfi_Controller_Action {
protected function _renderJsonResult($criteres_recherche) {
$datas = ['url' => Class_Url::absolute(),
'total' => 0,
'page_size' => $this->preferences['liste_nb_par_page'],
'page_size' => $criteres_recherche->getPageSize(),
'page' => $this->_getParam('page', 1),
'records' => []];
@@ -121,7 +121,7 @@ class RechercheController extends ZendAfi_Controller_Action {
$datas['total'] = $ret['nombre'];
$records = [];
(new Storm_Model_Collection($this->_getListNotices($ret['req_liste'])))
(new Storm_Model_Collection($this->_getListNotices($criteres_recherche, $ret['req_liste'])))
->eachDo(
function($record) use (&$records) {
$json = new Class_Notice_JsonVisitor();
@@ -231,9 +231,10 @@ class RechercheController extends ZendAfi_Controller_Action {
$this->addHistoRecherche(1,$criteres_recherche);
$this->view->liste = $this->_getListNotices($ret['req_liste']);
$this->view->liste = $this->_getListNotices($criteres_recherche, $ret['req_liste']);
$resultat = ['page_cours' => $this->_getParam('page'),
'page_size' => $criteres_recherche->getPageSize(),
'nombre' => $ret['nombre']];
$facettes = $this->moteur->getFacettes($ret["req_facettes"], $this->preferences);
@@ -257,8 +258,7 @@ class RechercheController extends ZendAfi_Controller_Action {
foreach($annexes as $annexe)
$this->view->annexes[$annexe->getCode()] = $annexe->getLibelle();
$this->view->criteres_recherche = (new Class_CriteresRecherche())
->setParams(array_filter($this->_request->getParams()));
$this->view->criteres_recherche = $this->newCriteresRecherches($this->_request->getParams());
}
@@ -298,7 +298,7 @@ class RechercheController extends ZendAfi_Controller_Action {
$ig->logRecord($this->view->notice_Unimarc($notice));
$notice_navigation = new Class_Notice_NavigationRecherche(
(new Class_CriteresRecherche())->setParams($this->_request->getParams()),
$this->newCriteresRecherches($this->_request->getParams()),
$this->moteur,
$notice);
@@ -328,7 +328,7 @@ class RechercheController extends ZendAfi_Controller_Action {
$this->view->notice = $notice;
$this->view->preferences = $this->preferences;
$criteres_recherche = (new Class_CriteresRecherche())->setParams($this->_request->getParams());
$criteres_recherche = $this->newCriteresRecherches($this->_request->getParams());
$this->view->criteres_recherche = $criteres_recherche;
$this->view->display_modifier_vignette_link = Class_Users::isCurrentUserCanAccesBackend() && $notice->isVignetteUpdatableToCacheServer();
@@ -741,5 +741,15 @@ class RechercheController extends ZendAfi_Controller_Action {
echo $unimarc;
}
protected function newCriteresRecherches($params) {
$criteres = (new Class_CriteresRecherche())->setParams($params);
if (isset($this->preferences['liste_nb_par_page']))
$criteres->setDefaultPageSize($this->preferences['liste_nb_par_page']);
return $criteres;
}
}
?>
\ No newline at end of file