From 5503bbcbcf7c35b1e7c32327bd06d201c0d01a68 Mon Sep 17 00:00:00 2001 From: gloas <gloas@git-test.afi-sa.fr> Date: Thu, 6 Jun 2013 12:09:39 +0000 Subject: [PATCH] =?UTF-8?q?Skin:=20modification=20du=20helper=20reseaux-so?= =?UTF-8?q?ciaux,=20ajout=20fonctionnalit=C3=A9=20partager=20sur=20les=20n?= =?UTF-8?q?otices=20du=20resultat=20de=20rechercher=20en=20mode=20mur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 2 +- .../opac/controllers/RechercheController.php | 4 +- .../opac/views/scripts/cms/reseau.phtml | 4 +- library/ZendAfi/View/Helper/Notice/Mur.php | 23 ++++++---- library/ZendAfi/View/Helper/Permalink.php | 4 +- .../ZendAfi/View/Helper/ReseauxSociaux.php | 43 +++++++++---------- public/opac/css/global.css | 5 +++ public/opac/js/liste_notices_mur.js | 10 ++++- .../ZendAfi/View/Helper/Notice/MurTest.php | 5 +++ ...SociauxTest.php => ReseauxSociauxTest.php} | 18 +++++--- 10 files changed, 71 insertions(+), 47 deletions(-) rename tests/library/ZendAfi/View/Helper/{ResauxSociauxTest.php => ReseauxSociauxTest.php} (65%) diff --git a/.gitattributes b/.gitattributes index 4be8e222e14..624327c7e15 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5924,7 +5924,7 @@ tests/library/ZendAfi/View/Helper/PageContextTest.php -text tests/library/ZendAfi/View/Helper/RenderAlbumTest.php -text tests/library/ZendAfi/View/Helper/RenderFormTest.php -text tests/library/ZendAfi/View/Helper/RenderLieuTest.php -text -tests/library/ZendAfi/View/Helper/ResauxSociauxTest.php -text +tests/library/ZendAfi/View/Helper/ReseauxSociauxTest.php -text tests/library/ZendAfi/View/Helper/SocialShareTest.php -text tests/library/ZendAfi/View/Helper/SubwordsTest.php -text tests/library/ZendAfi/View/Helper/TagAnchorTest.php -text diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index f0f6a151a24..6138e7a183b 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -315,10 +315,8 @@ class RechercheController extends Zend_Controller_Action $viewRenderer = $this->getHelper('ViewRenderer'); $viewRenderer->setNoRender(); - $id_notice = $this->_getParam('id_notice'); - $type_doc = $this->_getParam('type_doc'); $helper = new ZendAfi_View_Helper_ReseauxSociaux(); - echo $helper->reseauxSociaux('notice', $id_notice, $type_doc); + echo $helper->reseauxSociaux(Class_Notice::find($this->_getParam('id_notice', 0))); } diff --git a/application/modules/opac/views/scripts/cms/reseau.phtml b/application/modules/opac/views/scripts/cms/reseau.phtml index 1b158fc5d07..fc439519ba2 100644 --- a/application/modules/opac/views/scripts/cms/reseau.phtml +++ b/application/modules/opac/views/scripts/cms/reseau.phtml @@ -1,3 +1 @@ -<?php if ($this->article) { - echo $this->reseauxSociaux('article', $this->article->getId()); -} ?> \ No newline at end of file +<?php echo $this->reseauxSociaux($this->article); ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Notice/Mur.php b/library/ZendAfi/View/Helper/Notice/Mur.php index d4eb0e42a10..4988f8fa924 100644 --- a/library/ZendAfi/View/Helper/Notice/Mur.php +++ b/library/ZendAfi/View/Helper/Notice/Mur.php @@ -43,27 +43,32 @@ class ZendAfi_View_Helper_Notice_Mur extends Zend_View_Helper_HtmlElement { public function barreDeLien($notice){ $html = '<ul class="barre-de-lien">'; $html .= $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax', - 'action' => 'avis-abonne', - 'id_notice' => $notice->getId()], null, true) . '?iframe=true', $notice->numberOfAvisAbonne(), 'Avis abonnés'); - + 'action' => 'avis-abonne', + 'id_notice' => $notice->getId()], null, true) . '?iframe=true', + $notice->numberOfAvisAbonne(), + 'avis des abonnés'); + $html .= $this->barreDeLienAvis($this->view->url(['controller'=>'noticeajax', - 'action' => 'avis-bibliothecaire', - 'id_notice' => $notice->getId()], null, true) . '?iframe=true', $notice->numberOfAvisBibliothecaire(), 'Coups de coeur'); + 'action' => 'avis-bibliothecaire', + 'id_notice' => $notice->getId()], null, true) . '?iframe=true', + $notice->numberOfAvisBibliothecaire(), + 'coups de coeur'); + + $html .= '<li><a href="'. $this->view->urlNotice($notice) .'#reseaux-sociaux" data-mur-partager="' . $notice->getId() . '" title="Partager"> </a></li>'; - $html .= '<li><a href="#" > </a></li>'. - '<li><a href="' . $this->view->url(['controller' => 'panier', + $html .= '<li><a href="' . $this->view->url(['controller' => 'panier', 'action' => 'panierajouternotice', 'id_notice' => $notice->getId()], null, true) . '" title="Ajouter au panier"> </a></li>'. '<li title="Réserver">' . $this->view->notice_LienReserver($notice) . '</li>'; - return $html.'</ul>'; + return $html.'</ul>'.$this->view->reseauxSociaux($notice); } public function barreDeLienAvis($url, $count, $title) { if (0 < $count) - return '<li data-avis="true"><a href="' . $url .'" data-prettyphoto="true" title="' . $title . '"><span>'. sprintf('%02s', $count) . '</span></a></li>'; + return '<li data-avis="true"><a href="' . $url .'" data-prettyphoto="true" title="Voir les ' . $title . '"><span>'. sprintf('%02s', $count) . '</span></a></li>'; return '<li></li>'; } } diff --git a/library/ZendAfi/View/Helper/Permalink.php b/library/ZendAfi/View/Helper/Permalink.php index ed7d1c267c1..ecef2e4ab67 100644 --- a/library/ZendAfi/View/Helper/Permalink.php +++ b/library/ZendAfi/View/Helper/Permalink.php @@ -37,10 +37,10 @@ class ZendAfi_View_Helper_Permalink extends ZendAfi_View_Helper_BaseHelper { $lien_permanent = $this->translate()->_('Lien permanent'); $html = $this->view->tagImgHover($url_icone_permalink, - ['style' =>'margin-right:3px;cursor:pointer', + ['class' => 'permalien-img', 'title' => $lien_permanent, 'alt' => $lien_permanent, - 'onclick' => $onclick]); + 'onclick' => $onclick,]); $html.='<div id="permalink" style="background: #FFFFFF; display:none;position:absolute;padding:8px;text-align:center;border:1px solid #C8C8C8">'; $html.= sprintf('<div style="float:left">%s</div>', $this->translate()->_('Lien permanent')); diff --git a/library/ZendAfi/View/Helper/ReseauxSociaux.php b/library/ZendAfi/View/Helper/ReseauxSociaux.php index 50832c8883f..9a1902b2ba9 100644 --- a/library/ZendAfi/View/Helper/ReseauxSociaux.php +++ b/library/ZendAfi/View/Helper/ReseauxSociaux.php @@ -24,27 +24,24 @@ class ZendAfi_View_Helper_ReseauxSociaux extends ZendAfi_View_Helper_BaseHelper { - - //------------------------------------------------------------------------------------------------------ - // Main routine - //------------------------------------------------------------------------------------------------------ - function reseauxSociaux($type,$id_notice,$type_doc=0) { + + /** + * @param $object Class_Article or Class_Notice + * @return string + */ + public function reseauxSociaux($object) { $id_profil = Class_Profil::getCurrentProfil()->getId(); + if (!$object) + return ''; - switch($type) { - case "notice" : - if (!$notice = Class_Notice::find($id_notice)) - return ''; + if ($object instanceof Class_Article) + return $this->links($this->view->url($object->getUrl(), null, true).'?id_profil='.$id_profil, ''); - $url_portail="/recherche/viewnotice/clef/".$notice->getClefAlpha()."?id_profil=".$id_profil."&type_doc=".$notice->getTypeDoc(); - $message = $notice->getTitrePrincipal(); - break; - case "article" : - $url_portail="/cms/articleview/id/".$id_notice."?id_profil=".$id_profil; - $message = ''; - break; - } + if (!($object instanceof Class_Notice)) + return ''; + $message = $object->getTitrePrincipal(); + $url_portail = $this->view->urlNotice($object)."?id_profil=".$id_profil; return $this->links($url_portail, $message); } @@ -54,6 +51,7 @@ class ZendAfi_View_Helper_ReseauxSociaux extends ZendAfi_View_Helper_BaseHelper // Get reseaux $cls=new Class_WebService_ReseauxSociaux(); $reseaux=$cls->getReseau(); + $url_portail = $this->view->absoluteUrl($url_portail); // Html $html='<div class="vignette-reseaux-sociaux">'; @@ -69,20 +67,19 @@ class ZendAfi_View_Helper_ReseauxSociaux extends ZendAfi_View_Helper_BaseHelper $path_icone_reseau = PATH_SKIN.'images/'.$icone_reseau; $hover_path = PATH_SKIN.'images/reseaux/hover/'.$clef.'png'; $url_icone_reseau = file_exists($path_icone_reseau) - ? URL_IMG.$icone_reseau - : URL_ADMIN_IMG.'reseaux/'.$clef.'.gif'; + ? URL_IMG.$icone_reseau + : URL_ADMIN_IMG.'reseaux/'.$clef.'.gif'; - $html.=$this->view->tagImgHover($url_icone_reseau, + $html.=$this->view->tagImgHover($url_icone_reseau, ['class' => 'reseau-social-img', 'alt' => sprintf("%s ".$clef, $this->translate()->_('icone')), 'title' => sprintf("%s ".$clef, $this->translate()->_('partager sur')), 'onclick' => sprintf('$.getScript(\'%s\')',$url)]); - $html.='<script type="text/javascript">$(function(){initializeImgHover()});</script>'; + $html.='<script type="text/javascript">$(function(){initializeImgHover()});</script>'; } - $url = $this->view->absoluteUrl($url_portail); - $html .= $this->view->permalink($url); + $html .= $this->view->permalink($url_portail); $html.='</div>'; return $html; } diff --git a/public/opac/css/global.css b/public/opac/css/global.css index 4ad63413225..2d2851a9f65 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -1796,3 +1796,8 @@ button.vodeclic_link + img { margin-bottom: 5px; padding-left: 20px; } + +.permalien-img { + margin-right:3px; + cursor:pointer; +} \ No newline at end of file diff --git a/public/opac/js/liste_notices_mur.js b/public/opac/js/liste_notices_mur.js index b12b6b85707..82d8381d56d 100644 --- a/public/opac/js/liste_notices_mur.js +++ b/public/opac/js/liste_notices_mur.js @@ -32,7 +32,15 @@ function noticeMurTooltip(item) { open:function(event, ui){ var context = $(this); noticeMurOpen(context, id)}, - items: 'img:not(.icone_support)', + items: 'img:not(.icone_support, .reseau-social-img, .permalien-img )', tooltipClass: 'notice-mur-tooltip', position: {my: 'left top', at: 'right top' , collision: 'none'}} ); + + $(item).find('a[data-mur-partager]').each(function(){ + var anchor = $(this); + $(this).click(function(event) { + event.preventDefault(); +// $(anchor).toggleClass('yop'); + $(item).find('.vignette-reseaux-sociaux').toggle(); + })}); } diff --git a/tests/library/ZendAfi/View/Helper/Notice/MurTest.php b/tests/library/ZendAfi/View/Helper/Notice/MurTest.php index 917fca1120a..6f858b53bf9 100644 --- a/tests/library/ZendAfi/View/Helper/Notice/MurTest.php +++ b/tests/library/ZendAfi/View/Helper/Notice/MurTest.php @@ -166,5 +166,10 @@ class ZendAfi_View_Helper_Notice_Mur_BarreDeLienTest extends ZendAfi_View_Helper public function barreDeLienShouldContainUrlReserver() { $this->assertXPath($this->_html, '//a[contains(@href, "panierajouternotice/id_notice/34")]'); } + + /** @test */ + public function barreDeLienShouldContainUrlReseauxSociaux() { + $this->assertXPath($this->_html, '//a[contains(@href, "#reseaux-sociaux")]'); + } } ?> \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/ResauxSociauxTest.php b/tests/library/ZendAfi/View/Helper/ReseauxSociauxTest.php similarity index 65% rename from tests/library/ZendAfi/View/Helper/ResauxSociauxTest.php rename to tests/library/ZendAfi/View/Helper/ReseauxSociauxTest.php index a9152b2fa88..6bc19d8e0d0 100644 --- a/tests/library/ZendAfi/View/Helper/ResauxSociauxTest.php +++ b/tests/library/ZendAfi/View/Helper/ReseauxSociauxTest.php @@ -30,23 +30,31 @@ class ZendAfi_View_Helper_ReseauxSociauxTest extends ViewHelperTestCase { public function setUp() { parent::setUp(); $_SERVER["HTTP_HOST"] = 'localhost'; + defineConstant('PATH_SKIN', ''); $this->_helper = new ZendAfi_View_Helper_ReseauxSociaux(); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); } /** @test */ - public function onArticlelinkShouldContainsArticleId() { - $this->_html = $this->_helper->reseauxSociaux('article', 123456789); - $this->assertContains('id/123456789', $this->_html); + public function withArticleLinksShouldContainsArticleUrl() { + $this->_html = $this->_helper->reseauxSociaux(Class_Article::newInstanceWithId(123456789)); + $this->assertContains('cms/articleview/id/123456789', $this->_html); } /** @test */ - public function onInexistantNoticeLinkShouldBeEmpty() { - $this->_html = $this->_helper->reseauxSociaux('notice', -1); + public function withoutObjectLinksShouldBeEmpty() { + $this->_html = $this->_helper->reseauxSociaux(null); $this->assertEmpty($this->_html); } + + /** @test */ + public function withNoticeLinksShouldContainsNoticeUrl() { + $this->_html = $this->_helper->reseauxSociaux(Class_Notice::newInstanceWithId(777, ['titre_principal' => 'Tarzan', + 'clef_alpha' => 'tarzan'])); + $this->assertContains('recherche/viewnotice/clef/tarzan/id/777', $this->_html); + } } -- GitLab