From 8866c45097e2105a8b77d298ad61dd756141f216 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Sat, 6 Apr 2013 14:02:45 +0000
Subject: [PATCH] Paniers dans les domaines: ajout permalien + previsualisation

---
 .gitattributes                                |  1 +
 .../views/scripts/catalogue/paniers.phtml     | 15 +++++++--
 .../views/scripts/cms/_newsform_head.phtml    | 32 ++++++------------
 library/ZendAfi/View/Helper/TagPreview.php    | 33 +++++++++++++++++++
 public/admin/css/global.css                   |  4 +++
 .../controllers/CatalogueControllerTest.php   | 11 +++++++
 .../admin/controllers/CmsControllerTest.php   |  1 +
 7 files changed, 72 insertions(+), 25 deletions(-)
 create mode 100644 library/ZendAfi/View/Helper/TagPreview.php

diff --git a/.gitattributes b/.gitattributes
index 5e4155c8e01..6f49e484567 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2696,6 +2696,7 @@ library/ZendAfi/View/Helper/TagHistoriqueRecherche.php -text
 library/ZendAfi/View/Helper/TagImg.php -text
 library/ZendAfi/View/Helper/TagModelTable.php -text
 library/ZendAfi/View/Helper/TagObjetsImgProperties.php -text
+library/ZendAfi/View/Helper/TagPreview.php -text
 library/ZendAfi/View/Helper/TagRating.php -text
 library/ZendAfi/View/Helper/TagRss.php -text
 library/ZendAfi/View/Helper/TagSessionFormationInscription.php -text
diff --git a/application/modules/admin/views/scripts/catalogue/paniers.phtml b/application/modules/admin/views/scripts/catalogue/paniers.phtml
index 46ecb841b02..70b2c981e1d 100644
--- a/application/modules/admin/views/scripts/catalogue/paniers.phtml
+++ b/application/modules/admin/views/scripts/catalogue/paniers.phtml
@@ -4,9 +4,18 @@
 
 $paniers = $this->catalogue->getPanierNotices();
 foreach($paniers as $panier) {
-	echo sprintf('<li>%s %s</li>',
-							 $panier->getLibelleForAdmins(),
-							 
+	$panier_url = $this->absoluteUrl(['module' => 'opac', 
+																		'controller' => 'recherche',
+																		'action' => 'simple',
+																		'id_panier' => $panier->getId()],
+																	 null,
+																	 true);
+	$panier_libelle = $panier->getLibelleForAdmins();
+
+	echo sprintf('<li>%s %s %s %s</li>',
+							 $panier_libelle,
+							 $this->tagPreview($panier_url, 'Visualisation du panier: '.$panier_libelle),
+							 $this->permalink($panier_url), 
 							 $this->tagAnchor(['remove' => $panier->getId()], 
 																'<img src="'.URL_ADMIN_IMG.'ico/del.gif'.'" alt="Supprimer" title="Supprimer" />'));
 }
diff --git a/application/modules/admin/views/scripts/cms/_newsform_head.phtml b/application/modules/admin/views/scripts/cms/_newsform_head.phtml
index e2a958d79e8..c6701421bed 100644
--- a/application/modules/admin/views/scripts/cms/_newsform_head.phtml
+++ b/application/modules/admin/views/scripts/cms/_newsform_head.phtml
@@ -1,29 +1,17 @@
 <div class="content_edit_head"><?php echo $this->_('Localisation') . ' : ' . $this->article->getBibLibelle(); ?>
-	<?php if (!$this->article->isNew())  { 
-		  $article_url = $this->url(array('module' => 'opac', 
-																			'controller' => 'cms', 
-																			'action' => 'articleview', 
-																			'id' => $this->article->getId()));
-	    $title = "Visualisation de l'article: ".$this->article->getTitre(); ?>
-			<a data-prettyphoto="true" href="<?php echo $article_url ?>&amp;iframe=true&amp;width=80%25&amp;height=80%25;" title="<?php echo $title ?>">
-					 <img
-							 src="<?php echo URL_ADMIN_IMG ?>picto/show.gif" 
-							 title="<?php echo $title ?>"
-							 alt="Visualisation de l'article: <?php echo $this->article->getTitre() ?>" />
-			</a>
-		 <?php 
-			 echo $this->permalink($article_url); 
-		 ?> 
-
-	<?php }?>
-
-	<?php
-		 echo $this->partial('cms/_traduction_navigator.phtml',
-												 array('article' => $this->article));
-	?>
 
 <?php 
+if (!$this->article->isNew())  { 
+	$article_url = $this->url(array('module' => 'opac', 
+																	'controller' => 'cms', 
+																	'action' => 'articleview', 
+																	'id' => $this->article->getId()));
+	echo $this->tagPreview($article_url, "Visualisation de l'article: ".$this->article->getTitre());
+	echo $this->permalink($article_url);
+}
 
+echo $this->partial('cms/_traduction_navigator.phtml',
+										array('article' => $this->article));
 if ($this->article->hasDateMaj())  {
   echo sprintf('<br/><br/>%s : %s', 
                $this->_("Dernière modification"), 
diff --git a/library/ZendAfi/View/Helper/TagPreview.php b/library/ZendAfi/View/Helper/TagPreview.php
new file mode 100644
index 00000000000..79372c5e3f2
--- /dev/null
+++ b/library/ZendAfi/View/Helper/TagPreview.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * AFI-OPAC 2.0 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with AFI-OPAC 2.0; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ */
+class ZendAfi_View_Helper_TagPreview extends ZendAfi_View_Helper_BaseHelper {
+	public function tagPreview($url, $libelle) {
+		return 					
+			'<a data-prettyphoto="true" href="'.$url.'?>&amp;iframe=true&amp;width=95%25&amp;height=95%25;" title="'.$libelle.'">
+					<img
+					   src="'.URL_ADMIN_IMG.'picto/show.gif" 
+					   title="'.$libelle.'"
+					   alt="'.$libelle.'" />
+			 </a>';
+	}
+}
+
+?>
\ No newline at end of file
diff --git a/public/admin/css/global.css b/public/admin/css/global.css
index 42fa925fae0..06899e16446 100644
--- a/public/admin/css/global.css
+++ b/public/admin/css/global.css
@@ -758,6 +758,10 @@ form#sendparams dd {float: left}
     float: left;
 }
 
+.catalogue_paniers li img {
+		vertical-align: middle;
+}
+
 .actions img {
     margin-left: 2px;
     width: 16px;
diff --git a/tests/application/modules/admin/controllers/CatalogueControllerTest.php b/tests/application/modules/admin/controllers/CatalogueControllerTest.php
index 0c70ed658d0..0341f39ac28 100644
--- a/tests/application/modules/admin/controllers/CatalogueControllerTest.php
+++ b/tests/application/modules/admin/controllers/CatalogueControllerTest.php
@@ -595,6 +595,17 @@ class CatalogueControllerPaniersHistoireTest extends AdminCatalogueControllerTes
 		$this->assertXPathContentContains('//form//select[@name="id_panier"]//option[@value="9"]', 
 																			'selection senior - Duchamp');
 	}
+
+	/** @test */
+	public function pageShouldContainsPermalinkForPanier() {
+		$this->assertXPath('//div[@id="permalink"]//input[contains(@value, "recherche/simple/id_panier/8")]');
+	}
+
+
+	/** @test */
+	public function pageShouldContainsPanierPreview() {
+		$this->assertXPath('//a[@data-prettyphoto="true"][contains(@href, "recherche/simple/id_panier/8")]');
+	}
 }
 
 
diff --git a/tests/application/modules/admin/controllers/CmsControllerTest.php b/tests/application/modules/admin/controllers/CmsControllerTest.php
index c3c02ad6524..030136d152e 100644
--- a/tests/application/modules/admin/controllers/CmsControllerTest.php
+++ b/tests/application/modules/admin/controllers/CmsControllerTest.php
@@ -453,6 +453,7 @@ class CmsControllerArticleConcertEditActionTest extends CmsControllerTestCase {
 		$this->assertXPath('//a[@data-prettyphoto="true"][contains(@href, "/cms/articleview/id/4")]');
 	}
 
+
 	/** @test */
 	function previewTitleShouldBeVisualisationDeLArticle() {
 		$this->assertXPath('//a[@data-prettyphoto="true"][contains(@title, "Visualisation de l\'article: Erik Truffaz en concert")]');
-- 
GitLab