Skip to content
Snippets Groups Projects
Commit a2b2a741 authored by llaffont's avatar llaffont
Browse files

Amélioration partage réseaux sociaux, prends la bonne url de la page courante

parent dc70deb9
Branches
Tags
No related merge requests found
......@@ -50,15 +50,16 @@ class IndexController extends Zend_Controller_Action {
public function shareAction() {
$this->_helper->getHelper('viewRenderer')
->setNoRender();
$this->_helper->getHelper('viewRenderer')->setNoRender();
$profil = Class_Profil::getCurrentProfil();
$url = urldecode($this->_getParam('url'));
$url .= (false === strpos($url, '?')) ? '?' : '&';
$url .= 'id_profil='. Class_Profil::getCurrentProfil()->getId();
$rs = new Class_WebService_ReseauxSociaux();
$body = sprintf("window.open('%s','_blank','location=yes, width=800, height=410')",
$rs->getUrl($this->_getParam('on'),
$this->view->url(array('id_profil' => $profil->getId()), null, true),
$url,
urldecode($this->_getParam('titre'))));
$this->getResponse()->setHeader('Content-Type', 'application/javascript; charset=utf-8');
......
......@@ -48,7 +48,8 @@ class Class_WebService_ReseauxSociaux {
//------------------------------------------------------------------------------------------------------
public function getUrl($id_reseau,$url_afi, $message = '') {
// Short url
$url_afi="http://".$_SERVER["HTTP_HOST"].BASE_URL.$url_afi;
if (false === strpos($url_afi, 'http'))
$url_afi = "http://".$_SERVER["HTTP_HOST"].BASE_URL.$url_afi;
// Url réseau
return sprintf($this->reseaux[$id_reseau]["url"],
......
......@@ -49,7 +49,7 @@ class ZendAfi_View_Helper_SocialShare extends Zend_View_Helper_HtmlElement {
public function addHeadScript() {
Class_ScriptLoader::getInstance()
->addInlineScript(sprintf("function socialShare(network) {"
."jQuery.getScript('%s/index/share/on/' + network + '/titre/' + $(\"title\").text());"
."jQuery.getScript('%s/index/share/on/' + network + '/titre/' + $(\"title\").text() + '?url=' + encodeURIComponent(window.location));"
."}",
BASE_URL));
}
......
......@@ -80,7 +80,7 @@ class ProfilOptionsControllerTwitterLinkWithProfilAdulteTest extends ProfilOptio
$this->_mock_web_client
->whenCalled('open_url')
->with(sprintf('http://is.gd/api.php?longurl=%s',
urlencode('http://localhost' . BASE_URL . '/index/index/id_profil/2')))
urlencode('http://localhost' . BASE_URL . '/index/index?id_profil=2')))
->answers('http://is.gd/PkdNgD')
->beStrict();
}
......@@ -94,7 +94,7 @@ class ProfilOptionsControllerTwitterLinkWithProfilAdulteTest extends ProfilOptio
/** @test */
public function twitterLinkShouldReturnJavascriptForTweet() {
$this->dispatch('/opac/index/share/on/twitter/titre/Profil+Adulte');
$this->dispatch('/opac/index/share/on/twitter/titre/Profil+Adulte?url='.urlencode('http://localhost'.BASE_URL.'/index/index'));
$this->assertContains(sprintf("window.open('http://twitter.com/home?status=%s','_blank','location=yes, width=800, height=410')",
urlencode('Profil Adulte http://is.gd/PkdNgD')),
$this->_response->getBody());
......@@ -103,7 +103,7 @@ class ProfilOptionsControllerTwitterLinkWithProfilAdulteTest extends ProfilOptio
/** @test */
public function facebookLinkShouldReturnJavascriptForTweet() {
$this->dispatch('/opac/index/share/on/facebook/titre/Profil+Adulte');
$this->dispatch('/opac/index/share/on/facebook/titre/Profil+Adulte?url='.urlencode('/index/index'), true);
$this->assertContains(sprintf("window.open('http://www.facebook.com/share.php?u=%s','_blank','location=yes, width=800, height=410')",
urlencode('Profil Adulte http://is.gd/PkdNgD')),
$this->_response->getBody());
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment