Example #1
0
    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');
    }
Example #2
0
echo $CssClass;
?>
">
   <div class="Discussion">
      <div class="Item-Header DiscussionHeader">
         <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($Discussion);
?>
            </span>
            <span class="AuthorInfo">
               <?php 
echo WrapIf(htmlspecialchars(GetValue('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle'));
echo WrapIf(htmlspecialchars(GetValue('Location', $Author)), 'span', array('class' => 'MItem AuthorLocation'));
$this->FireEvent('AuthorInfo');
?>
            </span>
         </div>
         <div class="Meta DiscussionMeta">
            <span class="MItem DateCreated">
               <?php 
echo Anchor(Gdn_Format::Date($Discussion->DateInserted, 'html'), $Discussion->Url, 'Permalink', array('rel' => 'nofollow'));
?>
Example #3
0
    /**
     * Outputs a formatted comment.
     *
     * Prior to 2.1, this also output the discussion ("FirstComment") to the browser.
     * That has moved to the discussion.php view.
     *
     * @param DataSet $Comment .
     * @param Gdn_Controller $Sender .
     * @param Gdn_Session $Session .
     * @param int $CurrentOffet How many comments into the discussion we are (for anchors).
     */
    function writeComment($Comment, $Sender, $Session, $CurrentOffset)
    {
        // Whether to order the name & photo with the latter first.
        static $UserPhotoFirst = null;
        if ($UserPhotoFirst === null) {
            $UserPhotoFirst = c('Vanilla.Comment.UserPhotoFirst', true);
        }
        $Author = Gdn::userModel()->getID($Comment->InsertUserID);
        //UserBuilder($Comment, 'Insert');
        $Permalink = val('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;
        $Sender->EventArguments['CurrentOffset'] = $CurrentOffset;
        $Sender->EventArguments['Permalink'] = $Permalink;
        // Needed in writeCommentOptions()
        if ($Sender->data('Discussion', null) === null) {
            $discussionModel = new DiscussionModel();
            $discussion = $discussionModel->getID($Comment->DiscussionID);
            $Sender->setData('Discussion', $discussion);
        }
        // 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);
        $Sender->fireEvent('AuthorPhoto');
        ?>
            </span>
            <span class="AuthorInfo">
               <?php 
        echo ' ' . wrapIf(htmlspecialchars(val('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle'));
        echo ' ' . wrapIf(htmlspecialchars(val('Location', $Author)), 'span', array('class' => 'MItem AuthorLocation'));
        $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 
        echo DateUpdated($Comment, array('<span class="MItem">', '</span>'));
        ?>
                        <?php 
        // Include source if one was set
        if ($Source = val('Source', $Comment)) {
            echo wrap(sprintf(t('via %s'), t($Source . ' Source', $Source)), 'span', array('class' => 'MItem Source'));
        }
        // Include IP Address if we have permission
        if ($Session->checkPermission('Garden.PersonalInfo.View')) {
            echo wrap(ipAnchor($Comment->InsertIPAddress), 'span', array('class' => 'MItem IPAddress'));
        }
        $Sender->fireEvent('CommentInfo');
        $Sender->fireEvent('InsideCommentMeta');
        // DEPRECATED
        $Sender->fireEvent('AfterCommentMeta');
        // DEPRECATED
        ?>
                    </div>
                </div>
                <div class="Item-BodyWrap">
                    <div class="Item-Body">
                        <div class="Message">
                            <?php 
        echo formatBody($Comment);
        ?>
                        </div>
                        <?php 
        $Sender->fireEvent('AfterCommentBody');
        writeReactions($Comment);
        if (val('Attachments', $Comment)) {
            writeAttachments($Comment->Attachments);
        }
        ?>
                    </div>
                </div>
            </div>
        </li>
        <?php 
        $Sender->fireEvent('AfterComment');
    }