diff --git a/VERSIONS_HOTLINE/117624 b/VERSIONS_HOTLINE/117624 new file mode 100644 index 0000000000000000000000000000000000000000..0bc82816a94a5be77e7c1eb23a0062661ce48427 --- /dev/null +++ b/VERSIONS_HOTLINE/117624 @@ -0,0 +1 @@ + - ticket #117624 : Reprise des images d'articles sur les posts Facebook \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ShareUrl.php b/library/ZendAfi/View/Helper/ShareUrl.php index 94a0439818d2633a866c4240da2a3bd407ce7225..a935304f0d8e4d388b583ac3a82482be32e2deb3 100644 --- a/library/ZendAfi/View/Helper/ShareUrl.php +++ b/library/ZendAfi/View/Helper/ShareUrl.php @@ -37,17 +37,21 @@ 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)); + if ($url_img && false === strpos($url_img,'http')) + $url_img = $this->view->absoluteUrl(urldecode($url_img)); + return $id_reseau === 'facebook' - ? $this->getFacebookUrl($url_afi, $titre) + ? $this->getFacebookUrl($url_afi, $titre, $url_img) : $this->getTwitterUrl($url_afi, $titre, $message); } - public function getFacebookUrl($url, $titre) { + public function getFacebookUrl($url, $titre, $url_img) { return $this->reseaux['facebook']['url'] . '?' . http_build_query(['u' => $url, - 'title' => $titre]); + 'title' => $titre, + 'img_url' => $url_img]); } diff --git a/tests/application/modules/opac/controllers/SocialNetworkControllerTest.php b/tests/application/modules/opac/controllers/SocialNetworkControllerTest.php index 19be31f95e128b67fd69a24bed82aa64b521688b..0c3faa8865c8983d8f95431afd3384e45c74c881 100644 --- a/tests/application/modules/opac/controllers/SocialNetworkControllerTest.php +++ b/tests/application/modules/opac/controllers/SocialNetworkControllerTest.php @@ -29,4 +29,13 @@ class SocialNetworkControllerShareActionTest extends AbstractControllerTestCase $this->assertEquals("window.open('https://twitter.com/share?url=http%3A%2F%2Fwww.institut-francais.com&text=Vive+bucarest+%21&counturl=http%3A%2F%2Fwww.institut-francais.com','_blank','toolbar=0,status=0,width=800, height=410');", $this->_response->getBody()); } + + + /** @test */ + public function shareOnFacebookShouldInjectAllRequestedInformation() { + $this->dispatch('/social-network/share/on/facebook/url/'.urlencode('http://www.institut-francais.com').'/titre/'.urlencode('Vive bucarest !').'/img_url/'.urlencode('http://www.institut-francais.com/image/BIG.jpg'), true); + + $this->assertEquals("window.open('https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.institut-francais.com&title=Vive+bucarest+%21&img_url=http%3A%2F%2Fwww.institut-francais.com%2Fimage%2FBIG.jpg','_blank','toolbar=0,status=0,width=800, height=410');", + $this->_response->getBody()); + } } \ No newline at end of file