integrate Character groups Quest Stations into Character groups Quests

This commit is contained in:
oliver 2015-12-25 16:43:18 +01:00
commit c424cfe30c
4 changed files with 202 additions and 7 deletions

View file

@ -39,23 +39,63 @@
<section>
<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'])) : ?>
<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 ?>
</section>
<?php if(!empty($quest['won_text'])) : ?>
<section>
<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>
<?php endif ?>
<?php if(!empty($quest['lost_text'])) : ?>
<section>
<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>
<?php endif ?>
@ -71,3 +111,111 @@
<?php endforeach ?>
</ol>
</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>