* Gets a specific article decorated as viewable article.
*
* @param integer $articleID
+ * @param boolean $enableContentLoading Enables/disables the loading of article content objects
* @return ViewableArticle
*/
- public static function getArticle($articleID) {
+ public static function getArticle($articleID, $enableContentLoading = true) {
$list = new ViewableArticleList();
+ $list->enableContentLoading($enableContentLoading);
$list->setObjectIDs([$articleID]);
$list->readObjects();
$objects = $list->getObjects();
*/
public $decoratorClassName = ViewableArticle::class;
+ /**
+ * enables/disables the loading of article content objects
+ * @var boolean
+ */
+ protected $contentLoading = true;
+
/**
* @inheritDoc
*/
}
// get article content
- if (!empty($this->objectIDs)) {
+ if ($this->contentLoading && !empty($this->objectIDs)) {
$contentList = new ViewableArticleContentList();
$contentList->getConditionBuilder()->add('article_content.articleID IN (?)', [$this->objectIDs]);
$contentList->getConditionBuilder()->add('(article_content.languageID IS NULL OR article_content.languageID = ?)', [WCF::getLanguage()->languageID]);
}
}
}
+
+ /**
+ * Enables/disables the loading of article content objects.
+ *
+ * @param boolean $enable
+ */
+ public function enableContentLoading($enable = true) {
+ $this->contentLoading = $enable;
+ }
}
if ($this->articleContent === null) {
throw new IllegalLinkException();
}
- $this->article = ViewableArticle::getArticle($this->articleContent->articleID);
+ $this->article = ViewableArticle::getArticle($this->articleContent->articleID, false);
$this->category = $this->article->getCategory();
// update interface language