/**
  * Parse an item and return it as string
  * @param object
  * @param boolean
  * @param string
  * @param integer
  * @return string
  */
 protected function parseArticle($objArticle, $blnAddArchive = false, $strClass = '', $intCount = 0)
 {
     global $objPage;
     $arrCategories = deserialize($objArticle->categories, true);
     $objTemplate = new \FrontendTemplate($this->news_template);
     $objTemplate->setData($objArticle->row());
     $objTemplate->class = ($objArticle->cssClass != '' ? ' ' . $objArticle->cssClass : '') . $strClass;
     $objTemplate->newsHeadline = $objArticle->headline;
     $objTemplate->subHeadline = $objArticle->subheadline;
     $objTemplate->hasSubHeadline = $objArticle->subheadline ? true : false;
     $objTemplate->linkHeadline = $this->generateLink($objArticle->headline, $objArticle, $blnAddArchive);
     $objTemplate->more = $this->generateLink($GLOBALS['TL_LANG']['MSC']['more'], $objArticle, $blnAddArchive, true);
     $objTemplate->link = $this->generateNewsUrl($objArticle, $blnAddArchive);
     $objTemplate->linkTarget = $objArticle->target ? $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"' : '';
     $objTemplate->linkTitle = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objArticle->headline), true);
     $objTemplate->count = $intCount;
     // see #5708
     $objTemplate->text = '';
     $objTemplate->hasText = false;
     $objTemplate->hasTeaser = false;
     // print pdf
     if ($this->news_pdfJumpTo) {
         $objTemplate->showPdfButton = true;
         $pdfPage = \PageModel::findByPk($this->news_pdfJumpTo);
         $pdfArticle = \ArticleModel::findPublishedByPidAndColumn($this->news_pdfJumpTo, 'main');
         $options = deserialize($pdfArticle->printable);
         if (in_array('pdf', $options)) {
             $objTemplate->pdfArticleId = $pdfArticle->id;
         }
         $strUrl = \Controller::generateFrontendUrl($pdfPage->row());
         $objTemplate->pdfJumpTo = $strUrl;
     }
     $objArchive = \NewsArchiveModel::findByPk($objArticle->pid);
     $objTemplate->archive = $objArchive;
     $objTemplate->archive->title = $objTemplate->archive->displayTitle ? $objTemplate->archive->displayTitle : $objTemplate->archive->title;
     $objTemplate->archive->class = ModuleNewsListPlus::getArchiveClassFromTitle($objTemplate->archive->title, true);
     $objTemplate->archiveTitle = $objTemplate->archive->title;
     $arrCategoryTitles = array();
     if ($this->news_archiveTitleAppendCategories && !empty($arrCategories)) {
         $arrTitleCategories = array_intersect($arrCategories, deserialize($this->news_archiveTitleCategories, true));
         if (!empty($arrTitleCategories)) {
             $objTitleCategories = NewsCategoryModel::findPublishedByIds($arrTitleCategories);
             if ($objTitleCategories !== null) {
                 while ($objTitleCategories->next()) {
                     if ($objTitleCategories->frontendTitle) {
                         $arrCategoryTitles[$objTitleCategories->id] = $objTitleCategories->frontendTitle;
                         continue;
                     }
                     $arrCategoryTitles[$objTitleCategories->id] = $objTitleCategories->title;
                 }
                 $objTemplate->archiveTitle .= ' : ' . implode(' : ', $arrCategoryTitles);
             }
         }
     }
     // add tags
     $objTemplate->showTags = $this->news_showtags;
     if ($this->news_showtags && $this->news_template_modal && $this->Environment->isAjaxRequest) {
         $helper = new NewsPlusTagHelper();
         $tagsandlist = $helper->getTagsAndTaglistForIdAndTable($objArticle->id, 'tl_news', $this->tag_jumpTo);
         $tags = $tagsandlist['tags'];
         $taglist = $tagsandlist['taglist'];
         $objTemplate->showTagClass = $this->tag_named_class;
         $objTemplate->tags = $tags;
         $objTemplate->taglist = $taglist;
         $objTemplate->news = 'IN';
     }
     // nav
     $strUrl = '';
     $objArchive = \NewsArchiveModel::findByPk($objArticle->pid);
     if ($objArchive !== null && $objArchive->jumpTo && ($objTarget = $objArchive->getRelated('jumpTo')) !== null) {
         $strUrl = $this->generateFrontendUrl($objTarget->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/news/%s');
     }
     $objTemplate->nav = static::generateArrowNavigation($objArticle, $strUrl, $this->news_readerModule);
     // Clean the RTE output
     if ($objArticle->teaser != '') {
         $objTemplate->hasTeaser = true;
         if ($objPage->outputFormat == 'xhtml') {
             $objTemplate->teaser = \String::toXhtml($objArticle->teaser);
         } else {
             $objTemplate->teaser = \String::toHtml5($objArticle->teaser);
         }
         $objTemplate->teaser = \String::encodeEmail($objTemplate->teaser);
     }
     // Display the "read more" button for external/article links
     if ($objArticle->source != 'default') {
         $objTemplate->text = true;
         $objTemplate->hasText = true;
     } else {
         $id = $objArticle->id;
         $objTemplate->text = function () use($id) {
             $strText = '';
             $objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_news');
             if ($objElement !== null) {
                 while ($objElement->next()) {
                     $strText .= $this->getContentElement($objElement->current());
                 }
             }
             return $strText;
         };
         $objTemplate->hasText = \ContentModel::findPublishedByPidAndTable($objArticle->id, 'tl_news') !== null;
     }
     $arrMeta = $this->getMetaFields($objArticle);
     // Add the meta information
     $objTemplate->date = $arrMeta['date'];
     $objTemplate->hasMetaFields = !empty($arrMeta);
     $objTemplate->numberOfComments = $arrMeta['ccount'];
     $objTemplate->commentCount = $arrMeta['comments'];
     $objTemplate->timestamp = $objArticle->date;
     $objTemplate->author = $arrMeta['author'];
     $objTemplate->datetime = date('Y-m-d\\TH:i:sP', $objArticle->date);
     $objTemplate->addImage = false;
     // Add an image
     if ($objArticle->addImage && $objArticle->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($objArticle->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($objArticle->singleSRC)) {
                 $objTemplate->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             // Do not override the field now that we have a model registry (see #6303)
             $arrArticle = $objArticle->row();
             // Override the default image size
             if ($this->imgSize != '') {
                 $size = deserialize($this->imgSize);
                 if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
                     $arrArticle['size'] = $this->imgSize;
                 }
             }
             $arrArticle['singleSRC'] = $objModel->path;
             $this->addImageToTemplate($objTemplate, $arrArticle);
         }
     }
     $objTemplate->enclosure = array();
     // Add enclosures
     if ($objArticle->addEnclosure) {
         $this->addEnclosuresToTemplate($objTemplate, $objArticle->row());
     }
     if (in_array('share', \ModuleLoader::getActive())) {
         $objArticle->title = $objArticle->headline;
         $objShare = new \HeimrichHannot\Share\Share($this->objModel, $objArticle);
         $objTemplate->share = $objShare->generate();
     }
     // Modal
     if ($this->news_showInModal && $objArticle->source == 'default' && $this->news_readerModule) {
         $objTemplate->modal = true;
         $objTemplate->modalTarget = '#' . NewsPlusHelper::getCSSModalID($this->news_readerModule);
     }
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['parseArticles']) && is_array($GLOBALS['TL_HOOKS']['parseArticles'])) {
         foreach ($GLOBALS['TL_HOOKS']['parseArticles'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($objTemplate, $objArticle->row(), $this);
         }
     }
     return $objTemplate->parse();
 }
 public function getContaoCategories(DataContainer $dc)
 {
     $arrOptions = array();
     if (!in_array('news_categories', \Config::getInstance()->getActiveModules())) {
         return $arrOptions;
     }
     $objCategories = \NewsCategories\NewsCategoryModel::findBy('published', 1);
     if ($objCategories === null) {
         return $arrOptions;
     }
     while ($objCategories->next()) {
         $arrOptions[$objCategories->id] = $objCategories->title;
     }
     return $arrOptions;
 }
 protected function getNewsCategoriesAsSubmenu($arrArchive)
 {
     $strCat = '';
     $objCategories = \NewsCategories\NewsCategoryModel::findPublishedByParent($arrArchive);
     if ($objCategories === null) {
         return $strCat;
     }
     $arrCategories = array();
     while ($objCategories->next()) {
         $strCat .= self::getNewsCategoryLink($objCategories->current(), $arrArchive);
         $arrCategories[$objCategories->id] = $objCategories->row();
     }
     $objTemplate = new \FrontendTemplate($this->searchTpl ?: 'form_newsfilter_cat_ml_submenu');
     $objTemplate->title = $arrArchive['title'];
     $objTemplate->active = in_array($arrArchive['id'], deserialize(\Input::get('newscategories'), true)) && \Input::get('category') == '';
     $objTemplate->trail = in_array($arrArchive['id'], deserialize(\Input::get('newscategories'), true)) && \Input::get('category') != '';
     $objTemplate->groupPageLink = self::getPageLink(array_keys($arrCategories), array('newscategories' => $arrArchive['id']));
     $objTemplate->values = $strCat;
     return $objTemplate->parse();
     return $strCat;
 }