示例#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;
 }
示例#2
0
    /**
     * Render facebook comment viewhelper
     *
     * @param string $appId
     * @return string
     */
    public function render($appId)
    {
        $tsSettings = $this->pluginSettingsService->getSettings();
        $this->tag->addAttribute('data-href', GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
        $this->tag->forceClosingTag(true);
        $locale = !empty($tsSettings['facebookLocale']) && strlen($tsSettings['facebookLocale']) <= 5 ? $tsSettings['facebookLocale'] : 'en_US';
        $code = '<div id="fb-root"></div>
					<script src="http://connect.facebook.net/' . $locale . '/all.js#appId=' . htmlspecialchars($appId) . '&amp;xfbml=1"></script>';
        $code .= $this->tag->render();
        return $code;
    }
示例#3
0
 /**
  * Render the Google+ button
  *
  * @param string $jsCode Alternative JavaScript code which is used
  * @return string
  */
 public function render($jsCode = '')
 {
     if (empty($jsCode)) {
         $jsCode = 'https://apis.google.com/js/plusone.js';
     } elseif ($jsCode != '-1') {
         $jsCode = htmlspecialchars($jsCode);
     }
     $tsSettings = $this->pluginSettingsService->getSettings();
     $locale = !empty($tsSettings['googlePlusLocale']) && strlen($tsSettings['googlePlusLocale']) <= 5 ? '{lang:\'' . $tsSettings['googlePlusLocale'] . '\'}' : '';
     $code = '<script type="text/javascript" src="' . $jsCode . '">' . $locale . '</script>';
     $this->tag->setContent(' ');
     $code .= $this->tag->render();
     return $code;
 }
示例#4
0
 /**
  * Render the Google+ button
  *
  * @param string $jsCode Alternative JavaScript code which is used
  * @return string
  */
 public function render($jsCode = '')
 {
     if (empty($jsCode)) {
         $jsCode = 'https://apis.google.com/js/platform.js';
     } elseif ($jsCode != '-1') {
         $jsCode = htmlspecialchars($jsCode);
     }
     $tsSettings = $this->pluginSettingsService->getSettings();
     $locale = !empty($tsSettings['googlePlusLocale']) && strlen($tsSettings['googlePlusLocale']) <= 5 ? '{lang:\'' . $tsSettings['googlePlusLocale'] . '\'}' : '';
     $code = '<script type="text/javascript" src="' . $jsCode . '" async="async" defer="defer">' . $locale . '</script>';
     $this->tag->setContent(' ');
     $this->tag->addAttribute('class', 'g-plusone');
     if ($this->tag->hasAttribute('href')) {
         $this->tag->addAttribute('data-ref', $this->tag->getAttribute('href'));
         $this->tag->removeAttribute('href');
     }
     $code .= $this->tag->render();
     return $code;
 }
示例#5
0
    /**
     * Render disqus thread
     *
     * @param \GeorgRinger\News\Domain\Model\News $newsItem news item
     * @param string $shortName shortname
     * @param string $link link
     * @return string
     */
    public function render(\GeorgRinger\News\Domain\Model\News $newsItem, $shortName, $link)
    {
        $tsSettings = $this->pluginSettingsService->getSettings();
        $code = '<script type="text/javascript">
					var disqus_shortname = ' . GeneralUtility::quoteJSvalue($shortName, TRUE) . ';
					var disqus_identifier = \'news_' . $newsItem->getUid() . '\';
					var disqus_url = ' . GeneralUtility::quoteJSvalue($link, TRUE) . ';
					var disqus_title = ' . GeneralUtility::quoteJSvalue($newsItem->getTitle(), TRUE) . ';
					var disqus_config = function () {
						this.language = ' . GeneralUtility::quoteJSvalue($tsSettings['disqusLocale']) . ';
					};

					(function() {
						var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
						dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js";
						(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
					})();
				</script>';
        return $code;
    }
示例#6
0
 /**
  * Render link to news item or internal/external pages
  *
  * @param \GeorgRinger\News\Domain\Model\News $newsItem current news object
  * @param array $settings
  * @param boolean $uriOnly return only the url without the a-tag
  * @param array $configuration optional typolink configuration
  * @param string $content optional content which is linked
  * @return string link
  */
 public function render(\GeorgRinger\News\Domain\Model\News $newsItem, array $settings = array(), $uriOnly = FALSE, $configuration = array(), $content = '')
 {
     $tsSettings = $this->pluginSettingsService->getSettings();
     $this->init();
     $newsType = (int) $newsItem->getType();
     switch ($newsType) {
         // internal news
         case 1:
             $configuration['parameter'] = $newsItem->getInternalurl();
             break;
             // external news
         // external news
         case 2:
             $configuration['parameter'] = $newsItem->getExternalurl();
             break;
             // normal news record
         // normal news record
         default:
             $configuration = $this->getLinkToNewsItem($newsItem, $tsSettings, $configuration);
     }
     if (isset($tsSettings['link']['typesOpeningInNewWindow'])) {
         if (GeneralUtility::inList($tsSettings['link']['typesOpeningInNewWindow'], $newsType)) {
             $this->tag->addAttribute('target', '_blank');
         }
     }
     $url = $this->cObj->typoLink_URL($configuration);
     if ($uriOnly) {
         return $url;
     }
     $this->tag->addAttribute('href', $url);
     if (empty($content)) {
         $content = $this->renderChildren();
     }
     $this->tag->setContent($content);
     return $this->tag->render();
 }
示例#7
0
文件: Youtube.php 项目: r3h6/news
 /**
  * @param \GeorgRinger\News\Domain\Model\Media $element
  * @return null|string
  */
 public function getYoutubeUrl(\GeorgRinger\News\Domain\Model\Media $element)
 {
     $videoId = NULL;
     $youtubeUrl = NULL;
     if (preg_match('/(v=|v\\/|.be\\/)([^(\\&|$)]*)/', $element->getContent(), $matches)) {
         $videoId = $matches[2];
     }
     if ($videoId) {
         $youtubeUrl = '//www.youtube.com/embed/' . $videoId . '?fs=1&wmode=opaque';
         $settings = $this->pluginSettingsService->getSettings();
         if (isset($settings['mediaRenderer']) && isset($settings['mediaRenderer']['youtube']) && isset($settings['mediaRenderer']['youtube']['additionalParams'])) {
             $youtubeUrl .= $settings['mediaRenderer']['youtube']['additionalParams'];
         }
     }
     return $youtubeUrl;
 }