From f68f664a5898de38271c7154e5d4b4e01b0c9537 Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Thu, 22 Dec 2016 09:46:11 +0100
Subject: [PATCH] hotline #52395 fix link html in search result wall mode
 record toolbar

---
 VERSIONS_HOTLINE/52395                        |  1 +
 .../ZendAfi/View/Helper/ListeNotices/Mur.php  | 86 +++++++++++--------
 .../View/Helper/Notice/LienReserver.php       |  6 ++
 .../View/Helper/ListeNotices/MurTest.php      |  6 ++
 4 files changed, 63 insertions(+), 36 deletions(-)
 create mode 100644 VERSIONS_HOTLINE/52395

diff --git a/VERSIONS_HOTLINE/52395 b/VERSIONS_HOTLINE/52395
new file mode 100644
index 00000000000..971611e9db0
--- /dev/null
+++ b/VERSIONS_HOTLINE/52395
@@ -0,0 +1 @@
+ - ticket #52395 : Résultat recherche mode mur : correction de l'affichage des liens
\ No newline at end of file
diff --git a/library/ZendAfi/View/Helper/ListeNotices/Mur.php b/library/ZendAfi/View/Helper/ListeNotices/Mur.php
index 1797c20dd56..0a3dd297416 100644
--- a/library/ZendAfi/View/Helper/ListeNotices/Mur.php
+++ b/library/ZendAfi/View/Helper/ListeNotices/Mur.php
@@ -74,39 +74,48 @@ class ZendAfi_View_Helper_ListeNotices_Mur extends ZendAfi_View_Helper_ListeNoti
 
 
   protected function barreDeLien($notice){
-    $html =
-      $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax',
-                                               'action' => 'avis-abonne',
-                                               'id_notice' => $notice->getId()], null, true) . '?iframe=true',
-                             $notice->numberOfAvisAbonne(),
-                             $this->_('Avis des abonnés'))
-      . $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax',
-                                                 'action' => 'avis-bibliothecaire',
-                                                 'id_notice' => $notice->getId()], null, true) . '?iframe=true',
-                               $notice->numberOfAvisBibliothecaire(),
-                               $this->_('Coups de coeur'))
-      . $this->view->tag('li',
-                         $this->view->tagAnchor($this->view->urlNotice($notice) .'#reseaux-sociaux',
-                                                '&nbsp;',
-                                                ['data-mur-partager' => $notice->getId(),
-                                                 'title' => $this->view->_('Partager "%s" sur les réseaux sociaux',
-                                                                           $notice->getTitrePrincipal())]))
-      . $this->barreDeLienPanier($notice)
-      . $this->barreDeLienReserver($notice);
-
-    return
-      $this->_recordAvailability($notice)
-      . $this->_tag('ul',
-                    $html,
-                    ['class' => 'barre-de-lien'])
-      . $this->view->reseauxSociaux($notice);
+    $html = [$this->_usersReviews($notice),
+             $this->_adminsReviews($notice),
+             $this->_socialNetwork($notice),
+             $this->barreDeLienPanier($notice),
+             $this->barreDeLienReserver($notice)];
+
+    return implode([$this->_recordAvailability($notice),
+                    $this->_tag('ul', implode($html), ['class' => 'barre-de-lien']),
+                    $this->view->reseauxSociaux($notice)]);
   }
 
 
-  protected function barreDeLienReserver($notice) {
-    if ($notice->isRessourceNumerique() || $notice->isSite() || $notice->isArticleCms() || $notice->isRSS())
-      return '';
+  protected function _adminsReviews($record) {
+    return $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax',
+                                                    'action' => 'avis-bibliothecaire',
+                                                    'id_notice' => $record->getId()], null, true) . '?iframe=true',
+                                  $record->numberOfAvisBibliothecaire(),
+                                  $this->_('Coups de coeur'));
+  }
+
+
+  protected function _usersReviews($record) {
+    return $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax',
+                                                    'action' => 'avis-abonne',
+                                                    'id_notice' => $record->getId()], null, true) . '?iframe=true',
+                                  $record->numberOfAvisAbonne(),
+                                  $this->_('Avis des abonnés'));
+
+  }
+
 
+  protected function _socialNetwork($record) {
+    return $this->_tag('li', $this->view->tagAnchor($this->view->urlNotice($record) .'#reseaux-sociaux',
+                                                    '&nbsp;',
+                                                    ['data-mur-partager' => $record->getId(),
+                                                     'title' => $this->view->_('Partager "%s" sur les réseaux sociaux',
+                                                                               $record->getTitrePrincipal())]));
+
+  }
+
+
+  protected function barreDeLienReserver($notice) {
     $holdable = ($link = $this->view->Notice_LienReserver($notice))
       ? 'true'
       : 'false';
@@ -118,18 +127,23 @@ class ZendAfi_View_Helper_ListeNotices_Mur extends ZendAfi_View_Helper_ListeNoti
 
 
   protected function barreDeLienAvis($url, $count, $title) {
-    if (!$count)
-      return '';
+    $html = $count
+      ? $this->view->tagAnchor($url,
+                               $this->_tag('span', $count),
+                               ['title' => $this->_('Voir les avis du document "%s"', $title)])
+      : '';
+
+    $attribs = $count
+      ? ['data-avis' => 'true']
+      : [];
 
     return $this->_tag('li',
-                       $this->view->tagAnchor($url,
-                                              $this->_tag('span', $count),
-                                              ['title' => $this->_('Voir les avis du document "%s"', $title)]),
-                       ['data-avis' => 'true']);
+                       $html,
+                       $attribs);
   }
 
 
   protected function barreDeLienPanier($notice) {
     return $this->view->tag('li', $this->view->tagAddToCart($notice));
   }
-}
+}
\ No newline at end of file
diff --git a/library/ZendAfi/View/Helper/Notice/LienReserver.php b/library/ZendAfi/View/Helper/Notice/LienReserver.php
index f7ebc3aa51e..c0ef27a07d3 100644
--- a/library/ZendAfi/View/Helper/Notice/LienReserver.php
+++ b/library/ZendAfi/View/Helper/Notice/LienReserver.php
@@ -22,6 +22,12 @@ class ZendAfi_View_Helper_Notice_LienReserver extends Zend_View_Helper_HtmlEleme
   protected $_script_added = false;
 
   public function Notice_LienReserver($notice) {
+    if ($notice->isRessourceNumerique()
+        || $notice->isSite()
+        || $notice->isArticleCms()
+        || $notice->isRSS())
+      return '';
+
     $this->loadScript();
     $can_request_sigb = Class_AdminVar::isAfficherDispoSurRechercheEnabled();
     $id_notice = $notice->getId();
diff --git a/tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php b/tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php
index 7d75142917c..c5de8c4ed16 100644
--- a/tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php
+++ b/tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php
@@ -90,6 +90,12 @@ class ZendAfi_View_Helper_ListeNotices_MurForNoticeTest extends ZendAfi_View_Hel
   }
 
 
+  /** @test */
+  public function linkBarShouldContains5lis() {
+    $this->assertXPathCount($this->_html, '//ul[@class="barre-de-lien"]/li', 5);
+  }
+
+
   /** @test **/
   public function noticeInModeMurShouldDisplayNouveaute() {
     $this->assertXPathContentContains($this->_html,
-- 
GitLab