const names changed, indentation

This commit is contained in:
surrim 2020-02-04 16:33:58 +01:00
parent 42cad8edb9
commit 1bc8e125db
4 changed files with 178 additions and 186 deletions

View file

@ -1,5 +1,4 @@
<?php
@define('PLUGIN_EVENT_GEO_JSON_NAME', 'Geo-JSON');
@define('PLUGIN_EVENT_GEO_JSON_DESCRIPTION', 'Provides a JSON object with all geo data which can be processed by JavaScript.');
@define('PLUGIN_EVENT_GEO_JSON_NAME', 'Geo-JSON');
@define('PLUGIN_EVENT_GEO_JSON_DESCRIPTION', 'Provides a JSON object with all geo data which can be processed by JavaScript.');
?>

View file

@ -1,106 +1,104 @@
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
}
if (IN_serendipity !== true) {
die ("Don't hack!");
}
@serendipity_plugin_api::load_language(dirname(__FILE__));
@serendipity_plugin_api::load_language(dirname(__FILE__));
class serendipity_event_geo_json extends serendipity_event
{
function introspect(&$propbag)
{
$propbag->add('name', PLUGIN_EVENT_GEO_JSON_NAME);
$propbag->add('description', PLUGIN_EVENT_GEO_JSON_DESCRIPTION);
$propbag->add('copyright', 'GPL');
$propbag->add('configuration', array('content'));
$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', false);
$propbag->add('groups', array('FRONTEND_FEATURES'));
}
class serendipity_event_geo_json extends serendipity_event
{
function introspect(&$propbag)
{
$propbag->add('name', PLUGIN_EVENT_GEO_JSON_NAME);
$propbag->add('description', PLUGIN_EVENT_GEO_JSON_DESCRIPTION);
$propbag->add('copyright', 'GPL');
$propbag->add('configuration', array('content'));
$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', false);
$propbag->add('groups', array('FRONTEND_FEATURES'));
}
function generate_content(&$title)
{
$title = PLUGIN_EVENT_GEO_JSON_NAME;
}
function generate_content(&$title)
{
$title = PLUGIN_EVENT_GEO_JSON_NAME;
}
function event_hook($event, &$bag, &$eventData, $addData = null)
{
global $serendipity;
if ($event == 'frontend_header') {
$tt = serendipity_db_query(
"SELECT e.title, p.permalink, e.timestamp, LENGTH(e.body) AS size, a.realname, e2.value AS lat, e1.value AS lng
FROM {$serendipity['dbPrefix']}entries e
JOIN {$serendipity['dbPrefix']}entryproperties e1 ON (e1.entryid = e.id AND e1.property='geo_long')
JOIN {$serendipity['dbPrefix']}entryproperties e2 ON (e2.entryid = e.id AND e2.property='geo_lat')
LEFT JOIN {$serendipity['dbPrefix']}permalinks p ON (p.entry_id = e.id AND p.type='entry')
LEFT JOIN {$serendipity['dbPrefix']}authors a ON (a.authorid = e.authorid)
WHERE e.isdraft = 'false'
ORDER BY p.permalink"
);
function event_hook($event, &$bag, &$eventData, $addData = null)
{
global $serendipity;
if ($event == 'frontend_header') {
$tt = serendipity_db_query(
"SELECT e.title, p.permalink, e.timestamp, LENGTH(e.body) AS size, a.realname, e2.value AS lat, e1.value AS lng
FROM {$serendipity['dbPrefix']}entries e
JOIN {$serendipity['dbPrefix']}entryproperties e1 ON (e1.entryid = e.id AND e1.property='geo_long')
JOIN {$serendipity['dbPrefix']}entryproperties e2 ON (e2.entryid = e.id AND e2.property='geo_lat')
LEFT JOIN {$serendipity['dbPrefix']}permalinks p ON (p.entry_id = e.id AND p.type='entry')
LEFT JOIN {$serendipity['dbPrefix']}authors a ON (a.authorid = e.authorid)
WHERE e.isdraft = 'false'
ORDER BY p.permalink"
);
$entries = [];
if (is_array($tt)) {
foreach ($tt as $t) {
$entries[] = [
'title' => $t['title'],
'url' => $serendipity['serendipityHTTPPath'].$t['permalink'],
'date' => (int)$t['timestamp'],
'size' => (int)$t['size'],
'author' => $t['realname'],
'pos' => [(double)$t['lat'], (double)$t['lng']]
];
}
}
$entries = [];
if (is_array($tt)) {
foreach ($tt as $t) {
$entries[] = [
'title' => $t['title'],
'url' => $serendipity['serendipityHTTPPath'].$t['permalink'],
'date' => (int)$t['timestamp'],
'size' => (int)$t['size'],
'author' => $t['realname'],
'pos' => [(double)$t['lat'], (double)$t['lng']]
];
}
}
$tt = serendipity_db_query(
"SELECT i.realname, i.path, IFNULL(m.value, i.date) AS date, i.size
FROM {$serendipity['dbPrefix']}images i
LEFT JOIN {$serendipity['dbPrefix']}mediaproperties m ON (
m.mediaid = i.id AND m.property='DATE' AND m.property_group = 'base_property' AND property_subgroup = ''
)
WHERE i.extension = 'gpx'
ORDER BY i.path, i.realname"
);
$tt = serendipity_db_query(
"SELECT i.realname, i.path, IFNULL(m.value, i.date) AS date, i.size
FROM {$serendipity['dbPrefix']}images i
LEFT JOIN {$serendipity['dbPrefix']}mediaproperties m ON (
m.mediaid = i.id AND m.property='DATE' AND m.property_group = 'base_property' AND property_subgroup = ''
)
WHERE i.extension = 'gpx'
ORDER BY i.path, i.realname"
);
$uploads = [];
if (is_array($tt)) {
foreach ($tt as $t) {
$uploads[] = [
'title' => $t['realname'],
'url' => $serendipity['serendipityHTTPPath'].$serendipity['uploadPath'].$t['path'].$t['realname'],
'date' => (int)$t['date'],
'size' => (int)$t['size']
];
}
}
$uploads = [];
if (is_array($tt)) {
foreach ($tt as $t) {
$uploads[] = [
'title' => $t['realname'],
'url' => $serendipity['serendipityHTTPPath'].$serendipity['uploadPath'].$t['path'].$t['realname'],
'date' => (int)$t['date'],
'size' => (int)$t['size']
];
}
}
$object = [
'entries' => $entries,
'uploads' => $uploads
];
echo ' <script>const geo = '.json_encode($object, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES).';</script>'.PHP_EOL;
//echo $this->get_config('content'); //TODO
}
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'content':
$propbag->add('type', 'string');
$propbag->add('name', CONTENT);
$propbag->add('description', THE_NUGGET);
$propbag->add('default', '');
break;
default:
return false;
}
return true;
}
}
$object = [
'entries' => $entries,
'uploads' => $uploads
];
echo ' <script>const geo = '.json_encode($object, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES).';</script>'.PHP_EOL;
//echo $this->get_config('content'); //TODO
}
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'content':
$propbag->add('type', 'string');
$propbag->add('name', CONTENT);
$propbag->add('description', THE_NUGGET);
$propbag->add('default', '');
break;
default:
return false;
}
return true;
}
}
?>

View file

@ -1,14 +1,13 @@
<?php
@define('PLUGIN_EVENT_OSM_NAME', 'OpenStreetMaps integration');
@define('PLUGIN_EVENT_OSM_DESCRIPTION', 'Provides an interactive map with *.gpx uploads and tagged geo data.');
@define('HEAD_OSM_TITLE', 'OpenStreetMaps integration');
@define('HEAD_OSM_DESCRIPTION', 'Provides an interactive map with *.gpx uploads and tagged geo data.');
@define('PLUGIN_EVENT_OSM_LONG', 'Longitude');
@define('PLUGIN_EVENT_OSM_LONG_DESC', 'Longitude of the center of the map (entry editing), if the geodata are not set in the entry.');
@define('PLUGIN_EVENT_OSM_LAT', 'Latitude');
@define('PLUGIN_EVENT_OSM_LAT_DESC', 'Latitude of the center of the map (entry editing), if the geodata are not set in the entry.');
@define('PLUGIN_EVENT_OSM_ZOOM', 'Zoom');
@define('PLUGIN_EVENT_OSM_ZOOM_DESC', 'Zoom of the map (entry editing). The higher the number the more details you will see.');
@define('PLUGIN_EVENT_OSM_HEIGHT', 'Map height');
@define('PLUGIN_EVENT_OSM_HEIGHT_DESC', 'The height of the map.');
@define('PLUGIN_EVENT_OSM_LONG', 'Longitude');
@define('PLUGIN_EVENT_OSM_LONG_DESC', 'Longitude of the center of the map (entry editing), if the geodata are not set in the entry.');
@define('PLUGIN_EVENT_OSM_LAT', 'Latitude');
@define('PLUGIN_EVENT_OSM_LAT_DESC', 'Latitude of the center of the map (entry editing), if the geodata are not set in the entry.');
@define('PLUGIN_EVENT_OSM_ZOOM', 'Zoom');
@define('PLUGIN_EVENT_OSM_ZOOM_DESC', 'Zoom of the map (entry editing). The higher the number the more details you will see.');
@define('PLUGIN_EVENT_OSM_HEIGHT', 'Map height');
@define('PLUGIN_EVENT_OSM_HEIGHT_DESC', 'The height of the map.');
?>

View file

@ -1,82 +1,78 @@
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
}
if (IN_serendipity !== true) {
die ("Don't hack!");
}
@serendipity_plugin_api::load_language(dirname(__FILE__));
@serendipity_plugin_api::load_language(dirname(__FILE__));
class serendipity_event_osm extends serendipity_event
{
function introspect(&$propbag)
{
$propbag->add('name', PLUGIN_EVENT_OSM_NAME);
$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('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'));
}
class serendipity_event_osm extends serendipity_event
{
var $title = HEAD_OSM_TITLE;
function generate_content(&$title)
{
$title = PLUGIN_EVENT_OSM_NAME;
}
function introspect(&$propbag)
{
$propbag->add('name', HEAD_OSM_TITLE);
$propbag->add('description', HEAD_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('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 = $this->title;
}
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') {
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;
}
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'height':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_OSM_HEIGHT);
$propbag->add('description', PLUGIN_EVENT_OSM_HEIGHT_DESC);
$propbag->add('default', '463px');
break;
case 'latitude':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_OSM_LAT);
$propbag->add('description', PLUGIN_EVENT_OSM_LAT_DESC);
$propbag->add('default', '51.48165');
break;
case 'longitude':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_OSM_LONG);
$propbag->add('description', PLUGIN_EVENT_OSM_LONG_DESC);
$propbag->add('default', '7.21648');
break;
case 'zoom':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_OSM_ZOOM);
$propbag->add('description', PLUGIN_EVENT_OSM_ZOOM_DESC);
$propbag->add('default', '15');
break;
default:
return false;
}
return true;
}
}
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') {
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;
}
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'height':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_OSM_HEIGHT);
$propbag->add('description', PLUGIN_EVENT_OSM_HEIGHT_DESC);
$propbag->add('default', '463px');
break;
case 'latitude':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_OSM_LAT);
$propbag->add('description', PLUGIN_EVENT_OSM_LAT_DESC);
$propbag->add('default', '51.48165');
break;
case 'longitude':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_OSM_LONG);
$propbag->add('description', PLUGIN_EVENT_OSM_LONG_DESC);
$propbag->add('default', '7.21648');
break;
case 'zoom':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_OSM_ZOOM);
$propbag->add('description', PLUGIN_EVENT_OSM_ZOOM_DESC);
$propbag->add('default', '15');
break;
default:
return false;
}
return true;
}
}
?>