protected function compile() { global $objPage; // Set the flags $GLOBALS['NEWS_FILTER_SHOW_SEARCH'] = $this->news_filterShowSearch ? true : false; // filter news by search $GLOBALS['NEWS_FILTER_USE_SEARCH_INDEX'] = $this->news_filterUseSearchIndex ? true : false; // filter news by search index or tl_news table $GLOBALS['NEWS_FILTER_FUZZY_SEARCH'] = $this->news_filterFuzzySearch ? true : false; // use fuzzy search $GLOBALS['NEWS_FILTER_SEARCH_QUERY_TYPE'] = $this->news_filterSearchQueryType ? "and" : "or"; // query type 'and' or 'or' $this->strCategoryTemplate = $this->news_filterCategoryTemplate ?: NULL; // Show search form in template $this->Template->showSearch = $this->news_filterShowSearch ?: NULL; $this->Template->showCategories = $this->news_filterShowCategories ?: NULL; // Set Fields $this->Template->searchKeywords = trim(\Input::get('searchKeywords')); $this->news_archives = $this->sortOutProtected(deserialize($this->news_archives)); // Return if there are no archives if (!is_array($this->news_archives) || empty($this->news_archives)) { return ''; } // news archive, with newscategories (news_categories module) $this->news_filterNewsCategoryArchives = deserialize($this->news_filterNewsCategoryArchives, true); $sql = "SELECT * FROM tl_news_archive WHERE tl_news_archive.id IN(" . implode(',', array_map('intval', $this->news_archives)) . ") ORDER BY title"; /** @var \Contao\Database\Result $rs */ $rs = \Database::getInstance()->query($sql); $arrResult = $rs->fetchAllAssoc(); if (empty($arrResult)) { return ''; } $objTemplate = new \FrontendTemplate($this->searchTpl ?: $this->strCategoryTemplate); $objTemplate->filterName = $GLOBALS['TL_LANG']['news_plus']['filterLabel']; $objTemplate->rootPageLink = \Controller::generateFrontendUrl($objPage->row()); if ($this->strCategoryTemplate == 'filter_cat_multilevel') { $strNewsArchives = trim(\Input::get('newscategories')); $strNewsCategories = trim(\Input::get('category')); if ($strNewsArchives || $strNewsCategories) { $filterName = ModuleNewsListPlus::findArchiveTitleByPid($strNewsArchives); // overwrite title with news_category if ($filterName && $strNewsCategories) { $objNewsCategory = \NewsCategories\NewsCategoryModel::findPublishedByIdOrAlias($strNewsCategories); if ($objNewsCategory !== null) { $filterName = $objNewsCategory->frontendTitle ? $objNewsCategory->frontendTitle : $objNewsCategory->title; } } $objTemplate->filterName = self::getShortCategoryTitle($filterName); $objTemplate->filterResetName = $GLOBALS['TL_LANG']['news_plus']['resetFilterLabel']; $objTemplate->pageLink = $objPage->alias; $objTemplate->activeNewsArchive = $strNewsArchives; $objTemplate->activeCategory = $strNewsCategories; } $objTemplate->categories = self::groupCategoriesByArchivesTitle($arrResult); } else { $objTemplate->optionValues = self::getCategoriesFromArchiveTitle($arrResult); } $this->Template->categories = $objTemplate->parse(); }
protected static function getIdsOfNewsItemsFromSearchObject($objSearch) { foreach ($objSearch->fetchAllAssoc() as $news) { $news['archive_title'] = ModuleNewsListPlus::findArchiveTitleByPid($news['pid']); $arrNews[] = $news; } return $arrNews; }