From 807cf9db31f36f5712793f4fe3be8e7be5a7323e Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Sat, 27 Mar 2021 16:40:02 +0300 Subject: [PATCH] Issues-488: Fixed flat/threded view --- .../views/discussion/helper_functions.php | 37 ++++++++++++------- .../vanilla/views/post/comment.php | 13 ++++--- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/vanilla/applications/vanilla/views/discussion/helper_functions.php b/vanilla/applications/vanilla/views/discussion/helper_functions.php index 5e3646b..a5b7ba3 100644 --- a/vanilla/applications/vanilla/views/discussion/helper_functions.php +++ b/vanilla/applications/vanilla/views/discussion/helper_functions.php @@ -106,7 +106,12 @@ function writeComment($comment, $sender, $session, $currentOffset) { $sender->EventArguments['Type'] = 'Comment'; // First comment template event - $sender->fireEvent('BeforeCommentDisplay'); ?> + $sender->fireEvent('BeforeCommentDisplay'); + + // FIX: https://github.com/topcoder-platform/forums/issues/488: + // ViewMode should be set before displaying comment + $viewMode = $sender->data('ViewMode'); + ?>
  • @@ -144,18 +149,24 @@ function writeComment($comment, $sender, $session, $currentOffset) { data('Discussion')); - $parentCommentID = $comment->ParentCommentID; - if($parentCommentID) { - $commentModel = new CommentModel(); - $parentComment = $commentModel->getID($parentCommentID); - $parentCommentPermalink = '/discussion/comment/' . $parentCommentID . '/#Comment_' . $parentCommentID; - $parentCommentAuthor = Gdn::userModel()->getID($parentComment->InsertUserID); - $parentCommentAuthor = userAnchor($parentCommentAuthor); - $post = anchor('post', $parentCommentPermalink, 'ParentComment'); - echo ''. wrapIf($discussionName . ' (response to '.$post.' by '.$parentCommentAuthor.')', 'span', ['class' => '']); - } else { - echo ''. wrapIf($discussionName, 'span', ['class' => '']); + if($viewMode == 'flat') { + $discussionName = 'Re: ' . val('Name', $sender->data('Discussion')); + $parentCommentID = $comment->ParentCommentID; + if ($parentCommentID) { + $commentModel = new CommentModel(); + $parentComment = $commentModel->getID($parentCommentID); + $parentCommentPermalink = '/discussion/comment/' . $parentCommentID . '/?view='.$viewMode.'#Comment_' . $parentCommentID; + $parentCommentAuthor = Gdn::userModel()->getID($parentComment->InsertUserID); + $post = anchor('post', $parentCommentPermalink, 'ParentCommentLink'); + echo '' . wrapIf($discussionName . ' (response to ' . $post . ' by ' .userAnchor($parentCommentAuthor) . ')', 'span', ['class' => '']); + } else { + $discussion = $sender->data('Discussion'); + $discussionPermalink = discussionUrl($discussion).'?view='.$viewMode; + $discussionAuthor = Gdn::userModel()->getID($discussion->InsertUserID); + //echo '' . wrapIf($discussionName, 'span', ['class' => '']); + $post = anchor('post', $discussionPermalink, 'DiscussionLink'); + echo '' . wrapIf($discussionName . ' (response to ' . $post . ' by ' . userAnchor($discussionAuthor) . ')', 'span', ['class' => '']); + } } ?> diff --git a/vanilla/applications/vanilla/views/post/comment.php b/vanilla/applications/vanilla/views/post/comment.php index 5e3869b..e88fd2c 100644 --- a/vanilla/applications/vanilla/views/post/comment.php +++ b/vanilla/applications/vanilla/views/post/comment.php @@ -44,12 +44,13 @@ $CancelClass = 'Cancel'; } - echo ''; - echo anchor($CancelText, '/'); - if ($this->data('Editor.BackLink')) { - echo ' '.$this->data('Editor.BackLink') ; - } - echo ''; + // FIX: https://github.com/topcoder-platform/forums/issues/488 + // echo ''; + // echo anchor($CancelText, '/'); + // if ($this->data('Editor.BackLink')) { + // echo ' '.$this->data('Editor.BackLink') ; + // } + // echo ''; $ButtonOptions = ['class' => 'Button Primary CommentButton']; $ButtonOptions['tabindex'] = 1;