add location to seminaries
This commit is contained in:
parent
880b91d5e6
commit
a4f443d87a
3 changed files with 90 additions and 6 deletions
|
@ -298,6 +298,8 @@
|
|||
$title = $seminary['title'];
|
||||
$course = $seminary['course'];
|
||||
$description = $seminary['description'];
|
||||
$latitude = $seminary['latitude'];
|
||||
$longitude = $seminary['longitude'];
|
||||
$fields = array('title', 'course');
|
||||
$validation = array();
|
||||
|
||||
|
@ -312,6 +314,8 @@
|
|||
}
|
||||
$course = $this->request->getPostParam('course');
|
||||
$description = $this->request->getPostParam('description');
|
||||
$latitude = $this->request->getPostParam('latitude');
|
||||
$longitude = $this->request->getPostParam('longitude');
|
||||
|
||||
// Validate moodpic
|
||||
$moodpic = null;
|
||||
|
@ -348,7 +352,9 @@
|
|||
$seminary['id'],
|
||||
$title,
|
||||
$course,
|
||||
$description
|
||||
$description,
|
||||
$latitude,
|
||||
$longitude
|
||||
);
|
||||
$seminary = $this->Seminaries->getSeminaryById($seminary['id']);
|
||||
|
||||
|
@ -388,6 +394,8 @@
|
|||
$this->set('title', $title);
|
||||
$this->set('course', $course);
|
||||
$this->set('description', $description);
|
||||
$this->set('latitude', $latitude);
|
||||
$this->set('longitude', $longitude);
|
||||
$this->set('mimetypes', $mimetypes);
|
||||
$this->set('validation', $validation);
|
||||
$this->set('validationSettings', $validationSettings);
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
public function getSeminaryById($seminaryId)
|
||||
{
|
||||
$seminary = $this->db->query(
|
||||
'SELECT id, created, created_user_id, title, url, course, description, seminarymedia_id, charactergroups_seminarymedia_id, achievements_seminarymedia_id, library_seminarymedia_id, map_seminarymedia_id '.
|
||||
'SELECT id, created, created_user_id, title, url, course, description, latitude, longitude, seminarymedia_id, charactergroups_seminarymedia_id, achievements_seminarymedia_id, library_seminarymedia_id, map_seminarymedia_id '.
|
||||
'FROM seminaries '.
|
||||
'WHERE id = ?',
|
||||
'i',
|
||||
|
@ -91,7 +91,7 @@
|
|||
public function getSeminaryByUrl($seminaryUrl)
|
||||
{
|
||||
$seminary = $this->db->query(
|
||||
'SELECT id, created, created_user_id, title, url, course, description, seminarymedia_id, charactergroups_seminarymedia_id, achievements_seminarymedia_id, library_seminarymedia_id, map_seminarymedia_id '.
|
||||
'SELECT id, created, created_user_id, title, url, course, description, latitude, longitude, seminarymedia_id, charactergroups_seminarymedia_id, achievements_seminarymedia_id, library_seminarymedia_id, map_seminarymedia_id '.
|
||||
'FROM seminaries '.
|
||||
'WHERE url = ?',
|
||||
's',
|
||||
|
@ -309,17 +309,19 @@
|
|||
* @param string $course New course of Seminary
|
||||
* @param string $description New description of Seminary
|
||||
*/
|
||||
public function editSeminary($seminaryId, $title, $course, $description)
|
||||
public function editSeminary($seminaryId, $title, $course, $description, $latitude, $longitude)
|
||||
{
|
||||
$this->db->query(
|
||||
'UPDATE seminaries '.
|
||||
'SET title = ?, url = ?, course = ?, description = ? '.
|
||||
'SET title = ?, url = ?, course = ?, description = ?, latitude = ?, longitude = ? '.
|
||||
'WHERE id = ?',
|
||||
'ssssi',
|
||||
'ssssddi',
|
||||
$title,
|
||||
\nre\core\Linker::createLinkParam($title),
|
||||
$course,
|
||||
$description,
|
||||
$latitude,
|
||||
$longitude,
|
||||
$seminaryId
|
||||
);
|
||||
}
|
||||
|
|
|
@ -70,5 +70,79 @@
|
|||
<label for="description"><?=_('Description')?>:<br />
|
||||
<textarea name="description" placeholder="<?=_('Description')?>"><?=$description?></textarea><br />
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><?=_('Location')?></legend>
|
||||
<div id="map" class="map"></div>
|
||||
<input id="longitude" name="longitude" type="hidden" value="<?=$longitude?>" />
|
||||
<input id="latitude" name="latitude" type="hidden" value="<?=$latitude?>" />
|
||||
</fieldset>
|
||||
<input type="submit" name="edit" value="<?=_('edit')?>" />
|
||||
</form>
|
||||
<script>
|
||||
var drawSource = new ol.source.Vector({
|
||||
wrapX: false
|
||||
});
|
||||
var drawLayer = new ol.layer.Vector({
|
||||
source: drawSource,
|
||||
style: new ol.style.Style({
|
||||
text: new ol.style.Text({
|
||||
text: '\uf276',
|
||||
font: 'normal 28px FontAwesome',
|
||||
textBaseline: 'Bottom',
|
||||
fill: new ol.style.Fill({
|
||||
color: '#0F373C'
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
var map = new ol.Map({
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.OSM()
|
||||
}),
|
||||
drawLayer
|
||||
],
|
||||
controls: ol.control.defaults(),
|
||||
target: 'map',
|
||||
view: new ol.View({
|
||||
<?php if(!is_null($latitude) && !is_null($longitude)) : ?>
|
||||
center: ol.proj.transform([<?=$longitude?>, <?=$latitude?>], 'EPSG:4326', 'EPSG:3857'),
|
||||
zoom: 17,
|
||||
<?php else : ?>
|
||||
center: [0, 0],
|
||||
zoom: 0,
|
||||
<?php endif ?>
|
||||
maxZoom: 19
|
||||
})
|
||||
});
|
||||
var draw = new ol.interaction.Draw({
|
||||
source: drawSource,
|
||||
type: 'Point',
|
||||
maxPoints: 1,
|
||||
});
|
||||
map.addInteraction(draw);
|
||||
|
||||
// Add existing point
|
||||
var longitude = $('#longitude').val();
|
||||
var latitude = $('#latitude').val();
|
||||
if(longitude && latitude) {
|
||||
drawSource.addFeature(
|
||||
new ol.Feature({
|
||||
geometry: new ol.geom.Point(
|
||||
ol.proj.transform([parseFloat(longitude), parseFloat(latitude)], 'EPSG:4326', 'EPSG:3857')
|
||||
)
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// Wire events
|
||||
drawSource.on('addfeature', function(event) {
|
||||
var coordinates = event.feature.getGeometry().getCoordinates();
|
||||
coordinates = ol.proj.transform(coordinates, 'EPSG:3857', 'EPSG:4326');
|
||||
$('#longitude').val(coordinates[0]);
|
||||
$('#latitude').val(coordinates[1]);
|
||||
});
|
||||
draw.on('drawstart', function() {
|
||||
drawSource.clear();
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue