removed "?>" from php files and changed indentation

This commit is contained in:
surrim 2021-07-12 23:41:37 +02:00 committed by onli
parent 8f778c4119
commit c8086e5305
6 changed files with 282 additions and 285 deletions

View file

@ -1,23 +1,23 @@
<?php
@define('PLUGIN_EVENT_OSM_NAME', 'OpenStreetMap Integration');
@define('PLUGIN_EVENT_OSM_DESCRIPTION', 'Bietet eine interaktive Karte für *.gpx Uploads und Blogs mit Geo-Daten');
@define('PLUGIN_EVENT_OSM_NOT_SHOWN', 'Wird nicht auf der Webseite angezeigt');
@define('PLUGIN_EVENT_STATIC_OSM_NAME', 'OpenStreetMap Statische Dateien');
@define('PLUGIN_EVENT_STATIC_OSM_DESCRIPTION', 'Fügt Scripte und Stylesheets für OpenStreetMap ein');
@define('PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX', 'GPX-Dateien komprimieren');
@define('PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX_DESCRIPTION', 'Entfernt alle nicht benötigten Daten aus den GPX-Dateien beim Upload');
@define('PLUGIN_EVENT_OSM_CATEGORY', 'Kategorie');
@define('PLUGIN_EVENT_OSM_CATEGORY_DESCRIPTION', 'Karte wird für diese Kategorie angezeigt');
@define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Ohne');
@define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Beliebig');
@define('PLUGIN_EVENT_OSM_PATH', 'Pfad');
@define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Pfad(e) für GPX-Dateien, getrennt durch Zeilenumbruch');
@define('PLUGIN_EVENT_OSM_LAT', 'Breitengrad (Lat.)');
@define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Breitengrad für die Mitte der Karte');
@define('PLUGIN_EVENT_OSM_LONG', 'Längengrad (Lon.)');
@define('PLUGIN_EVENT_OSM_LONG_DESCRIPTION', 'Längengrad für die Mitte der Karte');
@define('PLUGIN_EVENT_OSM_ZOOM', 'Zoom');
@define('PLUGIN_EVENT_OSM_ZOOM_DESCRIPTION', 'Zoom Level der Karte');
@define('PLUGIN_EVENT_OSM_HEIGHT', 'Kartenhöhe');
@define('PLUGIN_EVENT_OSM_HEIGHT_DESCRIPTION', 'Die Höhe der Karte');
?>
@define('PLUGIN_EVENT_OSM_NAME', 'OpenStreetMap Integration');
@define('PLUGIN_EVENT_OSM_DESCRIPTION', 'Bietet eine interaktive Karte für *.gpx Uploads und Blogs mit Geo-Daten');
@define('PLUGIN_EVENT_OSM_NOT_SHOWN', 'Wird nicht auf der Webseite angezeigt');
@define('PLUGIN_EVENT_STATIC_OSM_NAME', 'OpenStreetMap Statische Dateien');
@define('PLUGIN_EVENT_STATIC_OSM_DESCRIPTION', 'Fügt Scripte und Stylesheets für OpenStreetMap ein');
@define('PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX', 'GPX-Dateien komprimieren');
@define('PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX_DESCRIPTION', 'Entfernt alle nicht benötigten Daten aus den GPX-Dateien beim Upload');
@define('PLUGIN_EVENT_OSM_CATEGORY', 'Kategorie');
@define('PLUGIN_EVENT_OSM_CATEGORY_DESCRIPTION', 'Karte wird für diese Kategorie angezeigt');
@define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Ohne');
@define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Beliebig');
@define('PLUGIN_EVENT_OSM_PATH', 'Pfad');
@define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Pfad(e) für GPX-Dateien, getrennt durch Zeilenumbruch');
@define('PLUGIN_EVENT_OSM_LAT', 'Breitengrad (Lat.)');
@define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Breitengrad für die Mitte der Karte');
@define('PLUGIN_EVENT_OSM_LONG', 'Längengrad (Lon.)');
@define('PLUGIN_EVENT_OSM_LONG_DESCRIPTION', 'Längengrad für die Mitte der Karte');
@define('PLUGIN_EVENT_OSM_ZOOM', 'Zoom');
@define('PLUGIN_EVENT_OSM_ZOOM_DESCRIPTION', 'Zoom Level der Karte');
@define('PLUGIN_EVENT_OSM_HEIGHT', 'Kartenhöhe');
@define('PLUGIN_EVENT_OSM_HEIGHT_DESCRIPTION', 'Die Höhe der Karte');

View file

@ -1,23 +1,22 @@
<?php
@define('PLUGIN_EVENT_OSM_NAME', 'OpenStreetMap Integration');
@define('PLUGIN_EVENT_OSM_DESCRIPTION', 'Bietet eine interaktive Karte für *.gpx Uploads und Blogs mit Geo-Daten');
@define('PLUGIN_EVENT_OSM_NOT_SHOWN', 'Wird nicht auf der Webseite angezeigt');
@define('PLUGIN_EVENT_STATIC_OSM_NAME', 'OpenStreetMap Statische Dateien');
@define('PLUGIN_EVENT_STATIC_OSM_DESCRIPTION', 'Fügt Scripte und Stylesheets für OpenStreetMap ein');
@define('PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX', 'GPX-Dateien komprimieren');
@define('PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX_DESCRIPTION', 'Entfernt alle nicht benötigten Daten aus den GPX-Dateien beim Upload');
@define('PLUGIN_EVENT_OSM_CATEGORY', 'Kategorie');
@define('PLUGIN_EVENT_OSM_CATEGORY_DESCRIPTION', 'Karte wird für diese Kategorie angezeigt');
@define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Ohne');
@define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Beliebig');
@define('PLUGIN_EVENT_OSM_PATH', 'Pfad');
@define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Pfad(e) für GPX-Dateien, getrennt durch Zeilenumbruch');
@define('PLUGIN_EVENT_OSM_LAT', 'Breitengrad (Lat.)');
@define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Breitengrad für die Mitte der Karte');
@define('PLUGIN_EVENT_OSM_LONG', 'Längengrad (Lon.)');
@define('PLUGIN_EVENT_OSM_LONG_DESCRIPTION', 'Längengrad für die Mitte der Karte');
@define('PLUGIN_EVENT_OSM_ZOOM', 'Zoom');
@define('PLUGIN_EVENT_OSM_ZOOM_DESCRIPTION', 'Zoom Level der Karte');
@define('PLUGIN_EVENT_OSM_HEIGHT', 'Kartenhöhe');
@define('PLUGIN_EVENT_OSM_HEIGHT_DESCRIPTION', 'Die Höhe der Karte');
?>
@define('PLUGIN_EVENT_OSM_NAME', 'OpenStreetMap Integration');
@define('PLUGIN_EVENT_OSM_DESCRIPTION', 'Bietet eine interaktive Karte für *.gpx Uploads und Blogs mit Geo-Daten');
@define('PLUGIN_EVENT_OSM_NOT_SHOWN', 'Wird nicht auf der Webseite angezeigt');
@define('PLUGIN_EVENT_STATIC_OSM_NAME', 'OpenStreetMap Statische Dateien');
@define('PLUGIN_EVENT_STATIC_OSM_DESCRIPTION', 'Fügt Scripte und Stylesheets für OpenStreetMap ein');
@define('PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX', 'GPX-Dateien komprimieren');
@define('PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX_DESCRIPTION', 'Entfernt alle nicht benötigten Daten aus den GPX-Dateien beim Upload');
@define('PLUGIN_EVENT_OSM_CATEGORY', 'Kategorie');
@define('PLUGIN_EVENT_OSM_CATEGORY_DESCRIPTION', 'Karte wird für diese Kategorie angezeigt');
@define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Ohne');
@define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Beliebig');
@define('PLUGIN_EVENT_OSM_PATH', 'Pfad');
@define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Pfad(e) für GPX-Dateien, getrennt durch Zeilenumbruch');
@define('PLUGIN_EVENT_OSM_LAT', 'Breitengrad (Lat.)');
@define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Breitengrad für die Mitte der Karte');
@define('PLUGIN_EVENT_OSM_LONG', 'Längengrad (Lon.)');
@define('PLUGIN_EVENT_OSM_LONG_DESCRIPTION', 'Längengrad für die Mitte der Karte');
@define('PLUGIN_EVENT_OSM_ZOOM', 'Zoom');
@define('PLUGIN_EVENT_OSM_ZOOM_DESCRIPTION', 'Zoom Level der Karte');
@define('PLUGIN_EVENT_OSM_HEIGHT', 'Kartenhöhe');
@define('PLUGIN_EVENT_OSM_HEIGHT_DESCRIPTION', 'Die Höhe der Karte');

View file

@ -1,23 +1,22 @@
<?php
@define('PLUGIN_EVENT_OSM_NAME', 'OpenStreetMap integration');
@define('PLUGIN_EVENT_OSM_DESCRIPTION', 'Provides an interactive map with *.gpx uploads and tagged geo data');
@define('PLUGIN_EVENT_OSM_NOT_SHOWN', 'Not shows on webpage');
@define('PLUGIN_EVENT_STATIC_OSM_NAME', 'OpenStreetMap static files');
@define('PLUGIN_EVENT_STATIC_OSM_DESCRIPTION', 'Includes scripts and stylesheets for OpenStreetMap support');
@define('PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX', 'Compress GPX-files');
@define('PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX_DESCRIPTION', 'Remove not needed information from GPX-files when uploading');
@define('PLUGIN_EVENT_OSM_CATEGORY', 'Category');
@define('PLUGIN_EVENT_OSM_CATEGORY_DESCRIPTION', 'Map will be shown for this category');
@define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Without');
@define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Any');
@define('PLUGIN_EVENT_OSM_PATH', 'Path');
@define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Path(s) for GPX-files, separated by linebreak');
@define('PLUGIN_EVENT_OSM_LAT', 'Latitude');
@define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Latitude of the center of the map');
@define('PLUGIN_EVENT_OSM_LONG', 'Longitude');
@define('PLUGIN_EVENT_OSM_LONG_DESCRIPTION', 'Longitude of the center of the map');
@define('PLUGIN_EVENT_OSM_ZOOM', 'Zoom');
@define('PLUGIN_EVENT_OSM_ZOOM_DESCRIPTION', 'Zoom level of the map');
@define('PLUGIN_EVENT_OSM_HEIGHT', 'Map height');
@define('PLUGIN_EVENT_OSM_HEIGHT_DESCRIPTION', 'The height of the map');
?>
@define('PLUGIN_EVENT_OSM_NAME', 'OpenStreetMap integration');
@define('PLUGIN_EVENT_OSM_DESCRIPTION', 'Provides an interactive map with *.gpx uploads and tagged geo data');
@define('PLUGIN_EVENT_OSM_NOT_SHOWN', 'Not shows on webpage');
@define('PLUGIN_EVENT_STATIC_OSM_NAME', 'OpenStreetMap static files');
@define('PLUGIN_EVENT_STATIC_OSM_DESCRIPTION', 'Includes scripts and stylesheets for OpenStreetMap support');
@define('PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX', 'Compress GPX-files');
@define('PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX_DESCRIPTION', 'Remove not needed information from GPX-files when uploading');
@define('PLUGIN_EVENT_OSM_CATEGORY', 'Category');
@define('PLUGIN_EVENT_OSM_CATEGORY_DESCRIPTION', 'Map will be shown for this category');
@define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Without');
@define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Any');
@define('PLUGIN_EVENT_OSM_PATH', 'Path');
@define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Path(s) for GPX-files, separated by linebreak');
@define('PLUGIN_EVENT_OSM_LAT', 'Latitude');
@define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Latitude of the center of the map');
@define('PLUGIN_EVENT_OSM_LONG', 'Longitude');
@define('PLUGIN_EVENT_OSM_LONG_DESCRIPTION', 'Longitude of the center of the map');
@define('PLUGIN_EVENT_OSM_ZOOM', 'Zoom');
@define('PLUGIN_EVENT_OSM_ZOOM_DESCRIPTION', 'Zoom level of the map');
@define('PLUGIN_EVENT_OSM_HEIGHT', 'Map height');
@define('PLUGIN_EVENT_OSM_HEIGHT_DESCRIPTION', 'The height of the map');

View file

@ -1,4 +1,3 @@
<?php
@define('PLUGIN_EVENT_OSM_VERSION', '0.3.7');
@define('PLUGIN_EVENT_OSM_AUTHOR', 'Martin Sewelies');
?>
@define('PLUGIN_EVENT_OSM_VERSION', '0.3.7');
@define('PLUGIN_EVENT_OSM_AUTHOR', 'Martin Sewelies');

View file

@ -1,145 +1,145 @@
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
}
@serendipity_plugin_api::load_language(dirname(__FILE__));
include_once dirname(__FILE__) . '/plugin_version.inc.php';
if (IN_serendipity !== true) {
die ("Don't hack!");
}
class serendipity_event_osm extends serendipity_event
@serendipity_plugin_api::load_language(dirname(__FILE__));
include_once dirname(__FILE__) . '/plugin_version.inc.php';
class serendipity_event_osm extends serendipity_event
{
function introspect(&$propbag)
{
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('title', 'category_id', 'path', 'height', 'latitude', 'longitude', 'zoom'));
$propbag->add('event_hooks', array('entries_header' => true));
$propbag->add('author', PLUGIN_EVENT_OSM_AUTHOR);
$propbag->add('version', PLUGIN_EVENT_OSM_VERSION);
$propbag->add('requirements', array(
'php' => '7.0.0',
'serendipity' => '2.3'
));
$propbag->add('stackable', true);
$propbag->add('groups', array('FRONTEND_ENTRY_RELATED'));
$this->dependencies = array(
'serendipity_event_geo_json' => 'keep'
);
}
$propbag->add('name', PLUGIN_EVENT_OSM_NAME);
$propbag->add('description', PLUGIN_EVENT_OSM_DESCRIPTION);
$propbag->add('copyright', 'GPL');
$propbag->add('configuration', array('title', 'category_id', 'path', 'height', 'latitude', 'longitude', 'zoom'));
$propbag->add('event_hooks', array('entries_header' => true));
$propbag->add('author', PLUGIN_EVENT_OSM_AUTHOR);
$propbag->add('version', PLUGIN_EVENT_OSM_VERSION);
$propbag->add('requirements', array(
'php' => '7.0.0',
'serendipity' => '2.3'
));
$propbag->add('stackable', true);
$propbag->add('groups', array('FRONTEND_ENTRY_RELATED'));
$this->dependencies = array(
'serendipity_event_geo_json' => 'keep'
);
}
function generate_content(&$title)
{
$title = $this->get_config('title');
}
function generate_content(&$title)
{
$title = $this->get_config('title');
}
function get_page_categories()
{
global $serendipity;
$vars = $serendipity['smarty']->get_template_vars() ?? [];
switch ($vars['view'] ?? '') {
case 'entry':
return array_map(function($x) {
return $x['categoryid'];
}, $vars['entry']['categories']);
case 'categories':
return $serendipity['POST']['multiCat'] ?? [$vars['category']];
case 'plugin':
case 'start':
return ($vars['staticpage_related_category_id'] ?? 0) !== '0'
? [$vars['staticpage_related_category_id']]
: [];
function get_page_categories()
{
global $serendipity;
$vars = $serendipity['smarty']->get_template_vars() ?? [];
switch ($vars['view'] ?? '') {
case 'entry':
return array_map(function($x) {
return $x['categoryid'];
}, $vars['entry']['categories']);
case 'categories':
return $serendipity['POST']['multiCat'] ?? [$vars['category']];
case 'plugin':
case 'start':
return ($vars['staticpage_related_category_id'] ?? 0) !== '0'
? [$vars['staticpage_related_category_id']]
: [];
}
return [];
}
function event_hook($event, &$bag, &$eventData, $addData = null)
{
if ($event == 'entries_header') {
$category_id = $this->get_config('category_id', 'any');
$page_categories = $this->get_page_categories();
if (
$category_id === 'any'
||
($category_id === 'without' && empty($page_categories))
||
in_array($category_id, $page_categories)
) {
echo ' <div class="map" data-category="' . $category_id
. '" data-path="' . addslashes($this->get_config('path', ''))
. '" data-latitude="' . ((float)$this->get_config('latitude', 51.48165))
. '" data-longitude="' . ((float)$this->get_config('longitude', 7.21648))
. '" data-zoom="' . ((int)$this->get_config('zoom', 15))
. '" style="height: ' . addslashes($this->get_config('height', '463px'))
. '"></div>'.PHP_EOL;
}
return [];
}
function event_hook($event, &$bag, &$eventData, $addData = null)
{
if ($event == 'entries_header') {
$category_id = $this->get_config('category_id', 'any');
$page_categories = $this->get_page_categories();
if (
$category_id === 'any'
||
($category_id === 'without' && empty($page_categories))
||
in_array($category_id, $page_categories)
) {
echo ' <div class="map" data-category="' . $category_id
. '" data-path="' . addslashes($this->get_config('path', ''))
. '" data-latitude="' . ((float)$this->get_config('latitude', 51.48165))
. '" data-longitude="' . ((float)$this->get_config('longitude', 7.21648))
. '" data-zoom="' . ((int)$this->get_config('zoom', 15))
. '" style="height: ' . addslashes($this->get_config('height', '463px'))
. '"></div>'.PHP_EOL;
}
}
}
function get_selectable_categories()
{
$categories = array('without' => PLUGIN_EVENT_OSM_CATEGORY_WITHOUT, 'any' => PLUGIN_EVENT_OSM_CATEGORY_ANY);
$cats = serendipity_fetchCategories();
if (is_array($cats)) {
$cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
foreach($cats as $cat) {
$categories[$cat['categoryid']] = str_repeat('   ', $cat['depth']) . $cat['category_name'];
}
}
return $categories;
}
function introspect_config_item($name, &$propbag)
{
global $serendipity;
switch($name) {
case 'title':
$propbag->add('type', 'string');
$propbag->add('name', TITLE);
$propbag->add('description', TITLE . ' (' . PLUGIN_EVENT_OSM_NOT_SHOWN . ')');
$propbag->add('default', PLUGIN_EVENT_OSM_NAME);
break;
case 'category_id':
$propbag->add('type', 'select');
$propbag->add('name', PLUGIN_EVENT_OSM_CATEGORY);
$propbag->add('description', PLUGIN_EVENT_OSM_CATEGORY_DESCRIPTION);
$propbag->add('select_values', $this->get_selectable_categories());
$propbag->add('default', 'without');
break;
case 'path':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_EVENT_OSM_PATH);
$propbag->add('description', PLUGIN_EVENT_OSM_PATH_DESCRIPTION);
$propbag->add('default', $serendipity['serendipityHTTPPath'] . $serendipity['uploadPath']);
break;
case 'height':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_OSM_HEIGHT);
$propbag->add('description', PLUGIN_EVENT_OSM_HEIGHT_DESCRIPTION);
$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_DESCRIPTION);
$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_DESCRIPTION);
$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_DESCRIPTION);
$propbag->add('default', '15');
break;
default:
return false;
}
return true;
}
}
?>
function get_selectable_categories()
{
$categories = array('without' => PLUGIN_EVENT_OSM_CATEGORY_WITHOUT, 'any' => PLUGIN_EVENT_OSM_CATEGORY_ANY);
$cats = serendipity_fetchCategories();
if (is_array($cats)) {
$cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
foreach($cats as $cat) {
$categories[$cat['categoryid']] = str_repeat('   ', $cat['depth']) . $cat['category_name'];
}
}
return $categories;
}
function introspect_config_item($name, &$propbag)
{
global $serendipity;
switch($name) {
case 'title':
$propbag->add('type', 'string');
$propbag->add('name', TITLE);
$propbag->add('description', TITLE . ' (' . PLUGIN_EVENT_OSM_NOT_SHOWN . ')');
$propbag->add('default', PLUGIN_EVENT_OSM_NAME);
break;
case 'category_id':
$propbag->add('type', 'select');
$propbag->add('name', PLUGIN_EVENT_OSM_CATEGORY);
$propbag->add('description', PLUGIN_EVENT_OSM_CATEGORY_DESCRIPTION);
$propbag->add('select_values', $this->get_selectable_categories());
$propbag->add('default', 'without');
break;
case 'path':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_EVENT_OSM_PATH);
$propbag->add('description', PLUGIN_EVENT_OSM_PATH_DESCRIPTION);
$propbag->add('default', $serendipity['serendipityHTTPPath'] . $serendipity['uploadPath']);
break;
case 'height':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_OSM_HEIGHT);
$propbag->add('description', PLUGIN_EVENT_OSM_HEIGHT_DESCRIPTION);
$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_DESCRIPTION);
$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_DESCRIPTION);
$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_DESCRIPTION);
$propbag->add('default', '15');
break;
default:
return false;
}
return true;
}
}

View file

@ -1,93 +1,93 @@
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
}
@serendipity_plugin_api::load_language(dirname(__FILE__));
include_once dirname(__FILE__) . '/plugin_version.inc.php';
if (IN_serendipity !== true) {
die ("Don't hack!");
}
class serendipity_event_static_osm extends serendipity_event
@serendipity_plugin_api::load_language(dirname(__FILE__));
include_once dirname(__FILE__) . '/plugin_version.inc.php';
class serendipity_event_static_osm extends serendipity_event
{
function introspect(&$propbag)
{
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('configuration', ['compress_gpx']);
$propbag->add('event_hooks', [
'frontend_header' => true,
'backend_image_add' => true
]);
$propbag->add('author', PLUGIN_EVENT_OSM_AUTHOR);
$propbag->add('version', PLUGIN_EVENT_OSM_VERSION);
$propbag->add('requirements', [
'serendipity' => '2.3'
]);
$propbag->add('stackable', false);
$propbag->add('groups', ['FRONTEND_ENTRY_RELATED']);
$this->dependencies = [
'serendipity_event_geo_osm' => 'keep'
];
}
$propbag->add('name', PLUGIN_EVENT_STATIC_OSM_NAME);
$propbag->add('description', PLUGIN_EVENT_STATIC_OSM_DESCRIPTION);
$propbag->add('copyright', 'GPL');
$propbag->add('configuration', ['compress_gpx']);
$propbag->add('event_hooks', [
'frontend_header' => true,
'backend_image_add' => true
]);
$propbag->add('author', PLUGIN_EVENT_OSM_AUTHOR);
$propbag->add('version', PLUGIN_EVENT_OSM_VERSION);
$propbag->add('requirements', [
'serendipity' => '2.3'
]);
$propbag->add('stackable', false);
$propbag->add('groups', ['FRONTEND_ENTRY_RELATED']);
$this->dependencies = [
'serendipity_event_geo_osm' => 'keep'
];
}
function generate_content(&$title)
{
$title = PLUGIN_EVENT_STATIC_OSM_NAME;
}
function generate_content(&$title)
{
$title = PLUGIN_EVENT_STATIC_OSM_NAME;
}
function event_hook($event, &$bag, &$eventData, $addData = null)
{
if ($event === 'frontend_header') {
echo ' <link rel="stylesheet" href="'.$this->getFile('ressources/ol.css', 'serendipityHTTPPath').'" type="text/css" />'.PHP_EOL;
echo ' <link rel="stylesheet" href="'.$this->getFile('ressources/osm.css', 'serendipityHTTPPath').'" type="text/css" />'.PHP_EOL;
echo ' <script src="'.$this->getFile('ressources/ol.js', 'serendipityHTTPPath').'"></script>'.PHP_EOL;
echo ' <script src="'.$this->getFile('ressources/osm.js', 'serendipityHTTPPath').'"></script>'.PHP_EOL;
} else if ($event === 'backend_image_add') {
if (preg_match('/\\.gpx$/i', mb_strtolower($eventData)) && $this->get_config('compress_gpx', true) === true) {
$fileName = $eventData;
$tmpFile = tmpfile();
fwrite($tmpFile, '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><gpx version="1.1" creator="surrim.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">');
$gpx = simplexml_load_file($fileName);
foreach (($gpx->trk ?? []) as $trk) {
fwrite($tmpFile, '<trk>');
foreach (($trk->trkseg ?? []) as $seg) {
fwrite($tmpFile, '<trkseg>');
foreach (($seg->trkpt ?? []) as $pt) {
fwrite($tmpFile, '<trkpt lat="'.$pt['lat'].'" lon="'.$pt['lon'].'"><ele>'.$pt->ele.'</ele></trkpt>');
}
fwrite($tmpFile, '</trkseg>');
function event_hook($event, &$bag, &$eventData, $addData = null)
{
if ($event === 'frontend_header') {
echo ' <link rel="stylesheet" href="'.$this->getFile('ressources/ol.css', 'serendipityHTTPPath').'" type="text/css" />'.PHP_EOL;
echo ' <link rel="stylesheet" href="'.$this->getFile('ressources/osm.css', 'serendipityHTTPPath').'" type="text/css" />'.PHP_EOL;
echo ' <script src="'.$this->getFile('ressources/ol.js', 'serendipityHTTPPath').'"></script>'.PHP_EOL;
echo ' <script src="'.$this->getFile('ressources/osm.js', 'serendipityHTTPPath').'"></script>'.PHP_EOL;
} else if ($event === 'backend_image_add') {
if (preg_match('/\\.gpx$/i', mb_strtolower($eventData)) && $this->get_config('compress_gpx', true) === true) {
$fileName = $eventData;
$tmpFile = tmpfile();
fwrite($tmpFile, '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><gpx version="1.1" creator="surrim.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">');
$gpx = simplexml_load_file($fileName);
foreach (($gpx->trk ?? []) as $trk) {
fwrite($tmpFile, '<trk>');
foreach (($trk->trkseg ?? []) as $seg) {
fwrite($tmpFile, '<trkseg>');
foreach (($seg->trkpt ?? []) as $pt) {
fwrite($tmpFile, '<trkpt lat="'.$pt['lat'].'" lon="'.$pt['lon'].'"><ele>'.$pt->ele.'</ele></trkpt>');
}
fwrite($tmpFile, '</trk>');
fwrite($tmpFile, '</trkseg>');
}
fwrite($tmpFile, '</gpx>');
$fileSize = ftell($tmpFile);
unset($gpx);
rewind($tmpFile);
$file = fopen($fileName, 'w');
stream_copy_to_stream($tmpFile, $file, $fileSize);
fclose($file);
fclose($tmpFile);
$fileId = $addData['image_id'];
serendipity_updateImageInDatabase(['size' => $fileSize], $fileId);
fwrite($tmpFile, '</trk>');
}
}
}
fwrite($tmpFile, '</gpx>');
$fileSize = ftell($tmpFile);
unset($gpx);
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'compress_gpx':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX);
$propbag->add('description', PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX_DESCRIPTION);
$propbag->add('default', true);
break;
default:
return false;
rewind($tmpFile);
$file = fopen($fileName, 'w');
stream_copy_to_stream($tmpFile, $file, $fileSize);
fclose($file);
fclose($tmpFile);
$fileId = $addData['image_id'];
serendipity_updateImageInDatabase(['size' => $fileSize], $fileId);
}
return true;
}
}
?>
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'compress_gpx':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX);
$propbag->add('description', PLUGIN_EVENT_STATIC_OSM_COMPRESS_GPX_DESCRIPTION);
$propbag->add('default', true);
break;
default:
return false;
}
return true;
}
}