Exemplo n.º 1
0
 /**
  * Add CSS class names to a row depending on other elements/values in that row.
  *
  * Used by category, discussion, and comment lists.
  *
  * @param array|object $Row
  * @return string The CSS classes to be inserted into the row.
  */
 function cssClass($Row, $InList = true)
 {
     static $Alt = false;
     $Row = (array) $Row;
     $CssClass = 'Item';
     $Session = Gdn::Session();
     // Alt rows
     if ($Alt) {
         $CssClass .= ' Alt';
     }
     $Alt = !$Alt;
     // Category list classes
     if (array_key_exists('UrlCode', $Row)) {
         $CssClass .= ' Category-' . Gdn_Format::AlphaNumeric($Row['UrlCode']);
     }
     if (GetValue('CssClass', $Row)) {
         $CssClass .= ' Item-' . $Row['CssClass'];
     }
     if (array_key_exists('Depth', $Row)) {
         $CssClass .= " Depth{$Row['Depth']} Depth-{$Row['Depth']}";
     }
     if (array_key_exists('Archive', $Row)) {
         $CssClass .= ' Archived';
     }
     // Discussion list classes.
     if ($InList) {
         $CssClass .= GetValue('Bookmarked', $Row) == '1' ? ' Bookmarked' : '';
         $Announce = GetValue('Announce', $Row);
         if ($Announce == 2) {
             $CssClass .= ' Announcement Announcement-Category';
         } elseif ($Announce) {
             $CssClass .= ' Announcement Announcement-Everywhere';
         }
         $CssClass .= GetValue('Closed', $Row) == '1' ? ' Closed' : '';
         $CssClass .= GetValue('InsertUserID', $Row) == $Session->UserID ? ' Mine' : '';
         $CssClass .= GetValue('Participated', $Row) == '1' ? ' Participated' : '';
         if (array_key_exists('CountUnreadComments', $Row) && $Session->IsValid()) {
             $CountUnreadComments = $Row['CountUnreadComments'];
             if ($CountUnreadComments === true) {
                 $CssClass .= ' New';
             } elseif ($CountUnreadComments == 0) {
                 $CssClass .= ' Read';
             } else {
                 $CssClass .= ' Unread';
             }
         } elseif (($IsRead = GetValue('Read', $Row, null)) !== null) {
             // Category list
             $CssClass .= $IsRead ? ' Read' : ' Unread';
         }
     }
     // Comment list classes
     if (array_key_exists('CommentID', $Row)) {
         $CssClass .= ' ItemComment';
     } elseif (array_key_exists('DiscussionID', $Row)) {
         $CssClass .= ' ItemDiscussion';
     }
     if (function_exists('IsMeAction')) {
         $CssClass .= IsMeAction($Row) ? ' MeAction' : '';
     }
     if ($_CssClss = GetValue('_CssClass', $Row)) {
         $CssClass .= ' ' . $_CssClss;
     }
     // Insert User classes.
     if ($UserID = GetValue('InsertUserID', $Row)) {
         $User = Gdn::UserModel()->GetID($UserID);
         if ($_CssClss = GetValue('_CssClass', $User)) {
             $CssClass .= ' ' . $_CssClss;
         }
     }
     return trim($CssClass);
 }
Exemplo n.º 2
0
 function FormatMeAction($Comment)
 {
     if (!IsMeAction($Comment)) {
         return;
     }
     // Maxlength (don't let people blow up the forum)
     $Maxlength = C('Vanilla.MeAction.MaxLength', 100);
     $Body = Gdn_Format::PlainText(substr($Comment->Body, 4));
     if (strlen($Body) > $Maxlength) {
         $Body = substr($Body, 0, $Maxlength) . '...';
     }
     return '<div class="AuthorAction">' . $Body . '</div>';
 }
 function formatMeAction($Comment)
 {
     if (!IsMeAction($Comment) || !C('Garden.Format.MeActions')) {
         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>';
 }