2013-11-12 16:51:34 -06:00
|
|
|
<?php if(!defined('APPLICATION')) exit();
|
|
|
|
/* Copyright 2013 Zachary Doll */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is all the frontend pages dealing with badges
|
|
|
|
*
|
|
|
|
* @since 1.0
|
|
|
|
* @package Yaga
|
|
|
|
*/
|
|
|
|
class BadgesController extends Gdn_Controller {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array These objects will be created on instantiation and available via
|
|
|
|
* $this->ObjectName
|
|
|
|
*/
|
|
|
|
public $Uses = array('BadgeModel');
|
|
|
|
|
|
|
|
public function Initialize() {
|
|
|
|
parent::Initialize();
|
|
|
|
$this->Head = new HeadModule($this);
|
|
|
|
$this->AddJsFile('jquery.js');
|
|
|
|
$this->AddJsFile('jquery-ui.js');
|
|
|
|
$this->AddJsFile('jquery.livequery.js');
|
|
|
|
$this->AddJsFile('jquery.popup.js');
|
|
|
|
$this->AddJsFile('global.js');
|
|
|
|
$this->AddCssFile('style.css');
|
|
|
|
$this->AddCssFile('badges.css');
|
2013-11-13 11:08:51 -06:00
|
|
|
$this->AddModule('BadgesModule');
|
2013-11-19 15:16:09 -06:00
|
|
|
$Module = new LeaderBoardModule();
|
|
|
|
$Module->GetData('w');
|
|
|
|
$this->AddModule($Module);
|
|
|
|
$Module = new LeaderBoardModule();
|
|
|
|
$this->AddModule($Module);
|
2013-11-12 16:51:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a blank page if no methods were specified in dispatch
|
|
|
|
*/
|
|
|
|
public function Index() {
|
|
|
|
//$this->Render('Blank', 'Utility', 'Dashboard');
|
|
|
|
$this->All();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This renders out the full list of badges
|
|
|
|
*/
|
|
|
|
public function All() {
|
2013-12-04 14:09:26 -06:00
|
|
|
$this->Title(T('Yaga.AllBadges'));
|
2013-11-12 16:51:34 -06:00
|
|
|
|
|
|
|
$UserID = Gdn::Session()->UserID;
|
|
|
|
// Get list of badges from the model and pass to the view
|
|
|
|
$this->SetData('Badges', $this->BadgeModel->GetAllBadgesUserAwards($UserID));
|
|
|
|
|
|
|
|
// TODO: Add leaderboard module
|
|
|
|
|
2013-11-13 11:25:11 -06:00
|
|
|
$this->Render('all');
|
2013-11-12 16:51:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show some facets about a specific badge
|
|
|
|
*
|
|
|
|
* @param int $BadgeID
|
|
|
|
* @param string $Slug
|
|
|
|
*/
|
|
|
|
public function Detail($BadgeID, $Slug = NULL) {
|
2013-11-13 10:41:39 -06:00
|
|
|
$UserID = Gdn::Session()->UserID;
|
2013-11-13 13:41:08 -06:00
|
|
|
$Badge = $this->BadgeModel->GetBadge($BadgeID);
|
|
|
|
$AwardCount = $this->BadgeModel->GetBadgeAwardCount($BadgeID);
|
|
|
|
$UserBadgeAward = $this->BadgeModel->GetUserBadgeAward($UserID, $BadgeID);
|
|
|
|
$RecentAwards = $this->BadgeModel->GetRecentBadgeAwards($BadgeID);
|
2013-11-13 10:41:39 -06:00
|
|
|
|
2013-11-13 13:41:08 -06:00
|
|
|
if(!$Badge) {
|
|
|
|
throw NotFoundException('Badge');
|
|
|
|
}
|
2013-11-12 16:51:34 -06:00
|
|
|
|
2013-11-13 13:41:08 -06:00
|
|
|
$this->SetData('AwardCount', $AwardCount);
|
|
|
|
$this->SetData('RecentAwards', $RecentAwards);
|
|
|
|
$this->SetData('UserBadgeAward', $UserBadgeAward);
|
|
|
|
$this->SetData('Badge', $Badge);
|
|
|
|
|
2013-12-04 14:09:26 -06:00
|
|
|
$this->Title(T('Yaga.ViewBadge') . $Badge->Name);
|
2013-11-13 13:41:08 -06:00
|
|
|
|
|
|
|
$this->Render();
|
2013-11-12 16:51:34 -06:00
|
|
|
}
|
|
|
|
}
|