Add frontend ranks page
This commit is contained in:
parent
e335454314
commit
3342558804
@ -98,6 +98,17 @@ class YagaController extends DashboardController {
|
||||
$this->AddModule($Module);
|
||||
}
|
||||
|
||||
public function Ranks() {
|
||||
$this->FrontendStyle();
|
||||
$this->AddCssFile('ranks.css');
|
||||
$this->Title(T('Yaga.Ranks.All'));
|
||||
|
||||
// Get list of ranks from the model and pass to the view
|
||||
$this->SetData('Ranks', Yaga::RankModel()->Get());
|
||||
|
||||
$this->Render('ranks');
|
||||
}
|
||||
|
||||
public function Badges($BadgeID = FALSE, $Slug = NULL) {
|
||||
$this->FrontendStyle();
|
||||
$this->AddCssFile('badges.css');
|
||||
|
13
design/ranks.css
Normal file
13
design/ranks.css
Normal file
@ -0,0 +1,13 @@
|
||||
/* Copyright 2015 Zachary Doll */
|
||||
.ItemRank .RankPhoto {
|
||||
float: left;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
.ItemRank .ItemContent {
|
||||
padding-left: 55px;
|
||||
min-height: 40px;
|
||||
}
|
||||
.ItemRank .Meta {
|
||||
line-height: 1.3;
|
||||
}
|
@ -141,6 +141,7 @@ $Definition['Yaga.Rank.RecordActivity'] = 'Record this rank edit to the public a
|
||||
$Definition['Yaga.Rank.Updated'] = 'Rank updated successfully!';
|
||||
$Definition['Yaga.Ranks'] = 'Ranks';
|
||||
$Definition['Yaga.Ranks.AgeReq'] = 'Age Required';
|
||||
$Definition['Yaga.Ranks.All'] = 'All Ranks';
|
||||
$Definition['Yaga.Ranks.Desc'] = "Ranks are awarded to users based on their account age, accumulated points, and total posts. Ranks have associated perks that can be used to alter the user's experience.";
|
||||
$Definition['Yaga.Ranks.Manage'] = 'Manage Ranks';
|
||||
$Definition['Yaga.Ranks.Notify'] = 'Notify me when I am promoted in rank.';
|
||||
@ -150,6 +151,15 @@ $Definition['Yaga.Ranks.RequiredAgeDNC'] = 'Account can be any age';
|
||||
$Definition['Yaga.Ranks.RequiredAgeFormat'] = 'Account must be at least %s old.';
|
||||
$Definition['Yaga.Ranks.Settings.Desc'] = 'You can manage the available ranks here. Disabled ranks will not be awarded automatically. Drag items to sort the promotion order.';
|
||||
$Definition['Yaga.Ranks.Use'] = 'Use Ranks';
|
||||
$Definition['Yaga.Ranks.Story.Manual'] = 'This rank is given out manually';
|
||||
$Definition['Yaga.Ranks.Story.Auto'] = 'This rank will be automatically awarded';
|
||||
$Definition['Yaga.Ranks.Story.PostReq'] = 'has %s posts';
|
||||
$Definition['Yaga.Ranks.Story.PostAndPointReq'] = '%s points';
|
||||
$Definition['Yaga.Ranks.Story.PointReq'] = 'has %s points';
|
||||
$Definition['Yaga.Ranks.Story.AgeReq'] = 'is at least %s old';
|
||||
$Definition['Yaga.Ranks.Story.3Reqs'] = 'This rank will be awarded once your account %s, %s, and %s';
|
||||
$Definition['Yaga.Ranks.Story.2Reqs'] = 'This rank will be awarded once your account %s and %s';
|
||||
$Definition['Yaga.Ranks.Story.1Reqs'] = 'This rank will be awarded once your account %s';
|
||||
|
||||
// Rules
|
||||
$Definition['Yaga.Rules.AwardCombo'] = 'Award Combo';
|
||||
|
73
views/yaga/ranks.php
Normal file
73
views/yaga/ranks.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php if(!defined('APPLICATION')) exit();
|
||||
/* Copyright 2015 Zachary Doll */
|
||||
echo Wrap($this->Title(), 'h1');
|
||||
$User = (Gdn::Session()->User) ?: (object)array('RankID' => 0);
|
||||
echo '<ul class="DataList Ranks">';
|
||||
foreach($this->Data('Ranks') as $Rank) {
|
||||
$Row = '';
|
||||
|
||||
// Construct the description of requirements only if it has auto enabled
|
||||
// TODO: Move this to a helper_functions file
|
||||
$MetaString = T('Yaga.Ranks.Story.Manual');
|
||||
if($Rank->Enabled) {
|
||||
$Reqs = array();
|
||||
$Posts = FALSE;
|
||||
if($Rank->PostReq > 0) {
|
||||
$Reqs[] = sprintf(T('Yaga.Ranks.Story.PostReq'), $Rank->PostReq);
|
||||
$Posts = TRUE;
|
||||
}
|
||||
if($Rank->PointReq > 0) {
|
||||
if($Posts) {
|
||||
$Reqs[] = sprintf(T('Yaga.Ranks.Story.PostAndPointReq'), $Rank->PointReq);
|
||||
}
|
||||
else {
|
||||
$Reqs[] = sprintf(T('Yaga.Ranks.Story.PointReq'), $Rank->PointReq);
|
||||
}
|
||||
}
|
||||
if($Rank->AgeReq > 0) {
|
||||
$Reqs[] = sprintf(T('Yaga.Ranks.Story.AgeReq'), Gdn_Format::Seconds($Rank->AgeReq));
|
||||
}
|
||||
|
||||
switch(count($Reqs)) {
|
||||
case 3:
|
||||
$MetaString = sprintf(T('Yaga.Ranks.Story.3Reqs'), $Reqs[0], $Reqs[1], $Reqs[2]);
|
||||
break;
|
||||
case 2:
|
||||
$MetaString = sprintf(T('Yaga.Ranks.Story.2Reqs'), $Reqs[0], $Reqs[1]);
|
||||
break;
|
||||
case 1:
|
||||
$MetaString = sprintf(T('Yaga.Ranks.Story.1Reqs'), $Reqs[0]);
|
||||
break;
|
||||
default:
|
||||
case 0:
|
||||
$MetaString = T('Yaga.Ranks.Story.Auto');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$ReadClass = ($User->RankID == $Rank->RankID) ? ' ' : ' Read';
|
||||
|
||||
// TODO: Add rank photos
|
||||
//if($Rank->Photo) {
|
||||
// $Row .= Img($Rank->Photo, array('class' => 'RankPhoto'));
|
||||
//}
|
||||
//else {
|
||||
$Row .= Img('applications/yaga/design/images/default_promotion.png', array('class' => 'RankPhoto'));
|
||||
//}
|
||||
|
||||
$Row .= Wrap(
|
||||
Wrap(
|
||||
$Rank->Name, 'div', array('class' => 'Title')
|
||||
) .
|
||||
Wrap($Rank->Description, 'div', array('class' => 'Description')) .
|
||||
Wrap(
|
||||
WrapIf($MetaString, 'span', array('class' => 'MItem RankRequirements')),
|
||||
'div',
|
||||
array('class' => 'Meta')),
|
||||
'div',
|
||||
array('class' => 'ItemContent Rank')
|
||||
);
|
||||
echo Wrap($Row, 'li', array('class' => 'Item ItemRank' . $ReadClass));
|
||||
}
|
||||
|
||||
echo '</ul>';
|
Loading…
x
Reference in New Issue
Block a user