Update geo json (#153)
* Changed my name * More generic JSON data * Improved translations * Added Spanish translations * Update event_geo_json to 0.3.0 * Added Spanish translations * Improved translations * More generic JSON data * Changed my name --------- Co-authored-by: surrim <root@surrim.org>
This commit is contained in:
parent
c29c6aafa7
commit
736d2bfeaa
|
@ -1,9 +1,14 @@
|
|||
0.3.0:
|
||||
---
|
||||
* Added Spanish translations
|
||||
* Improved translations
|
||||
* More generic JSON data
|
||||
* Changed my name
|
||||
|
||||
0.2.2:
|
||||
---
|
||||
|
||||
* Added missing include
|
||||
* Added missing include
|
||||
|
||||
0.2.1:
|
||||
---
|
||||
|
||||
* Convert date, size and catergory ids to int, 3% smaller output
|
||||
* Convert date, size and catergory ids to int, 3% smaller output
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
@define('PLUGIN_EVENT_GEO_JSON_NAME', 'Geo-JSON');
|
||||
@define('PLUGIN_EVENT_GEO_JSON_DESCRIPTION', 'Erstellt ein JSON-Object mit allen Geo-Daten, welches mit JavaScript verarbeiete werden kann.');
|
||||
@define('PLUGIN_EVENT_GEO_JSON_DESCRIPTION', 'Erstellt ein JSON-Object, welches alle Geo-Daten enthält und mit JavaScript verarbeitet werden kann');
|
||||
?>
|
||||
|
|
4
serendipity_event_geo_json/UTF-8/lang_es.inc.php
Normal file
4
serendipity_event_geo_json/UTF-8/lang_es.inc.php
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
@define('PLUGIN_EVENT_GEO_JSON_NAME', 'Geo-JSON');
|
||||
@define('PLUGIN_EVENT_GEO_JSON_DESCRIPTION', 'Crea un objeto JSON que contiene todos los datos geográficos y puede procesarse con JavaScript');
|
||||
?>
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
@define('PLUGIN_EVENT_GEO_JSON_NAME', 'Geo-JSON');
|
||||
@define('PLUGIN_EVENT_GEO_JSON_DESCRIPTION', 'Erstellt ein JSON-Object mit allen Geo-Daten, welches mit JavaScript verarbeiete werden kann.');
|
||||
@define('PLUGIN_EVENT_GEO_JSON_DESCRIPTION', 'Erstellt ein JSON-Object, welches alle Geo-Daten enthält und mit JavaScript verarbeitet werden kann');
|
||||
?>
|
||||
|
|
|
@ -1,4 +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_DESCRIPTION', 'Provides a JSON object which contains all geographic data and can be processed with JavaScript');
|
||||
?>
|
||||
|
|
4
serendipity_event_geo_json/lang_es.inc.php
Normal file
4
serendipity_event_geo_json/lang_es.inc.php
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
@define('PLUGIN_EVENT_GEO_JSON_NAME', 'Geo-JSON');
|
||||
@define('PLUGIN_EVENT_GEO_JSON_DESCRIPTION', 'Crea un objeto JSON que contiene todos los datos geográficos y puede procesarse con JavaScript');
|
||||
?>
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
@define('PLUGIN_EVENT_GEO_JSON_VERSION', '0.2.2');
|
||||
@define('PLUGIN_EVENT_GEO_JSON_AUTHOR', 'Martin Sewelies');
|
||||
@define('PLUGIN_EVENT_GEO_JSON_VERSION', '0.3.0');
|
||||
@define('PLUGIN_EVENT_GEO_JSON_AUTHOR', 'Kathi Sewelies');
|
||||
?>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
$propbag->add('event_hooks', array('frontend_header' => true));
|
||||
$propbag->add('author', PLUGIN_EVENT_GEO_JSON_AUTHOR);
|
||||
$propbag->add('version', PLUGIN_EVENT_GEO_JSON_VERSION);
|
||||
$propbag->add('requirements', array('serendipity' => '2.3'));
|
||||
$propbag->add('requirements', ['serendipity' => '2.3']);
|
||||
$propbag->add('stackable', false);
|
||||
$propbag->add('groups', array('FRONTEND_FEATURES'));
|
||||
}
|
||||
|
@ -31,9 +31,11 @@
|
|||
return is_array($rows) ? $rows : [];
|
||||
}
|
||||
|
||||
function get_entries() {
|
||||
function get_articles() {
|
||||
global $serendipity;
|
||||
$entries = [];
|
||||
$timestamp = serendipity_db_time();
|
||||
$showFutureEntries = serendipity_db_bool($serendipity['showFutureEntries']);
|
||||
$articles = [];
|
||||
foreach ($this->simple_query(
|
||||
"SELECT e.id, e.title, p.permalink, e.timestamp, LENGTH(e.body) AS size, a.realname, eplat.value AS lat, eplng.value AS lng
|
||||
FROM {$serendipity['dbPrefix']}entries e
|
||||
|
@ -44,16 +46,16 @@
|
|||
WHERE e.isdraft = 'false'
|
||||
ORDER BY e.timestamp",
|
||||
false, 'assoc'
|
||||
) as $row) {
|
||||
$entries[$row['id']] = [
|
||||
'title' => $row['title'],
|
||||
'url' => serendipity_db_bool($serendipity['showFutureEntries']) || $row['timestamp'] <= serendipity_db_time()
|
||||
? $serendipity['serendipityHTTPPath'].$row['permalink']
|
||||
) as $article) {
|
||||
$articles[$article['id']] = [
|
||||
'title' => $article['title'],
|
||||
'url' => $article['timestamp'] <= $timestamp || $showFutureEntries
|
||||
? $serendipity['serendipityHTTPPath'] . $article['permalink']
|
||||
: null,
|
||||
'date' => intval($row['timestamp']),
|
||||
'size' => intval($row['size']),
|
||||
'author' => $row['realname'],
|
||||
'pos' => [floatval($row['lat']), floatval($row['lng'])],
|
||||
'date' => intval($article['timestamp']),
|
||||
'size' => intval($article['size']),
|
||||
'author' => $article['realname'],
|
||||
'location' => [floatval($article['lat']), floatval($article['lng'])],
|
||||
'categories' => []
|
||||
];
|
||||
}
|
||||
|
@ -64,21 +66,21 @@
|
|||
JOIN {$serendipity['dbPrefix']}entryproperties eplat ON (eplat.entryid = ec.entryid AND eplat.property = 'geo_lat')
|
||||
JOIN {$serendipity['dbPrefix']}entryproperties eplng ON (eplng.entryid = ec.entryid AND eplng.property = 'geo_long')
|
||||
WHERE e.isdraft = 'false'"
|
||||
) as $row) {
|
||||
$entries[$row['entryid']]['categories'][] = intval($row['categoryid']);
|
||||
) as $articleCategory) {
|
||||
$articles[$articleCategory['entryid']]['categories'][] = intval($articleCategory['categoryid']);
|
||||
}
|
||||
return array_values($entries);
|
||||
return array_values($articles);
|
||||
}
|
||||
|
||||
function get_uploads() {
|
||||
function get_tracks() {
|
||||
global $serendipity;
|
||||
return array_map(function($row) {
|
||||
return array_map(function($track) {
|
||||
global $serendipity;
|
||||
return [
|
||||
'title' => $row['realname'],
|
||||
'url' => $serendipity['serendipityHTTPPath'].$serendipity['uploadPath'].$row['path'].$row['realname'],
|
||||
'date' => intval($row['date']),
|
||||
'size' => intval($row['size'])
|
||||
'title' => $track['realname'],
|
||||
'url' => $serendipity['serendipityHTTPPath'] . $serendipity['uploadPath'] . $track['path'] . $track['realname'],
|
||||
'date' => intval($track['date']),
|
||||
'size' => intval($track['size'])
|
||||
];
|
||||
}, $this->simple_query(
|
||||
"SELECT i.realname, i.path, IFNULL(m.value, i.date) AS date, i.size
|
||||
|
@ -87,23 +89,22 @@
|
|||
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",
|
||||
ORDER BY i.path",
|
||||
false, 'assoc'
|
||||
));
|
||||
}
|
||||
|
||||
function get_geo_json()
|
||||
{
|
||||
function get_geo_json() {
|
||||
return json_encode([
|
||||
'entries' => $this->get_entries(),
|
||||
'uploads' => $this->get_uploads()
|
||||
'articles' => $this->get_articles(),
|
||||
'tracks' => $this->get_tracks()
|
||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
function event_hook($event, &$bag, &$eventData, $addData = null)
|
||||
{
|
||||
if ($event == 'frontend_header') {
|
||||
echo ' <script>const geo = '.$this->get_geo_json().';</script>'.PHP_EOL;
|
||||
echo ' <script>const geo = ' . $this->get_geo_json() . ';</script>' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue