function WriteComment($Comment, $Sender, $Session, $CurrentOffset) { static $UserPhotoFirst = NULL; if ($UserPhotoFirst === NULL) { $UserPhotoFirst = C('Vanilla.Comment.UserPhotoFirst', TRUE); } $Author = Gdn::UserModel()->GetID($Comment->InsertUserID); //UserBuilder($Comment, 'Insert'); $Permalink = GetValue('Url', $Comment, '/discussion/comment/' . $Comment->CommentID . '/#Comment_' . $Comment->CommentID); // Set CanEditComments (whether to show checkboxes) if (!property_exists($Sender, 'CanEditComments')) { $Sender->CanEditComments = $Session->CheckPermission('Vanilla.Comments.Edit', TRUE, 'Category', 'any') && C('Vanilla.AdminCheckboxes.Use'); } // Prep event args $CssClass = CssClass($Comment, $CurrentOffset); $Sender->EventArguments['Comment'] =& $Comment; $Sender->EventArguments['Author'] =& $Author; $Sender->EventArguments['CssClass'] =& $CssClass; // DEPRECATED ARGUMENTS (as of 2.1) $Sender->EventArguments['Object'] =& $Comment; $Sender->EventArguments['Type'] = 'Comment'; // First comment template event $Sender->FireEvent('BeforeCommentDisplay'); ?> <li class="<?php echo $CssClass; ?> " id="<?php echo 'Comment_' . $Comment->CommentID; ?> "> <div class="Comment"> <?php // Write a stub for the latest comment so it's easy to link to it from outside. if ($CurrentOffset == Gdn::Controller()->Data('_LatestItem')) { echo '<span id="latest"></span>'; } ?> <div class="Options"> <?php WriteCommentOptions($Comment); ?> </div> <?php $Sender->FireEvent('BeforeCommentMeta'); ?> <div class="Item-Header CommentHeader"> <div class="AuthorWrap"> <span class="Author"> <?php if ($UserPhotoFirst) { echo UserPhoto($Author); echo UserAnchor($Author, 'Username'); } else { echo UserAnchor($Author, 'Username'); echo UserPhoto($Author); } echo FormatMeAction($Comment); ?> </span> <span class="AuthorInfo"> <?php echo ' ' . WrapIf(htmlspecialchars(GetValue('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle')); $Sender->FireEvent('AuthorInfo'); ?> </span> </div> <div class="Meta CommentMeta CommentInfo"> <span class="MItem DateCreated"> <?php echo Anchor(Gdn_Format::Date($Comment->DateInserted, 'html'), $Permalink, 'Permalink', array('name' => 'Item_' . $CurrentOffset, 'rel' => 'nofollow')); ?> </span> <?php // Include source if one was set if ($Source = GetValue('Source', $Comment)) { echo Wrap(sprintf(T('via %s'), T($Source . ' Source', $Source)), 'span', array('class' => 'MItem Source')); } $Sender->FireEvent('CommentInfo'); $Sender->FireEvent('InsideCommentMeta'); // DEPRECATED $Sender->FireEvent('AfterCommentMeta'); // DEPRECATED // Include IP Address if we have permission if ($Session->CheckPermission('Garden.Moderation.Manage')) { echo Wrap(IPAnchor($Comment->InsertIPAddress), 'span', array('class' => 'MItem IPAddress')); } ?> </div> </div> <div class="Item-BodyWrap"> <div class="Item-Body"> <div class="Message"> <?php echo FormatBody($Comment); ?> </div> <?php $Sender->FireEvent('AfterCommentBody'); WriteReactions($Comment); ?> </div> </div> </div> </li> <?php $Sender->FireEvent('AfterComment'); }
echo Anchor(htmlspecialchars($this->Data('Discussion.Category')), CategoryUrl($this->Data('Discussion.CategoryUrlCode'))); echo '</span> '; } $this->FireEvent('DiscussionInfo'); $this->FireEvent('AfterDiscussionMeta'); // DEPRECATED ?> </div> </div> <?php $this->FireEvent('BeforeDiscussionBody'); ?> <div class="Item-BodyWrap"> <div class="Item-Body"> <div class="Message"> <?php echo FormatBody($Discussion); ?> </div> <?php $this->FireEvent('AfterDiscussionBody'); WriteReactions($Discussion); if (GetValue('Attachments', $Discussion)) { WriteAttachments($Discussion->Attachments); } ?> </div> </div> </div> </div>
function FormatMeAction($Comment) { if (!IsMeAction($Comment)) { return; } // Maxlength (don't let people blow up the forum) $Comment->Body = substr($Comment->Body, 4); $Maxlength = C('Vanilla.MeAction.MaxLength', 100); $Body = FormatBody($Comment); if (strlen($Body) > $Maxlength) { $Body = substr($Body, 0, $Maxlength) . '...'; } return '<div class="AuthorAction">' . $Body . '</div>'; }