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:  * This is all the frontend pages dealing with badges
 6:  *
 7:  * @since 1.0
 8:  * @package Yaga
 9:  */
10: class BadgesController extends Gdn_Controller {
11: 
12:   /**
13:    * @var array These objects will be created on instantiation and available via
14:    * $this->ObjectName
15:    */
16:   public $Uses = array('BadgeModel', 'BadgeAwardModel');
17: 
18:   /**
19:    * This sets the badges controller up to look like a front end page. It also
20:    * adds some leader board modules.
21:    */
22:   public function Initialize() {
23:     parent::Initialize();
24:     $this->Application = 'Yaga';
25:     $this->Head = new HeadModule($this);
26:     $this->AddJsFile('jquery.js');
27:     $this->AddJsFile('jquery-ui.js');
28:     $this->AddJsFile('jquery.livequery.js');
29:     $this->AddJsFile('jquery.popup.js');
30:     $this->AddJsFile('global.js');
31:     $this->AddCssFile('style.css');
32:     $this->AddCssFile('badges.css');
33:     $this->AddModule('BadgesModule');
34:     $Module = new LeaderBoardModule();
35:     $Module->GetData('w');
36:     $this->AddModule($Module);
37:     $Module = new LeaderBoardModule();
38:     $this->AddModule($Module);
39:   }
40: 
41:   /**
42:    * Render a blank page if no methods were specified in dispatch
43:    */
44:   public function Index() {
45:     //$this->Render('Blank', 'Utility', 'Dashboard');
46:     $this->All();
47:   }
48: 
49:   /**
50:    * This renders out the full list of badges
51:    */
52:   public function All() {
53:     $this->Title(T('Yaga.AllBadges'));
54: 
55:     $UserID = Gdn::Session()->UserID;
56: 
57:     // Get list of badges from the model and pass to the view
58:     $AllBadges = $this->BadgeModel->GetWithEarned($UserID);
59: 
60:     $this->SetData('Badges', $AllBadges);
61:     //$this->SetData('Earned')
62: 
63:     $this->Render('all');
64:   }
65: 
66:   /**
67:    * Show some facets about a specific badge
68:    *
69:    * @param int $BadgeID
70:    * @param string $Slug
71:    * @throws NotFoundException
72:    */
73:   public function Detail($BadgeID, $Slug = NULL) {
74:     $UserID = Gdn::Session()->UserID;
75:     $Badge = $this->BadgeModel->GetByID($BadgeID);
76:     $AwardCount = $this->BadgeAwardModel->GetCount($BadgeID);
77:     $UserBadgeAward = $this->BadgeAwardModel->Exists($UserID, $BadgeID);
78:     $RecentAwards = $this->BadgeAwardModel->GetRecent($BadgeID);
79: 
80:     if(!$Badge) {
81:       throw NotFoundException('Badge');
82:     }
83: 
84:     $this->SetData('AwardCount', $AwardCount);
85:     $this->SetData('RecentAwards', $RecentAwards);
86:     $this->SetData('UserBadgeAward', $UserBadgeAward);
87:     $this->SetData('Badge', $Badge);
88: 
89:     $this->Title(T('Yaga.ViewBadge') . $Badge->Name);
90: 
91:     $this->Render();
92:   }
93: }
94: 
Yaga API documentation generated by ApiGen 2.8.0