function bigPlural($Number, $Singular, $Plural = false) { if (!$Plural) { $Plural = $Singular . 's'; } $Title = sprintf(T($Number == 1 ? $Singular : $Plural), number_format($Number)); return '<span title="' . $Title . '" class="Number">' . Gdn_Format::BigNumber($Number) . '</span>'; }
public function DiscussionsController_AfterRenderAsset_Handler($Sender) { $AssetName = GetValueR('EventArguments.AssetName', $Sender); if ($AssetName != "Content") { return; } $CurTime = time(); $LastTime = Gdn::Get('TimeCheck', $LastTime); $SFVcount = Gdn::Get('ViewCount', $SFVcount); $SFUcount = Gdn::Get('UserCount', $SFUcount); $SFDcount = Gdn::Get('DiscussionCount', $SFDcount); $SFCcount = Gdn::Get('CommentCount', $SFCcount); // refresh counts every 60 seconds unless config is set // e.g. $Configuration['Plugins']['StatisticsFooter']['Refresh'] = '90'; $IncSec = C('Plugins.StatisticsFooter.Refresh', 60); if ($CurTime > $LastTime) { $LastTime = time() + $IncSec; Gdn::Set('TimeCheck', $LastTime); $SFVcount = $this->GetViewCount(); Gdn::Set('ViewCount', $SFVcount); $SFUcount = $this->GetUserCount(); Gdn::Set('UserCount', $SFUcount); $SFDcount = $this->GetDiscussionCount(); Gdn::Set('DiscussionCount', $SFDcount); $SFCcount = $this->GetCommentCount(); Gdn::Set('CommentCount', $SFCcount); } $SFPcount = $SFDcount + $SFCcount; $ShowMe = C('Plugins.StatisticsFooter.Show'); if (strpos($ShowMe, "v") !== FALSE) { echo Wrap(Wrap(T('View Count')) . Gdn_Format::BigNumber($SFVcount), 'div', array('class' => 'SFBox SFVCBox')); } if (strpos($ShowMe, "u") !== FALSE) { echo Wrap(Wrap(T('User Count')) . Gdn_Format::BigNumber($SFUcount), 'div', array('class' => 'SFBox SFUBox')); } if (strpos($ShowMe, "t") !== FALSE) { echo Wrap(Wrap(T('Topic Count')) . Gdn_Format::BigNumber($SFDcount), 'div', array('class' => 'SFBox SFTBox')); } if (strpos($ShowMe, "c") !== FALSE) { echo Wrap(Wrap(T('Post Count')) . Gdn_Format::BigNumber($SFPcount), 'div', array('class' => 'SFBox SFPBox')); } }
function WriteTable($Results, $WriteText, $CssClass) { $String = ''; $Total = sizeof($Results); if ($Total == 0) { return $String; //return an empty string if no results } $Count = 0; //for toggling the message div if text ob_start(); ?> <div class="SphinxSearch Table"> <table> <thead> <tr> <th class="Title">Discussion</th> <th class="Starter">Starter</th> <th class="Forum">Forum</th> <th class="InfoCount">R / V</th> <th class="Latest">Latest</th> </tr> </thead> <tbody> <?php foreach ($Results as $Row) { ?> <?php $ID = 'T_' . $Count++; //unique identifer $OAuthor->Name = $Row->UserName; $OAuthor->UserID = $Row->UserID; //original author $LAuthor->Name = $Row->LastUserName; $LAuthor->UserID = $Row->LastUserID; //latest author $Row->CountCommentWatch = $Row->CountComments; //for discussion link $TitleURL = $Row->IsComment ? 'discussion/comment/' . $Row->CommentID . '/#Comment_' . $Row->CommentID : DiscussionLink($Row, FALSE); //if the comment is from the orignal discussion poster, simply link to the front page of that ?> <tr <?php echo Alternate(); ?> > <td class="Title"> <?php if ($WriteText) { ?> <span id="<?php echo $ID; ?> " class="PlusImage Toggle"></span> <?php } ?> <span class="Title"><?php echo Anchor($Row->Title . Wrap(htmlspecialchars(SliceString($Row->DiscussionBody, SS_PREVIEW_BODY_LIMIT)), 'span', array('class' => 'ToolTip')), $TitleURL, FALSE, array('class' => 'HasToolTip')); ?> </span> </td> <td class="Starter"> <?php echo UserAnchor($OAuthor); ?> <?php Anchor(Gdn_Format::Date($Row->DateInserted), $TitleURL); ?> </td> <td class="Forum"> <?php echo Anchor(Gdn_Format::Text($Row->CatName), 'categories/' . $Row->CatUrlCode); ?> </td> <td class="InfoCount"> <?php echo Gdn_Format::BigNumber($Row->CountComments); ?> / <?php echo Gdn_Format::BigNumber($Row->CountViews); ?> </td> <td class="Latest"> <?php echo UserAnchor($LAuthor) . ' on '; echo Anchor(Gdn_Format::Date($Row->DateInserted), DiscussionLink($Row, $Extended = TRUE)); ?> </td> </tr> <?php if ($WriteText) { ?> <tr id="<?php echo $ID . 'T'; ?> " style="display: none" class="ExpandText"> <td colspan="5"> <!-- Need this since this column will expand the width of the table !--> <div class="Message Excerpt"> <?php echo nl2br(SliceString($Row->Body, SS_BODY_LIMIT)); ?> </div> </td> </tr> <?php } ?> <?php } ?> </tbody> </table> <div style="clear: both"></div> </div> <?php $String = ob_get_contents(); @ob_end_clean(); return $String; }
public function ToString() { $String = ''; if (sizeof($this->Words) == 0) { return $String; //return an empty string if no results } ob_start(); ?> <div id="HitBox" class="Box HitBox"> <h4 class="Header"><?php echo T('HitBox'); ?> </h4> <table> <thead> <tr> <th class="Word"> <?php echo T('Word'); ?> </th> <th class="Docs"> <?php echo T('Docs'); ?> </th> <th class="Hits"> <?php echo T('Hits'); ?> </th> </tr> </thead> <tbody> <?php foreach ($this->Words as $Word => $WordArray) { ?> <tr> <td class="Word"> <?php echo $Word; ?> </td> <td class="Docs"> <?php echo Gdn_Format::BigNumber($WordArray['docs']); ?> </td> <td class="Hits"> <?php echo Gdn_Format::BigNumber($WordArray['hits']); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <?php $String .= ob_get_contents(); @ob_end_clean(); return $String; }
public function DiscussionController_AfterCommentMeta_Handler($Sender) { // if (!C('Plugins.Voting.Enabled')) // return; /* echo '<span class="Votes">'; $Session = Gdn::Session(); $Object = GetValue('Object', $Sender->EventArguments); $VoteType = $Sender->EventArguments['Type'] == 'Discussion' ? 'votediscussion' : 'votecomment'; $ID = $Sender->EventArguments['Type'] == 'Discussion' ? $Object->DiscussionID : $Object->CommentID; $CssClass = ''; $VoteUpUrl = '/discussion/'.$VoteType.'/'.$ID.'/voteup/'.$Session->TransientKey().'/'; $VoteDownUrl = '/discussion/'.$VoteType.'/'.$ID.'/votedown/'.$Session->TransientKey().'/'; if (!$Session->IsValid()) { $VoteUpUrl = Gdn::Authenticator()->SignInUrl($Sender->SelfUrl); $VoteDownUrl = $VoteUpUrl; $CssClass = ' SignInPopup'; } echo Anchor(Wrap(Wrap('Vote Up', 'i'), 'i', array('class' => 'ArrowSprite SpriteUp', 'rel' => 'nofollow')), $VoteUpUrl, 'VoteUp'.$CssClass); echo Wrap(StringIsNullOrEmpty($Object->Score) ? '0' : Gdn_Format::BigNumber($Object->Score)); echo Anchor(Wrap(Wrap('Vote Down', 'i'), 'i', array('class' => 'ArrowSprite SpriteDown', 'rel' => 'nofollow')), $VoteDownUrl, 'VoteDown'.$CssClass); echo '</span>'; */ $Session = Gdn::Session(); $Object = GetValue('Object', $Sender->EventArguments); $VoteType = $Sender->EventArguments['Type'] == 'Discussion' ? 'votediscussion' : 'votecomment'; $ID = $Sender->EventArguments['Type'] == 'Discussion' ? $Object->DiscussionID : $Object->CommentID; $CssClass = ''; $VoteUpUrl = '/discussion/' . $VoteType . '/' . $ID . '/voteup/' . $Session->TransientKey() . '/'; $VoteDownUrl = '/discussion/' . $VoteType . '/' . $ID . '/votedown/' . $Session->TransientKey() . '/'; if (!$Session->IsValid()) { $VoteUpUrl = Gdn::Authenticator()->SignInUrl($Sender->SelfUrl); $VoteDownUrl = $VoteUpUrl; $CssClass = ' SignInPopup'; } echo '<span class="Voter">'; echo Anchor(Wrap(Wrap('Vote Up', 'i'), 'i', array('class' => 'ArrowSprite SpriteUp', 'rel' => 'nofollow')), $VoteUpUrl, 'VoteUp' . $CssClass); echo Wrap(StringIsNullOrEmpty($Object->Score) ? '0' : Gdn_Format::BigNumber($Object->Score)); echo Anchor(Wrap(Wrap('Vote Down', 'i'), 'i', array('class' => 'ArrowSprite SpriteDown', 'rel' => 'nofollow')), $VoteDownUrl, 'VoteDown' . $CssClass); echo '</span>'; }
?> <?php if ($Row['Description']) { ?> <div class="CategoryDescription"> <?php echo $Row['Description']; ?> </div> <?php } ?> <div class="Meta Hidden"> <span class="MItem MItem-Count DiscussionCount"><?php echo Plural($Row['CountDiscussions'], '%s discussion', '%s discussions', Gdn_Format::BigNumber($Row['CountDiscussions'], 'html')); ?> </span> <span class="MItem MItem-Count CommentCount"><?php echo Plural($Row['CountComments'], '%s comment', '%s comments', Gdn_Format::BigNumber($Row['CountComments'], 'html')); ?> </span> </div> </div> </li> <?php } ?> </ul>
/** * Display the reaction counts on the profile page * @param ProfileController $Sender */ public function ProfileController_AfterUserInfo_Handler($Sender) { if (!C('Yaga.Reactions.Enabled')) { return; } $User = $Sender->User; $Method = $Sender->RequestMethod; if ($Method == 'reactions') { $ActionID = $Sender->RequestArgs[2]; } else { $ActionID = -1; } echo '<div class="Yaga ReactionsWrap">'; echo Wrap(T('Yaga.Reactions', 'Reactions'), 'h2', array('class' => 'H')); // insert the reaction totals in the profile $ReactionModel = Yaga::ReactionModel(); $Actions = Yaga::ActionModel()->Get(); $String = ''; foreach ($Actions as $Action) { $Selected = $ActionID == $Action->ActionID ? ' Selected' : ''; $Count = $ReactionModel->GetUserCount($User->UserID, $Action->ActionID); $TempString = Wrap(Wrap(Gdn_Format::BigNumber($Count), 'span', array('title' => $Count)), 'span', array('class' => 'Yaga_ReactionCount CountTotal')); $TempString .= Wrap($Action->Name, 'span', array('class' => 'Yaga_ReactionName CountLabel')); $String .= Wrap(Wrap(Anchor($TempString, '/profile/reactions/' . $User->UserID . '/' . Gdn_Format::Url($User->Name) . '/' . $Action->ActionID, array('class' => 'Yaga_Reaction TextColor', 'title' => $Action->Description)), 'span', array('class' => 'CountItem' . $Selected)), 'span', array('class' => 'CountItemWrap')); } echo Wrap($String, 'div', array('class' => 'DataCounts')); echo '</div>'; }
function WriteListItem($Row, $Depth = 1) { $Children = $Row['Children']; $WriteChildren = FALSE; if (!empty($Children)) { if ($Depth + 1 >= C('Vanilla.Categories.MaxDisplayDepth')) { $WriteChildren = 'list'; } else { $WriteChildren = 'items'; } } $H = 'h' . ($Depth + 1); ?> <li id="Category_<?php echo $Row['CategoryID']; ?> " class="<?php echo CssClass($Row); ?> "> <div class="ItemContent Category"> <?php echo GetOptions($Row); ?> <?php echo Wrap(Anchor($Row['Name'], $Row['Url'], 'Title'), $H, array('class' => 'CategoryName TitleWrap')); ?> <div class="CategoryDescription"> <?php echo $Row['Description']; ?> </div> <?php if ($WriteChildren === 'list') { ?> <div class="ChildCategories"> <?php echo Wrap(T('Child Categories') . ': ', 'b'); echo CategoryString($Children, $Depth + 1); ?> </div> <?php } ?> <div class="Meta"> <span class="MItem RSS"><?php echo Anchor(' ', '/categories/' . rawurlencode($Row['UrlCode']) . '/feed.rss', 'SpRSS'); ?> </span> <span class="MItem MItem-Count DiscussionCount"><?php echo Plural($Row['CountDiscussions'], '%s discussion', '%s discussions', Gdn_Format::BigNumber($Row['CountDiscussions'], 'html')); ?> </span> <span class="MItem MItem-Count CommentCount"><?php echo Plural($Row['CountDiscussions'], '%s comment', '%s comments', Gdn_Format::BigNumber($Row['CountComments'], 'html')); ?> </span> <span class="MItem LastestPost LastDiscussionTitle"><?php echo MostRecentString($Row); ?> </span> </div> </div> </li> <?php if ($WriteChildren === 'items') { foreach ($Children as $ChildRow) { WriteListItem($ChildRow, $Depth + 1); } } }
/** * Add the "Stats" buttons to the discussion list. */ public function Base_BeforeDiscussionContent_Handler($Sender) { if (!C('Plugins.Voting.Enabled')) { return; } $Session = Gdn::Session(); $Discussion = GetValue('Discussion', $Sender->EventArguments); // Answers $Css = 'StatBox AnswersBox'; if ($Discussion->CountComments > 1) { $Css .= ' HasAnswersBox'; } $CountVotes = 0; if (is_numeric($Discussion->Score)) { // && $Discussion->Score > 0) $CountVotes = $Discussion->Score; } if (!is_numeric($Discussion->CountBookmarks)) { $Discussion->CountBookmarks = 0; } echo Wrap(Wrap(T('Comments')) . Gdn_Format::BigNumber($Discussion->CountComments - 1), 'div', array('class' => $Css)); // Views echo Wrap(Wrap(T('Views')) . Gdn_Format::BigNumber($Discussion->CountViews), 'div', array('class' => 'StatBox ViewsBox')); // Follows $Title = T($Discussion->Bookmarked == '1' ? 'Unbookmark' : 'Bookmark'); if ($Session->IsValid()) { echo Wrap(Anchor(Wrap(T('Follows')) . Gdn_Format::BigNumber($Discussion->CountBookmarks), '/vanilla/discussion/bookmark/' . $Discussion->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), '', array('title' => $Title)), 'div', array('class' => 'StatBox FollowsBox')); } else { echo Wrap(Wrap(T('Follows')) . $Discussion->CountBookmarks, 'div', array('class' => 'StatBox FollowsBox')); } // Votes if ($Session->IsValid()) { echo Wrap(Anchor(Wrap(T('Votes')) . Gdn_Format::BigNumber($CountVotes), '/vanilla/discussion/votediscussion/' . $Discussion->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), '', array('title' => T('Vote'))), 'div', array('class' => 'StatBox VotesBox')); } else { echo Wrap(Wrap(T('Votes')) . $CountVotes, 'div', array('class' => 'StatBox VotesBox')); } }