public function renderOrigin($Sender)
 {
     $Discussion = $Sender->EventArguments['Discussion'];
     if ($Discussion !== NULL && $Discussion->LastCommentID != '') {
         $Creator = UserBuilder($Discussion, 'First');
         $CreationDate = $Discussion->DateInserted;
         echo ' <span class="MItem LastCommentBy">' . sprintf(T('Started by %1$s'), UserAnchor($Creator)) . '</span>';
         echo ' <span class="MItem LastCommentDate">' . Gdn_Format::Date($CreationDate, 'html') . '</span>';
     }
 }
Beispiel #2
0
function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt)
{
    $CssClass = 'Item';
    $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : '';
    $CssClass .= $Alt . ' ';
    $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : '';
    $CssClass .= $Discussion->Closed == '1' ? ' Closed' : '';
    $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : '';
    $CssClass .= $Discussion->CountUnreadComments > 0 && $Session->IsValid() ? ' New' : '';
    $Sender->EventArguments['Discussion'] =& $Discussion;
    $Sender->FireEvent('BeforeDiscussionName');
    $DiscussionName = Gdn_Format::Text($Discussion->Name);
    if ($DiscussionName == '') {
        $DiscussionName = T('Blank Discussion Topic');
    }
    static $FirstDiscussion = TRUE;
    if (!$FirstDiscussion) {
        $Sender->FireEvent('BetweenDiscussion');
    } else {
        $FirstDiscussion = FALSE;
    }
    ?>
<li class="<?php 
    echo $CssClass;
    ?>
">
   <?php 
    echo UserPhoto(UserBuilder($Discussion, 'First'));
    ?>
   <div class="ItemContent Discussion">
      <?php 
    echo Anchor($DiscussionName, '/discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'Title');
    ?>
      <?php 
    $Sender->FireEvent('AfterDiscussionTitle');
    ?>
      <div class="Meta">
         <span class="Author"><?php 
    echo $Discussion->FirstName;
    ?>
</span>
         <?php 
    echo '<span class="Counts' . ($Discussion->CountUnreadComments > 0 ? ' NewCounts' : '') . '">' . ($Discussion->CountUnreadComments > 0 ? $Discussion->CountUnreadComments . '/' : '') . $Discussion->CountComments . '</span>';
    if ($Discussion->LastCommentID != '') {
        echo '<span class="LastCommentBy">' . sprintf(T('Latest %1$s'), $Discussion->LastName) . '</span> ';
    }
    echo '<span class="LastCommentDate">' . Gdn_Format::Date($Discussion->LastDate) . '</span> ';
    ?>
      </div>
   </div>
</li>
<?php 
}
Beispiel #3
0
function WriteComment($Comment, &$Sender, &$Session, $CurrentOffset)
{
    $Author = UserBuilder($Comment, 'Insert');
    $Sender->EventArguments['Comment'] =& $Comment;
    $Sender->Options = '';
    $CssClass = 'Item Comment';
    $CssClass .= $Comment->InsertUserID == $Session->UserID ? ' Mine' : '';
    ?>
<li class="<?php 
    echo $CssClass;
    ?>
" id="Comment_<?php 
    echo $Comment->CommentID;
    ?>
">
   <?php 
    WriteOptions($Comment, $Sender, $Session);
    ?>
   <div class="Comment">
      <div class="Meta">
         <span class="Author">
            <?php 
    echo UserPhoto($Author);
    echo UserAnchor($Author);
    ?>
         </span>
         <span class="DateCreated">
            <?php 
    echo Format::Date($Comment->DateInserted);
    ?>
         </span>
         <span class="Permalink">
            <?php 
    echo Anchor(T('Permalink'), '/discussion/comment/' . $Comment->CommentID . '/#Comment_' . $Comment->CommentID, 'Permalink', array('name' => 'Item_' . $CurrentOffset));
    ?>
         </span>
         <?php 
    $Sender->FireEvent('AfterCommentMeta');
    ?>
      </div>
      <div class="Message"><?php 
    echo Format::To($Comment->Body, $Comment->Format);
    ?>
</div>
      <?php 
    $Sender->FireEvent('AfterCommentBody');
    ?>
   </div>
</li>
<?php 
}
Beispiel #4
0
 public function DiscussionsController_AfterCountMeta_Handler(&$Sender)
 {
     $Discussion = $Sender->EventArguments['Discussion'];
     if (C('Plugins.AuthorTimeView.Show_AuthorTime')) {
         $First = UserBuilder($Discussion, 'First');
         $Last = UserBuilder($Discussion, 'Last');
         if ($Discussion->LastCommentID != '') {
             echo '<span class="LastCommentBy">' . sprintf(T(' %1$s'), UserAnchor($First)) . '</span>';
             echo '<span class="AuthorDate">' . Gdn_Format::Date($Discussion->FirstDate) . '</span>';
             echo '<span class="LastCommentBy">' . sprintf(T('| Recent %1$s'), UserAnchor($Last)) . '</span>';
         } else {
             // leave space preceding Started in ' Started by' or it will be removed by locale definitions
             echo '<span class="LastCommentBy">' . sprintf(T(' Started by %1$s'), UserAnchor($First)) . '</span>';
         }
     }
 }
    public function ToString($Results)
    {
        $UserIDs = array();
        foreach ($Results as $Row) {
            $UserIDs[] = $Row->{SS_ATTR_USERID};
            ///IMPORTANT, this is lowercase since grab results directly from sphinx
        }
        // print_r($Return); die;
        $Sql = clone Gdn::Sql();
        $Users = $Sql->Select('Photo, UserID, Name')->From('User')->WhereIn('UserID', $UserIDs)->Get()->ResultObject();
        ob_start();
        ?>
        <div id="People" class="Box People">
            <h4 class="Header"><?php 
        echo T('People');
        ?>
</h4>
            <ul class="PanelInfo PanelDiscussions">
                <?php 
        foreach ($Users as $Row) {
            ?>
                    <li class="Item">
                        <?php 
            $User = UserBuilder($Row);
            ?>
                        <?php 
            echo UserPhoto($User);
            echo UserAnchor($User);
            ?>
                    </li>
                <?php 
        }
        ?>
            </ul>
        </div>
        <?php 
        $String = ob_get_contents();
        @ob_end_clean();
        return $String;
    }
Beispiel #6
0
function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt)
{
    $CssClass = 'Item';
    $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : '';
    $CssClass .= $Alt . ' ';
    $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : '';
    $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : '';
    $CountUnreadComments = $Discussion->CountComments - $Discussion->CountCommentWatch;
    $CssClass .= $CountUnreadComments > 0 && $Session->IsValid() ? ' New' : '';
    $Sender->EventArguments['Discussion'] =& $Discussion;
    $Last = UserBuilder($Discussion, 'Last');
    ?>
<li class="<?php 
    echo $CssClass;
    ?>
">
   <?php 
    WriteOptions($Discussion, $Sender, $Session);
    ?>
   <div class="ItemContent Discussion">
      <?php 
    echo Anchor(Format::Text($Discussion->Name), '/discussion/' . $Discussion->DiscussionID . '/' . Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'Title');
    ?>
      <?php 
    $Sender->FireEvent('AfterDiscussionTitle');
    ?>
      <div class="Meta">
         <?php 
    if ($Discussion->Announce == '1') {
        ?>
         <span class="Announcement"><?php 
        echo T('Announcement');
        ?>
</span>
         <?php 
    }
    ?>
         <span><?php 
    printf(Plural($Discussion->CountComments, '%s comment', '%s comments'), $Discussion->CountComments);
    ?>
</span>
         <?php 
    if ($CountUnreadComments > 0 && $Session->IsValid()) {
        echo '<strong>', sprintf(T('%s new'), $CountUnreadComments), '</strong>';
    }
    ?>
         <span><?php 
    printf(T('Most recent by %1$s %2$s'), UserAnchor($Last), Format::Date($Discussion->LastDate));
    ?>
</span>
         <span><?php 
    echo Anchor($Discussion->Category, '/categories/' . $Discussion->CategoryUrlCode, 'Category');
    ?>
</span>
         <?php 
    $Sender->FireEvent('DiscussionMeta');
    ?>
      </div>
   </div>
</li>
<?php 
}
Beispiel #7
0
    $CurrentOffset++;
    $Alt = $Alt == TRUE ? FALSE : TRUE;
    $Class = 'Item';
    $Class .= $Alt ? ' Alt' : '';
    if ($this->Conversation->DateLastViewed < $Message->DateInserted) {
        $Class .= ' New';
    }
    if ($Message->InsertUserID == $Session->UserID) {
        $Class .= ' Mine';
    }
    if ($Message->InsertPhoto != '') {
        $Class .= ' HasPhoto';
    }
    $Class = trim($Class);
    $Format = empty($Message->Format) ? 'Display' : $Message->Format;
    $Author = UserBuilder($Message, 'Insert');
    ?>
<li id="<?php 
    echo $Message->MessageID;
    ?>
"<?php 
    echo $Class == '' ? '' : ' class="' . $Class . '"';
    ?>
>
   <div class="ConversationMessage">
      <div class="Meta">
         <span class="Author">
            <?php 
    echo UserPhoto($Author, 'Photo');
    echo UserAnchor($Author, 'Name');
    ?>
Beispiel #8
0
   <?php 
    foreach ($this->Data('Conversations') as $Row) {
        $Subject = '';
        if ($Row['Subject']) {
            $Subject = Gdn_Format::Text($Row['Subject']);
        } else {
            $Subject = '';
            foreach ($Row['Participants'] as $User) {
                if (!isset($PhotoUser)) {
                    $PhotoUser = $User;
                }
                $Subject = ConcatSep(', ', $Subject, FormatUsername($User, 'You'));
            }
        }
        if (!isset($PhotoUser)) {
            $PhotoUser = UserBuilder($Row, 'LastMessage');
        }
        ?>
   <li class="Item" rel="<?php 
        echo Url("/messages/{$Row['ConversationID']}#latest");
        ?>
">
      <div class="Author Photo"><?php 
        echo UserPhoto($PhotoUser);
        ?>
</div>
      <div class="ItemContent">
         <b class="Subject"><?php 
        echo Anchor($Subject, "/messages/{$Row['ConversationID']}#latest");
        ?>
</b>
Beispiel #9
0
    public static function WriteReply(&$Sender, &$Session)
    {
        ?>
         <li class="Reply" id="Comment_<?php 
        echo $Sender->CurrentReply->CommentID;
        ?>
">
            <?php 
        // Delete comment
        if ($Session->CheckPermission('Vanilla.Comments.Delete', $Sender->Discussion->CategoryID)) {
            echo Anchor(T('Delete'), 'vanilla/discussion/deletecomment/' . $Sender->CurrentReply->CommentID . '/' . $Session->TransientKey(), 'DeleteReply');
        }
        ?>
            <ul class="Info<?php 
        echo $Sender->CurrentReply->InsertUserID == $Session->UserID ? ' Author' : '';
        ?>
">
               <li class="Author"><?php 
        $Author = UserBuilder($Sender->CurrentReply, 'Insert');
        echo UserPhoto($Author);
        echo UserAnchor($Author);
        ?>
</li>
               <li class="Created"><?php 
        echo Gdn_Format::Date($Sender->CurrentReply->DateInserted);
        ?>
</li>
               <li class="Permalink"><?php 
        echo Anchor(T('Permalink'), '/discussion/comment/' . (isset($Sender->CurrentComment) ? $Sender->CurrentComment->CommentID : $Sender->ReplyCommentID) . '/#Comment_' . $Sender->CurrentReply->CommentID, T('Permalink'));
        ?>
</li>
            </ul>
            <div class="Body"><?php 
        echo Gdn_Format::To($Sender->CurrentReply->Body, $Sender->CurrentReply->Format);
        ?>
</div>
         </li>
      <?php 
    }
Beispiel #10
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 = val('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('', ' ')) . anchor($DiscussionName, $DiscussionUrl);
        $Sender->fireEvent('AfterDiscussionTitle');
        ?>
                </div>
                <div class="Meta Meta-Discussion">
                    <?php 
        WriteTags($Discussion);
        ?>
                    <span class="MItem MCount ViewCount"><?php 
        printf(PluralTranslate($Discussion->CountViews, '%s view html', '%s views html', t('%s view'), t('%s views')), BigPlural($Discussion->CountViews, '%s view'));
        ?>
</span>
         <span class="MItem MCount CommentCount"><?php 
        printf(PluralTranslate($Discussion->CountComments, '%s comment html', '%s comments html', t('%s comment'), t('%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>
                    <?php 
        echo NewComments($Discussion);
        $Sender->fireEvent('AfterCountMeta');
        if ($Discussion->LastCommentID != '') {
            echo ' <span class="MItem LastCommentBy">' . sprintf(t('Most recent by %1$s'), userAnchor($Last)) . '</span> ';
            echo ' <span class="MItem LastCommentDate">' . Gdn_Format::date($Discussion->LastDate, 'html') . '</span>';
        } else {
            echo ' <span class="MItem LastCommentBy">' . sprintf(t('Started by %1$s'), userAnchor($First)) . '</span> ';
            echo ' <span class="MItem LastCommentDate">' . Gdn_Format::date($Discussion->FirstDate, 'html');
            if ($Source = val('Source', $Discussion)) {
                echo ' ' . sprintf(t('via %s'), t($Source . ' Source', $Source));
            }
            echo '</span> ';
        }
        if ($Sender->data('_ShowCategoryLink', true) && c('Vanilla.Categories.Use') && $Category) {
            echo wrap(Anchor(htmlspecialchars($Discussion->Category), CategoryUrl($Discussion->CategoryUrlCode)), 'span', array('class' => 'MItem Category ' . $Category['CssClass']));
        }
        $Sender->fireEvent('DiscussionMeta');
        ?>
                </div>
            </div>
            <?php 
        $Sender->fireEvent('AfterDiscussionContent');
        ?>
        </li>
    <?php 
    }
?>
</h4>
   <ul class="PanelActivity">
      <?php 
$Data = $this->ActivityData;
foreach ($Data->Result() as $Activity) {
    echo '<li class="Activity ' . $Activity->ActivityType . '">';
    // 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');
    if (in_array($ActivityType, array('WallComment', 'AboutUpdate'))) {
        echo UserAnchor($Author, 'Name');
        if ($Activity->ActivityType == 'WallComment' && $Activity->RegardingUserID > 0) {
            $Author = UserBuilder($Activity, 'Regarding');
            echo '<span>&rarr;</span>' . UserAnchor($Author, 'Name');
        }
        echo ' ' . Gdn_Format::Display($Activity->Story) . ' ';
        echo '<em>' . Gdn_Format::Date($Activity->DateInserted) . '</em>';
    } else {
        echo Gdn_Format::ActivityHeadline($Activity);
        echo '<em>' . Gdn_Format::Date($Activity->DateInserted) . '</em>';
        if ($Activity->Story != '') {
            echo '<div class="Story">';
            echo $Activity->Story;
            echo '</div>';
        }
    }
    echo '</li>';
}
/**
 * $Object is either a Comment or the original Discussion.
 */
function WriteComment($Object, $Sender, $Session, $CurrentOffset) {
   $Alt = ($CurrentOffset % 2) != 0;

   $Author = UserBuilder($Object, 'Insert');
   $Type = property_exists($Object, 'CommentID') ? 'Comment' : 'Discussion';
	$Sender->EventArguments['Object'] = $Object;
   $Sender->EventArguments['Type'] = $Type;
   $Sender->EventArguments['Author'] = $Author;
   $CssClass = 'Item Comment';
   $Permalink = GetValue('Url', $Object, FALSE);

   if ($Type == 'Comment') {
      $Sender->EventArguments['Comment'] = $Object;   
      $Id = 'Comment_'.$Object->CommentID;
      if ($Permalink === FALSE)
         $Permalink = '/discussion/comment/'.$Object->CommentID.'/#Comment_'.$Object->CommentID;
   } else {
      $Sender->EventArguments['Discussion'] = $Object;   
      $CssClass .= ' FirstComment';
      $Id = 'Discussion_'.$Object->DiscussionID;
      if ($Permalink === FALSE)
         $Permalink = '/discussion/'.$Object->DiscussionID.'/'.Gdn_Format::Url($Object->Name).'/p1';
   }
   $Sender->EventArguments['CssClass'] = &$CssClass;
   $Sender->Options = '';
   $CssClass .= $Object->InsertUserID == $Session->UserID ? ' Mine' : '';

   if ($Alt)
      $CssClass .= ' Alt';
   $Alt = !$Alt;
	
	if (!property_exists($Sender, 'CanEditComments'))
		$Sender->CanEditComments = $Session->CheckPermission('Vanilla.Comments.Edit', TRUE, 'Category', 'any') && C('Vanilla.AdminCheckboxes.Use');
		
   $Sender->FireEvent('BeforeCommentDisplay');
?>
<li class="<?php echo $CssClass; ?>" id="<?php echo $Id; ?>">
   <div class="Comment">
      <div class="Meta">
         <?php $Sender->FireEvent('BeforeCommentMeta'); ?>
         <span class="Author">
            <?php
            echo UserPhoto($Author);
            echo UserAnchor($Author);
            ?>
         </span>
         <span class="DateCreated">
            <?php
            echo Anchor(Gdn_Format::Date($Object->DateInserted), $Permalink, 'Permalink', array('name' => 'Item_'.($CurrentOffset+1), 'rel' => 'nofollow'));
            ?>
         </span>
         <?php
			WriteOptionList($Object, $Sender, $Session);
			if ($Type == 'Comment' && $Sender->CanEditComments) {
				if (!property_exists($Sender, 'CheckedComments'))
					$Sender->CheckedComments = $Session->GetAttribute('CheckedComments', array());
					
				$ItemSelected = InSubArray($Id, $Sender->CheckedComments);
				echo '<div class="Administration"><input type="checkbox" name="'.$Type.'ID[]" value="'.$Id.'"'.($ItemSelected?' checked="checked"':'').' /></div>';
			}
			?>
         <div class="CommentInfo">
            <?php $Sender->FireEvent('CommentInfo'); ?>
         </div>
         <?php $Sender->FireEvent('AfterCommentMeta'); ?>
      </div>
      <div class="Message">
			<?php 
            $Sender->FireEvent('BeforeCommentBody'); 
			   $Object->FormatBody = Gdn_Format::To($Object->Body, $Object->Format);
			   $Sender->FireEvent('AfterCommentFormat');
			   $Object = $Sender->EventArguments['Object'];
			   echo $Object->FormatBody;
			?>
		</div>
      <?php $Sender->FireEvent('AfterCommentBody'); ?>
   </div>
</li>
<?php
	$Sender->FireEvent('AfterComment');
}
Beispiel #13
0
</th>
         </tr>
      </thead>
      -->
        <tbody>
        <?php 
$Alt = '';
foreach ($this->ActiveUserData as $User) {
    ?>
            <tr<?php 
    $Alt = $Alt == '' ? ' class="Alt"' : '';
    echo $Alt;
    ?>
>
                <th><?php 
    $PhotoUser = UserBuilder($User);
    echo userPhoto($PhotoUser);
    echo userAnchor($User);
    ?>
</th>
                <td class="Alt"><?php 
    echo Gdn_Format::date($User->DateLastActive, 'html');
    ?>
</td>
            </tr>
        <?php 
}
?>
        </tbody>
    </table>
</div>
 /**
  * Display user photo for first user in each discussion.
  */
 protected function DisplayPhoto($Sender)
 {
     // Build user object & output photo
     $FirstUser = UserBuilder($Sender->EventArguments['Discussion'], 'First');
     echo UserPhoto($FirstUser);
 }
<?php

if (!defined('APPLICATION')) {
    exit;
}
?>
<div class="Box RecentUsers">
    <h4><?php 
echo t('Recently Active Users');
?>
</h4>

    <div class="Icons">
        <?php 
$Data = $this->_Sender->RecentUserData;
foreach ($Data->result() as $User) {
    $Visitor = UserBuilder($User);
    echo userPhoto($Visitor);
}
?>
    </div>
</div>
<?php if (!defined('APPLICATION')) exit();
$Session = Gdn::Session();
$Alt = FALSE;
$SubjectsVisible = C('Conversations.Subjects.Visible');

foreach ($this->ConversationData->Result() as $Conversation) {
   $Alt = $Alt == TRUE ? FALSE : TRUE;
   $LastAuthor = UserBuilder($Conversation, 'LastMessage');
   $LastPhoto = UserPhoto($LastAuthor, 'Photo');
   $CssClass = 'Item';
   $CssClass .= $Alt ? ' Alt' : '';
   $CssClass .= $Conversation->CountNewMessages > 0 ? ' New' : '';
   $CssClass .= $LastPhoto != '' ? ' HasPhoto' : '';
   $JumpToItem = $Conversation->CountMessages - $Conversation->CountNewMessages;
   if ($Conversation->Format == 'Text')
      $Message = nl2br(SliceString(Gdn_Format::To($Conversation->LastMessage, $Conversation->Format), 100));
   else
      $Message = nl2br(SliceString(Gdn_Format::Text(Gdn_Format::To($Conversation->LastMessage, $Conversation->Format), FALSE), 100));

   if (StringIsNullOrEmpty(trim($Message)))
      $Message = T('Blank Message');


   $this->EventArguments['Conversation'] = $Conversation;
?>
<li class="<?php echo $CssClass; ?>">
   <?php
   $Names = '';
   $PhotoUser = NULL;
   foreach ($Conversation->Participants as $User) {
      if (GetValue('UserID', $User) == Gdn::Session()->UserID)
Beispiel #17
0
/**
 * $Object is either a Comment or the original Discussion.
 */
function WriteComment($Object, $Sender, $Session, $CurrentOffset)
{
    $Author = UserBuilder($Object, 'Insert');
    $Type = property_exists($Object, 'CommentID') ? 'Comment' : 'Discussion';
    $Sender->EventArguments['Object'] = $Object;
    $Sender->EventArguments['Type'] = $Type;
    $Sender->EventArguments['Author'] = $Author;
    $CssClass = 'Item Comment';
    if ($Type == 'Comment') {
        $Sender->EventArguments['Comment'] = $Object;
        $Id = 'Comment_' . $Object->CommentID;
        $Permalink = '/discussion/comment/' . $Object->CommentID . '/#Comment_' . $Object->CommentID;
    } else {
        $Sender->EventArguments['Discussion'] = $Object;
        $CssClass .= ' FirstComment';
        $Id = 'Discussion_' . $Object->DiscussionID;
        $Permalink = '/discussion/' . $Object->DiscussionID . '/' . Gdn_Format::Url($Object->Name) . '/p1';
    }
    $Sender->Options = '';
    $CssClass .= $Object->InsertUserID == $Session->UserID ? ' Mine' : '';
    $Sender->FireEvent('BeforeCommentDisplay');
    ?>
<li class="<?php 
    echo $CssClass;
    ?>
" id="<?php 
    echo $Id;
    ?>
">
   <div class="Comment">
      <div class="Meta">
         <?php 
    $Sender->FireEvent('BeforeCommentMeta');
    ?>
         <span class="Author">
            <?php 
    echo UserPhoto($Author);
    echo UserAnchor($Author);
    ?>
         </span>
         <span class="DateCreated">
            <?php 
    echo Gdn_Format::Date($Object->DateInserted);
    ?>
         </span>
         <span class="Permalink">
            <?php 
    echo Anchor(T('Permalink'), $Permalink, 'Permalink', array('name' => 'Item_' . ($CurrentOffset + 1), 'rel' => 'nofollow'));
    ?>
         </span>
         <?php 
    WriteOptionList($Object, $Sender, $Session);
    ?>
         <?php 
    $Sender->FireEvent('AfterCommentMeta');
    ?>
      </div>
      <div class="Message">
			<?php 
    $Sender->FireEvent('BeforeCommentBody');
    ?>
			<p><?php 
    echo Gdn_Format::To($Object->Body, $Object->Format);
    ?>
</p>
		</div>
      <?php 
    $Sender->FireEvent('AfterCommentBody');
    ?>
   </div>
</li>
<?php 
    $Sender->FireEvent('AfterComment');
}
 /**
  * Grabs all new notifications and adds them to the sender's inform queue.
  *
  * This method gets called by dashboard's hooks file to display new
  * notifications on every pageload. 
  *
  * @since 2.0.18
  * @access public
  *
  * @param object $Sender The object calling this method.
  */
 public static function InformNotifications($Sender)
 {
     $Session = Gdn::Session();
     if (!$Session->IsValid()) {
         return;
     }
     // Set the user's DateLastInform attribute to now. This value can be used
     // by addons to determine if their inform messages have already been sent.
     $InformLastActivityID = $Session->GetAttribute('Notifications.InformLastActivityID', 0);
     // Allow pluggability
     $Sender->EventArguments['InformLastActivityID'] =& $InformLastActivityID;
     $Sender->FireEvent('BeforeInformNotifications');
     // Retrieve default preferences
     $Preferences = array();
     $DefaultPreferences = C('Preferences.Popup', array());
     foreach ($DefaultPreferences as $Preference => $Val) {
         if ($Val) {
             $Preferences[] = $Preference;
         }
     }
     //		$User = Gdn::Database()->SQL()->Select('Preferences')->From('User')->Where('UserID', $Session->UserID)->Get()->FirstRow();
     //      if ($User) {
     //         $PrefData = Gdn_Format::Unserialize($User->Preferences);
     //			foreach ($PrefData as $Pref => $Val) {
     //				if (substr($Pref, 0, 6) == 'Popup.') {
     //					$Pref = substr($Pref, 6);
     //					if ($Val) {
     //						$Preferences[] = $Pref;
     //					} else {
     //						if (in_array($Pref, $Preferences))
     //							unset($Preferences[array_search($Pref, $Preferences)]);
     //					}
     //				}
     //			}
     //		}
     //		if (count($Preferences) > 0) {
     // Grab the activity type ids for the desired notification prefs.
     $ActivityTypeIDs = array();
     //         $ActivityTypes = array();
     $Data = Gdn::Database()->SQL()->GetWhere('ActivityType', array('Notify' => TRUE))->ResultArray();
     //  ->WhereIn('Name', $Preferences)->Get();
     foreach ($Data as $ActivityType) {
         if (Gdn::Session()->GetPreference("Popup.{$ActivityType['Name']}", C("Preferences.Popup.{$ActivityType['Name']}", TRUE))) {
             $ActivityTypeIDs[] = $ActivityType['ActivityTypeID'];
             //               $ActivityTypes[] = $ActivityType['Name'];
         }
     }
     if (count($ActivityTypeIDs) > 0) {
         // Retrieve new notifications
         $ActivityModel = new ActivityModel();
         $NotificationData = $ActivityModel->GetNotificationsSince($Session->UserID, $InformLastActivityID, $ActivityTypeIDs);
         $InformLastActivityID = -1;
         // Add (no more than 5) notifications to the inform stack
         foreach ($NotificationData->Result() as $Notification) {
             // Make sure the user wants to be notified of this
             //					if (!in_array($Notification->ActivityType, $Preferences)) {
             //                  continue;
             //               }
             $UserPhoto = UserPhoto(UserBuilder($Notification, 'Activity'), 'Icon');
             $ActivityType = explode(' ', $Notification->ActivityType);
             $ActivityType = $ActivityType[0];
             $Excerpt = $Notification->Story;
             if (in_array($ActivityType, array('WallComment', 'AboutUpdate'))) {
                 $Excerpt = Gdn_Format::Display($Excerpt);
             }
             // Inform the user of new messages
             $Sender->InformMessage($UserPhoto . Wrap(Gdn_Format::ActivityHeadline($Notification, $Session->UserID), 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . ($UserPhoto == '' ? '' : ' HasIcon'));
             // Assign the most recent activity id
             if ($InformLastActivityID == -1) {
                 $InformLastActivityID = $Notification->ActivityID;
             }
         }
     }
     //		}
     if ($InformLastActivityID > 0) {
         Gdn::UserModel()->SaveAttribute($Session->UserID, 'Notifications.InformLastActivityID', $InformLastActivityID);
     }
 }
Beispiel #19
0
     $CatList = str_replace('{ChildCategories}', '<span class="ChildCategories">' . Wrap(t('Child Categories:'), 'b') . ' ' . $ChildCategories . '</span>', $CatList);
     $ChildCategories = '';
 }
 if ($Category->Depth >= $MaxDisplayDepth && $MaxDisplayDepth > 0) {
     if ($ChildCategories != '') {
         $ChildCategories .= ', ';
     }
     $ChildCategories .= anchor(Gdn_Format::text($Category->Name), CategoryUrl($Category));
 } else {
     if ($Category->DisplayAs === 'Heading') {
         $CatList .= '<li id="Category_' . $CategoryID . '" class="CategoryHeading ' . $CssClass . '">
        <div class="ItemContent Category"><div class="Options">' . getOptions($Category, $this) . '</div>' . Gdn_Format::text($Category->Name) . '</div>
     </li>';
         $Alt = FALSE;
     } else {
         $LastComment = UserBuilder($Category, 'Last');
         $AltCss = $Alt ? ' Alt' : '';
         $Alt = !$Alt;
         $CatList .= '<li id="Category_' . $CategoryID . '" class="' . $CssClass . '">
        <div class="ItemContent Category">' . '<div class="Options">' . getOptions($Category, $this) . '</div>' . CategoryPhoto($Category) . '<div class="TitleWrap">' . anchor(Gdn_Format::text($Category->Name), CategoryUrl($Category), 'Title') . '</div>
           <div class="CategoryDescription">' . $Category->Description . '</div>
           <div class="Meta">
              <span class="MItem RSS">' . anchor(img('applications/dashboard/design/images/rss.gif', array('alt' => T('RSS Feed'))), '/categories/' . $Category->UrlCode . '/feed.rss', '', array('title' => T('RSS Feed'))) . '</span>
              <span class="MItem DiscussionCount">' . sprintf(PluralTranslate($Category->CountDiscussions, '%s discussion html', '%s discussions html', t('%s discussion'), t('%s discussions')), BigPlural($Category->CountDiscussions, '%s discussion')) . '</span>
              <span class="MItem CommentCount">' . sprintf(PluralTranslate($Category->CountComments, '%s comment html', '%s comments html', t('%s comment'), t('%s comments')), BigPlural($Category->CountComments, '%s comment')) . '</span>';
         if ($Category->LastTitle != '') {
             $CatList .= '<span class="MItem LastDiscussionTitle">' . sprintf(t('Most recent: %1$s by %2$s'), anchor(Gdn_Format::text(sliceString($Category->LastTitle, 40)), $Category->LastUrl), userAnchor($LastComment)) . '</span>' . '<span class="MItem LastCommentDate">' . Gdn_Format::date($Category->LastDateInserted) . '</span>';
         }
         // If this category is one level above the max display depth, and it
         // has children, add a replacement string for them.
         if ($MaxDisplayDepth > 0 && $Category->Depth == $MaxDisplayDepth - 1 && $Category->TreeRight - $Category->TreeLeft > 1) {
Beispiel #20
0
function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt)
{
    $CssClass = 'Item';
    $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : '';
    $CssClass .= $Discussion->Closed == '1' ? ' Closed' : '';
    $CssClass .= $Alt . ' ';
    $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : '';
    $CssClass .= $Discussion->Dismissed == '1' ? ' Dismissed' : '';
    $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : '';
    $CssClass .= $Discussion->CountUnreadComments > 0 && $Session->IsValid() ? ' New' : '';
    $Sender->EventArguments['Discussion'] =& $Discussion;
    $First = UserBuilder($Discussion, 'First');
    $Last = UserBuilder($Discussion, 'Last');
    $Sender->FireEvent('BeforeDiscussionName');
    $DiscussionName = Gdn_Format::Text($Discussion->Name);
    if ($DiscussionName == '') {
        $DiscussionName = T('Blank Discussion Topic');
    }
    static $FirstDiscussion = TRUE;
    if (!$FirstDiscussion) {
        $Sender->FireEvent('BetweenDiscussion');
    } else {
        $FirstDiscussion = FALSE;
    }
    ?>
<li class="<?php 
    echo $CssClass;
    ?>
 ">
   <?php 
    $Sender->FireEvent('BeforeDiscussionContent');
    WriteOptions($Discussion, $Sender, $Session);
    ?>
   
   
   <div class="ItemContent Discussion">
      <?php 
    echo Anchor($DiscussionName, '/discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'Title');
    ?>
      <?php 
    $Sender->FireEvent('AfterDiscussionTitle');
    ?>
      <div class="Meta">
         <?php 
    if ($Discussion->Announce == '1') {
        ?>
         <span class="Announcement"><?php 
        echo T('Announcement');
        ?>
</span>
         <?php 
    }
    ?>
         <?php 
    if ($Discussion->Closed == '1') {
        ?>
         <span class="Closed"><?php 
        echo T('Closed');
        ?>
</span>
         <?php 
    }
    ?>
         <span class="CommentCount"><?php 
    printf(Plural($Discussion->CountComments, '%s comment', '%s comments'), $Discussion->CountComments);
    ?>
</span>
         <?php 
    if ($Session->IsValid() && $Discussion->CountUnreadComments > 0) {
        echo '<strong>' . Plural($Discussion->CountUnreadComments, '%s New', '%s New Plural') . '</strong>';
    }
    if ($Discussion->LastCommentID != '') {
        echo '<span class="LastCommentBy">' . sprintf(T('Most recent by %1$s'), UserAnchor($Last)) . '</span>';
        echo '<span class="LastCommentDate">' . Gdn_Format::Date($Discussion->LastDate) . '</span>';
    } else {
        echo '<span class="LastCommentBy">' . sprintf(T('Started by %1$s'), UserAnchor($First)) . '</span>';
        echo '<span class="LastCommentDate">' . Gdn_Format::Date($Discussion->FirstDate) . '</span>';
    }
    if (C('Vanilla.Categories.Use')) {
        echo Wrap(Anchor($Discussion->Category, '/categories/' . $Discussion->CategoryUrlCode, 'Category'));
    }
    $Sender->FireEvent('DiscussionMeta');
    ?>
      </div>
   </div>
   <div class="clear"></div>
</li>
<?php 
}
Beispiel #21
0
}
echo Wrap(T('Inbox'), 'strong');
?>
   </li>
<?php 
if (count($this->Data('Conversations'))) {
    ?>
   <?php 
    foreach ($this->Data('Conversations') as $Row) {
        $Subject = '';
        if ($Row['Subject']) {
            $Subject = Gdn_Format::Text($Row['Subject']);
        } else {
            $Subject = ConversationModel::ParticipantTitle($Row, FALSE);
        }
        $PhotoUser = UserBuilder($Row, 'LastInsert');
        ?>
   <li class="Item" rel="<?php 
        echo Url("/messages/{$Row['ConversationID']}#latest");
        ?>
">
      <div class="Author Photo"><?php 
        echo UserPhoto($PhotoUser);
        ?>
</div>
      <div class="ItemContent">
         <b class="Subject"><?php 
        echo Anchor($Subject, "/messages/{$Row['ConversationID']}#latest");
        ?>
</b>
         <?php 
    <description><?php 
echo Gdn_Format::text($this->Head->title());
?>
</description>
    <language><?php 
echo Gdn::config('Garden.Locale', 'en-US');
?>
</language>
    <atom:link href="<?php 
echo htmlspecialchars(url($this->SelfUrl, true));
?>
" rel="self" type="application/rss+xml"/>
<?php 
$Activities = $this->data('Activities', array());
foreach ($Activities as $Activity) {
    $Author = UserBuilder($Activity, 'Activity');
    ?>
    <item>
        <title><?php 
    echo Gdn_Format::text(val('Headline', $Activity));
    ?>
</title>
        <link><?php 
    echo url(userUrl($Author, '', 'activity'), true);
    ?>
</link>
        <pubDate><?php 
    echo date('r', Gdn_Format::ToTimeStamp(val('DateUpdated', $Activity)));
    ?>
</pubDate>
        <dc:creator><?php 
<?php

if (!defined('APPLICATION')) {
    exit;
}
?>
<div class="Box Moderators">
    <?php 
echo panelHeading(t('Moderators'));
?>
    <ul class="PanelInfo">
        <?php 
foreach ($this->ModeratorData[0]->Moderators as $Mod) {
    $Mod = UserBuilder($Mod);
    echo '<li>' . UserPhoto($Mod, 'Small') . ' ' . UserAnchor($Mod) . '</li>';
}
?>
    </ul>
</div>
Beispiel #24
0
function WriteActivityComment($Comment, &$Sender, &$Session)
{
    $Author = UserBuilder($Comment, 'Insert');
    $PhotoAnchor = UserPhoto($Author, 'Photo');
    $CssClass = 'Item ActivityComment ActivityComment';
    if ($PhotoAnchor != '') {
        $CssClass .= ' HasPhoto';
    }
    ?>
<li id="ActivityComment_<?php 
    echo $Comment['ActivityCommentID'];
    ?>
" class="<?php 
    echo $CssClass;
    ?>
">
   <?php 
    if ($PhotoAnchor != '') {
        ?>
   <div class="Author Photo"><?php 
        echo $PhotoAnchor;
        ?>
</div>
   <?php 
    }
    ?>
   <div class="ItemContent ActivityComment">
      <?php 
    echo UserAnchor($Author, 'Title Name');
    ?>
      <div class="Excerpt"><?php 
    echo Gdn_Format::To($Comment['Body'], $Comment['Format']);
    ?>
</div>
      <div class="Meta">
         <span class="DateCreated"><?php 
    echo Gdn_Format::Date($Comment['DateInserted'], 'html');
    ?>
</span>
         <?php 
    if ($Session->UserID == $Comment['InsertUserID'] || $Session->CheckPermission('Garden.Activity.Delete')) {
        echo Anchor(T('Delete'), "dashboard/activity/deletecomment?id={$Comment['ActivityCommentID']}&tk=" . $Session->TransientKey() . '&target=' . urlencode(Gdn_Url::Request()), 'DeleteComment');
    }
    ?>
      </div>
   </div>
</li>
<?php 
}
    /**
     * Writes a discussion in table row format.
     */
    function WriteDiscussionRow($Discussion, &$Sender, &$Session, $Alt2)
    {
        if (!property_exists($Sender, 'CanEditDiscussions')) {
            $Sender->CanEditDiscussions = GetValue('PermsDiscussionsEdit', CategoryModel::Categories($Discussion->CategoryID)) && C('Vanilla.AdminCheckboxes.Use');
        }
        $CssClass = CssClass($Discussion);
        $DiscussionUrl = $Discussion->Url;
        if ($Session->UserID) {
            $DiscussionUrl .= '#latest';
        }
        $Sender->EventArguments['DiscussionUrl'] =& $DiscussionUrl;
        $Sender->EventArguments['Discussion'] =& $Discussion;
        $Sender->EventArguments['CssClass'] =& $CssClass;
        $First = UserBuilder($Discussion, 'First');
        if ($Discussion->LastUserID) {
            $Last = UserBuilder($Discussion, 'Last');
        } else {
            $Last = $First;
        }
        //   $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;
        $Discussion->CountPages = ceil($Discussion->CountComments / $Sender->CountCommentsPerPage);
        $FirstPageUrl = DiscussionUrl($Discussion, 1);
        $LastPageUrl = DiscussionUrl($Discussion, FALSE) . '#latest';
        ?>
<tr id="Discussion_<?php 
        echo $Discussion->DiscussionID;
        ?>
" class="<?php 
        echo $CssClass;
        ?>
">
   <?php 
        echo AdminCheck($Discussion, array('<td class="CheckBoxColumn"><div class="Wrap">', '</div></td>'));
        ?>
	<td class="DiscussionName">
		<div class="Wrap">
         <span class="Options">
            <?php 
        echo OptionsList($Discussion);
        echo BookmarkButton($Discussion);
        ?>
         </span>
			<?php 
        echo Anchor($DiscussionName, $DiscussionUrl, 'Title') . ' ';
        $Sender->FireEvent('AfterDiscussionTitle');
        WriteMiniPager($Discussion);
        echo NewComments($Discussion);
        if ($Sender->Data('_ShowCategoryLink', TRUE)) {
            echo CategoryLink($Discussion, ' ' . T('in') . ' ');
        }
        // Other stuff that was in the standard view that you may want to display:
        echo '<div class="Meta Meta-Discussion">';
        WriteTags($Discussion);
        echo '</div>';
        //			if ($Source = GetValue('Source', $Discussion))
        //				echo ' '.sprintf(T('via %s'), T($Source.' Source', $Source));
        //
        ?>
		</div>
	</td>
	<td class="BlockColumn BlockColumn-User FirstUser">
		<div class="Block Wrap">
			<?php 
        echo UserPhoto($First, array('Size' => 'Small'));
        echo UserAnchor($First, 'UserLink BlockTitle');
        echo '<div class="Meta">';
        echo Anchor(Gdn_Format::Date($Discussion->FirstDate, 'html'), $FirstPageUrl, 'CommentDate MItem');
        echo '</div>';
        ?>
		</div>
   </td>
	<td class="BigCount CountComments">
      <div class="Wrap">
         <?php 
        // Exact Number
        // echo number_format($Discussion->CountComments);
        // Round Number
        echo BigPlural($Discussion->CountComments, '%s comment');
        ?>
      </div>
	</td>
	<td class="BigCount CountViews">
      <div class="Wrap">
         <?php 
        // Exact Number
        // echo number_format($Discussion->CountViews);
        // Round Number
        echo BigPlural($Discussion->CountViews, '%s view');
        ?>
      </div>
	</td>
	<td class="BlockColumn BlockColumn-User LastUser">
		<div class="Block Wrap">
			<?php 
        if ($Last) {
            echo UserPhoto($Last, array('Size' => 'Small'));
            echo UserAnchor($Last, 'UserLink BlockTitle');
            echo '<div class="Meta">';
            echo Anchor(Gdn_Format::Date($Discussion->LastDate, 'html'), $LastPageUrl, 'CommentDate MItem');
            echo '</div>';
        } else {
            echo '&nbsp;';
        }
        ?>
		</div>
	</td>
</tr>
<?php 
    }
Beispiel #26
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
foreach ($this->CommentData->Result() as $Comment) {
    $Permalink = '/discussion/comment/' . $Comment->CommentID . '/#Comment_' . $Comment->CommentID;
    $User = UserBuilder($Comment, 'Insert');
    $this->EventArguments['User'] = $User;
    ?>
<li class="Item">
	<?php 
    $this->FireEvent('BeforeItemContent');
    ?>
	<div class="ItemContent">
		<?php 
    echo Anchor(Gdn_Format::Text($Comment->DiscussionName), $Permalink, 'Title');
    ?>
		<div class="Excerpt"><?php 
    echo Anchor(SliceString(Gdn_Format::Text(Gdn_Format::To($Comment->Body, $Comment->Format), FALSE), 250), $Permalink);
    ?>
</div>
		<div class="Meta">
			<span><?php 
    printf(T('Comment by %s'), UserAnchor($User));
    ?>
</span>
			<span><?php 
    echo Gdn_Format::Date($Comment->DateInserted);
    ?>
</span>
Beispiel #27
0
function WriteActivityComment($Comment, &$Sender, &$Session)
{
    $Author = UserBuilder($Comment, 'Activity');
    $PhotoAnchor = UserPhoto($Author, 'Photo');
    $CssClass = 'Item ActivityComment Condensed ' . $Comment->ActivityType;
    if ($PhotoAnchor != '') {
        $CssClass .= ' HasPhoto';
    }
    ?>
<li id="Activity_<?php 
    echo $Comment->ActivityID;
    ?>
" class="<?php 
    echo $CssClass;
    ?>
">
   <?php 
    if ($PhotoAnchor != '') {
        ?>
   <div class="Author Photo"><?php 
        echo $PhotoAnchor;
        ?>
</div>
   <?php 
    }
    ?>
   <div class="ItemContent ActivityComment">
      <?php 
    echo UserAnchor($Author, 'Title Name');
    ?>
      <div class="Excerpt"><?php 
    echo Gdn_Format::Display($Comment->Story);
    ?>
</div>
      <div class="Meta">
         <span class="DateCreated"><?php 
    echo Gdn_Format::Date($Comment->DateInserted);
    ?>
</span>
         <?php 
    if ($Session->UserID == $Comment->InsertUserID || $Session->CheckPermission('Garden.Activity.Delete')) {
        echo Anchor(T('Delete'), 'dashboard/activity/delete/' . $Comment->ActivityID . '/' . $Session->TransientKey() . '?Return=' . urlencode(Gdn_Url::Request()), 'DeleteComment');
    }
    ?>
      </div>
   </div>
</li>
<?php 
}
Beispiel #28
0
function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt2)
{
    static $Alt = FALSE;
    $CssClass = 'Item';
    $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : '';
    $CssClass .= $Alt ? ' Alt ' : '';
    $Alt = !$Alt;
    $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : '';
    $CssClass .= $Discussion->Dismissed == '1' ? ' Dismissed' : '';
    $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : '';
    $CssClass .= $Discussion->CountUnreadComments > 0 && $Session->IsValid() ? ' New' : '';
    $DiscussionUrl = '/discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') && $Session->UserID > 0 ? '/#Item_' . $Discussion->CountCommentWatch : '');
    //   $DiscussionUrl = $Discussion->Url;
    $Sender->EventArguments['DiscussionUrl'] =& $DiscussionUrl;
    $Sender->EventArguments['Discussion'] =& $Discussion;
    $Sender->EventArguments['CssClass'] =& $CssClass;
    $First = UserBuilder($Discussion, 'First');
    $Last = UserBuilder($Discussion, '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;
    }
    ?>
<li 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);
    ?>
   <div class="ItemContent Discussion">
      <?php 
    echo Anchor($DiscussionName, $DiscussionUrl, 'Title');
    ?>
      <?php 
    $Sender->FireEvent('AfterDiscussionTitle');
    ?>
      <div class="Meta">
         <?php 
    $Sender->FireEvent('BeforeDiscussionMeta');
    ?>
         <?php 
    if ($Discussion->Announce == '1') {
        ?>
         <span class="Tag Announcement"><?php 
        echo T('Announcement');
        ?>
</span>
         <?php 
    }
    ?>
         <?php 
    if ($Discussion->Closed == '1') {
        ?>
         <span class="Tag Closed"><?php 
        echo T('Closed');
        ?>
</span>
         <?php 
    }
    ?>
         <span class="MItem CommentCount"><?php 
    printf(Plural($Discussion->CountComments, '%s comment', '%s comments'), $Discussion->CountComments);
    if ($Session->IsValid() && $Discussion->CountUnreadComments > 0) {
        echo ' <strong class="HasNew">' . Plural($Discussion->CountUnreadComments, '%s new', '%s new plural') . '</strong>';
    }
    ?>
</span>
         <?php 
    $Sender->FireEvent('AfterCountMeta');
    if ($Discussion->LastCommentID != '') {
        echo ' <span class="MItem LastCommentBy">' . sprintf(T('Most recent by %1$s'), UserAnchor($Last)) . '</span> ';
        echo ' <span class="MItem LastCommentDate">' . Gdn_Format::Date($Discussion->LastDate) . '</span>';
    } else {
        echo ' <span class="MItem LastCommentBy">' . sprintf(T('Started by %1$s'), UserAnchor($First)) . '</span> ';
        echo ' <span class="MItem LastCommentDate">' . Gdn_Format::Date($Discussion->FirstDate);
        if ($Source = GetValue('Source', $Discussion)) {
            echo ' ' . sprintf(T('via %s'), T($Source . ' Source', $Source));
        }
        echo '</span> ';
    }
    if (C('Vanilla.Categories.Use') && $Discussion->CategoryUrlCode != '') {
        echo ' ' . Wrap(Anchor($Discussion->Category, '/categories/' . rawurlencode($Discussion->CategoryUrlCode)), 'span', array('class' => 'Tag Category'));
    }
    $Sender->FireEvent('DiscussionMeta');
    ?>
      </div>
   </div>
</li>
<?php 
}
Beispiel #29
0
    /**
     * Writes a discussion in table row format.
     */
    function writeDiscussionRow($Discussion, $Sender, $Session)
    {
        if (!property_exists($Sender, 'CanEditDiscussions')) {
            $Sender->CanEditDiscussions = val('PermsDiscussionsEdit', CategoryModel::categories($Discussion->CategoryID)) && c('Vanilla.AdminCheckboxes.Use');
        }
        $CssClass = CssClass($Discussion);
        $DiscussionUrl = $Discussion->Url;
        if ($Session->UserID) {
            $DiscussionUrl .= '#latest';
        }
        $Sender->EventArguments['DiscussionUrl'] =& $DiscussionUrl;
        $Sender->EventArguments['Discussion'] =& $Discussion;
        $Sender->EventArguments['CssClass'] =& $CssClass;
        $First = UserBuilder($Discussion, 'First');
        if ($Discussion->LastUserID) {
            $Last = UserBuilder($Discussion, 'Last');
        } else {
            $Last = $First;
        }
        $Sender->EventArguments['FirstUser'] =& $First;
        $Sender->EventArguments['LastUser'] =& $Last;
        $Sender->fireEvent('BeforeDiscussionName');
        $DiscussionName = $Discussion->Name;
        // If there are no word character detected in the title treat it as if it is blank.
        if (!preg_match('/\\w/u', $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);
        $FirstPageUrl = DiscussionUrl($Discussion, 1);
        $LastPageUrl = DiscussionUrl($Discussion, val('CountPages', $Discussion)) . '#latest';
        ?>
        <tr id="Discussion_<?php 
        echo $Discussion->DiscussionID;
        ?>
" class="<?php 
        echo $CssClass;
        ?>
">
            <?php 
        $Sender->fireEvent('BeforeDiscussionContent');
        ?>
            <?php 
        echo AdminCheck($Discussion, array('<td class="CheckBoxColumn"><div class="Wrap">', '</div></td>'));
        ?>
            <td class="DiscussionName">
                <div class="Wrap">
         <span class="Options">
            <?php 
        echo OptionsList($Discussion);
        echo BookmarkButton($Discussion);
        ?>
         </span>
                    <?php 
        $Sender->fireEvent('BeforeDiscussionTitle');
        echo anchor($DiscussionName, $DiscussionUrl, 'Title') . ' ';
        $Sender->fireEvent('AfterDiscussionTitle');
        WriteMiniPager($Discussion);
        echo NewComments($Discussion);
        if ($Sender->data('_ShowCategoryLink', true)) {
            echo CategoryLink($Discussion, ' ' . t('in') . ' ');
        }
        // Other stuff that was in the standard view that you may want to display:
        echo '<div class="Meta Meta-Discussion">';
        WriteTags($Discussion);
        echo '</div>';
        //			if ($Source = val('Source', $Discussion))
        //				echo ' '.sprintf(t('via %s'), t($Source.' Source', $Source));
        //
        ?>
                </div>
            </td>
            <td class="BlockColumn BlockColumn-User FirstUser">
                <div class="Block Wrap">
                    <?php 
        echo userPhoto($First, array('Size' => 'Small'));
        echo userAnchor($First, 'UserLink BlockTitle');
        echo '<div class="Meta">';
        echo anchor(Gdn_Format::date($Discussion->FirstDate, 'html'), $FirstPageUrl, 'CommentDate MItem');
        echo '</div>';
        ?>
                </div>
            </td>
            <td class="BigCount CountComments">
                <div class="Wrap">
                    <?php 
        // Exact Number
        // echo number_format($Discussion->CountComments);
        // Round Number
        echo BigPlural($Discussion->CountComments, '%s comment');
        ?>
                </div>
            </td>
            <td class="BigCount CountViews">
                <div class="Wrap">
                    <?php 
        // Exact Number
        // echo number_format($Discussion->CountViews);
        // Round Number
        echo BigPlural($Discussion->CountViews, '%s view');
        ?>
                </div>
            </td>
            <td class="BlockColumn BlockColumn-User LastUser">
                <div class="Block Wrap">
                    <?php 
        if ($Last) {
            echo userPhoto($Last, array('Size' => 'Small'));
            echo userAnchor($Last, 'UserLink BlockTitle');
            echo '<div class="Meta">';
            echo anchor(Gdn_Format::date($Discussion->LastDate, 'html'), $LastPageUrl, 'CommentDate MItem');
            echo '</div>';
        } else {
            echo '&nbsp;';
        }
        ?>
                </div>
            </td>
        </tr>
    <?php 
    }
Beispiel #30
0
 /**
  * Takes a user object, and writes out an anchor of the user's icon to the user's profile.
  *
  * @param object|array $User A user object or array.
  * @param array $Options
  */
 function userPhoto($User, $Options = array())
 {
     if (is_string($Options)) {
         $Options = array('LinkClass' => $Options);
     }
     if ($Px = GetValue('Px', $Options)) {
         $User = UserBuilder($User, $Px);
     } else {
         $User = (object) $User;
     }
     $LinkClass = ConcatSep(' ', GetValue('LinkClass', $Options, ''), 'PhotoWrap');
     $ImgClass = GetValue('ImageClass', $Options, 'ProfilePhoto');
     $Size = GetValue('Size', $Options);
     if ($Size) {
         $LinkClass .= " PhotoWrap{$Size}";
         $ImgClass .= " {$ImgClass}{$Size}";
     } else {
         $ImgClass .= " {$ImgClass}Medium";
         // backwards compat
     }
     $FullUser = Gdn::UserModel()->GetID(GetValue('UserID', $User), DATASET_TYPE_ARRAY);
     $UserCssClass = GetValue('_CssClass', $FullUser);
     if ($UserCssClass) {
         $LinkClass .= ' ' . $UserCssClass;
     }
     $LinkClass = $LinkClass == '' ? '' : ' class="' . $LinkClass . '"';
     $Photo = GetValue('Photo', $User);
     $Name = GetValue('Name', $User);
     $Title = htmlspecialchars(GetValue('Title', $Options, $Name));
     if ($FullUser && $FullUser['Banned']) {
         $Photo = C('Garden.BannedPhoto', 'http://cdn.vanillaforums.com/images/banned_large.png');
         $Title .= ' (' . T('Banned') . ')';
     }
     if (!$Photo && function_exists('UserPhotoDefaultUrl')) {
         $Photo = UserPhotoDefaultUrl($User, $ImgClass);
     }
     if ($Photo) {
         if (!isUrl($Photo)) {
             $PhotoUrl = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s'));
         } else {
             $PhotoUrl = $Photo;
         }
         $Href = Url(UserUrl($User));
         return '<a title="' . $Title . '" href="' . $Href . '"' . $LinkClass . '>' . Img($PhotoUrl, array('alt' => $Name, 'class' => $ImgClass)) . '</a>';
     } else {
         return '';
     }
 }