Commit 4a6ddb54 authored by Laurent's avatar Laurent
Browse files

dev #13615 fix search result back links + refactoring

parent 29dfc640
......@@ -669,36 +669,52 @@ class Class_CriteresRecherche {
public function getUrlRetourRechercheInitiale(){
if ($url = $this->_getNotSearchPagesBackUrl())
return array_filter($url);
if (array_key_exists('rubrique', $this->_params))
return ['controller' => 'recherche',
'action' => 'guidee' ];
$action = 'avancee';
if (array_key_exists('expressionRecherche',$this->_params) || array_key_exists('id_panier',$this->_params) || array_key_exists('id_catalogue',$this->_params))
$action = 'saisie';
if (array_key_exists('retour_panier', $this->_params))
$url = array_merge(array_intersect_key($this->_params, self::$criteres),
['controller' => 'recherche',
'action' => $action ]);
return array_filter($url);
}
protected function _getNotSearchPagesBackUrl() {
if (array_key_exists('retour_panier',$this->_params))
return ['controller' => 'panier',
'action' => 'index',
'id_panier' => $this->_params['retour_panier']];
'id_panier' => $this->_params['retour_panier']] ;
if (array_key_exists('retour_abonne',$this->_params)) {
$url = ['controller' => 'abonne',
'action' => $this->_params['retour_abonne'],
'page' => isset($this->_params['page']) ? $this->_params['page'] : null] ;
return array_filter($url);
};
if (array_key_exists('retour_abonne',$this->_params))
return ['controller' => 'abonne',
'action' => $this->_params['retour_abonne'],
'page' => $this->getParam('page') ,
'page_size' => $this->getParam('page_size')];
if (array_key_exists('rubrique',$this->_params))
return ['controller' => 'recherche',
'action' => 'guidee' ];
$url = array_merge(array_intersect_key($this->_params, self::$criteres),
['controller' => 'recherche',
'action' => $action ]);
if (array_key_exists('retour_avis',$this->_params))
return ['controller' => 'blog',
'action' => 'viewcritiques',
'id_module' => $this->_params['retour_avis'],
'retour_avis' => $this->_params['retour_avis']] ;
return array_filter($url);
return null;
}
public function getUrlCriteresWithFacettes() {
$intersect=$this->_params;
if ($this->getFacettesUrlEncoded()!='')
......@@ -792,26 +808,9 @@ class Class_CriteresRecherche {
public function getUrlRetourListe() {
if (!array_key_exists('code_rebond', $this->_params)) {
if (array_key_exists('retour_panier',$this->_params))
return ['controller' => 'panier',
'action' => 'index',
'id_panier' => $this->_params['retour_panier']] ;
if (array_key_exists('retour_abonne',$this->_params)) {
$url = ['controller' => 'abonne',
'action' => $this->_params['retour_abonne'],
'page' => isset($this->_params['page']) ? $this->_params['page'] : null] ;
return array_filter($url);
};
if (array_key_exists('retour_avis',$this->_params))
return ['controller' => 'blog',
'action' => 'viewcritiques',
'id_module' => $this->_params['retour_avis'],
'retour_avis' => $this->_params['retour_avis']] ;
}
if (!array_key_exists('code_rebond', $this->_params)
&& ($url = $this->_getNotSearchPagesBackUrl()))
return array_filter($url);
return $this->getUrlCriteresWithFacettes();
}
......
......@@ -21,17 +21,20 @@
class ZendAfi_View_Helper_Abonne_LoansHistory extends ZendAfi_View_Helper_Abonne_Loans {
protected $_paginator;
public function abonne_LoansHistory($loans, $page_number, $page_size) {
$paginator = (new Zend_Paginator(new Zend_Paginator_Adapter_Array(array_reverse($loans->getArrayCopy()))))
$loans = array_reverse($loans->getArrayCopy());
$this->_paginator = (new Zend_Paginator(new Zend_Paginator_Adapter_Array($loans)))
->setItemCountPerPage($page_size)
->setCurrentPageNumber($page_number);
$this->_operations = $paginator->getCurrentItems();
$this->_operations = $this->_paginator->getCurrentItems();
Class_ScriptLoader::getInstance()->loadTableSorter();
return
$this->renderPaginator($paginator) .
$this->renderPaginator() .
$this->_tag('table',
$this->renderHeader()
. $this->renderLoans(),
......@@ -39,12 +42,12 @@ class ZendAfi_View_Helper_Abonne_LoansHistory extends ZendAfi_View_Helper_Abonne
}
protected function renderPaginator($paginator) {
protected function renderPaginator() {
$reload_link = ['module' => 'opac',
'controller' => 'abonne',
'action' => 'loans-history',
'page_size' => $paginator->getItemCountPerPage()];
return $this->view->paginationControl($paginator,
'page_size' => $this->_paginator->getItemCountPerPage()];
return $this->view->paginationControl($this->_paginator,
null,
null,
['url_link' => $reload_link,
......@@ -68,6 +71,9 @@ class ZendAfi_View_Helper_Abonne_LoansHistory extends ZendAfi_View_Helper_Abonne
protected function renderLoan($loan) {
$url = ['retour_abonne' => 'loans-history',
'page' => $this->_paginator->getCurrentPageNumber(),
'page_size' => $this->_paginator->getItemCountPerPage()];
return
$this->_tag('tr',
$this->_tag('td',
......@@ -75,11 +81,11 @@ class ZendAfi_View_Helper_Abonne_LoansHistory extends ZendAfi_View_Helper_Abonne
. $this->_tag('td',
$this->_renderDocTypeLabel($loan))
. $this->_tag('td',
$this->_renderThumbnail($loan, ['retour_abonne' => 'loans-history']))
$this->_renderThumbnail($loan, $url))
. $this->_tag('td',
$this->_renderTitle($loan, ['retour_abonne' => 'loans-history']))
$this->_renderTitle($loan, $url))
. $this->_tag('td',
$this->_renderAuthor($loan, ['retour_abonne' => 'loans-history']))
$this->_renderAuthor($loan, $url))
. $this->_tag('td',
$loan->getIssueDate())
. $this->_tag('td',
......
......@@ -31,7 +31,7 @@ class ZendAfi_View_Helper_AuthorAnchor extends ZendAfi_View_Helper_BaseHelper {
$params = array_merge(['controller' => 'recherche',
'action' => 'simple',
'facette' => Class_CodifAuteur::CODE_FACETTE . $facet->getId()],
'code_rebond' => Class_CodifAuteur::CODE_FACETTE . $facet->getId()],
$params);
return $this->view->tagAnchor($this->view->url($params, null, true),
......
......@@ -41,6 +41,8 @@ class ZendAfi_View_Helper_UrlNotice extends Zend_View_Helper_HtmlElement {
'id_catalogue' => 0,
'module' => 'opac',
'tri' => '',
'page' => null,
'page_size' => null,
'id_profil' => null,
'id_module' => null]));
......
......@@ -104,14 +104,14 @@ class AbonneControllerLoansHistoryNanookIndexTest extends AbonneControllerLoansH
/** @test */
public function pageShouldContainLoanLaFemmeADroiteLink() {
$this->assertXPathContentContains('//table//a[contains(@href, "/recherche/viewnotice/page_size/2/id/464732/retour_abonne/loans-history")]',
$this->assertXPathContentContains('//table//a[contains(@href, "/recherche/viewnotice/page_size/2/id/464732/retour_abonne/loans-history/page/1")]',
'La femme à droite sur la photo');
}
/** @test */
public function valentinMussoShouldLinkToFacetA11() {
$this->assertXPathContentContains('//table//a[contains(@href, "/recherche/simple/facette/A11/retour_abonne/loans-history")]',
$this->assertXPathContentContains('//table//a[contains(@href, "/recherche/simple/code_rebond/A11/retour_abonne/loans-history/page/1/page_size/2")]',
'Valentin Musso');
}
......
......@@ -112,11 +112,13 @@ class CriteresRechercheRetourTest extends ModelTestCase {
[['retour_abonne' => 'loans-history',
'page' => 2],
'page' => 2,
'page_size' => 10],
['controller' => 'abonne',
'action' => 'loans-history',
'page' => '2']],
'page' => '2',
'page_size' => 10]],
[['id_panier' => '23',
'code_rebond' => 'G123'],
......@@ -195,11 +197,13 @@ class CriteresRechercheRetourRechercheInitialeTest extends ModelTestCase {
]],
[['retour_abonne' => 'loans-history',
'page' => 2],
'page' => 2,
'page_size' => 20],
['controller' => 'abonne',
'action' => 'loans-history',
'page' => '2']],
'page' => 2,
'page_size' => '20']],
];
}
......
......@@ -56,14 +56,14 @@ class ZendAfi_View_Helper_AnchorAuthorSimpleTest extends ViewHelperTestCase {
/** @test */
public function shouldReturnAnchorWithFacetA10() {
$this->assertContains('/recherche/simple/facette/A10">Stéphanie BRISSON</a>', $this->_helper->authorAnchor('Stéphanie BRISSON'));
public function shouldReturnAnchorWithCodeRebondA10() {
$this->assertContains('/recherche/simple/code_rebond/A10">Stéphanie BRISSON</a>', $this->_helper->authorAnchor('Stéphanie BRISSON'));
}
/** @test */
public function shouldReturnAnchorWithFacetA11() {
$this->assertContains('/recherche/simple/facette/A11">Marie Kondō</a>', $this->_helper->authorAnchor('Marie Kondō'));
public function shouldReturnAnchorWithCodeRebondA11() {
$this->assertContains('/recherche/simple/code_rebond/A11">Marie Kondō</a>', $this->_helper->authorAnchor('Marie Kondō'));
}
......
Markdown is supported
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