-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathgpx.inc.php
103 lines (90 loc) · 3.19 KB
/
gpx.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/***********************************************
* File : gpx.inc.php
* Project : piwigo-openstreetmap
* Descr : Display an OSM map with elevation on GPX item
*
* Created : 01.11.2014
*
* Copyright 2013-2016 <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
************************************************/
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
// Add GPX support file extensions
array_push($conf['file_ext'], 'gpx');
// Hook on to an event to display videos as standard images
add_event_handler('render_element_content', 'osm_render_media', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
function osm_render_media($content, $picture)
{
global $template, $picture, $conf;
//print_r( $picture['current']);
// do nothing if the current picture is actually an image !
if ( (array_key_exists('src_image', @$picture['current'])
&& @$picture['current']['src_image']->is_original()) )
{
return $content;
}
// If not a GPX file
if ( (array_key_exists('path', @$picture['current']))
&& strpos($picture['current']['path'],".gpx") === false)
{
return $content;
}
$filename = embellish_url(get_gallery_home_url() . $picture['current']['element_url']);
$height = isset($conf['osm_conf']['gpx']['height']) ? $conf['osm_conf']['gpx']['height'] : '500';
$width = isset($conf['osm_conf']['gpx']['width']) ? $conf['osm_conf']['gpx']['width'] : '320';
$local_conf = array();
$local_conf['contextmenu'] = 'false';
$local_conf['control'] = true;
$local_conf['img_popup'] = false;
$local_conf['popup'] = 2;
$local_conf['center_lat'] = 0;
$local_conf['center_lng'] = 0;
$local_conf['zoom'] = '12';
$local_conf['divname'] = 'mapgpx';
$js_data = array(array(null, null, null, null, null, null, null, null));
$js = osm_get_js($conf, $local_conf, $js_data);
// Select the template
$template->set_filenames(
array('osm_content' => dirname(__FILE__)."/template/osm-gpx.tpl")
);
// Assign the template variables
$template->assign(
array(
'OSM_HEIGHT' => $height,
'OSM_WIDTH' => $width,
'FILENAME' => $filename,
'OSM_PATH' => embellish_url(get_gallery_home_url().OSM_PATH),
'OSMGPX' => $js,
)
);
// Return the rendered html
$osm_content = $template->parse('osm_content', true);
return $osm_content;
}
// Hook to display a fallback thumbnail if not defined
add_event_handler('get_mimetype_location', 'osm_get_mimetype_icon');
function osm_get_mimetype_icon($location, $element_info)
{
if ($element_info == 'gpx')
{
$location = 'plugins/'
. basename(dirname(__FILE__))
. '/mimetypes/'. $element_info. '.png';
}
return $location;
}
?>