This commit is contained in:
parent
8a4a510722
commit
2f6aae8455
|
@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=basti
|
|||
Tags: maps, gpx, gps, graph, google maps, google chart, track, garmin
|
||||
Requires at least: 2.0.0
|
||||
Tested up to: 3.3
|
||||
Stable tag: 1.1.1
|
||||
Stable tag: 1.1.2
|
||||
License: GPLv2 or later
|
||||
|
||||
Draws a gpx track with altitude graph
|
||||
|
@ -72,6 +72,9 @@ Yes!
|
|||
2. Admin area
|
||||
|
||||
== Changelog ==
|
||||
= 1.1.2 =
|
||||
* Improved page load time
|
||||
* Added compatibility to Wordpress Multisite (WPMU)
|
||||
= 1.1.1 =
|
||||
* minor bug fixes
|
||||
= 1.1.0 =
|
||||
|
@ -104,6 +107,7 @@ Yes!
|
|||
* Initial release.
|
||||
|
||||
== Upgrade Notice ==
|
||||
= 1.1.2 =
|
||||
= 1.1.1 =
|
||||
= 1.1.0 =
|
||||
= 1.0.9 =
|
||||
|
|
|
@ -3,12 +3,14 @@
|
|||
Plugin Name: WP-GPX-Maps
|
||||
Plugin URI: http://www.darwinner.it/
|
||||
Description: Draws a gpx track with altitude graph
|
||||
Version: 1.1.1
|
||||
Version: 1.1.2
|
||||
Author: Bastianon Massimo
|
||||
Author URI: http://www.pedemontanadelgrappa.it/
|
||||
License: GPL
|
||||
*/
|
||||
|
||||
//error_reporting (E_ALL);
|
||||
|
||||
include 'wp-gpx-maps_Utils.php';
|
||||
include 'wp-gpx-maps_admin.php';
|
||||
|
||||
|
@ -36,7 +38,6 @@ function WP_GPX_Maps_action_links($links, $file) {
|
|||
return $links;
|
||||
}
|
||||
|
||||
|
||||
function enqueue_WP_GPX_Maps_scripts()
|
||||
{
|
||||
?>
|
||||
|
@ -49,65 +50,39 @@ function enqueue_WP_GPX_Maps_scripts()
|
|||
<?php
|
||||
}
|
||||
|
||||
|
||||
function findValue($attr, $attributeName, $optionName, $defaultValue)
|
||||
{
|
||||
$val = '';
|
||||
if ( isset($attr[$attributeName]) )
|
||||
{
|
||||
$val = $attr[$attributeName];
|
||||
}
|
||||
if ($val == '')
|
||||
{
|
||||
$val = get_option($optionName);
|
||||
}
|
||||
if ($val == '')
|
||||
{
|
||||
$val = $defaultValue;
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
|
||||
{
|
||||
$gpx = $attr["gpx"];
|
||||
$w = $attr["width"];
|
||||
$mh = $attr["mheight"];
|
||||
$mt = $attr["mtype"];
|
||||
$gh = $attr["gheight"];
|
||||
$showW = $attr['waypoints'];
|
||||
$donotreducegpx = $attr['donotreducegpx'];
|
||||
$pointsoffset = $attr['pointsoffset'];
|
||||
|
||||
if ($w == '')
|
||||
{
|
||||
$w = get_option("wpgpxmaps_width");
|
||||
}
|
||||
|
||||
if ($mh == '')
|
||||
{
|
||||
$mh = get_option("wpgpxmaps_height");
|
||||
}
|
||||
|
||||
if ($gh == '')
|
||||
{
|
||||
$gh = get_option("wpgpxmaps_graph_height");
|
||||
}
|
||||
if ($gh == '')
|
||||
{
|
||||
$gh = "200px";
|
||||
}
|
||||
|
||||
if ($pointsoffset == '')
|
||||
{
|
||||
$pointsoffset = get_option("wpgpxmaps_pointsoffset");
|
||||
}
|
||||
if ($pointsoffset == '')
|
||||
{
|
||||
$pointsoffset = 10;
|
||||
}
|
||||
|
||||
|
||||
if ($mt == '')
|
||||
{
|
||||
$mt = get_option("wpgpxmaps_map_type");
|
||||
}
|
||||
|
||||
if ($donotreducegpx == '')
|
||||
{
|
||||
$donotreducegpx = get_option("wpgpxmaps_donotreducegpx");
|
||||
}
|
||||
|
||||
if ($showW == '')
|
||||
{
|
||||
$showW = get_option("wpgpxmaps_show_waypoint");
|
||||
}
|
||||
$gpx = findValue($attr, "gpx", "", "");
|
||||
$w = findValue($attr, "width", "wpgpxmaps_width", "100%");
|
||||
$mh = findValue($attr, "mheight", "wpgpxmaps_height", "450px");
|
||||
$mt = findValue($attr, "mtype", "wpgpxmaps_map_type", "HYBRID");
|
||||
$gh = findValue($attr, "gheight", "wpgpxmaps_graph_height", "200px");
|
||||
$showW = findValue($attr, "waypoints", "wpgpxmaps_show_waypoint", false);
|
||||
$donotreducegpx = findValue($attr, "donotreducegpx", "wpgpxmaps_donotreducegpx", false);
|
||||
$pointsoffset = findValue($attr, "pointsoffset", "wpgpxmaps_pointsoffset", 10);
|
||||
|
||||
$r = rand(1,5000000);
|
||||
|
||||
$sitePath = substr (__FILE__, 0, strrpos(__FILE__,'wp-content')).DIRECTORY_SEPARATOR;
|
||||
$sitePath = sitePath();
|
||||
|
||||
$gpx = trim($gpx);
|
||||
|
||||
|
@ -121,15 +96,15 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
|
|||
$waypoints = '';
|
||||
|
||||
foreach ($points as $p) {
|
||||
$points_maps .= "[".(float)$p[0].",".(float)$p[1]."],";
|
||||
$points_graph .= "[".(float)$p[3].",".(float)$p[2]."],";
|
||||
$points_maps .= '['.(float)$p[0].','.(float)$p[1].'],';
|
||||
$points_graph .= '['.(float)$p[3].','.(float)$p[2].'],';
|
||||
} //all the points are [0,0] $points_graph = preg_replace("/^(\[0,0\],)+$/", "", $points_graph);
|
||||
|
||||
if ($showW == true)
|
||||
{
|
||||
$wpoints = getWayPoints($gpx);
|
||||
foreach ($wpoints as $p) {
|
||||
$waypoints .= "[".(float)$p[0].",".(float)$p[1].",'".unescape($p[4])."','".unescape($p[5])."','".unescape($p[7])."'],";
|
||||
$waypoints .= '['.(float)$p[0].','.(float)$p[1].',\''.unescape($p[4]).'\',\''.unescape($p[5]).'\',\''.unescape($p[7]).'\'],';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,28 @@
|
|||
<?php
|
||||
|
||||
|
||||
function sitePath()
|
||||
{
|
||||
return substr(substr(__FILE__, 0, strrpos(__FILE__,'wp-content')), 0, -1);
|
||||
// $uploadsPath = substr($uploadsPath, 0, -1);
|
||||
}
|
||||
|
||||
function gpxFolderPath()
|
||||
{
|
||||
$upload_dir = wp_upload_dir();
|
||||
$uploadsPath = $upload_dir['basedir'];
|
||||
$ret = $uploadsPath.DIRECTORY_SEPARATOR."gpx";
|
||||
return str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $ret);
|
||||
}
|
||||
|
||||
function relativeGpxFolderPath()
|
||||
{
|
||||
$sitePath = sitePath();
|
||||
$realGpxPath = gpxFolderPath();
|
||||
$ret = str_replace($sitePath,'',$realGpxPath).DIRECTORY_SEPARATOR;
|
||||
return str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $ret);
|
||||
}
|
||||
|
||||
function getPoints($gpxPath,$gpxOffset = 10, $donotreducegpx)
|
||||
{
|
||||
|
||||
|
@ -41,6 +65,10 @@
|
|||
|
||||
$points = array();
|
||||
$gpx = simplexml_load_file($filePath);
|
||||
|
||||
if($gpx === FALSE)
|
||||
return;
|
||||
|
||||
$gpx->registerXPathNamespace('10', 'http://www.topografix.com/GPX/1/0');
|
||||
$gpx->registerXPathNamespace('11', 'http://www.topografix.com/GPX/1/1');
|
||||
$gpx->registerXPathNamespace('gpxx', 'http://www.garmin.com/xmlschemas/GpxExtensions/v3');
|
||||
|
@ -49,6 +77,13 @@
|
|||
|
||||
if ( count($nodes) > 0 )
|
||||
{
|
||||
|
||||
$lastLat = 0;
|
||||
$lastLon = 0;
|
||||
$lastEle = 0;
|
||||
$dist = 0;
|
||||
$lastOffset = 0;
|
||||
|
||||
// normal case
|
||||
foreach($nodes as $trkpt)
|
||||
{
|
||||
|
@ -84,6 +119,7 @@
|
|||
$lastLon=$lon;
|
||||
$lastEle=$ele;
|
||||
}
|
||||
unset($nodes);
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -94,6 +130,12 @@
|
|||
if ( count($nodes) > 0 )
|
||||
{
|
||||
|
||||
$lastLat = 0;
|
||||
$lastLon = 0;
|
||||
$lastEle = 0;
|
||||
$dist = 0;
|
||||
$lastOffset = 0;
|
||||
|
||||
// Garmin case
|
||||
foreach($nodes as $rpt)
|
||||
{
|
||||
|
@ -127,13 +169,14 @@
|
|||
$lastLat=$lat;
|
||||
$lastLon=$lon;
|
||||
}
|
||||
|
||||
unset($nodes);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Gpx Empty or not supported!";
|
||||
echo "Empty Gpx or not supported File!";
|
||||
}
|
||||
}
|
||||
unset($gpx);
|
||||
return $points;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,10 @@ if ( is_admin() ){
|
|||
}
|
||||
|
||||
function WP_GPX_Maps_html_page() {
|
||||
|
||||
$uploadsPath = substr (__FILE__, 0, strrpos(__FILE__,'wp-content')).DIRECTORY_SEPARATOR."wp-content".DIRECTORY_SEPARATOR."uploads";
|
||||
$realGpxPath = substr (__FILE__, 0, strrpos(__FILE__,'wp-content')).DIRECTORY_SEPARATOR."wp-content".DIRECTORY_SEPARATOR."uploads".DIRECTORY_SEPARATOR."gpx";
|
||||
$realGpxPath = gpxFolderPath();
|
||||
$relativeGpxPath = relativeGpxFolderPath();
|
||||
$relativeGpxPath = str_replace("\\","/", $relativeGpxPath);
|
||||
$gpxRegEx = '/.gpx$/';
|
||||
|
||||
?>
|
||||
|
||||
<div>
|
||||
|
@ -28,13 +27,7 @@ function WP_GPX_Maps_html_page() {
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(!file_exists($uploadsPath))
|
||||
{
|
||||
@mkdir($uploadsPath);
|
||||
}
|
||||
|
||||
if (!@mkdir($realGpxPath)) {
|
||||
if (!@mkdir($realGpxPath,755,true)) {
|
||||
echo '<div class="error" style="padding:10px">
|
||||
Can\'t create <b>'.$realGpxPath.'</b> folder. Please create it and make it writable!<br />
|
||||
If not, you will must update the file manually!
|
||||
|
@ -54,9 +47,9 @@ function WP_GPX_Maps_html_page() {
|
|||
|
||||
<div style="padding:10px;">
|
||||
<b>The fastest way to use this plugin:</b> upload the file using the uploader below, than put this
|
||||
shotcode: <b>[sgpx gpx="/wp-content/uploads/gpx/< gpx file name >"]</b> in the pages/posts.
|
||||
shotcode: <b>[sgpx gpx="<?php echo $relativeGpxPath; ?>< gpx file name >"]</b> in the pages/posts.
|
||||
<p>
|
||||
<i>Full set of attributes:</i> <b>[sgpx gpx="/wp-content/uploads/gpx/< gpx file name >" width=100% mheight=450px gheight=200px mtype=SATELLITE waypoints=true donotreducegpx=false pointsoffset=10]</b>
|
||||
<i>Full set of attributes:</i> <b>[sgpx gpx="<?php echo $relativeGpxPath; ?>< gpx file name >" width=100% mheight=450px gheight=200px mtype=SATELLITE waypoints=true donotreducegpx=false pointsoffset=10]</b>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
@ -115,7 +108,6 @@ function WP_GPX_Maps_html_page() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if ( is_writable ( $realGpxPath ) ){
|
||||
|
||||
?>
|
||||
|
@ -194,7 +186,7 @@ function WP_GPX_Maps_html_page() {
|
|||
|
|
||||
<a href="../wp-content/uploads/gpx/<?php echo $entry?>">Download</a>
|
||||
|
|
||||
Shortcode: [sgpx gpx="/wp-content/uploads/gpx/<?php echo $entry?>"]
|
||||
Shortcode: [sgpx gpx="<?php echo $relativeGpxPath . $entry; ?>"]
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
Loading…
Reference in New Issue