From 0181b6f44065006567a512903f133ccdcaaa9524 Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@afi-sa.fr>
Date: Tue, 19 Nov 2019 14:44:41 +0100
Subject: [PATCH] hotline #96083: add print button on article view

---
 VERSIONS_HOTLINE/96083                         |   1 +
 library/Class/WebService/SIGB/Koha/Service.php |   2 ++
 .../View/Helper/Article/RenderAbstract.php     |   3 +++
 .../View/Helper/Article/RenderFullContent.php  |   9 +++++++++
 library/ZendAfi/View/Helper/TagPrintLink.php   |   4 +++-
 public/opac/css/global.css                     |   5 +++++
 public/opac/images/print.png                   | Bin 0 -> 184 bytes
 .../CmsControllerPrintActionTest.php           |  17 ++++++++++++++++-
 8 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 VERSIONS_HOTLINE/96083
 create mode 100644 public/opac/images/print.png

diff --git a/VERSIONS_HOTLINE/96083 b/VERSIONS_HOTLINE/96083
new file mode 100644
index 00000000000..d0695bdf3cf
--- /dev/null
+++ b/VERSIONS_HOTLINE/96083
@@ -0,0 +1 @@
+ - ticket #96083 : Ajout d'un bouton imprimer dans un article
\ No newline at end of file
diff --git a/library/Class/WebService/SIGB/Koha/Service.php b/library/Class/WebService/SIGB/Koha/Service.php
index 24392e14aaf..045bd66320c 100644
--- a/library/Class/WebService/SIGB/Koha/Service.php
+++ b/library/Class/WebService/SIGB/Koha/Service.php
@@ -164,6 +164,8 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR
 
       $reader = $this->ilsdiGetLoansPage($params,
                                                     Class_WebService_SIGB_Koha_LoansPageReader::newInstance());
+      if (!$reader)
+        break;
       $loans_page ++;
       $loans->addAll($reader->getLoans());
     } while ($reader->getTotal() > $loans->count());
diff --git a/library/ZendAfi/View/Helper/Article/RenderAbstract.php b/library/ZendAfi/View/Helper/Article/RenderAbstract.php
index 41aa6c54754..a55dbd180b9 100644
--- a/library/ZendAfi/View/Helper/Article/RenderAbstract.php
+++ b/library/ZendAfi/View/Helper/Article/RenderAbstract.php
@@ -35,6 +35,7 @@ abstract class ZendAfi_View_Helper_Article_RenderAbstract
       . $this->_tag('footer',
                     $this->renderLieu($article)
                     .$this->renderICalLink($article)
+                    .$this->renderPrintLink($article)
                     .$this->renderReseauxSociaux($article)
                     .$this->renderAvis($article))
       . '<!-- RSPEAK_STOP -->';
@@ -134,6 +135,8 @@ abstract class ZendAfi_View_Helper_Article_RenderAbstract
 
   public function renderICalLink($article) { }
 
+  public function renderPrintLink($article) { }
+
 
   public function renderArticleInfo($article) {
     return $this->view->tagArticleInfo($article);
diff --git a/library/ZendAfi/View/Helper/Article/RenderFullContent.php b/library/ZendAfi/View/Helper/Article/RenderFullContent.php
index b27c4ea50cb..64e2f9431b6 100644
--- a/library/ZendAfi/View/Helper/Article/RenderFullContent.php
+++ b/library/ZendAfi/View/Helper/Article/RenderFullContent.php
@@ -44,5 +44,14 @@ class ZendAfi_View_Helper_Article_RenderFullContent extends ZendAfi_View_Helper_
       : '';
   }
 
+
+  public function renderPrintLink($article) {
+    return  $this->view->tag('div',
+                             $this->view->tagPrintLink((new Class_Entity())
+                                                       ->setModels([$article])
+                                                       ->setStrategy('Article_List')),
+                             ['class' => 'print']);;
+
+  }
 }
 ?>
\ No newline at end of file
diff --git a/library/ZendAfi/View/Helper/TagPrintLink.php b/library/ZendAfi/View/Helper/TagPrintLink.php
index 2be07218b3b..08ddfbbeb77 100644
--- a/library/ZendAfi/View/Helper/TagPrintLink.php
+++ b/library/ZendAfi/View/Helper/TagPrintLink.php
@@ -25,7 +25,9 @@ class ZendAfi_View_Helper_TagPrintLink  extends ZendAfi_View_Helper_ModeleFusion
   public function tagPrintLink($instance) {
     $instance
       ->setAction('print')
-      ->setLink($this->_('Imprimer'))
+      ->setLink($this->view->tagImg(
+                                    $this->view->skinImageUrl('print.png'),
+                                    ['alt' => $this->_("Imprimer")]))
       ->setAttribs(['title' => $this->_('Aperçu avant impression'),
                     'target' => '_blank']);
 
diff --git a/public/opac/css/global.css b/public/opac/css/global.css
index 52546e2366c..9f6abde0ded 100644
--- a/public/opac/css/global.css
+++ b/public/opac/css/global.css
@@ -128,6 +128,11 @@ article footer .ical {
     margin-right: 3px;
 }
 
+article footer .print {
+    float: left;
+    margin-right: 3px;
+}
+
 dl.article_info {
     display:none;
 }
diff --git a/public/opac/images/print.png b/public/opac/images/print.png
new file mode 100644
index 0000000000000000000000000000000000000000..bc452a1816fed3752b964440302aeb36d36e1a74
GIT binary patch
literal 184
zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_+o-U3d
z7QJUDI&w7_@UXalWc|D8sQgd!>aOJp3p6wLyl~<>dx`VSq3cm|=I;4n%===G=_1#l
z1B@ocj%<tLm{+lyE>PhUf3S&r>3q%(9(l<FViRR|n%?3`%X(w9!baDHAvdvqolj*P
eo8Xi5U5x2hluu`W;wS}L%;4$j=d#Wzp$Pze$w3wX

literal 0
HcmV?d00001

diff --git a/tests/application/modules/opac/controllers/CmsControllerPrintActionTest.php b/tests/application/modules/opac/controllers/CmsControllerPrintActionTest.php
index f80ae76fd35..5bcc20c4ba7 100644
--- a/tests/application/modules/opac/controllers/CmsControllerPrintActionTest.php
+++ b/tests/application/modules/opac/controllers/CmsControllerPrintActionTest.php
@@ -69,12 +69,27 @@ class CmsControllerPrintActionArticleviewByDate extends AbstractControllerTestCa
 
 
   /** @test */
-  public function printLinkShouldBePresentInArticleview() {
+  public function printLinkShouldBePresentInArticleviewSelection() {
     $this->dispatch('cms/articleviewselection', true);
     $this->assertXPathContentContains('//a[contains(@href, "/cms/print/ids/2241%3B245/strategy/Article_List/modele_fusion/1")]', 'Imprimer', $this->_response->getBody());
   }
 
 
+  /** @test */
+  public function printLinkShouldBePresentInArticleview() {
+    $this->dispatch('/cms/articleview/id/2241', true);
+    $this->assertXPath('//a[contains(@href, "/cms/print/id/2241/ids/2241/strategy/Article_List/modele_fusion/1")]//img[@alt="Imprimer"]', $this->_response->getBody());
+  }
+
+
+  /** @test */
+  public function printLinkShouldBeNotPresentInArticleviewWhenNoTemplate() {
+    Class_ModeleFusion::find(1)->delete();
+    $this->dispatch('/cms/articleview/id/2241', true);
+    $this->assertNotXPath('//a//img[@alt="Imprimer"]', $this->_response->getBody());
+  }
+
+
   /** @test */
   public function dispatchPrintCmsShouldContainsArticle() {
     $this->dispatch('/cms/print/ids/2241%3B245/strategy/Article_List/modele_fusion/1', true);
-- 
GitLab