Example #1
0
 /** Returns the HTML of the comments of the user, including the header */
 public function get_comments_html(Website $website)
 {
     $oComments = new CommentRepository($website->getDatabase());
     $comments = $oComments->getCommentsUser($this->user->getId());
     $returnValue = '<h3 class="notable">' . $website->t("comments.comments") . "</h3>\n";
     if (count($comments) > 0) {
         $commentsTemplate = new CommentsTreeTemplate($website->getText(), $comments, true, $this->user);
         $returnValue .= $commentsTemplate->getText();
     } else {
         $returnValue .= "<p><em>" . $website->t("comments.no_comments_found_user") . "</em></p>";
     }
     return $returnValue;
 }
Example #2
0
 private function writeArticleTextFull(StreamInterface $stream, Article $article, array $comments)
 {
     // Store some variables for later use
     $text = $this->text;
     $id = $article->getId();
     $loggedIn = $this->editLink;
     // Echo the sidebar
     $stream->write('<div id="sidebar_page_sidebar">');
     // Featured image
     if (!empty($article->featuredImage)) {
         $stream->write('<p><img src="' . htmlSpecialChars($article->featuredImage) . '" alt="' . htmlSpecialChars($article->getTitle()) . '" /></p>');
     }
     $stream->write('<p class="meta">');
     // Created and last edited
     $stream->write($text->t('articles.created') . " <br />&nbsp;&nbsp;&nbsp;" . $text->formatDateTime($article->getDateCreated()));
     if ($article->getDateLastEdited()) {
         $stream->write(" <br />  " . $text->t('articles.last_edited') . " <br />&nbsp;&nbsp;&nbsp;" . $text->formatDateTime($article->getDateLastEdited()));
     }
     // Category
     $stream->write(" <br /> " . $text->t('main.category') . ': ');
     $stream->write('<a href="' . $text->e($text->getUrlPage("category", $article->categoryId)) . '">');
     $stream->write($text->e($article->category) . '</a>');
     // Author
     $stream->write(" <br /> " . $text->t('articles.author') . ': ');
     $stream->write('<a href="' . $text->e($text->getUrlPage("account", $article->authorId)) . '">');
     $stream->write($text->e($article->author) . '</a>');
     // Pinned, hidden, comments
     if ($article->pinned) {
         $stream->write("<br />" . $text->t('articles.pinned') . " ");
     }
     if ($article->isHidden()) {
         $stream->write("<br />" . $text->t('articles.hidden'));
     }
     if ($loggedIn && $article->showComments) {
         $stream->write("<br />" . $text->t('comments.allowed'));
     }
     // Edit, delete
     $stream->write('</p>');
     if ($loggedIn) {
         $stream->write("<p style=\"clear:both\">");
         $stream->write('&nbsp;&nbsp;&nbsp;<a class="arrow" href="' . $text->e($text->getUrlPage("edit_article", $id)) . '">' . $text->t('main.edit') . '</a>&nbsp;&nbsp;' . '<a class="arrow" href="' . $text->e($text->getUrlPage("delete_article", $id)) . '">' . $text->t('main.delete') . '</a>');
         $stream->write("</p>");
     }
     $stream->write('</div>');
     // Article
     $stream->write('<div id="sidebar_page_content">');
     if ($loggedIn && $article->isHidden()) {
         $stream->write('<p class="meta">' . $text->t('articles.is_hidden') . "<br /> \n" . $text->t('articles.hidden.explained') . '</p>');
     }
     $stream->write('<p class="intro">' . $text->e($article->getIntro()) . '</p>');
     $stream->write($article->getBody());
     // Comments
     if ($article->showComments) {
         $commentCount = count($comments);
         // Title
         $stream->write('<h3 class="notable">' . $text->t("comments.comments"));
         if ($commentCount > 0) {
             $stream->write(' (' . $commentCount . ')');
         }
         $stream->write("</h3>\n\n");
         // "No comments found" if needed
         if ($commentCount == 0) {
             $stream->write('<p><em>' . $text->t("comments.no_comments_found") . '</em></p>');
         }
         // Comment add link
         $stream->write('<p><a class="button primary_button" href="' . $text->e($text->getUrlPage("add_comment", $id)) . '">' . $text->t("comments.add") . "</a></p>");
         // Show comments
         $commentTreeTemplate = new CommentsTreeTemplate($text, $comments, false, $this->userTemplateingComments);
         $commentTreeTemplate->writeText($stream);
     }
     $stream->write('</div>');
 }