/**
     * @param Tx_News_Domain_Model_News $news
     * @param $pidList
     * @param $sortField
     * @return array
     */
    protected function getNeighbours(Tx_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;
    }
Esempio n. 2
0
 /**
  * Checks if the news pid could be found in the startingpoint settings of the detail plugin and
  * if the pid could not be found it return NULL instead of the news object.
  *
  * @param Tx_News_Domain_Model_News $news
  * @return NULL|Tx_News_Domain_Model_News
  */
 protected function checkPidOfNewsRecord(Tx_News_Domain_Model_News $news)
 {
     $allowedStoragePages = GeneralUtility::trimExplode(',', Tx_News_Utility_Page::extendPidListByChildren($this->settings['startingpoint'], $this->settings['recursive']), TRUE);
     if (count($allowedStoragePages) > 0 && !in_array($news->getPid(), $allowedStoragePages)) {
         $this->signalSlotDispatcher->dispatch(__CLASS__, 'checkPidOfNewsRecordFailedInDetailAction', array('news' => $news, 'newsController' => $this));
         $news = NULL;
     }
     return $news;
 }