Ejemplo n.º 1
0
 function dateUpdated($Row, $Wrap = null)
 {
     $Result = '';
     $DateUpdated = GetValue('DateUpdated', $Row);
     $UpdateUserID = GetValue('UpdateUserID', $Row);
     if ($DateUpdated) {
         $UpdateUser = Gdn::UserModel()->GetID($UpdateUserID);
         if ($UpdateUser) {
             $Title = sprintf(T('Edited %s by %s.'), Gdn_Format::DateFull($DateUpdated), GetValue('Name', $UpdateUser));
         } else {
             $Title = sprintf(T('Edited %s.'), Gdn_Format::DateFull($DateUpdated));
         }
         $Result = ' <span title="' . htmlspecialchars($Title) . '" class="DateUpdated">' . sprintf(T('edited %s'), Gdn_Format::Date($DateUpdated)) . '</span> ';
         if ($Wrap) {
             $Result = $Wrap[0] . $Result . $Wrap[1];
         }
     }
     return $Result;
 }
Ejemplo n.º 2
0
    function WriteDiscussion($Discussion, &$Sender, &$Session)
    {
        $CssClass = CssClass($Discussion);
        $DiscussionUrl = $Discussion->Url;
        $Category = CategoryModel::Categories($Discussion->CategoryID);
        if ($Session->UserID) {
            $DiscussionUrl .= '#latest';
        }
        $Sender->EventArguments['DiscussionUrl'] =& $DiscussionUrl;
        $Sender->EventArguments['Discussion'] =& $Discussion;
        $Sender->EventArguments['CssClass'] =& $CssClass;
        $First = UserBuilder($Discussion, 'First');
        $Last = UserBuilder($Discussion, 'Last');
        $Sender->EventArguments['FirstUser'] =& $First;
        $Sender->EventArguments['LastUser'] =& $Last;
        $Sender->FireEvent('BeforeDiscussionName');
        $DiscussionName = $Discussion->Name;
        if ($DiscussionName == '') {
            $DiscussionName = T('Blank Discussion Topic');
        }
        $Sender->EventArguments['DiscussionName'] =& $DiscussionName;
        static $FirstDiscussion = TRUE;
        if (!$FirstDiscussion) {
            $Sender->FireEvent('BetweenDiscussion');
        } else {
            $FirstDiscussion = FALSE;
        }
        $Discussion->CountPages = ceil($Discussion->CountComments / $Sender->CountCommentsPerPage);
        ?>
<li id="Discussion_<?php 
        echo $Discussion->DiscussionID;
        ?>
" class="<?php 
        echo $CssClass;
        ?>
">
   <?php 
        if (!property_exists($Sender, 'CanEditDiscussions')) {
            $Sender->CanEditDiscussions = GetValue('PermsDiscussionsEdit', CategoryModel::Categories($Discussion->CategoryID)) && C('Vanilla.AdminCheckboxes.Use');
        }
        $Sender->FireEvent('BeforeDiscussionContent');
        //   WriteOptions($Discussion, $Sender, $Session);
        ?>
   <span class="Options">
      <?php 
        echo OptionsList($Discussion);
        echo BookmarkButton($Discussion);
        ?>
   </span>
   <div class="ItemContent Discussion">
      <div class="Title">
      <?php 
        echo AdminCheck($Discussion, array('', ' '));
        WriteTags($Discussion);
        echo Anchor(SliceString($DiscussionName, 80), $DiscussionUrl, '', array('title' => $DiscussionName));
        if (C('Vanilla.Categories.Use') && $Category) {
            echo Wrap(Anchor(htmlspecialchars($Discussion->Category), CategoryUrl($Discussion->CategoryUrlCode)), 'span', array('class' => 'Tag MItem Category ' . $Category['CssClass']));
        }
        $Sender->FireEvent('AfterDiscussionTitle');
        echo NewComments($Discussion);
        ?>
      </div>
      <div class="Meta Meta-Discussion">
         <div class="row">
            <div class="col-lg-4">
               <span class="MItem LastCommentBy"><?php 
        echo UserAnchor($First);
        ?>
</span>
            </div>
            <div class="col-lg-3">
               <span class="MItem MCount ViewCount"><?php 
        printf(PluralTranslate($Discussion->CountViews, '%s view html', '%s views html', '%s view', '%s views'), BigPlural($Discussion->CountViews, '%s view'));
        ?>
</span>
               <span class="MItem MCount CommentCount"><?php 
        printf(PluralTranslate($Discussion->CountComments, '%s comment html', '%s comments html', '%s comment', '%s comments'), BigPlural($Discussion->CountComments, '%s comment'));
        ?>
</span>
               <span class="MItem MCount DiscussionScore Hidden"><?php 
        $Score = $Discussion->Score;
        if ($Score == '') {
            $Score = 0;
        }
        printf(Plural($Score, '%s point', '%s points', BigPlural($Score, '%s point')));
        ?>
</span>
            </div>
            <div class="col-lg-5 LastPost">
               <?php 
        $Sender->FireEvent('AfterCountMeta');
        if ($Discussion->LastCommentID != '') {
            echo ' <span class="MItem LastCommentBy">' . sprintf(T('Latest: %1$s'), UserAnchor($Last)) . '</span> ';
            echo '• <span class="MItem LastCommentDate">' . Gdn_Format::DateFull($Discussion->LastDate, 'html') . '</span>';
            //echo ' <span class="MItem LastCommentDate">'.Gdn_Format::Date($Discussion->LastDate, 'html').'</span>';
        } else {
            echo ' <span class="MItem LastCommentBy">' . sprintf(T('Latest: %1$s'), UserAnchor($First)) . '</span> ';
            echo '• <span class="MItem LastCommentDate">' . Gdn_Format::DateFull($Discussion->FirstDate, 'html');
            if ($Source = GetValue('Source', $Discussion)) {
                echo ' ' . sprintf(T('via %s'), T($Source . ' Source', $Source));
            }
            echo '</span> ';
        }
        $Sender->FireEvent('DiscussionMeta');
        ?>
            </div>
         </div>
      </div>
   </div>
   <?php 
        $Sender->FireEvent('AfterDiscussionContent');
        ?>
</li>
<?php 
    }
Ejemplo n.º 3
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;
        ?>
">
   <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 '<a class="anchor" id="latest"></a>';
            echo '<a class="anchor" id="Comment_' . $Comment->CommentID . '"></a>';
        } else {
            echo '<a class="anchor" id="Comment_' . $Comment->CommentID . '"></a>';
        }
        ?>
      <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(GetValue('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle'));
        echo ' ' . WrapIf(htmlspecialchars(GetValue('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::DateFull($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 = 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');
    }
Ejemplo n.º 4
0
                }
                if (count($Category->ChildIDs) > 0) {
                    foreach ($Category->ChildIDs as $SubcatRow) {
                        if (isset($lastPosts[$SubcatRow])) {
                            $lastPostsInner[] = $lastPosts[$SubcatRow];
                        }
                    }
                    foreach ($lastPostsInner as $key => $row) {
                        $postDates[$key] = $row['LastDateInserted'];
                    }
                }
                if (count($lastPostsInner) > 1) {
                    array_multisort($postDates, SORT_DESC, $lastPostsInner);
                }
                if (count($lastPostsInner) > 0) {
                    $CatList .= '<div class="MItem LastDiscussionTitle">' . Anchor(Gdn_Format::Text(SliceString($lastPostsInner[0]['LastTitle'], 40)), $lastPostsInner[0]['LastUrl']) . '</div>' . '<div class="MItem LastCommentDate">' . Anchor($lastPostsInner[0]['LastName'], 'profile/' . $lastPostsInner[0]['LastUserID'] . '/' . $lastPostsInner[0]['LastName']) . ' • ' . Gdn_Format::DateFull($lastPostsInner[0]['LastDateInserted'], 'html') . '</div>';
                }
                $CatList .= '</div>
                 </div>
               </div>

            </li>';
            }
        }
    }
}
// If there are any remaining child categories that have been collected, do
// the replacement one last time.
if ($ChildCategories != '') {
    $CatList = str_replace('{ChildCategories}', '<span class="ChildCategories">' . Wrap(T('Child Categories:'), 'b') . ' ' . $ChildCategories . '</span>', $CatList);
}
Ejemplo n.º 5
0
}
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::DateFull($Discussion->DateInserted, 'html'), $Discussion->Url, 'Permalink', array('rel' => 'nofollow'));
?>
            </span>
            <?php 
echo DateUpdated($Discussion, array('<span class="MItem">', '</span>'));
?>
            <?php 
// Include source if one was set
if ($Source = GetValue('Source', $Discussion)) {
    echo ' ' . Wrap(sprintf(T('via %s'), T($Source . ' Source', $Source)), 'span', array('class' => 'MItem MItem-Source')) . ' ';
}
// Category
if (C('Vanilla.Categories.Use')) {
    echo ' <span class="MItem Category">';
    echo ' ' . T('in') . ' ';
    echo Anchor(htmlspecialchars($this->Data('Discussion.Category')), CategoryUrl($this->Data('Discussion.CategoryUrlCode')));