Example #1
0
 /**
  * Render the facebook like viewhelper
  *
  * @return string
  */
 public function render()
 {
     $code = '';
     $url = !empty($this->arguments['href']) ? $this->arguments['href'] : GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
     // absolute urls are needed
     $this->tag->addAttribute('href', 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']) && strlen($tsSettings['facebookLocale']) <= 5 ? $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 .= 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;
 }
Example #2
0
 /**
  * @test
  * @dataProvider correctUrlIsDeliveredDataProvider
  */
 public function correctUrlIsDelivered($actual, $expected)
 {
     $this->assertEquals($expected, Url::prependDomain($actual));
 }