2 // Note: This file is included from the library/Vanilla/Vanilla.Control.CommentGrid.php class.
5 if ($this->Context
->WarningCollector
->Count() > 0) {
6 $CommentList .= '<div class="ErrorContainer">
7 <div class="ErrorTitle">'.$this->Context
->GetDefinition('ErrorTitle').'</div>'
8 .$this->Context
->WarningCollector
->GetMessages()
11 $PageDetails = $this->pl
->GetPageDetails($this->Context
);
12 $PageList = $this->pl
->GetNumericList();
13 $SessionPostBackKey = $this->Context
->Session
->GetCsrfValidationKey();
15 $CommentList .= '<div class="ContentInfo Top">
17 if ($this->Context
->Configuration
['USE_CATEGORIES']) $CommentList .= '<a href="'.GetUrl($this->Context
->Configuration
, 'index.php', '', 'CategoryID', $this->Discussion
->CategoryID
).'">'.$this->Discussion
->Category
.'</a>: ';
18 $CommentList .= DiscussionPrefix($this->Context
, $this->Discussion
).' ';
19 if ($this->Discussion
->WhisperUserID
> 0) {
20 $CommentList .= $this->Discussion
->WhisperUsername
.': ';
22 $CommentList .= $this->Discussion
->Name
24 <a href="#pgbottom">'.$this->Context
->GetDefinition('BottomOfPage').'</a>
25 <div class="PageInfo">
26 <p>'.$PageDetails.'</p>
30 <div id="ContentBody">
33 $Comment = $this->Context
->ObjectFactory
->NewContextObject($this->Context
, 'Comment');
38 if ($this->CurrentPage
> 1) {
42 // Define the current user's permissions and preferences
43 // (small optimization so they don't have to be checked every loop):
44 $PERMISSION_EDIT_COMMENTS = $this->Context
->Session
->User
->Permission('PERMISSION_EDIT_COMMENTS');
45 $PERMISSION_HIDE_COMMENTS = $this->Context
->Session
->User
->Permission('PERMISSION_HIDE_COMMENTS');
46 $PERMISSION_HIDE_DISCUSSIONS = $this->Context
->Session
->User
->Permission('PERMISSION_HIDE_DISCUSSIONS');
47 $PERMISSION_EDIT_DISCUSSIONS = $this->Context
->Session
->User
->Permission('PERMISSION_EDIT_DISCUSSIONS');
49 while ($Row = $this->Context
->Database
->GetRow($this->CommentData
)) {
50 if ($RowNumber > 0) $PERMISSION_EDIT_DISCUSSIONS = 0;
53 $Comment->GetPropertiesFromDataSet($Row, $this->Context
->Session
->UserID
);
54 $CommentAuthUsername = $Comment->AuthUsername
; // Get an unencoded version of the author's username
55 $ShowHtml = $Comment->FormatPropertiesForDisplay();
56 $ShowIcon = $Comment->AuthIcon
!= '' ?
1 : 0;
57 $this->DelegateParameters
['ShowHtml'] = &$ShowHtml;
58 $this->DelegateParameters
['ShowIcon'] = &$ShowIcon;
59 $this->DelegateParameters
['RowNumber'] = &$RowNumber;
62 if ($Comment->WhisperUserID
> 0) {
64 ($Comment->WhisperUserID
== $this->Context
->Session
->UserID
&& $Comment->AuthUserID
== $this->Context
->Session
->UserID
)
65 or $Comment->WhisperUserID
== $this->Context
->Session
->UserID
67 $CommentClass = 'WhisperTo';
69 $CommentClass = 'WhisperFrom';
71 } else if ($this->Discussion
->WhisperUserID
> 0) {
72 $CommentClass = ($Comment->AuthUserID
== $this->Context
->Session
->UserID
) ?
'WhisperFrom' : 'WhisperTo';
75 if ($Comment->Deleted
) $CommentClass .= ' Hidden';
76 if ($Alternate) $CommentClass .= ' Alternate';
77 $CommentClass = trim($CommentClass);
79 $CommentList .= '<li id="Comment_'.$Comment->CommentID
.'"'.($CommentClass == ''?
'':' class="'.$CommentClass.'"').'>
80 <a name="Item_'.$RowNumber.'"></a>
81 <div class="CommentHeader">
84 '.($ShowIcon?
'<div class="CommentIcon" style="'."background-image:url('".$Comment->AuthIcon
."');".'"> </div>':'').'
85 <span>'.$this->Context
->GetDefinition('CommentAuthor').'</span><a href="'.GetUrl($this->Context
->Configuration
, 'account.php', '', 'u', $Comment->AuthUserID
).'">'.$Comment->AuthUsername
.'</a>';
87 // Point out who it was whispered to if necessary
88 if ($Comment->WhisperUserID
> 0) {
89 if ($Comment->WhisperUserID
== $this->Context
->Session
->UserID
&& $Comment->AuthUserID
== $this->Context
->Session
->UserID
) {
90 $CommentList .= $this->Context
->GetDefinition('ToYourself');
91 } elseif ($Comment->WhisperUserID
== $this->Context
->Session
->UserID
) {
92 $CommentList .= $this->Context
->GetDefinition('ToYou');
94 $CommentList .= str_replace('//1', $Comment->WhisperUsername
, $this->Context
->GetDefinition('ToX'));
98 $CommentList .= '</li>
100 <span>'.$this->Context
->GetDefinition('CommentTime').'</span>'.TimeDiff($this->Context
, $Comment->DateCreated
);
101 if ($Comment->DateEdited
!= '') $CommentList .= ' <em>'.$this->Context
->GetDefinition('Edited').'</em>';
102 if ($Comment->Deleted
) $CommentList .= ' <i>'.str_replace(array('//1', '//2'), array(TimeDiff($this->Context
, $Comment->DateDeleted
), $Comment->DeleteUsername
), $this->Context
->GetDefinition('CommentHiddenOnXByY')).'</i>';
103 // Whisper back button
104 if (!$this->Discussion
->Closed
&& $Comment->WhisperUserID
> 0 && $Comment->WhisperUserID
== $this->Context
->Session
->UserID
) $CommentList .= '<a class="WhisperBack" onclick="'
105 ."WhisperBack('".$Comment->DiscussionID
."', '".str_replace("'", "\\'", $CommentAuthUsername)."', '".$this->Context
->Configuration
['BASE_URL']."');"
106 .'">'.$this->Context
->GetDefinition('WhisperBack').'</a>';
108 $CommentList .= '</li>
113 // Set up comment options
114 $this->DelegateParameters
['Comment'] = &$Comment;
115 $this->DelegateParameters
['CommentList'] = &$CommentList;
116 $this->DelegateParameters
['RowNumber'] = &$RowNumber;
117 $CommentList .= $this->CallDelegate('PreCommentOptionsRender');
118 if ($this->Context
->Session
->UserID
> 0) {
119 if ($Comment->AuthUserID
== $this->Context
->Session
->UserID ||
$PERMISSION_EDIT_COMMENTS ||
$PERMISSION_EDIT_DISCUSSIONS) {
120 if ((!$this->Discussion
->Closed
&& $this->Discussion
->Active
) ||
$PERMISSION_EDIT_COMMENTS ||
$PERMISSION_EDIT_DISCUSSIONS) $CommentList .= '<a href="'.GetUrl($this->Context
->Configuration
, 'post.php', '', 'CommentID', $Comment->CommentID
).'">'.$this->Context
->GetDefinition('edit').'</a>
123 if ($PERMISSION_HIDE_COMMENTS && !$FirstComment) {
124 $CommentList .= '<a id="HideComment'.$Comment->CommentID
.'" href="./" onclick="'
125 ."HideComment('".$this->Context
->Configuration
['WEB_ROOT']."ajax/switch.php', '".($Comment->Deleted?
"0":"1")."', '".$this->Discussion
->DiscussionID
."', '".$Comment->CommentID
."', '".$this->Context
->GetDefinition("ShowConfirm")."', '".$this->Context
->GetDefinition("HideConfirm")."', 'HideComment".$Comment->CommentID
."', '".$SessionPostBackKey."');"
126 .' return false;">'.$this->Context
->GetDefinition($Comment->Deleted?
'Show':'Hide').'</a>
129 if ($PERMISSION_HIDE_DISCUSSIONS && $FirstComment) {
130 $CommentList .= "<a id=\"HideDiscussion".$this->Discussion
->DiscussionID
."\" href=\"./\" onclick=\"if (confirm('".$this->Context
->GetDefinition($this->Discussion
->Active?
"ConfirmHideDiscussion":"ConfirmUnhideDiscussion")."')) DiscussionSwitch('".$this->Context
->Configuration
['WEB_ROOT']."ajax/switch.php', 'Active', '".$this->Discussion
->DiscussionID
."', '".FlipBool($this->Discussion
->Active
)."', 'HideDiscussion', '".$SessionPostBackKey."'); return false;\">".$this->Context
->GetDefinition(($this->Discussion
->Active?
"Hide":"Unhide")."DiscussionLC")."</a>";
134 $this->DelegateParameters
['CommentList'] = &$CommentList;
135 $this->CallDelegate('PostCommentOptionsRender');
140 if ($Comment->AuthRoleDesc
!= '') $CommentList .= '<div class="CommentNotice">'.$Comment->AuthRoleDesc
.'</div>';
141 $CommentList .= '<div class="CommentBody" id="CommentBody_'.$Comment->CommentID
.'">';
142 $CommentList .= $Comment->Body
.'
145 $Alternate = FlipBool($Alternate);
148 $CommentList .= '</ol>
151 if (@$PageList && @$PageDetails) {
152 $CommentList .= '<div class="ContentInfo Middle">
153 <div class="PageInfo">
154 <p>'.$PageDetails.'</p>