Added mybadges module
This commit is contained in:
parent
ea0c4532f0
commit
9dd0267a58
@ -25,6 +25,7 @@ class BadgesController extends Gdn_Controller {
|
||||
$this->AddJsFile('global.js');
|
||||
$this->AddCssFile('style.css');
|
||||
$this->AddCssFile('badges.css');
|
||||
$this->AddModule('MyBadgesModule');
|
||||
}
|
||||
|
||||
/**
|
||||
|
34
modules/class.mybadgesmodule.php
Executable file
34
modules/class.mybadgesmodule.php
Executable file
@ -0,0 +1,34 @@
|
||||
<?php if(!defined('APPLICATION')) exit();
|
||||
/* Copyright 2013 Zachary Doll */
|
||||
|
||||
/**
|
||||
* Renders a users badges in a nice grid in the panel
|
||||
*/
|
||||
class MyBadgesModule extends Gdn_Module {
|
||||
|
||||
public function __construct($Sender = '') {
|
||||
parent::__construct($Sender);
|
||||
|
||||
// Load badges
|
||||
$this->Data = FALSE;
|
||||
if(Gdn::Session()->IsValid()) {
|
||||
$UserID = Gdn::Session()->UserID;
|
||||
$BadgeModel = new BadgeModel();
|
||||
|
||||
$Data = $BadgeModel->GetUserBadgeAwards($UserID);
|
||||
$this->Data = $Data;
|
||||
}
|
||||
}
|
||||
|
||||
public function AssetTarget() {
|
||||
return 'Panel';
|
||||
}
|
||||
|
||||
public function ToString() {
|
||||
if($this->Data)
|
||||
return parent::ToString();
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
46
views/badges/detail.php
Normal file
46
views/badges/detail.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php if(!defined('APPLICATION')) exit();
|
||||
/* Copyright 2013 Zachary Doll */
|
||||
|
||||
echo Wrap($this->Title(), 'h1');
|
||||
echo '<ul class="DataList Badges">';
|
||||
foreach($this->Data('Badges') as $Badge) {
|
||||
// Don't show disabled badges
|
||||
//if(!$Badge->Enabled) {
|
||||
// continue;
|
||||
//}
|
||||
$Row = '';
|
||||
$AwardDescription = '';
|
||||
$ReadClass = ' Read';
|
||||
|
||||
if($Badge->UserID) {
|
||||
$ReadClass = '';
|
||||
$AwardDescription = 'You earned this badge ' . Gdn_Format::Date($Badge->DateInserted, 'html') . ' from ' . $Badge->InsertUserName;
|
||||
if($Badge->Reason) {
|
||||
$AwardDescription .= ': "' . $Badge->Reason . '"';
|
||||
}
|
||||
}
|
||||
|
||||
if($Badge->Photo) {
|
||||
$Row .= Img(Gdn_Upload::Url($Badge->Photo), array('class' => 'BadgePhoto'));
|
||||
}
|
||||
else {
|
||||
$Row .= Img('tododefault', array('class' => 'BadgePhoto'));
|
||||
}
|
||||
|
||||
$Row .= Wrap(
|
||||
Wrap(
|
||||
Anchor($Badge->Name, 'badges/detail/' . $Badge->BadgeID . '/' . Gdn_Format::Url($Badge->Name), array('class' => 'Title')), 'div', array('class' => 'Title')
|
||||
) .
|
||||
Wrap(
|
||||
Wrap($Badge->Description, 'span', array('class' => 'MItem BadgeDescription')) .
|
||||
Wrap($Badge->AwardValue . ' points.', 'span', array('class' => 'MItem BadgePoints')) .
|
||||
WrapIf($AwardDescription, 'p'),
|
||||
'div',
|
||||
array('class' => 'Meta')),
|
||||
'div',
|
||||
array('class' => 'ItemContent Badge')
|
||||
);
|
||||
echo Wrap($Row, 'li', array('class' => 'Item ItemBadge' . $ReadClass));
|
||||
}
|
||||
|
||||
echo '</ul>';
|
18
views/modules/mybadges.php
Normal file
18
views/modules/mybadges.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php if(!defined('APPLICATION')) exit();
|
||||
/* Copyright 2013 Zachary Doll */
|
||||
|
||||
echo '<div id="Badges" class="Column PanelColumn">';
|
||||
echo '<h4>' . T('My Badges') . '</h4>';
|
||||
echo '<div class="PhotoGrid">';
|
||||
foreach($this->Data as $Badge) {
|
||||
echo Anchor(
|
||||
Img(
|
||||
Gdn_Upload::Url($Badge['Photo']),
|
||||
array('class' => 'ProfilePhoto ProfilePhotoSmall')
|
||||
),
|
||||
'badges/detail/' . $Badge['BadgeID'] . '/' . Gdn_Format::Url($Badge['Name']),
|
||||
array('title' => $Badge['Name'])
|
||||
);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div>';
|
Loading…
x
Reference in New Issue
Block a user