display icons for Character groups Quest Stations

This commit is contained in:
oliver 2016-01-22 20:51:23 +01:00
parent a27352cb66
commit d5c68803f0
9 changed files with 144 additions and 36 deletions

View file

@ -104,6 +104,10 @@
'charactergroupsquest' => array(
'width' => 80,
'height' => 80
),
'charactergroupsqueststation' => array(
'width' => 100,
'height' => 100
)
);

View file

@ -89,12 +89,20 @@
// Get Stations
$stations = null;
if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) {
$stations = $this->Charactergroupsqueststations->getStationsForQuest($quest['id']);
}
elseif(!is_null($charactergroup)) {
$stations = $this->Charactergroupsqueststations->getStationsForQuestAndGroup($quest['id'], $charactergroup['id']);
foreach($stations as &$station) {
$stations = $this->Charactergroupsqueststations->getStationsForQuest($quest['id']);
foreach($stations as &$station)
{
// Icon
if(!is_null($station['stationpicture_id'])) {
$station['picture'] = $this->Media->getSeminaryMediaById($station['stationpicture_id']);
}
// Entered state
if(!is_null($charactergroup)) {
$station['entered'] = $this->Charactergroupsqueststations->hasCharactergroupEnteredStation(
$station['id'],
$charactergroup['id']
);
$station['solved'] = $this->Charactergroupsqueststations->hasCharactergroupSolvedStation(
$station['id'],
$charactergroup['id']

View file

@ -124,9 +124,6 @@
// Get Station
$station = $this->Charactergroupsqueststations->getStationByUrl($quest['id'], $stationUrl);
if(!is_null($station['stationpicture_id'])) {
$station['picture'] = $this->Media->getSeminaryMediaById($station['stationpicture_id']);
}
// Get Character group
$charactergroup = null;

View file

@ -25,14 +25,15 @@
* @var array
*/
public $permissions = array(
'index' => array('admin', 'moderator', 'user', 'guest'),
'seminarymoodpic' => array('admin', 'moderator', 'user'),
'seminarymap' => array('admin', 'moderator', 'user'),
'seminary' => array('admin', 'moderator', 'user'),
'avatar' => array('admin', 'moderator', 'user'),
'achievement' => array('admin', 'moderator', 'user'),
'charactergroup' => array('admin', 'moderator', 'user'),
'charactergroupsquest' => array('admin', 'moderator', 'user')
'index' => array('admin', 'moderator', 'user', 'guest'),
'seminarymoodpic' => array('admin', 'moderator', 'user'),
'seminarymap' => array('admin', 'moderator', 'user'),
'seminary' => array('admin', 'moderator', 'user'),
'avatar' => array('admin', 'moderator', 'user'),
'achievement' => array('admin', 'moderator', 'user'),
'charactergroup' => array('admin', 'moderator', 'user'),
'charactergroupsquest' => array('admin', 'moderator', 'user'),
'charactergroupsqueststation' => array('admin', 'moderator', 'user')
);
/**
* User seminary permissions
@ -40,17 +41,18 @@
* @var array
*/
public $seminaryPermissions = array(
'seminary' => array('admin', 'moderator', 'user', 'guest'),
'achievement' => array('admin', 'moderator', 'user', 'guest'),
'charactergroup' => array('admin', 'moderator', 'user', 'guest'),
'charactergroupsquest' => array('admin', 'moderator', 'user', 'guest')
'seminary' => array('admin', 'moderator', 'user', 'guest'),
'achievement' => array('admin', 'moderator', 'user', 'guest'),
'charactergroup' => array('admin', 'moderator', 'user', 'guest'),
'charactergroupsquest' => array('admin', 'moderator', 'user', 'guest'),
'charactergroupsqueststation' => array('admin', 'moderator', 'user', 'guest')
);
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'achievements', 'media', 'avatars', 'charactergroups', 'charactergroupsquests', 'map');
public $models = array('seminaries', 'achievements', 'media', 'avatars', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations', 'map');
@ -403,6 +405,47 @@
}
/**
* Action: charactergroupsqueststation
*
* Display the icon for a Character groups Quest Station.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
* @param string $groupsgroupUrl URL-Title of a Character groups-group
* @param string $questUrl URL-Title of a Character groups Quest
* @param string $stationUrl URL-title of Station
*/
public function charactergroupsqueststation($seminaryUrl, $groupsgroupUrl, $questUrl, $stationUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Character groups-group
$groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl);
// Get Character groups Quests
$quest = $this->Charactergroupsquests->getQuestByUrl($groupsgroup['id'], $questUrl);
// Get Station
$station = $this->Charactergroupsqueststations->getStationByUrl($quest['id'], $stationUrl);
// Get media
$media = $this->Media->getSeminaryMediaById($station['stationpicture_id']);
// Get file
$file = $this->getMediaFile($media, 'charactergroupsqueststation');
if(is_null($file)) {
return;
}
// Pass data to view
$this->set('media', $media);
$this->set('file', $file);
}
/**
@ -495,6 +538,14 @@
\nre\configs\AppConfig::$media[$action]['height']
);
break;
case 'charactergroupsqueststation':
$file = self::resizeImage(
$media['filename'],
$format,
\nre\configs\AppConfig::$media[$action]['width'],
\nre\configs\AppConfig::$media[$action]['height']
);
break;
default:
throw new ParamsNotValidException($action);
break;

View file

@ -184,6 +184,33 @@
}
/**
* Check if a Character group has entered a Station.
*
* @param int $stationId ID of Station to check
* @param int $groupId ID of Character group to check
* @return bool Whether the group has tried the station or not
*/
public function hasCharactergroupEnteredStation($stationId, $groupId)
{
$data = $this->db->query(
'SELECT created '.
'FROM charactergroupsqueststations_charactergroups '.
'WHERE charactergroupsqueststation_id = ? AND charactergroup_id = ? AND status >= ?',
'iii',
$stationId,
$groupId,
self::STATUS_ENTERED
);
if(!empty($data)) {
return $data[0]['created'];
}
return false;
}
/**
* Check if a Character group has tried to solve a Station.
*

View file

@ -0,0 +1 @@
<?=$file?>

View file

@ -78,27 +78,42 @@
</ul>
</nav>
<?php endif ?>
<?php if(!empty($stations)) : ?>
<ol class="grpqlist">
<?php foreach($stations as &$station) : ?>
<li>
<?php if(array_key_exists('created', $station)) : ?>
<span class="date">
<?=$dateFormatter->format(new \DateTime($station['created']))?>
<?=$timeFormatter->format(new \DateTime($station['created']))?>
</span>
<?php endif ?>
<span class="group">
<?php if(!array_key_exists('entered', $station) || $station['entered']) : ?>
<a href="<?=$linker->link(array('charactergroupsqueststations','station',$seminary['url'],$groupsgroup['url'],$quest['url'],$station['url']))?>"><?=$station['title']?></a>
<?php else : ?>
<?=_('Station not yet discovered')?>
<?php endif ?>
</span>
<?php if(array_key_exists('solved', $station) && $station['solved']) : ?>
<span class="xp">
<i class="fa fa-check-circle fa-fw"></i>
</span>
<?php if(!array_key_exists('created', $station) || $station['solved'] !== false) : ?>
<?php endif ?>
</li>
<?php endforeach ?>
</ol>
<?php else : ?>
<p><?=sprintf(_('Your %s-group has not discovered any station yet'), $groupsgroup['name'])?>.</p>
<?php endif ?>
<ol class="grpqslist">
<?php foreach($stations as &$station) : ?>
<li>
<?php if(!array_key_exists('entered', $station) || $station['entered']) : ?>
<a href="<?=$linker->link(array('charactergroupsqueststations','station',$seminary['url'],$groupsgroup['url'],$quest['url'],$station['url']))?>">
<?php if(!is_null($station['stationpicture_id'])) : ?>
<img title="<?=$station['title']?>" src="<?=$linker->link(array('media','charactergroupsqueststation',$seminary['url'],$groupsgroup['url'],$quest['url'],$station['url']))?>" />
<?php else : ?>
<i class="fa fa-globe"></i>
<?php endif ?>
</a>
<?php else : ?>
<i class="fa fa-question-circle"></i>
<?php endif ?>
</li>
<?php endforeach ?>
</ol>
</section>
<section>

View file

@ -13,9 +13,7 @@
</nav>
<?php endif ?>
<?php if(array_key_exists('picture', $station)) : ?>
<h1><?=$station['title']?></h1>
<?php endif ?>
<ul class="gdata cf">
<?php if(!empty($station['longitude']) && !empty($station['latitude'])) : ?>
<li>
@ -29,6 +27,10 @@
</a>
</li>
<?php endif ?>
<?php if($solved !== false) : ?>
<li>
<i class="fa fa-check-circle fa-fw"></i>
<?php endif ?>
</ul>
<?php if(!empty($station['longitude']) && !empty($station['latitude'])) : ?>
@ -94,8 +96,8 @@
<span class="group"><a href="<?=$linker->link(array('charactergroups','group',$seminary['url'],$groupsgroup['url'],$group['url']))?>"><?=$group['name']?></a></span>
<?php if($group['solved'] !== false) : ?>
<span class="xp">
<i class="fa fa-check-square-o fa-fw"></i>
<?=_(sprintf('solved at %s', $timeFormatter->format(new \DateTime($group['solved']))))?>
<i class="fa fa-check-circle fa-fw"></i>
</span>
<?php endif ?>
</li>

View file

@ -298,6 +298,9 @@ input[type="submit"][disabled]{text-shadow:1px 2px #d48c4e;background:#f9ac69;bo
.grpqlist .date{padding:0 15px 0 0;display:block}
.grpqlist .xp{display:block}
.gqgllry li{display:inline-block}
.grpqslist li{display:inline-block;width:100px;height:100px}
.grpqslist li a{color:#5e5c58}
.grpqslist li i{font-size:100px;padding:0}
/** Achievements **/