Example #1
0
 /**
  * Handles the blogpost visits
  *
  * @param \GeorgRinger\News\Domain\Model\News $news
  * @return void
  */
 public function detailActionSlot(\GeorgRinger\News\Domain\Model\News $news = null)
 {
     $sessionKey = $this->extensionName . '_visits_news';
     $excludedIps = $this->settings['excludedIpsForVisits'];
     $this->isExcludedIp = in_array($GLOBALS['_SERVER']['REMOTE_ADDR'], GeneralUtility::trimExplode(',', $excludedIps, true));
     $viewedNewsArray = $this->feSession->get($sessionKey);
     // Increases view count, updates news object, remembers object UID in session for unique views
     if ((!is_array($viewedNewsArray) || is_array($viewedNewsArray) && !in_array($news->getUid(), $viewedNewsArray)) && !$this->isExcludedIp) {
         $viewedNewsArray[] = $news->getUid();
         /** @var \Ecom\EcomToolbox\Domain\Model\News $news */
         $news->setEcomBlogpostVisits($news->getEcomBlogpostVisits() + 1);
         $this->newsRepository->update($news);
         $this->feSession->store($sessionKey, $viewedNewsArray);
     }
 }
 public function render(\GeorgRinger\News\Domain\Model\News $newsItem)
 {
     $vars = GeneralUtility::_GET('tx_news_pi1');
     if (isset($vars['news']) && (int) $newsItem->getUid() === (int) $vars['news']) {
         return $this->renderThenChild();
     } else {
         return $this->renderElseChild();
     }
 }
 /**
  * Add the news uid to a global variable to be able to exclude it later
  *
  * @param \GeorgRinger\News\Domain\Model\News $newsItem current news item
  * @return void
  */
 public function render(\GeorgRinger\News\Domain\Model\News $newsItem)
 {
     $uid = $newsItem->getUid();
     if (empty($GLOBALS['EXT']['news']['alreadyDisplayed'])) {
         $GLOBALS['EXT']['news']['alreadyDisplayed'] = array();
     }
     $GLOBALS['EXT']['news']['alreadyDisplayed'][$uid] = $uid;
     // Add localized uid as well
     $originalUid = (int) $newsItem->_getProperty('_localizedUid');
     if ($originalUid > 0) {
         $GLOBALS['EXT']['news']['alreadyDisplayed'][$originalUid] = $originalUid;
     }
 }
Example #4
0
 /**
  * Output different objects
  *
  * @param \GeorgRinger\News\Domain\Model\News $newsItem current newsitem
  * @param string $as output variable
  * @param string $className custom class which handles the new objects
  * @param string $extendedTable table which is extended
  * @return string output
  */
 public function render(\GeorgRinger\News\Domain\Model\News $newsItem, $as, $className, $extendedTable = 'tx_news_domain_model_news')
 {
     $rawRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', $extendedTable, 'uid=' . (int) $newsItem->getUid());
     $rawRecord = $GLOBALS['TSFE']->sys_page->getRecordOverlay($extendedTable, $rawRecord, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL);
     $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
     /* @var $dataMapper DataMapper */
     $dataMapper = $objectManager->get(DataMapper::class);
     $records = $dataMapper->map($className, array($rawRecord));
     $record = array_shift($records);
     $this->templateVariableContainer->add($as, $record);
     $output = $this->renderChildren();
     $this->templateVariableContainer->remove($as);
     return $output;
 }
Example #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;
    }
Example #6
0
 /**
  * @param \GeorgRinger\News\Domain\Model\News $newsItem
  * @return int
  */
 protected function getNewsId(\GeorgRinger\News\Domain\Model\News $newsItem)
 {
     $uid = $newsItem->getUid();
     // If a user is logged in and not in live workspace
     if ($GLOBALS['BE_USER'] && $GLOBALS['BE_USER']->workspace > 0) {
         $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getLiveVersionOfRecord('tx_news_domain_model_news', $newsItem->getUid());
         if ($record['uid']) {
             $uid = $record['uid'];
         }
     }
     return $uid;
 }
Example #7
0
    /**
     * @param \GeorgRinger\News\Domain\Model\News $news
     * @param $pidList
     * @param $sortField
     * @return array
     */
    protected function getNeighbours(\GeorgRinger\News\Domain\Model\News $news, $pidList, $sortField)
    {
        $pidList = empty($pidList) ? $news->getPid() : $pidList;
        $select = 'SELECT tx_news_domain_model_news.uid,tx_news_domain_model_news.title ';
        $from = 'FROM tx_news_domain_model_news';
        $whereClause = 'tx_news_domain_model_news.pid IN(' . $this->databaseConnection->cleanIntList($pidList) . ') ' . $this->getEnableFieldsWhereClauseForTable();
        $query = $select . $from . '
					WHERE ' . $whereClause . ' && ' . $sortField . ' >= (SELECT MAX(' . $sortField . ')
						' . $from . '
					WHERE ' . $whereClause . ' AND ' . $sortField . ' < (SELECT ' . $sortField . '
						FROM tx_news_domain_model_news
						WHERE tx_news_domain_model_news.uid = ' . $news->getUid() . '))
					ORDER BY ' . $sortField . ' ASC
					LIMIT 3';
        $query2 = $select . $from . '
			WHERE ' . $whereClause . ' AND ' . $sortField . '= (SELECT MIN(' . $sortField . ')
				FROM tx_news_domain_model_news
				WHERE ' . $whereClause . ' AND ' . $sortField . ' >
					(SELECT ' . $sortField . '
					FROM tx_news_domain_model_news
					WHERE tx_news_domain_model_news.uid = ' . $news->getUid() . '))
			';
        $res = $this->databaseConnection->sql_query($query);
        $out = array();
        while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
            $out[] = $row;
        }
        $this->databaseConnection->sql_free_result($res);
        if (count($out) === 0) {
            $res = $this->databaseConnection->sql_query($query2);
            while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
                $out[] = $row;
            }
            $this->databaseConnection->sql_free_result($res);
            return $out;
        }
        return $out;
    }
 /**
  * @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
 }