/** * Render the facebook like viewhelper * * @return string */ public function render() { $code = ''; $url = !empty($this->arguments['href']) ? $this->arguments['href'] : \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'); // absolute urls are needed $this->tag->addAttribute('href', Tx_MooxNews_Utility_Url::prependDomain($url)); $this->tag->forceClosingTag(TRUE); // -1 means no JS if ($this->arguments['javaScript'] != '-1') { if (empty($this->arguments['javaScript'])) { $tsSettings = $this->pluginSettingsService->getSettings(); $locale = !empty($tsSettings['facebookLocale']) ? $tsSettings['facebookLocale'] : 'en_US'; $code = '<script src="https://connect.facebook.net/' . $locale . '/all.js#xfbml=1"></script>'; // Social interaction Google Analytics if ($this->pluginSettingsService->getByPath('analytics.social.facebookLike') == 1) { $code .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS("\n\t\t\t\t\t\tFB.Event.subscribe('edge.create', function(targetUrl) {\n\t\t\t\t\t\t \t_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tFB.Event.subscribe('edge.remove', function(targetUrl) {\n\t\t\t\t\t\t _gaq.push(['_trackSocial', 'facebook', 'unlike', targetUrl]);\n\t\t\t\t\t\t});\n\t\t\t\t\t"); } } else { $code = '<script src="' . htmlspecialchars($this->arguments['javaScript']) . '"></script>'; } } // seems as if a div with id fb-root is needed this is just a dirty // workaround to make things work again Perhaps we should // use the iframe variation. $code .= '<div id="fb-root"></div>' . $this->tag->render(); return $code; }
/** * Render the socialshareprivacy-bar * * @param string $href Given url, if empty, current url is used. * @param string $uid Uid of news item. Please add a prefix if a list- and details-view are on the same page. * @return string */ public function render($href = '', $uid = '') { $this->extKey = 'moox_news'; //get configuration $this->config = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_mooxnews.']['socialshareprivacynews.']; //t3lib_utility_Debug::debug($this->config); //t3lib_utility_Debug::debug($href); //t3lib_utility_Debug::debug($uid); //get uri if (empty($this->config['uri'])) { $this->config['uri'] = !empty($href) ? $href : t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'); // absolute urls are required $this->config['uri'] = Tx_MooxNews_Utility_Url::prependDomain($this->config['uri']); } //get uid of newsItem if (empty($uid)) { //prevent from empty uid if not set in template $uid = \TYPO3\CMS\Core\Utility\GeneralUtility::md5int($this->config['href']) . '-0'; } // render js-code $this->tmpl = $this->setTmpl($uid); // include CSS if set if ($this->config['css_path'] != '') { $GLOBALS['TSFE']->pSetup['includeCSS.'][$this->extKey . '_1'] = $this->config['css_path']; } //include javascript files if ($this->config['socialshareprivacy_path'] != '') { //$GLOBALS['TSFE']->pSetup['includeJS.'][$this->extKey.'_2'] = $this->config['socialshareprivacy_path']; $GLOBALS['TSFE']->additionalFooterData[] = '<script type="text/javascript" src="' . t3lib_extMgm::siteRelPath($this->extKey) . 'Resources/Public/socialshareprivacy/jquery.socialshareprivacy.js"></script>'; } $code = ''; if ($this->config['js_to_head'] == 1) { $GLOBALS['TSFE']->setJS($this->extKey, $this->tmpl); } else { //$code = '<script type="text/javascript">' . $this->tmpl . '</script>'; $GLOBALS['TSFE']->additionalFooterData[] = '<script type="text/javascript">' . $this->tmpl . '</script>'; } $code .= '<div id="socialshareprivacy_' . $uid . '"></div>'; return $code; }
/** * @test * @dataProvider correctUrlIsDeliveredDataProvider */ public function correctUrlIsDelivered($actual, $expected) { $this->assertEquals($expected, Tx_MooxNews_Utility_Url::prependDomain($actual)); }