/**
  * Display a wildcard in the back end
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['newslist_plus'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     $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 '';
     }
     $this->news_featured = 'featured';
     // unset search string for highlighted section
     \Input::setGet('searchKeywords', null);
     $this->objArticles = NewsPlusModel::findPublishedByPids($this->news_archives, array(), array(), $this->news_featured == 'featured', $this->numberOfItems, 0);
     if ($this->objArticles === null) {
         return '';
     }
     return parent::generate();
 }
 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;
 }