コード例 #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 .= val('Bookmarked', $Row) == '1' ? ' Bookmarked' : '';
         $Announce = val('Announce', $Row);
         if ($Announce == 2) {
             $CssClass .= ' Announcement Announcement-Category';
         } elseif ($Announce) {
             $CssClass .= ' Announcement Announcement-Everywhere';
         }
         $CssClass .= val('Closed', $Row) == '1' ? ' Closed' : '';
         $CssClass .= val('InsertUserID', $Row) == $Session->UserID ? ' Mine' : '';
         $CssClass .= val('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 = val('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 = val('_CssClass', $Row)) {
         $CssClass .= ' ' . $_CssClss;
     }
     // Insert User classes.
     if ($UserID = val('InsertUserID', $Row)) {
         $User = Gdn::userModel()->getID($UserID);
         if ($_CssClss = val('_CssClass', $User)) {
             $CssClass .= ' ' . $_CssClss;
         }
     }
     return trim($CssClass);
 }
コード例 #2
0
ファイル: helper_functions.php プロジェクト: vanilla/vanilla
 /**
  *
  *
  * @param $Comment
  * @return string|void
  */
 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>';
 }