protected function parseArticle($objArticle, $blnAddArchive=false, $strClass='', $intCount=0)
	{
		$objTemplate = new FrontendTemplate($this->news_template);
		$objTemplate->setData($objArticle->row());

		if ($objArticle->cssClass != '')
		{
			$strClass = ' ' . $objArticle->cssClass . $strClass;
		}

		if ($objArticle->featured)
		{
			$strClass = ' featured' . $strClass;
		}

		$objTemplate->class = $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 = News::generateNewsUrl($objArticle, $blnAddArchive);
		$objTemplate->archive = $objArticle->getRelated('pid');
		$objTemplate->count = $intCount; // see #5708
		$objTemplate->text = '';
		$objTemplate->hasText = false;
		$objTemplate->hasTeaser = false;

		// Clean the RTE output
		if ($objArticle->teaser != '')
		{
			$objTemplate->hasTeaser = true;
			$objTemplate->teaser = StringUtil::toHtml5($objArticle->teaser);
			$objTemplate->teaser = StringUtil::encodeEmail($objTemplate->teaser);
		}

		// Display the "read more" button for external/article links
		if ($objArticle->source != 'default')
		{
			$objTemplate->text = true;
			$objTemplate->hasText = true;
		}

		// Compile the news text
		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 = function () use ($objArticle)
			{
				return ContentModel::countPublishedByPidAndTable($objArticle->id, 'tl_news') > 0;
			};
		}

		$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 && is_file(System::getContainer()->getParameter('kernel.project_dir') . '/' . $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 = StringUtil::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, null, null, $objModel);

				// Link to the news article if no image link has been defined (see #30)
				if (!$objTemplate->fullsize && !$objTemplate->imageUrl)
				{
					// Unset the image title attribute
					$picture = $objTemplate->picture;
					unset($picture['title']);
					$objTemplate->picture = $picture;

					// Link to the news article
					$objTemplate->href = $objTemplate->link;
					$objTemplate->linkTitle = StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objArticle->headline), true);

					// If the external link is opened in a new window, open the image link in a new window, too (see #210)
					if ($objTemplate->source == 'external' && $objTemplate->target && strpos($objTemplate->attributes, 'target="_blank"') === false)
					{
						$objTemplate->attributes .= ' target="_blank"';
					}
				}
			}
		}

		$objTemplate->enclosure = array();

		// Add enclosures
		if ($objArticle->addEnclosure)
		{
			$this->addEnclosuresToTemplate($objTemplate, $objArticle->row());
		}

		// 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);
			}
		}

		// Tag the response
		if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
		{
			/** @var ResponseTagger $responseTagger */
			$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
			$responseTagger->addTags(array('contao.db.tl_news.' . $objArticle->id));
			$responseTagger->addTags(array('contao.db.tl_news_archive.' . $objArticle->pid));
		}

		return $objTemplate->parse();
	}
protected function parseArticle($objArticle, $blnAddArchive=false, $strClass='', $intCount=0)
	{
		$objTemplate = new FrontendTemplate($this->news_template);
		$objTemplate->setData($objArticle->row());

		if ($objArticle->cssClass != '')
		{
			$strClass = ' ' . $objArticle->cssClass . $strClass;
		}

		if ($objArticle->featured)
		{
			$strClass = ' featured' . $strClass;
		}

		$objTemplate->class = $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 = News::generateNewsUrl($objArticle, $blnAddArchive);
		$objTemplate->archive = $objArticle->getRelated('pid');
		$objTemplate->count = $intCount; 
		$objTemplate->text = '';
		$objTemplate->hasText = false;
		$objTemplate->hasTeaser = false;

		
		if ($objArticle->teaser != '')
		{
			$objTemplate->hasTeaser = true;
			$objTemplate->teaser = StringUtil::toHtml5($objArticle->teaser);
			$objTemplate->teaser = StringUtil::encodeEmail($objTemplate->teaser);
		}

		
		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 = function () use ($objArticle)
			{
				return ContentModel::countPublishedByPidAndTable($objArticle->id, 'tl_news') > 0;
			};
		}

		$arrMeta = $this->getMetaFields($objArticle);

		
		$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;

		
		if ($objArticle->addImage && $objArticle->singleSRC != '')
		{
			$objModel = FilesModel::findByUuid($objArticle->singleSRC);

			if ($objModel !== null && is_file(System::getContainer()->getParameter('kernel.project_dir') . '/' . $objModel->path))
			{
				
				$arrArticle = $objArticle->row();

				
				if ($this->imgSize != '')
				{
					$size = StringUtil::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, null, null, $objModel);

				
				if (!$objTemplate->fullsize && !$objTemplate->imageUrl)
				{
					
					$picture = $objTemplate->picture;
					unset($picture['title']);
					$objTemplate->picture = $picture;

					
					$objTemplate->href = $objTemplate->link;
					$objTemplate->linkTitle = StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objArticle->headline), true);

					
					if ($objTemplate->source == 'external' && $objTemplate->target && strpos($objTemplate->attributes, 'target="_blank"') === false)
					{
						$objTemplate->attributes .= ' target="_blank"';
					}
				}
			}
		}

		$objTemplate->enclosure = array();

		
		if ($objArticle->addEnclosure)
		{
			$this->addEnclosuresToTemplate($objTemplate, $objArticle->row());
		}

		
		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);
			}
		}

		
		if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
		{
			
			$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
			$responseTagger->addTags(array('contao.db.tl_news.' . $objArticle->id));
			$responseTagger->addTags(array('contao.db.tl_news_archive.' . $objArticle->pid));
		}

		return $objTemplate->parse();
	}
protected function parseArticle ( $ objArticle , $ blnAddArchive = false , $ strClass = '' , $ intCount = 0 ) { $ objTemplate = new FrontendTemplate ( $ this -> news_template ) ; $ objTemplate -> setData ( $ objArticle -> row ( ) ) ; if ( $ objArticle -> cssClass != '' ) { $ strClass = ' ' . $ objArticle -> cssClass . $ strClass ; } if ( $ objArticle -> featured ) { $ strClass = ' featured' . $ strClass ; } $ objTemplate -> class = $ 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 = News :: generateNewsUrl ( $ objArticle , $ blnAddArchive ) ; $ objTemplate -> archive = $ objArticle -> getRelated ( 'pid' ) ; $ objTemplate -> count = $ intCount ; // see #5708 $ objTemplate -> text = '' ; $ objTemplate -> hasText = false ; $ objTemplate -> hasTeaser = false ; // Clean the RTE output if ( $ objArticle -> teaser != '' ) { $ objTemplate -> hasTeaser = true ; $ objTemplate -> teaser = StringUtil :: toHtml5 ( $ objArticle -> teaser ) ; $ objTemplate -> teaser = StringUtil :: encodeEmail ( $ objTemplate -> teaser ) ; } // Display the "read more" button for external/article links if ( $ objArticle -> source != 'default' ) { $ objTemplate -> text = true ; $ objTemplate -> hasText = true ; } // Compile the news text 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 = function ( ) use ( $ objArticle ) { return ContentModel :: countPublishedByPidAndTable ( $ objArticle -> id , 'tl_news' ) > 0 ; } ; } $ 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 && is_file ( System :: getContainer ( ) -> getParameter ( 'kernel.project_dir' ) . '/' . $ 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 = StringUtil :: 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 , null , null , $ objModel ) ; // Link to the news article if no image link has been defined (see #30) if ( ! $ objTemplate -> fullsize && ! $ objTemplate -> imageUrl ) { // Unset the image title attribute $ picture = $ objTemplate -> picture ; unset ( $ picture [ 'title' ] ) ; $ objTemplate -> picture = $ picture ; // Link to the news article $ objTemplate -> href = $ objTemplate -> link ; $ objTemplate -> linkTitle = StringUtil :: specialchars ( sprintf ( $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'readMore' ] , $ objArticle -> headline ) , true ) ; // If the external link is opened in a new window, open the image link in a new window, too (see #210) if ( $ objTemplate -> source == 'external' && $ objTemplate -> target && strpos ( $ objTemplate -> attributes , 'target="_blank"' ) === false ) { $ objTemplate -> attributes .= ' target="_blank"' ; } } } } $ objTemplate -> enclosure = array ( ) ; // Add enclosures if ( $ objArticle -> addEnclosure ) { $ this -> addEnclosuresToTemplate ( $ objTemplate , $ objArticle -> row ( ) ) ; } // 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 ) ; } } // Tag the response if ( System :: getContainer ( ) -> has ( 'fos_http_cache.http.symfony_response_tagger' ) ) { /** @var ResponseTagger $responseTagger */ $ responseTagger = System :: getContainer ( ) -> get ( 'fos_http_cache.http.symfony_response_tagger' ) ; $ responseTagger -> addTags ( array ( 'contao.db.tl_news.' . $ objArticle -> id ) ) ; $ responseTagger -> addTags ( array ( 'contao.db.tl_news_archive.' . $ objArticle -> pid ) ) ; } return $ objTemplate -> parse ( ) ; }
Parse an item and return it as string

@param NewsModel $objArticle
@param boolean   $blnAddArchive
@param string    $strClass
@param integer   $intCount

@return string
Parse an item and return it as string