diff --git a/VERSIONS_HOTLINE/48232 b/VERSIONS_HOTLINE/48232 new file mode 100644 index 0000000000000000000000000000000000000000..f51110a3e63be495eb526a3660341104c557d7e0 --- /dev/null +++ b/VERSIONS_HOTLINE/48232 @@ -0,0 +1 @@ + - ticket #48232 : adaptation du partage Facebook à l'évolution de l'API \ No newline at end of file diff --git a/application/modules/opac/views/scripts/head.phtml b/application/modules/opac/views/scripts/head.phtml index d441477840222623e4d61c10a0a28b939f4c445e..a1865277b9803185a8a4690e0fe85022b2654092 100644 --- a/application/modules/opac/views/scripts/head.phtml +++ b/application/modules/opac/views/scripts/head.phtml @@ -29,10 +29,9 @@ ->addAdminScripts(['onload_utils', 'global', 'toolbar', 'common']) ->addOPACScripts(['abonne', 'menu', 'bib', 'avis', 'recherche', - 'jquery.placeholder.min', 'accessibility', 'subModal', + 'accessibility', 'subModal', 'division-five', 'reload_module']) ->addJQueryReady(' - $("input").placeholder(); autoHideShowConfigurationModule(); initializeNoticeMurAnimation(); initializeImgHover(); diff --git a/library/ZendAfi/View/Helper/ShareUrl.php b/library/ZendAfi/View/Helper/ShareUrl.php index 82961559d44bcc2896f110d9fd629a8a09d40a5e..94a0439818d2633a866c4240da2a3bd407ce7225 100644 --- a/library/ZendAfi/View/Helper/ShareUrl.php +++ b/library/ZendAfi/View/Helper/ShareUrl.php @@ -21,15 +21,15 @@ class ZendAfi_View_Helper_ShareUrl extends Zend_View_Helper_HtmlElement { static protected $_web_client; + protected $reseaux=["facebook" => ["url" => "https://www.facebook.com/sharer/sharer.php"], - "twitter" => ["url" => "https://twitter.com/share?"]]; + "twitter" => ["url" => "https://twitter.com/share"]]; public function getReseaux($id_reseau=false) { - if($id_reseau) - return $this->reseaux[$id_reseau]; - else - return $this->reseaux; + return $id_reseau + ? $this->reseaux[$id_reseau] + : $this->reseaux; } @@ -37,23 +37,25 @@ class ZendAfi_View_Helper_ShareUrl extends Zend_View_Helper_HtmlElement { public function shareUrl($id_reseau,$url_afi,$titre= '', $message = '', $url_img = '') { $url_afi = $this->view->absoluteUrl(urldecode($url_afi)); - // Url réseau - if($id_reseau==='facebook') - return $this->reseaux[$id_reseau]["url"]; - - if($id_reseau==='twitter') - return $this->reseaux[$id_reseau]["url"]. - $this->getTwitterUrl($url_afi, + return $id_reseau === 'facebook' + ? $this->getFacebookUrl($url_afi, $titre) + : $this->getTwitterUrl($url_afi, $titre, $message); } + public function getFacebookUrl($url, $titre) { + return $this->reseaux['facebook']['url'] . '?' . http_build_query(['u' => $url, + 'title' => $titre]); + } + + public function getTwitterUrl($url_afi, $titre, $message) { - return http_build_query(['url' => $url_afi, - 'text' => $titre, - 'counturl' => $url_afi], - '','&'); + return $this->reseaux['twitter']['url'] . '?' . http_build_query(['url' => $url_afi, + 'text' => $titre, + 'counturl' => $url_afi], + '','&'); } diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index c00b9d8d337c2f6ed381dfaa32030389922b4b61..fa705424e5dc58e386b1a470e88e77a268765a88 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -398,7 +398,10 @@ class ProfilOptionsControllerTwitterLinkWithProfilAdulteTest extends ProfilOptio /** @test */ public function facebookLinkShouldReturnJavascriptForTweet() { $this->dispatch('/opac/index/share/on/facebook/titre/Profil+Adulte?url='.urlencode('/index/index'), true); - $this->assertContains("window.open('https://www.facebook.com/sharer/sharer.php','_blank','toolbar=0,status=0,width=800, height=410');", + $share_url = 'https://www.facebook.com/sharer/sharer.php?' + . http_build_query(['u' => Class_Url::absolute('/index/index?id_profil=22'), + 'title' => 'Profil Adulte']); + $this->assertContains("window.open('" . $share_url . "','_blank','toolbar=0,status=0,width=800, height=410');", $this->_response->getBody()); } }