/** * 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_MooxNews_Domain_Model_News $news * @return NULL|Tx_MooxNews_Domain_Model_News */ protected function checkPidOfNewsRecord(Tx_MooxNews_Domain_Model_News $news) { $allowedStoragePages = GeneralUtility::trimExplode(',', Tx_MooxNews_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; }
/** * @param Tx_MooxNews_Domain_Model_News $news * @param $pidList * @param $sortField * @return array */ protected function getNeighbours(Tx_MooxNews_Domain_Model_News $news, $pidList, $sortField) { $pidList = empty($pidList) ? $news->getPid() : $pidList; $select = 'SELECT tx_mooxnews_domain_model_news.uid,tx_mooxnews_domain_model_news.title '; $from = 'FROM tx_mooxnews_domain_model_news'; $whereClause = 'tx_mooxnews_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_mooxnews_domain_model_news WHERE tx_mooxnews_domain_model_news.uid = ' . $news->getUid() . ')) ORDER BY ' . $sortField . ' ASC LIMIT 3'; $query2 = $select . $from . ' WHERE ' . $whereClause . ' AND ' . $sortField . '= (SELECT MIN(' . $sortField . ') FROM tx_mooxnews_domain_model_news WHERE ' . $whereClause . ' AND ' . $sortField . ' > (SELECT ' . $sortField . ' FROM tx_mooxnews_domain_model_news WHERE tx_mooxnews_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; }