From 27c49e617e7c9bfa9a29107ef8d0ab1bae85b8e8 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@afi-sa.fr>
Date: Fri, 24 Jul 2015 11:35:06 +0200
Subject: [PATCH] dev #22209 search result feed

refactoring before implementation
---
 .../opac/controllers/RechercheController.php    |  2 +-
 .../opac/views/scripts/recherche/guidee.phtml   | 17 ++---------------
 .../ZendAfi/View/Helper/ListeNotices/Chrono.php |  6 +++---
 .../ChronoSource.php}                           |  6 +++---
 .../ChronoSourceTest.php}                       | 16 +++++++---------
 5 files changed, 16 insertions(+), 31 deletions(-)
 rename library/ZendAfi/View/Helper/{MoteurRecherche/Resultat/TimelineJsonVisitor.php => ListeNotices/ChronoSource.php} (92%)
 rename tests/library/ZendAfi/View/Helper/{MoteurRecherche/Resultat/TimelineJsonVisitorTest.php => ListeNotices/ChronoSourceTest.php} (94%)

diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php
index 290fd75ed88..dae20555c21 100644
--- a/application/modules/opac/controllers/RechercheController.php
+++ b/application/modules/opac/controllers/RechercheController.php
@@ -48,7 +48,7 @@ class RechercheController extends ZendAfi_Controller_Action {
 
     return Class_Notice::findAllByRequeteRecherche($req,
                                                    $criteres_recherche->getPageSize(),
-                                                   $this->_getParam('page',1));
+                                                   $criteres_recherche->getPage());
   }
 
 
diff --git a/application/modules/opac/views/scripts/recherche/guidee.phtml b/application/modules/opac/views/scripts/recherche/guidee.phtml
index fd59625172e..4fbd1cc2989 100644
--- a/application/modules/opac/views/scripts/recherche/guidee.phtml
+++ b/application/modules/opac/views/scripts/recherche/guidee.phtml
@@ -17,25 +17,12 @@ echo $this->tagCriteresRecherche($this->criteres_recherche);
 print('<hr>');
 
 // Rubriques
-if(!$this->rubriques) 
+if(!$this->rubriques)
   print($this->_("Il n'y a plus de sous-niveau"));
-else {  
+else {
   foreach($this->rubriques as $rubrique)  {
     print('<a href="'.$this->url($rubrique["url"],null,true).'">&raquo;&nbsp;'.$rubrique["libelle"].'</a><br>');
   }
 }
 
-$this->display_bib_selected;
-
-
-// Liste
-/*
-if(strlen($this->fil_ariane["fil"]) > 4)
-{
-  echo '<div class="conteneur_simple">';
-  echo $this->listeNotices($this->liste,$nombre,$page_cours,$this->_current_module["preferences"]); 
-  echo '<div style="width:630px;text-align:center">'.$this->pager($nombre,$this->current_module["preferences"]["liste_nb_par_page"],$page_cours,$_SESSION["recherche"]["retour_liste"]).'</div>'; 
-  echo '</div>';
-
-  }*/
 ?>
diff --git a/library/ZendAfi/View/Helper/ListeNotices/Chrono.php b/library/ZendAfi/View/Helper/ListeNotices/Chrono.php
index 8a8b4dd83db..e8c8091570c 100644
--- a/library/ZendAfi/View/Helper/ListeNotices/Chrono.php
+++ b/library/ZendAfi/View/Helper/ListeNotices/Chrono.php
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 class ZendAfi_View_Helper_ListeNotices_Chrono extends ZendAfi_View_Helper_ListeNotices_Abstract {
   protected static $_id_counter = 0;
@@ -43,13 +43,13 @@ class ZendAfi_View_Helper_ListeNotices_Chrono extends ZendAfi_View_Helper_ListeN
       'height' => (isset($preferences['op_hauteur']) ? $preferences['op_hauteur'] : 600),
       'start_at_end' => true,
       'start_zoom_adjust' => -4,
-      'source' => json_decode($this->view->MoteurRecherche_Resultat_TimelineJsonVisitor($resultat, $preferences)),
+      'source' => json_decode($this->view->listeNotices_ChronoSource($resultat, $preferences)),
       'js' => BASE_URL.'/public/opac/TimelineJS-2.25/compiled/js/timeline.js',
       'css' => BASE_URL.'/public/opac/TimelineJS-2.25/compiled/css/timeline.css',
       'lang' => 'fr',
       'debug' => false
       ];
-    
+
     $html = '<script>$(function(){ createStoryJS('.json_encode($storyjs_params).')})</script>';
     $html .= '<script></script>';
 
diff --git a/library/ZendAfi/View/Helper/MoteurRecherche/Resultat/TimelineJsonVisitor.php b/library/ZendAfi/View/Helper/ListeNotices/ChronoSource.php
similarity index 92%
rename from library/ZendAfi/View/Helper/MoteurRecherche/Resultat/TimelineJsonVisitor.php
rename to library/ZendAfi/View/Helper/ListeNotices/ChronoSource.php
index 3a01c3d3ba0..0f40c411ba8 100644
--- a/library/ZendAfi/View/Helper/MoteurRecherche/Resultat/TimelineJsonVisitor.php
+++ b/library/ZendAfi/View/Helper/ListeNotices/ChronoSource.php
@@ -18,7 +18,7 @@
  * along with BOKEH; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
-class ZendAfi_View_Helper_MoteurRecherche_Resultat_TimelineJsonVisitor extends Zend_View_Helper_HtmlElement {
+class ZendAfi_View_Helper_ListeNotices_ChronoSource extends Zend_View_Helper_HtmlElement {
   use Trait_Translator, Trait_NoticeVisitor;
 
   protected
@@ -30,11 +30,11 @@ class ZendAfi_View_Helper_MoteurRecherche_Resultat_TimelineJsonVisitor extends Z
   /**
    * @param $resultat Class_MoteurRecherche_Resultat
    */
-  public function MoteurRecherche_Resultat_TimelineJsonVisitor($resultat, $preferences = []) {
+  public function listeNotices_ChronoSource($notices, $preferences = []) {
     $this->_preferences = $preferences;
     $this->_dates = [];
 
-    $resultat->acceptVisitor($this);
+    array_map([$this, 'visitNotice'], $notices);
 
     $this->_json = ['timeline' => [
         'type' => 'default',
diff --git a/tests/library/ZendAfi/View/Helper/MoteurRecherche/Resultat/TimelineJsonVisitorTest.php b/tests/library/ZendAfi/View/Helper/ListeNotices/ChronoSourceTest.php
similarity index 94%
rename from tests/library/ZendAfi/View/Helper/MoteurRecherche/Resultat/TimelineJsonVisitorTest.php
rename to tests/library/ZendAfi/View/Helper/ListeNotices/ChronoSourceTest.php
index 6e99d4431c4..cae5694f2e4 100644
--- a/tests/library/ZendAfi/View/Helper/MoteurRecherche/Resultat/TimelineJsonVisitorTest.php
+++ b/tests/library/ZendAfi/View/Helper/ListeNotices/ChronoSourceTest.php
@@ -16,11 +16,11 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
 
-class ZendAfi_View_Helper_MoteurRecherche_Resultat_TimelineJsonVisitorTest extends ViewHelperTestCase {
+class ZendAfi_View_Helper_ListeNotices_ChronoSourceTest extends ViewHelperTestCase {
   protected $_json;
 
   public function setUp() {
@@ -53,11 +53,9 @@ class ZendAfi_View_Helper_MoteurRecherche_Resultat_TimelineJsonVisitorTest exten
 
          ];
 
-      $resultat = new Class_MoteurRecherche_Resultat($notices);
-
-      $this->_helper = new ZendAfi_View_Helper_MoteurRecherche_Resultat_TimelineJsonVisitor();
+      $this->_helper = new ZendAfi_View_Helper_ListeNotices_ChronoSource();
       $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View());
-      $this->_json = json_decode($this->_helper->MoteurRecherche_Resultat_TimelineJsonVisitor($resultat));
+      $this->_json = json_decode($this->_helper->listeNotices_ChronoSource($notices));
   }
 
 
@@ -87,7 +85,7 @@ class ZendAfi_View_Helper_MoteurRecherche_Resultat_TimelineJsonVisitorTest exten
 
   /** @test */
   public function firstNoticeHeadlineShouldContainsHarryPotterPrisonnierAzkaban() {
-    $this->assertContains('Harry Potter et le prisonnier d\'Azkaban', 
+    $this->assertContains('Harry Potter et le prisonnier d\'Azkaban',
                           $this->_json->timeline->date[0]->headline);
   }
 
@@ -100,14 +98,14 @@ class ZendAfi_View_Helper_MoteurRecherche_Resultat_TimelineJsonVisitorTest exten
 
   /** @test */
   public function firstNoticeTextShouldContainsLinkToNotice() {
-    $this->assertContains('/recherche/viewnotice/clef/POTTER/id/2', 
+    $this->assertContains('/recherche/viewnotice/clef/POTTER/id/2',
                           $this->_json->timeline->date[0]->text);
   }
 
 
   /** @test */
   public function secondNoticeTextShouldBeSekouEstRenvoye() {
-    $this->assertContains('Sékou est renvoyé de l\'usine parce qu\'il a osé', 
+    $this->assertContains('Sékou est renvoyé de l\'usine parce qu\'il a osé',
                           $this->_json->timeline->date[1]->text);
   }
 
-- 
GitLab