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 WriteActivity($Activity, &$Sender, &$Session) { $Activity = (object) $Activity; // If this was a status update or a wall comment, don't bother with activity strings $ActivityType = explode(' ', $Activity->ActivityType); // Make sure you strip out any extra css classes munged in here $ActivityType = $ActivityType[0]; $Author = UserBuilder($Activity, 'Activity'); $PhotoAnchor = ''; if ($Activity->Photo) { $PhotoAnchor = Anchor(Img($Activity->Photo, array('class' => 'ProfilePhoto ProfilePhotoMedium')), $Activity->PhotoUrl, 'PhotoWrap'); } $CssClass = 'Item Activity Activity-' . $ActivityType; if ($PhotoAnchor != '') { $CssClass .= ' HasPhoto'; } $Format = GetValue('Format', $Activity); $Title = ''; $Excerpt = $Activity->Story; if ($Format) { $Excerpt = Gdn_Format::To($Excerpt, $Format); } if (!in_array($ActivityType, array('WallComment', 'WallPost', 'AboutUpdate'))) { $Title = '<div class="Title">' . GetValue('Headline', $Activity) . '</div>'; } else { if ($ActivityType == 'WallPost') { $RegardingUser = UserBuilder($Activity, 'Regarding'); $PhotoAnchor = UserPhoto($RegardingUser); $Title = '<div class="Title">' . UserAnchor($RegardingUser, 'Name') . ' <span>→</span> ' . UserAnchor($Author, 'Name') . '</div>'; if (!$Format) { $Excerpt = Gdn_Format::Display($Excerpt); } } else { $Title = UserAnchor($Author, 'Name'); if (!$Format) { $Excerpt = Gdn_Format::Display($Excerpt); } } } $Sender->EventArguments['Activity'] =& $Activity; $Sender->EventArguments['CssClass'] =& $CssClass; $Sender->FireEvent('BeforeActivity'); ?> <li id="Activity_<?php echo $Activity->ActivityID; ?> " class="<?php echo $CssClass; ?> "> <?php if ($Session->IsValid() && ($Session->UserID == $Activity->InsertUserID || $Session->CheckPermission('Garden.Activity.Delete'))) { echo '<div class="Options">' . Anchor('×', 'dashboard/activity/delete/' . $Activity->ActivityID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'Delete') . '</div>'; } if ($PhotoAnchor != '') { ?> <div class="Author Photo"><?php echo $PhotoAnchor; ?> </div> <?php } ?> <div class="ItemContent Activity"> <?php echo $Title; ?> <?php echo WrapIf($Excerpt, 'div', array('class' => 'Excerpt')); ?> <?php $Sender->EventArguments['Activity'] = $Activity; $Sender->FireAs('ActivityController')->FireEvent('AfterActivityBody'); // Reactions stub if (in_array(GetValue('ActivityType', $Activity), array('Status', 'WallPost'))) { WriteReactions($Activity); } ?> <div class="Meta"> <span class="MItem DateCreated"><?php echo Gdn_Format::Date($Activity->DateInserted); ?> </span> <?php $SharedString = FALSE; $ID = GetValue('SharedNotifyUserID', $Activity->Data); if (!$ID) { $ID = GetValue('CommentNotifyUserID', $Activity->Data); } if ($ID) { $SharedString = FormatString(T('Comments are between {UserID,you}.'), array('UserID' => array($Activity->NotifyUserID, $ID))); } $AllowComments = $Activity->NotifyUserID < 0 || $SharedString; if ($AllowComments && $Session->CheckPermission('Garden.Profiles.Edit')) { echo '<span class="MItem AddComment">' . Anchor(T('Activity.Comment', 'Comment'), '#CommentForm_' . $Activity->ActivityID, 'CommentOption'); } if ($SharedString) { echo ' <span class="MItem"><i>' . $SharedString . '</i></span>'; } echo '</span>'; $Sender->FireEvent('AfterMeta'); ?> </div> </div> <?php $Comments = GetValue('Comments', $Activity, array()); if (count($Comments) > 0) { echo '<ul class="DataList ActivityComments">'; foreach ($Comments as $Comment) { WriteActivityComment($Comment, $Sender, $Session); } } else { echo '<ul class="DataList ActivityComments Hidden">'; } if ($Session->CheckPermission('Garden.Profiles.Edit')) { ?> <li class="CommentForm"> <?php echo Anchor(T('Write a comment'), '/dashboard/activity/comment/' . $Activity->ActivityID, 'CommentLink'); $CommentForm = Gdn::Factory('Form'); $CommentForm->SetModel($Sender->ActivityModel); $CommentForm->AddHidden('ActivityID', $Activity->ActivityID); $CommentForm->AddHidden('Return', Gdn_Url::Request()); echo $CommentForm->Open(array('action' => Url('/dashboard/activity/comment'), 'class' => 'Hidden')); echo '<div class="TextBoxWrapper">' . $CommentForm->TextBox('Body', array('MultiLine' => TRUE, 'value' => '')) . '</div>'; echo '<div class="Buttons">'; echo $CommentForm->Button('Comment', array('class' => 'Button Primary')); echo '</div>'; echo $CommentForm->Close(); ?> </li> <?php } echo '</ul>'; ?> </li> <?php }