integrate Character groups Quest Stations into Character groups Quests
This commit is contained in:
parent
5c48ac1f94
commit
623ff64e0a
4 changed files with 202 additions and 7 deletions
|
|
@ -25,7 +25,7 @@
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $models = array('seminaries', 'charactergroups', 'charactergroupsquests', 'media', 'questgroups', 'uploads');
|
public $models = array('seminaries', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations', 'media', 'questgroups', 'uploads');
|
||||||
/**
|
/**
|
||||||
* Required components
|
* Required components
|
||||||
*
|
*
|
||||||
|
|
@ -78,6 +78,30 @@
|
||||||
$questgroup = $this->Questgroups->getQuestgroupById($quest['questgroups_id']);
|
$questgroup = $this->Questgroups->getQuestgroupById($quest['questgroups_id']);
|
||||||
$questgroup['entered'] = $this->Questgroups->hasCharacterEnteredQuestgroup($questgroup['id'], self::$character['id']);
|
$questgroup['entered'] = $this->Questgroups->hasCharacterEnteredQuestgroup($questgroup['id'], self::$character['id']);
|
||||||
|
|
||||||
|
// Get Character group
|
||||||
|
$charactergroup = null;
|
||||||
|
$character = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']);
|
||||||
|
$charactergroups = $this->Charactergroups->getGroupsForCharacter($character['id']);
|
||||||
|
if(!empty($charactergroups)) {
|
||||||
|
// TODO Multiple Character groups
|
||||||
|
$charactergroup = $charactergroups[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
$station['solved'] = $this->Charactergroupsqueststations->hasCharactergroupSolvedStation(
|
||||||
|
$station['id'],
|
||||||
|
$charactergroup['id']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get Character groups-groups
|
// Get Character groups-groups
|
||||||
$groups = $this->Charactergroups->getGroupsForQuest($quest['id']);
|
$groups = $this->Charactergroups->getGroupsForQuest($quest['id']);
|
||||||
|
|
||||||
|
|
@ -98,6 +122,7 @@
|
||||||
$this->set('groupsgroup', $groupsgroup);
|
$this->set('groupsgroup', $groupsgroup);
|
||||||
$this->set('quest', $quest);
|
$this->set('quest', $quest);
|
||||||
$this->set('questgroup', $questgroup);
|
$this->set('questgroup', $questgroup);
|
||||||
|
$this->set('stations', $stations);
|
||||||
$this->set('groups', $groups);
|
$this->set('groups', $groups);
|
||||||
$this->set('uploads', $uploads);
|
$this->set('uploads', $uploads);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@
|
||||||
public function getGroupsgroupById($groupsgroupId)
|
public function getGroupsgroupById($groupsgroupId)
|
||||||
{
|
{
|
||||||
$data = $this->db->query(
|
$data = $this->db->query(
|
||||||
'SELECT id, name, url, preferred '.
|
'SELECT id, seminary_id, name, url, preferred '.
|
||||||
'FROM charactergroupsgroups '.
|
'FROM charactergroupsgroups '.
|
||||||
'WHERE id = ?',
|
'WHERE id = ?',
|
||||||
'i',
|
'i',
|
||||||
|
|
@ -400,6 +400,28 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Character groups that have entered a Character groups Quest
|
||||||
|
* station.
|
||||||
|
*
|
||||||
|
* @param int $stationId ID of station
|
||||||
|
* @return array List of groups
|
||||||
|
*/
|
||||||
|
public function getGroupsForQueststation($stationId)
|
||||||
|
{
|
||||||
|
return $this->db->query(
|
||||||
|
'SELECT charactergroups.id, charactergroups.name, charactergroups.url, charactergroupsqueststations_charactergroups.created '.
|
||||||
|
'FROM charactergroupsqueststations_charactergroups '.
|
||||||
|
'INNER JOIN charactergroups ON charactergroups.id = charactergroupsqueststations_charactergroups.charactergroup_id '.
|
||||||
|
'WHERE charactergroupsqueststations_charactergroups.charactergroupsqueststation_id = ? AND status = ? '.
|
||||||
|
'ORDER BY charactergroupsqueststations_charactergroups.created ASC',
|
||||||
|
'ii',
|
||||||
|
$stationId,
|
||||||
|
CharactergroupsqueststationsModel::STATUS_ENTERED
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a Character group name already exists.
|
* Check if a Character group name already exists.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@
|
||||||
public function getQuestById($questId)
|
public function getQuestById($questId)
|
||||||
{
|
{
|
||||||
$data = $this->db->query(
|
$data = $this->db->query(
|
||||||
'SELECT id, questgroups_id, title, url, description, xps, rules, won_text, lost_text, questsmedia_id '.
|
'SELECT id, charactergroupsgroup_id, questgroups_id, title, url, description, xps, rules, won_text, lost_text, questsmedia_id '.
|
||||||
'FROM charactergroupsquests '.
|
'FROM charactergroupsquests '.
|
||||||
'WHERE id = ?',
|
'WHERE id = ?',
|
||||||
'i',
|
'i',
|
||||||
|
|
|
||||||
|
|
@ -39,23 +39,63 @@
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h1><i class="fa fa-envelope fa-fw"></i><?=_('Description')?></h1>
|
<h1><i class="fa fa-envelope fa-fw"></i><?=_('Description')?></h1>
|
||||||
<p><?=$t->t($quest['description'])?></p>
|
<div class="qtextbox">
|
||||||
|
<p class="qtext"><?=$t->t($quest['description'])?></p>
|
||||||
|
</div>
|
||||||
<?php if(!empty($quest['rules'])) : ?>
|
<?php if(!empty($quest['rules'])) : ?>
|
||||||
<h1><i class="fa fa-exclamation-triangle fa-fw"></i><?=_('Rules')?></h1>
|
<h1><i class="fa fa-exclamation-triangle fa-fw"></i><?=_('Rules')?></h1>
|
||||||
<p><?=$t->t($quest['rules'])?></p>
|
<div class="qtextbox">
|
||||||
|
<p class="qtext"><?=$t->t($quest['rules'])?></p>
|
||||||
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php if(!empty($quest['won_text'])) : ?>
|
<?php if(!empty($quest['won_text'])) : ?>
|
||||||
<section>
|
<section>
|
||||||
<h1><i class="fa fa-thumbs-up fa-fw"></i><?=_('Won Quest')?></h1>
|
<h1><i class="fa fa-thumbs-up fa-fw"></i><?=_('Won Quest')?></h1>
|
||||||
<p><?=$t->t($quest['won_text'])?></p>
|
<div class="qtextbox">
|
||||||
|
<p class="qtext"><?=$t->t($quest['won_text'])?></p>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php if(!empty($quest['lost_text'])) : ?>
|
<?php if(!empty($quest['lost_text'])) : ?>
|
||||||
<section>
|
<section>
|
||||||
<h1><i class="fa fa-thumbs-down fa-fw"></i><?=_('Lost Quest')?></h1>
|
<h1><i class="fa fa-thumbs-down fa-fw"></i><?=_('Lost Quest')?></h1>
|
||||||
<p><?=$t->t($quest['lost_text'])?></p>
|
<div class="qtextbox">
|
||||||
|
<p class="qtext"><?=$t->t($quest['lost_text'])?></p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php if(!empty($stations)) : ?>
|
||||||
|
<section>
|
||||||
|
<h1><i class="fa fa-map-signs fa-fw"></i><?=_('Stations')?></h1>
|
||||||
|
<div id="map" class="map"></div>
|
||||||
|
|
||||||
|
<?php if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) : ?>
|
||||||
|
<nav class="admin">
|
||||||
|
<ul>
|
||||||
|
<li><a href="<?=$linker->link(array('charactergroupsqueststations','create',$seminary['url'],$groupsgroup['url'],$quest['url']))?>"><?=_('Create new station')?></a></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<?php endif ?>
|
||||||
|
<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">
|
||||||
|
<a href="<?=$linker->link(array('charactergroupsqueststations','station',$seminary['url'],$groupsgroup['url'],$quest['url'],$station['url']))?>"><?=$station['title']?></a>
|
||||||
|
</span>
|
||||||
|
<?php if(!array_key_exists('created', $station) || $station['solved'] !== false) : ?>
|
||||||
|
<?php endif ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ol>
|
||||||
</section>
|
</section>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
|
|
@ -71,3 +111,111 @@
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</ol>
|
</ol>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var markersSource = new ol.source.Vector({
|
||||||
|
url: '<?=$linker->link(array('charactergroupsqueststations','index',$seminary['url'],$groupsgroup['url'],$quest['url']))?>',
|
||||||
|
format: new ol.format.GeoJSON()
|
||||||
|
});
|
||||||
|
markersSource.on('change', function(e) {
|
||||||
|
map.getView().fit(
|
||||||
|
markersSource.getExtent(),
|
||||||
|
map.getSize(), {
|
||||||
|
padding: [10, 10, 10, 10]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
/*
|
||||||
|
var pathSource = new ol.source.Vector({
|
||||||
|
url: '<?=$linker->link(array('charactergroupsqueststations','index',$seminary['url'],$groupsgroup['url'],$quest['url']))?>',
|
||||||
|
format: new ol.format.GeoJSON()
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
var styleFunction = function(feature, resolution) {
|
||||||
|
var styles = [];
|
||||||
|
var geometry = feature.getGeometry();
|
||||||
|
if(geometry instanceof ol.geom.Point) {
|
||||||
|
// Point styling
|
||||||
|
styles.push(
|
||||||
|
new ol.style.Style({
|
||||||
|
text: new ol.style.Text({
|
||||||
|
//text: '\uf041',
|
||||||
|
text: '\uf276',
|
||||||
|
font: 'normal 28px FontAwesome',
|
||||||
|
textBaseline: 'Bottom',
|
||||||
|
fill: new ol.style.Fill({
|
||||||
|
color: '#0F373C'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if(geometry instanceof ol.geom.LineString) {
|
||||||
|
// Line styling
|
||||||
|
styles.push(
|
||||||
|
new ol.style.Style({
|
||||||
|
stroke: new ol.style.Stroke({
|
||||||
|
color: '#50A4AB',
|
||||||
|
width: 3
|
||||||
|
})
|
||||||
|
})
|
||||||
|
);
|
||||||
|
// Add arrows
|
||||||
|
geometry.forEachSegment(function(start, end) {
|
||||||
|
var dx = end[0] - start[0];
|
||||||
|
var dy = end[1] - start[1];
|
||||||
|
var rotation = Math.atan2(dy, dx);
|
||||||
|
var cx = (start[0] + end[0]) / 2;
|
||||||
|
var cy = (start[1] + end[1]) / 2;
|
||||||
|
styles.push(new ol.style.Style({
|
||||||
|
geometry: new ol.geom.Point([cx, cy]),
|
||||||
|
text: new ol.style.Text({
|
||||||
|
text: '\uf178',
|
||||||
|
font: 'normal 28px FontAwesome',
|
||||||
|
fill: new ol.style.Fill({
|
||||||
|
color: '#0F373C'
|
||||||
|
}),
|
||||||
|
rotation: -rotation
|
||||||
|
})
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return styles;
|
||||||
|
};
|
||||||
|
|
||||||
|
var map = new ol.Map({
|
||||||
|
layers: [
|
||||||
|
new ol.layer.Tile({
|
||||||
|
source: new ol.source.OSM()
|
||||||
|
}),
|
||||||
|
new ol.layer.Vector({
|
||||||
|
source: markersSource,
|
||||||
|
style: styleFunction
|
||||||
|
/*
|
||||||
|
style: new ol.style.Style({
|
||||||
|
text: new ol.style.Text({
|
||||||
|
text: '\uf041',
|
||||||
|
//text: '\uf276',
|
||||||
|
font: 'normal 28px FontAwesome',
|
||||||
|
textBaseline: 'Bottom',
|
||||||
|
fill: new ol.style.Fill({
|
||||||
|
color: '#0F373C'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
*/
|
||||||
|
})/*,
|
||||||
|
new ol.layer.Vector({
|
||||||
|
source: pathSource
|
||||||
|
})
|
||||||
|
*/
|
||||||
|
],
|
||||||
|
target: 'map',
|
||||||
|
view: new ol.View({
|
||||||
|
center: ol.proj.transform([<?=$station['longitude']?>, <?=$station['latitude']?>], 'EPSG:4326', 'EPSG:3857'),
|
||||||
|
zoom: 19,
|
||||||
|
maxZoom: 19
|
||||||
|
})
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue