コード例 #1
0
ファイル: showcommon.php プロジェクト: sea75300/fanpresscm3
 /**
  * 
  * @param \fpcm\model\articles\article $article
  * @return string
  */
 protected function assignData(\fpcm\model\articles\article $article)
 {
     /**
      * @var \fpcm\model\pubtemplates\article
      */
     $tpl = $this->template;
     $categoryTexts = array();
     $categoryIcons = array();
     foreach ($article->getCategories() as $categoryId) {
         /**
          * @var \fpcm\model\categories\category
          */
         $category = isset($this->categories[$categoryId]) ? $this->categories[$categoryId] : false;
         if (!$category) {
             continue;
         }
         $categoryTexts[] = '<span class="fpcm-pub-category-text">' . $category->getName() . '</span>';
         if (!$category->getIconPath()) {
             continue;
         }
         $categoryIcons[] = $category->getCategoryImage();
     }
     $shareButtonParser = new \fpcm\model\pubtemplates\sharebuttons($article->getArticleLink(), $article->getTitle());
     $commentCount = $this->config->system_comments_enabled && $article->getComments() ? isset($this->commentCounts[$article->getId()]) ? (int) $this->commentCounts[$article->getId()] : 0 : '';
     $tpl->setCommentsEnabled($this->config->system_comments_enabled && $article->getComments());
     if (isset($this->usersEmails[$article->getCreateuser()])) {
         $emailAddress = '<a href="mailto:' . $this->usersEmails[$article->getCreateuser()] . '">' . $this->users[$article->getCreateuser()] . '</a>';
     } else {
         $emailAddress = '';
     }
     $replacements = array('{{headline}}' => $article->getTitle(), '{{text}}' => $article->getContent(), '{{author}}' => isset($this->users[$article->getCreateuser()]) ? $this->users[$article->getCreateuser()] : $this->lang->translate('GLOBAL_NOTFOUND'), '{{authorEmail}}' => $emailAddress, '{{date}}' => date($this->config->system_dtmask, $article->getCreatetime()), '{{changeDate}}' => date($this->config->system_dtmask, $article->getChangetime()), '{{changeUser}}' => isset($this->users[$article->getChangeuser()]) ? $this->users[$article->getChangeuser()] : $this->lang->translate('GLOBAL_NOTFOUND'), '{{statusPinned}}' => $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}}' => $article->getArticleLink(), '{{commentLink}}:{{/commentLink}}' => $article->getArticleLink() . '#comments', '<readmore>:</readmore>' => $article->getMd5path(), '{{articleImage}}' => $article->getArticleImage(), '{{sources}}' => $article->getSources());
     $tpl->setReplacementTags($replacements);
     $parsed = $tpl->parse();
     if ($this->session->exists()) {
         $html = array();
         $html[] = '<div class="fpcm-pub-articletoolbar-article fpcm-pub-articletoolbar-article' . $article->getId() . '">';
         $html[] = '<a href="' . $article->getEditLink() . '">' . $this->lang->translate('HL_ARTICLE_EDIT') . '</a>';
         $html[] = '</div>';
         $parsed = implode(PHP_EOL, $html) . $parsed;
     }
     return $parsed;
 }
コード例 #2
0
 private function getArticlePreview()
 {
     $this->view = new \fpcm\model\view\pub('showsingle', 'public');
     $categoryTexts = array('<span class="fpcm-pub-category-text">Category 1</span>', '<span class="fpcm-pub-category-text">Category 2</span>');
     $shareButtonParser = new \fpcm\model\pubtemplates\sharebuttons($this->config->system_url, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr!');
     $replacements = array('{{headline}}' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr!', '{{text}}' => 'Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.', '{{author}}' => $this->session->getCurrentUser()->getDisplayname(), '{{authorEmail}}' => '<a href="mailto:' . $this->session->getCurrentUser()->getEmail() . '">' . $this->session->getCurrentUser()->getDisplayname() . '</a>', '{{date}}' => date($this->config->system_dtmask, time()), '{{changeDate}}' => date($this->config->system_dtmask, time()), '{{changeUser}}' => $this->session->getCurrentUser()->getDisplayname(), '{{statusPinned}}' => '', '{{shareButtons}}' => $shareButtonParser->parse(), '{{categoryIcons}}' => '', '{{categoryTexts}}' => implode(PHP_EOL, $categoryTexts), '{{commentCount}}' => 0, '{{permaLink}}:{{/permaLink}}' => $this->config->system_url, '{{commentLink}}:{{/commentLink}}' => $this->config->system_url . '#comments', '<readmore>:</readmore>' => md5(time()), '{{articleImage}}' => '', '{{sources}}' => $this->config->system_url);
     $this->template->setReplacementTags($replacements);
     $this->view->assign('article', $this->template->parse());
     $this->view->assign('comments', '');
     $this->view->assign('commentform', '');
 }