protected static function generateArrowNavigation($objCurrentArchive, $strUrl, $modalId) { $objT = new \FrontendTemplate('navigation_arrows'); // get ids from NewsPlus::getAllNews $session = \Session::getInstance()->getData(); $arrIds = $session[NEWSPLUS_SESSION_NEWS_IDS]; if (count($arrIds) < 1) { return ''; } $prevID = null; $nextID = null; $currentIndex = array_search($objCurrentArchive->id, $arrIds); // prev only of not first item if (isset($arrIds[$currentIndex - 1])) { $prevID = $arrIds[$currentIndex - 1]; $objNews = NewsPlusModel::findByPk($prevID, array()); if ($objNews !== null) { $objT->prev = static::getNewsDetails($objNews, $strUrl, $modalId); $objT->prevLink = $GLOBALS['TL_LANG']['news_plus']['prevLink']; } } // next only of not last item if (isset($arrIds[$currentIndex + 1])) { $nextID = $arrIds[$currentIndex + 1]; $objNews = NewsPlusModel::findByPk($nextID, array()); if ($objNews !== null) { $objT->next = static::getNewsDetails($objNews, $strUrl, $modalId); $objT->nextLink = $GLOBALS['TL_LANG']['news_plus']['nextLink']; } } return $objT->parse(); }
protected function findNewsInSearchIndex() { $arrIds = array(); // Reference page if ($this->rootPage > 0) { $arrPages = $this->Database->getChildRecords($this->rootPage, 'tl_page'); array_unshift($arrPages, $this->rootPage); } else { global $objPage; $arrPages = $this->Database->getChildRecords($objPage->rootId, 'tl_page'); } try { $objSearch = \Search::searchFor($this->strKeywords, $this->objFilter->news_filterSearchQueryType === false, $arrPages, 0, 0, $this->objFilter->news_filterFuzzySearch); if ($objSearch->numRows > 0) { $arrUrls = array(); while ($objSearch->next()) { $arrUrls[] = $objSearch->url; } $strKeyWordColumns = ""; $n = 0; foreach ($arrUrls as $i => $strAlias) { $strKeyWordColumns .= ($n > 0 ? " OR " : "") . "{$this->t}.alias = ?"; $arrValues[] = basename($strAlias); $n++; } $arrColumns[] = "({$strKeyWordColumns})"; $objArticles = \HeimrichHannot\NewsPlus\NewsPlusModel::findBy($arrColumns, $arrValues); if ($objArticles !== null) { $arrIds = $objArticles->fetchEach('id'); } return $arrIds; } else { return $arrIds; } } catch (\Exception $e) { $this->log('Website search failed: ' . $e->getMessage(), __METHOD__, TL_ERROR); return $arrIds; } }