/** * Artikel parsen * @return string */ protected function assignArticleData() { $categoryTexts = array(); $categoryIcons = array(); $categories = $this->categoryList->getCategoriesAll(); foreach ($this->article->getCategories() as $categoryId) { $category = isset($categories[$categoryId]) ? $categories[$categoryId] : false; if (!$category) { continue; } $categoryTexts[] = '<span class="fpcm-pub-category-text">' . $category->getName() . '</span>'; if (!$category->getIconPath()) { continue; } $categoryIcons[] = '<img src="' . $category->getIconPath() . '" alt="' . $category->getName() . '" title="' . $category->getName() . '" class="fpcm-pub-category-icon">'; } $shareButtonParser = new \fpcm\model\pubtemplates\sharebuttons($this->article->getArticleLink(), $this->article->getTitle()); $users = $this->userList->getUsersByIds(array($this->article->getCreateuser(), $this->article->getChangeuser())); $commentCounts = $this->commentList->countComments(array($this->article->getId()), 0, 1, 0); $commentCount = $this->config->system_comments_enabled && $this->article->getComments() ? isset($commentCounts[$this->article->getId()]) ? (int) $commentCounts[$this->article->getId()] : 0 : ''; $this->articleTemplate->setCommentsEnabled($this->config->system_comments_enabled && $this->article->getComments()); if (isset($users[$this->article->getCreateuser()])) { $emailAddress = '<a href="mailto:' . $users[$this->article->getCreateuser()]->getEmail() . '">' . $users[$this->article->getCreateuser()]->getDisplayname() . '</a>'; } else { $emailAddress = ''; } $replacements = array('{{headline}}' => $this->article->getTitle(), '{{text}}' => $this->article->getContent(), '{{author}}' => isset($users[$this->article->getCreateuser()]) ? $users[$this->article->getCreateuser()]->getDisplayname() : $this->lang->translate('GLOBAL_NOTFOUND'), '{{authorEmail}}' => $emailAddress, '{{date}}' => date($this->config->system_dtmask, $this->article->getCreatetime()), '{{changeDate}}' => date($this->config->system_dtmask, $this->article->getChangetime()), '{{changeUser}}' => isset($users[$this->article->getChangeuser()]) ? $users[$this->article->getChangeuser()]->getDisplayname() : $this->lang->translate('GLOBAL_NOTFOUND'), '{{statusPinned}}' => $this->article->getPinned() ? $this->lang->translate('PUBLIC_ARTICLE_PINNED') : '', '{{shareButtons}}' => $shareButtonParser->parse(), '{{categoryIcons}}' => implode(PHP_EOL, $categoryIcons), '{{categoryTexts}}' => implode(PHP_EOL, $categoryTexts), '{{commentCount}}' => $commentCount, '{{permaLink}}:{{/permaLink}}' => $this->article->getArticleLink(), '{{commentLink}}:{{/commentLink}}' => $this->article->getArticleLink() . '#comments', '<readmore>:</readmore>' => $this->article->getMd5path(), '{{articleImage}}' => $this->article->getArticleImage(), '{{sources}}' => $this->article->getSources()); $this->articleTemplate->setReplacementTags($replacements); $parsed = $this->articleTemplate->parse(); if ($this->session->exists()) { $html = array(); $html[] = '<div class="fpcm-pub-articletoolbar-article fpcm-pub-articletoolbar-article' . $this->articleId . '">'; $html[] = '<a href="' . $this->article->getEditLink() . '">' . $this->lang->translate('HL_ARTICLE_EDIT') . '</a>'; $html[] = '</div>'; $parsed = implode(PHP_EOL, $html) . $parsed; } return $parsed; }