/** * 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; }
/** * Test if title can be set * * @test * @return void */ public function titleCanBeSet() { $title = 'News title'; $this->newsDomainModelInstance->setTitle($title); $this->assertEquals($title, $this->newsDomainModelInstance->getTitle()); }
/** * @param \GeorgRinger\News\Domain\Model\News $news * @param integer $currentPage */ public function detailActionSlot($news, $currentPage) { $plenigoFields = $this->getPlenigoFields($news->getUid()); // \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($plenigoFields); if (empty($plenigoFields)) { $GLOBALS['TSFE']->pageUnavailableAndExit("Plenigo Extension not configured yet or Error reading Data", 'HTTP/1.1 500 Internal Server Error'); throw new \Exception("Plenigo Extension not configured yet or Error reading Data from News-Table"); return true; } $this->plenigoSettings = $this->getPlenigoSettings(); if (is_null($this->plenigoSettings)) { $GLOBALS['TSFE']->pageUnavailableAndExit("Plenigo Extension not configured yet or Error reading Data", 'HTTP/1.1 500 Internal Server Error'); } $hasUserBought = null; // $secret = $plenigoSetting->getCompanyPrivateKey(); // $companyId = $plenigoSetting->getCompanyID(); // $isTestMode = $plenigoSetting->isTestMode(); $this->connect(); // is there a category if ($plenigoFields['plenigo_category']) { $category = $this->getPlenigoCategory($plenigoFields['plenigo_category']); $productID = 'item-' . $news->getUid(); // is it bought already? $hasUserBought = \plenigo\services\UserService::hasUserBought($productID); if (!$hasUserBought) { //creating the product ($productId, $productTitle, $price, $currency) try { // new custom ProductID (https://github.com/plenigo/plenigo_php_sdk/wiki/Checkout#other-products) $product = new \plenigo\models\ProductBase($productID, $news->getTitle()); $product->setCategoryId($category['plenigo_i_d']); } catch (\Exception $e) { $GLOBALS['TSFE']->pageUnavailableAndExit("Could not create Plenigo-Product", 'HTTP/1.1 500 Internal Server Error'); } } } // its not bought yet, but we have an associated product if (!$hasUserBought && $plenigoFields['plenigo_product']) { $productData = $this->getPlenigoProduct($plenigoFields['plenigo_product']); // ist it bought? $hasUserBought = \plenigo\services\UserService::hasUserBought($productData['product_i_d']); if (!$hasUserBought) { // https://github.com/plenigo/plenigo_php_sdk/wiki/Checkout#plenigo-managed-product try { $product = new \plenigo\models\ProductBase($productData['product_i_d']); // \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($productData); } catch (\Exception $e) { $GLOBALS['TSFE']->pageUnavailableAndExit("Could not create Plenigo-Product", 'HTTP/1.1 500 Internal Server Error'); } } } if (FALSE === $hasUserBought) { // inject our js-sdk into html-header $this->buildHeader(); if (!is_object($product)) { $GLOBALS['TSFE']->pageUnavailableAndExit("Product is not bought, but no productidentity given", 'HTTP/1.1 500 Internal Server Error'); throw new \Exception("no Product given!"); } $curtain = new Curtain($this->plenigoSettings); $checkout = new \plenigo\builders\CheckoutSnippetBuilder($product); $builder = new \plenigo\builders\LoginSnippetBuilder(); //This will generate the login snippet of the following format: //plenigo.login(); $curtain->setLoginButton($builder->build()); $curtain->setCheckoutCode($checkout->build()); $news->setBodytext($this->getPaymentInfo($news->getBodytext()) . $curtain->getCode()); } // else displaying normal news }