Skip to content

Commit 807cf9d

Browse files
committed
Issues-488: Fixed flat/threded view
1 parent 664f738 commit 807cf9d

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

vanilla/applications/vanilla/views/discussion/helper_functions.php

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ function writeComment($comment, $sender, $session, $currentOffset) {
106106
$sender->EventArguments['Type'] = 'Comment';
107107

108108
// First comment template event
109-
$sender->fireEvent('BeforeCommentDisplay'); ?>
109+
$sender->fireEvent('BeforeCommentDisplay');
110+
111+
// FIX: https://github.com/topcoder-platform/forums/issues/488:
112+
// ViewMode should be set before displaying comment
113+
$viewMode = $sender->data('ViewMode');
114+
?>
110115
<li class="<?php echo $cssClass; ?>" id="<?php echo 'Comment_'.$comment->CommentID; ?>">
111116
<div class="Comment">
112117

@@ -144,18 +149,24 @@ function writeComment($comment, $sender, $session, $currentOffset) {
144149
</span>
145150
<span class="DiscussionInfo right">
146151
<?php
147-
$discussionName = 'Re: '. val('Name', $sender->data('Discussion'));
148-
$parentCommentID = $comment->ParentCommentID;
149-
if($parentCommentID) {
150-
$commentModel = new CommentModel();
151-
$parentComment = $commentModel->getID($parentCommentID);
152-
$parentCommentPermalink = '/discussion/comment/' . $parentCommentID . '/#Comment_' . $parentCommentID;
153-
$parentCommentAuthor = Gdn::userModel()->getID($parentComment->InsertUserID);
154-
$parentCommentAuthor = userAnchor($parentCommentAuthor);
155-
$post = anchor('post', $parentCommentPermalink, 'ParentComment');
156-
echo ''. wrapIf($discussionName . ' (response to '.$post.' by '.$parentCommentAuthor.')', 'span', ['class' => '']);
157-
} else {
158-
echo ''. wrapIf($discussionName, 'span', ['class' => '']);
152+
if($viewMode == 'flat') {
153+
$discussionName = 'Re: ' . val('Name', $sender->data('Discussion'));
154+
$parentCommentID = $comment->ParentCommentID;
155+
if ($parentCommentID) {
156+
$commentModel = new CommentModel();
157+
$parentComment = $commentModel->getID($parentCommentID);
158+
$parentCommentPermalink = '/discussion/comment/' . $parentCommentID . '/?view='.$viewMode.'#Comment_' . $parentCommentID;
159+
$parentCommentAuthor = Gdn::userModel()->getID($parentComment->InsertUserID);
160+
$post = anchor('post', $parentCommentPermalink, 'ParentCommentLink');
161+
echo '' . wrapIf($discussionName . ' (response to ' . $post . ' by ' .userAnchor($parentCommentAuthor) . ')', 'span', ['class' => '']);
162+
} else {
163+
$discussion = $sender->data('Discussion');
164+
$discussionPermalink = discussionUrl($discussion).'?view='.$viewMode;
165+
$discussionAuthor = Gdn::userModel()->getID($discussion->InsertUserID);
166+
//echo '' . wrapIf($discussionName, 'span', ['class' => '']);
167+
$post = anchor('post', $discussionPermalink, 'DiscussionLink');
168+
echo '' . wrapIf($discussionName . ' (response to ' . $post . ' by ' . userAnchor($discussionAuthor) . ')', 'span', ['class' => '']);
169+
}
159170
}
160171
?>
161172
</span>

vanilla/applications/vanilla/views/post/comment.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@
4444
$CancelClass = 'Cancel';
4545
}
4646

47-
echo '<span class="'.$CancelClass.'">';
48-
echo anchor($CancelText, '/');
49-
if ($this->data('Editor.BackLink')) {
50-
echo ' <span class="Bullet">•</span> '.$this->data('Editor.BackLink') ;
51-
}
52-
echo '</span>';
47+
// FIX: https://github.com/topcoder-platform/forums/issues/488
48+
// echo '<span class="'.$CancelClass.'">';
49+
// echo anchor($CancelText, '/');
50+
// if ($this->data('Editor.BackLink')) {
51+
// echo ' <span class="Bullet">•</span> '.$this->data('Editor.BackLink') ;
52+
// }
53+
// echo '</span>';
5354

5455
$ButtonOptions = ['class' => 'Button Primary CommentButton'];
5556
$ButtonOptions['tabindex'] = 1;

0 commit comments

Comments
 (0)