Overview

Packages

  • None
  • Yaga

Classes

  • ActedModel
  • ActionController
  • ActionModel
  • AwardCombo
  • BadgeAwardModel
  • BadgeController
  • BadgeModel
  • BadgesController
  • BadgesModule
  • BestController
  • BestFilterModule
  • CakeDayPost
  • CommentCount
  • CommentMarathon
  • DiscussionBodyLength
  • DiscussionCategory
  • DiscussionCount
  • DiscussionPageCount
  • HasMentioned
  • HolidayVisit
  • LeaderBoardModule
  • LengthOfService
  • ManualAward
  • NecroPost
  • NewbieComment
  • PhotoExists
  • PostCount
  • PostReactions
  • QnAAnserCount
  • RankController
  • RankModel
  • ReactController
  • ReactionCount
  • ReactionModel
  • ReflexComment
  • RulesController
  • SocialConnection
  • Yaga
  • YagaController
  • YagaHooks

Interfaces

  • YagaRule
  • Overview
  • Package
  • Class
  • Tree
  • Todo
  • Download
 1: <?php if(!defined('APPLICATION')) exit();
 2: /* Copyright 2013 Zachary Doll */
 3: 
 4: /**
 5:  * Renders a leaderboard in the panel detailing points earned of all time
 6:  * 
 7:  * @package Yaga
 8:  * @since 1.0
 9:  */
10: class LeaderBoardModule extends Gdn_Module {
11:   
12:   /**
13:    * Holds the title of the module.
14:    * 
15:    * @var string
16:    */
17:   protected $Title = FALSE;
18: 
19:   
20:   /**
21:    * Don't do anything special on construct.
22:    * 
23:    * @param string $Sender
24:    */
25:   public function __construct($Sender = '') {
26:     parent::__construct($Sender);
27:   }
28: 
29:   /**
30:    * Specifies the asset this module should be rendered to.
31:    * 
32:    * @return string
33:    */
34:   public function AssetTarget() {
35:     return 'Panel';
36:   }
37: 
38:   /**
39:    * Load up the leaderboard module data based on a specific time slot
40:    * 
41:    * @param string $SlotType Valid options are 'a': All Time, 'w': Weekly, 'm':
42:    * Monthly, 'y': Yearly
43:    */
44:   public function GetData($SlotType = 'a') {
45:     // Get the leaderboard data
46:     $Leaders = Gdn::SQL()
47:             ->Select('up.Points as YagaPoints, u.*')
48:             ->From('User u')
49:             ->Join('UserPoints up', 'u.UserID = up.UserID')
50:             ->Where('up.SlotType', $SlotType)
51:             ->Where('up.TimeSlot', gmdate('Y-m-d', Gdn_Statistics::TimeSlotStamp($SlotType)))
52:             ->Where('up.Source', 'Total')
53:             ->OrderBy('up.Points', 'desc')
54:             ->Limit(C('Yaga.LeaderBoard.Limit', 10), 0)
55:             ->Get()
56:             ->Result();
57: 
58:     $this->Data = $Leaders;
59:     switch($SlotType) {
60:       case 'a':
61:         $this->Title = T('Yaga.LeaderBoard.AllTime');
62:         break;
63:       case 'w':
64:         $this->Title = T('Yaga.LeaderBoard.Week');
65:         break;
66:       case 'm':
67:         $this->Title = T('Yaga.LeaderBoard.Month');
68:         break;
69:       case 'y':
70:         $this->Title = T('Yaga.LeaderBoard.Year');
71:         break;
72:     }
73: 
74:   }
75: 
76:   /**
77:    * Renders the leaderboard.
78:    * 
79:    * @return string
80:    */
81:   public function ToString() {
82:     if(!$this->Data && !$this->Title) {
83:       $this->GetData();
84:     }
85: 
86:     if($this->Visible && count($this->Data)) {
87:       $ViewPath = $this->FetchViewLocation('leaderboard', 'yaga');
88:       $String = '';
89:       ob_start();
90:       include ($ViewPath);
91:       $String = ob_get_contents();
92:       @ob_end_clean();
93:       return $String;
94:     }
95:     return '';
96:   }
97: 
98: }
99: 
Yaga API documentation generated by ApiGen 2.8.0