Skip to content
Snippets Groups Projects
Commit 729ae5e1 authored by gloas's avatar gloas
Browse files

Navigation: ajout des liens dans viewnotice.phtml + ajout de tests + corrections

parent 6f3b718f
Branches
Tags
No related merge requests found
......@@ -214,14 +214,12 @@ class RechercheController extends ZendAfi_Controller_Action {
}
if($navigation=$this->_getParam('navigation')) {
$criteres_recherche = new Class_CriteresRecherche();
$criteres_recherche->setParams($this->_request->getParams());
if($navigation ==='suivant')
$navigation_notice = $this->moteur->getNoticeSuivante($criteres_recherche, $notice);
if($navigation ==='precedent')
$navigation_notice = $this->moteur->getNoticePrecedente($criteres_recherche, $notice);
$this->_redirect($this->view->absoluteUrl(['id'=>$navigation_notice->getId(),
'clef'=>$navigation_notice->getClefAlpha(),
'navigation'=> null]));
......
......@@ -21,11 +21,12 @@ $script_loader = Class_ScriptLoader::getInstance()
?>
<div class="navigation">
<a class="resultat_precedent" href="<?php echo $this->url(['navigation'=>'precedent']); ?>"><?php echo $this->_('Résultat précédent') ?></a>
<a class="retour" href="<?php echo $this->url($this->criteres_recherche->getUrlRetourListe(), null, true); ?>"><?php echo $this->_('Retour à la liste') ?></a>
<a class="panier" href="<?php echo $this->url_panier ?>" data-popup="true" data-action="<?php echo $this->url_panier ?>"><?php echo $this->_('Ajouter au Panier') ?></a>
<?php echo $this->notice_LienReserver($this->notice); ?>
<a class="resultat_suivant" href="<?php echo $this->url(['navigation'=>'suivant']); ?>"><?php echo $this->_('Résultat suivant') ?></a>
</div>
<div class="notice_vignette">
......
......@@ -223,23 +223,28 @@ class Class_MoteurRecherche {
public function getNoticeSuivante($criteres_recherche, $notice) {
$all_ids= $this->_getAllNoticeIdsTableFromCriteresRecherche($criteres_recherche);
if(!$navigation_position = $this->_getNoticePositionInIdsTable($all_ids, $notice))
if(null === $navigation_position = $this->_getNoticePositionInIdsTableWithAction($all_ids, $notice,'suivant'))
return $notice;
$next_id = $all_ids[$navigation_position+1];
return Class_Notice::find($next_id);
}
public function getNoticePrecedente($criteres_recherche, $notice) {
$all_ids = $this->_getAllNoticeIdsTableFromCriteresRecherche($criteres_recherche);
if(!$navigation_position = $this->_getNoticePositionInIdsTable($all_ids, $notice))
if(null === $navigation_position = $this->_getNoticePositionInIdsTableWithAction($all_ids, $notice,'precedent'))
return $notice;
$previous_id = $all_ids[$navigation_position-1];
return Class_Notice::find($previous_id);
}
protected function _getNoticePositionInIdsTable($all_ids, $notice) {
protected function _getNoticePositionInIdsTableWithAction($all_ids, $notice, $action) {
$position= array_search($notice->getId(), $all_ids);
if($position == 0 || $position == count($all_ids)-1)
if( [] == $all_ids)
return null;
if($position == 0 && $action === 'precedent')
return null;
if($position == count($all_ids)-1 && $action === 'suivant')
return null;
return $position;
}
......
......@@ -48,7 +48,6 @@ class Class_WebService_SIGB_Koha_GetRecordsResponseReader {
}
public function getNoticeFromXML($xml) {
xdebug_break();
$this->_xml_parser = Class_WebService_XMLParser::newInstance();
$this->_xml_parser
->setElementHandler($this)
......
......@@ -91,8 +91,7 @@ class ZendAfi_Form_Login extends ZendAfi_Form {
['value' => $this->_redirect_url]);
array_push($group, 'redirect');
}
xdebug_break();
if(strlen($this->_service)>1){
$this->addElement('hidden',
'service',
......
......@@ -311,6 +311,18 @@ class RechercheControllerViewNoticeClefAlphaTest extends RechercheControllerView
$this->assertXPathContentContains('//div/a[contains(@href, "/recherche/simple/expressionRecherche/Millenium")]',
'Retour à la liste');
}
/** @test */
public function resultatSuivantShouldLinkToNavigationSuivant() {
$this->assertXPathContentContains('//div//a[contains(@href, "recherche/viewnotice/clef/TESTINGALPHAKEY---101/expressionRecherche/Millenium/navigation/suivant")]',
'Résultat suivant', $this->_response->getBody());
}
/** @test */
public function resultatPrecedentShouldLinkToNavigationPrecedent() {
$this->assertXPathContentContains('//div//a[contains(@href, "recherche/viewnotice/clef/TESTINGALPHAKEY---101/expressionRecherche/Millenium/navigation/precedent")]',
'Résultat précédent', $this->_response->getBody());
}
}
......@@ -1259,17 +1271,29 @@ class RechercheControllerNavigationTest extends RechercheControllerNoticeTestCas
}
/** @test */
public function navigationPrecedentOnTheFirstNoticeOfResultatRechercheShouldRedirectToMusso() {
public function navigationPrecedentOnTheFirstNoticeMussoOfResultatRechercheShouldRedirectToMusso() {
$this->dispatch('/recherche/viewnotice/id/28/tri/alpha_titre/navigation/precedent',true);
$this->assertRedirectRegex('|/recherche/viewnotice/id/28/tri/alpha_titre/clef/musso|');
}
/** @test */
public function navigationSuivantOnTheLastNoticeOfResultatRechercheShouldRedirectToLesarbres() {
public function navigationSuivantOnTheLastNoticeLesArbresOfResultatRechercheShouldRedirectToLesarbres() {
$this->dispatch('/recherche/viewnotice/id/99/tri/alpha_titre/navigation/suivant',true);
$this->assertRedirectRegex('|/recherche/viewnotice/id/99/tri/alpha_titre/clef/lesarbres|');
}
/** @test */
public function navigationSuivantOnTheFirstNoticeMussoOfResultatRechercheShouldRedirectToTarzan() {
$this->dispatch('/recherche/viewnotice/id/28/tri/alpha_titre/navigation/suivant',true);
$this->assertRedirectRegex('|/recherche/viewnotice/id/12/tri/alpha_titre/clef/tarzan|');
}
/** @test */
public function navigationPrecedentOnTheLastNoticeLesarbresOfResultatRechercheShouldRedirectToBatman() {
$this->dispatch('/recherche/viewnotice/id/99/tri/alpha_titre/navigation/precedent',true);
$this->assertRedirectRegex('|/recherche/viewnotice/id/1/tri/alpha_titre/clef/batman|');
}
/** @test */
public function navigationSuivantOnNoticeLesarbresWhenResultatRechercheIsEmptyShouldRedirectToCurrentNoticeLsearbres() {
Class_Notice::whenCalled('getNoticeIdsByRequeteRecherche')
......
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