split osm static and integration

This commit is contained in:
surrim 2020-02-04 17:05:27 +01:00
parent a413a22745
commit 0b32070b99
9 changed files with 52 additions and 8 deletions

View file

@ -13,7 +13,7 @@
$propbag->add('description', PLUGIN_EVENT_OSM_DESCRIPTION);
$propbag->add('copyright', 'GPL');
$propbag->add('configuration', array('height', 'latitude', 'longitude', 'zoom'));
$propbag->add('event_hooks', array('frontend_header' => true, 'entries_header' => true));
$propbag->add('event_hooks', array('entries_header' => true));
$propbag->add('author', 'Martin Sewelies');
$propbag->add('version', '0.1');
$propbag->add('requirements', array(
@ -30,13 +30,7 @@
function event_hook($event, &$bag, &$eventData, $addData = null)
{
global $serendipity;
if ($event == 'frontend_header') {
echo ' <link rel="stylesheet" href="'.$this->getFile('ol.css', 'serendipityHTTPPath').'" type="text/css">'.PHP_EOL;
echo ' <link rel="stylesheet" href="'.$this->getFile('osm.css', 'serendipityHTTPPath').'" type="text/css">'.PHP_EOL;
echo ' <script src="'.$this->getFile('ol.js', 'serendipityHTTPPath').'"></script>'.PHP_EOL;
echo ' <script src="'.$this->getFile('osm.js', 'serendipityHTTPPath').'"></script>'.PHP_EOL;
} else if ($event == 'entries_header') {
if ($event == 'entries_header') {
echo ' <div id="map" style="height: '.$this->get_config('height', '463px').'" data-latitude="'.$this->get_config('latitude', 51.48165).'" data-longitude="'.$this->get_config('longitude', 7.21648).'" data-zoom="'.$this->get_config('zoom', 15).'"></div>'.PHP_EOL;
echo ' <div id="popup" class="ol-popup"></div>'.PHP_EOL;
}

View file

@ -0,0 +1,4 @@
<?php
@define('PLUGIN_EVENT_STATIC_OSM_NAME', 'OpenStreetMaps static files');
@define('PLUGIN_EVENT_STATIC_OSM_DESCRIPTION', 'Includes scripts and css for OpenStreetMap support.');
?>

View file

@ -0,0 +1,46 @@
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
}
@serendipity_plugin_api::load_language(dirname(__FILE__));
class serendipity_event_static_osm extends serendipity_event
{
function introspect(&$propbag)
{
$propbag->add('name', PLUGIN_EVENT_STATIC_OSM_NAME);
$propbag->add('description', PLUGIN_EVENT_STATIC_OSM_DESCRIPTION);
$propbag->add('copyright', 'GPL');
$propbag->add('event_hooks', array('frontend_header' => true));
$propbag->add('author', 'Martin Sewelies');
$propbag->add('version', '0.1');
$propbag->add('requirements', array(
'serendipity' => '2.3'
));
$propbag->add('stackable', true);
$propbag->add('groups', array('FRONTEND_ENTRY_RELATED'));
}
function generate_content(&$title)
{
$title = PLUGIN_EVENT_STATIC_OSM_NAME;
}
function event_hook($event, &$bag, &$eventData, $addData = null)
{
global $serendipity;
if ($event == 'frontend_header') {
echo ' <link rel="stylesheet" href="'.$this->getFile('ol.css', 'serendipityHTTPPath').'" type="text/css">'.PHP_EOL;
echo ' <link rel="stylesheet" href="'.$this->getFile('osm.css', 'serendipityHTTPPath').'" type="text/css">'.PHP_EOL;
echo ' <script src="'.$this->getFile('ol.js', 'serendipityHTTPPath').'"></script>'.PHP_EOL;
echo ' <script src="'.$this->getFile('osm.js', 'serendipityHTTPPath').'"></script>'.PHP_EOL;
}
}
function introspect_config_item($name, &$propbag)
{
return true;
}
}
?>