This commit is contained in:
bastianonm 2011-12-30 20:49:06 +00:00
parent 39f93d35a8
commit 1335f6f8c1
4 changed files with 49 additions and 19 deletions

View File

@ -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 Tags: maps, gpx, gps, graph, google maps, google chart, track, garmin
Requires at least: 2.0.0 Requires at least: 2.0.0
Tested up to: 3.3 Tested up to: 3.3
Stable tag: 1.0.8 Stable tag: 1.0.9
License: GPLv2 or later License: GPLv2 or later
Draws a gpx track with altitude graph Draws a gpx track with altitude graph
@ -68,6 +68,9 @@ Yes!
2. Admin area 2. Admin area
== Changelog == == Changelog ==
= 1.0.9 =
* Minor bug fix
* Windows/IIS compatibility
= 1.0.8 = = 1.0.8 =
* New icons (from google maps) * New icons (from google maps)
* Added interactivity over the map * Added interactivity over the map
@ -92,6 +95,7 @@ Yes!
* Initial release. * Initial release.
== Upgrade Notice == == Upgrade Notice ==
= 1.0.9 =
= 1.0.8 = = 1.0.8 =
= 1.0.7 = = 1.0.7 =
* Added waypoints support. To enable this feature please check the plugin settings * Added waypoints support. To enable this feature please check the plugin settings

View File

@ -3,7 +3,7 @@
Plugin Name: WP-GPX-Maps Plugin Name: WP-GPX-Maps
Plugin URI: http://www.darwinner.it/ Plugin URI: http://www.darwinner.it/
Description: Draws a gpx track with altitude graph Description: Draws a gpx track with altitude graph
Version: 1.0.8 Version: 1.0.9
Author: Bastianon Massimo Author: Bastianon Massimo
Author URI: http://www.pedemontanadelgrappa.it/ Author URI: http://www.pedemontanadelgrappa.it/
License: GPL License: GPL
@ -58,7 +58,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$mt = $attr["mtype"]; $mt = $attr["mtype"];
$gh = $attr["gheight"]; $gh = $attr["gheight"];
$showW = $attr['waypoints']; $showW = $attr['waypoints'];
if ($w == '') if ($w == '')
{ {
$w = get_option("wpgpxmaps_width"); $w = get_option("wpgpxmaps_width");
@ -91,9 +91,15 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$r = rand(1,5000000); $r = rand(1,5000000);
$sitePath = substr (__FILE__, 0, strrpos(__FILE__,'wp-content')).DIRECTORY_SEPARATOR;
$gpx = trim($gpx); $gpx = trim($gpx);
$points = getPoints($gpx); $gpx = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $gpx);
$gpx = $sitePath . $gpx;
$points = getPoints( $gpx );
$points_maps = ''; $points_maps = '';
$points_graph = ''; $points_graph = '';
$waypoints = ''; $waypoints = '';

View File

@ -14,17 +14,15 @@
{ {
$gpxOffset = 10; $gpxOffset = 10;
} }
$realGpxPath = substr (__FILE__, 0, strrpos(__FILE__,'/wp-content/')).$gpxPath;
if (file_exists($realGpxPath)) if (file_exists($gpxPath))
{ {
$points = parseXml($realGpxPath, $gpxOffset); $points = parseXml($gpxPath, $gpxOffset);
} }
else else
{ {
array_push($points, array((float)0,(float)0,(float)0,(float)0)); array_push($points, array((float)0,(float)0,(float)0,(float)0));
echo "File $realGpxPath not found!"; echo "File $gpxPath not found!";
} }
// riduco l'array a circa 200 punti per non appensantire la pagina(mappa e grafico)! // riduco l'array a circa 200 punti per non appensantire la pagina(mappa e grafico)!
$count=sizeof($points); $count=sizeof($points);
@ -143,11 +141,10 @@
function getWayPoints($gpxPath) function getWayPoints($gpxPath)
{ {
$points = array(); $points = array();
$realGpxPath = substr (__FILE__, 0, strrpos(__FILE__,'/wp-content/')).$gpxPath; if (file_exists($gpxPath))
if (file_exists($realGpxPath))
{ {
$points = array(); $points = array();
$gpx = simplexml_load_file($realGpxPath); $gpx = simplexml_load_file($gpxPath);
$gpx->registerXPathNamespace('10', 'http://www.topografix.com/GPX/1/0'); $gpx->registerXPathNamespace('10', 'http://www.topografix.com/GPX/1/0');
$gpx->registerXPathNamespace('11', 'http://www.topografix.com/GPX/1/1'); $gpx->registerXPathNamespace('11', 'http://www.topografix.com/GPX/1/1');
$nodes = $gpx->xpath('//wpt | //10:wpt | //11:wpt'); $nodes = $gpx->xpath('//wpt | //10:wpt | //11:wpt');

View File

@ -11,7 +11,8 @@ if ( is_admin() ){
function WP_GPX_Maps_html_page() { function WP_GPX_Maps_html_page() {
$realGpxPath = substr (__FILE__, 0, strrpos(__FILE__,'/wp-content/'))."/wp-content/uploads/gpx"; $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";
$gpxRegEx = '/.gpx$/'; $gpxRegEx = '/.gpx$/';
?> ?>
@ -27,7 +28,13 @@ function WP_GPX_Maps_html_page() {
} }
else else
{ {
if (!@mkdir($dir)) {
if(!file_exists($uploadsPath))
{
@mkdir($uploadsPath);
}
if (!@mkdir($realGpxPath)) {
echo '<div class="error" style="padding:10px"> echo '<div class="error" style="padding:10px">
Can\'t create <b>'.$realGpxPath.'</b> folder. Please create it and make it writable!<br /> Can\'t create <b>'.$realGpxPath.'</b> folder. Please create it and make it writable!<br />
If not, you will must update the file manually! If not, you will must update the file manually!
@ -57,9 +64,9 @@ function WP_GPX_Maps_html_page() {
<td> <td>
<i>Width:</i> <input name="wpgpxmaps_width" type="text" id="wpgpxmaps_width" value="<?php echo get_option('wpgpxmaps_width'); ?>" style="width:50px;" />, <i>Width:</i> <input name="wpgpxmaps_width" type="text" id="wpgpxmaps_width" value="<?php echo get_option('wpgpxmaps_width'); ?>" style="width:50px;" />,
<i>Maps Height:</i> <input name="wpgpxmaps_height" type="text" id="wpgpxmaps_height" value="<?php echo get_option('wpgpxmaps_height'); ?>" style="width:50px;" />, <i>Maps Height:</i> <input name="wpgpxmaps_height" type="text" id="wpgpxmaps_height" value="<?php echo get_option('wpgpxmaps_height'); ?>" style="width:50px;" />,
<i>Graph Height:</i> <input name="wpgpxmaps_height" type="text" id="wpgpxmaps_height" value="<?php echo get_option('wpgpxmaps_height'); ?>" style="width:50px;" />, <i>Graph Height:</i> <input name="wpgpxmaps_graph_height" type="text" id="wpgpxmaps_graph_height" value="<?php echo get_option('wpgpxmaps_graph_height'); ?>" style="width:50px;" />,
<input name="wpgpxmaps_show_waypoint" type="checkbox" value="true" <?php if($showW == true){echo('checked');} ?> onchange="this.value = (this.checked)" /><i>Show Waypoints</i> <input name="wpgpxmaps_show_waypoint" type="checkbox" value="true" <?php if($showW == true){echo('checked');} ?> onchange="this.value = (this.checked)" /><i>Show Waypoints</i>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -98,8 +105,10 @@ function WP_GPX_Maps_html_page() {
} }
} }
if ( is_readable ( $realGpxPath ) && $handle = opendir($realGpxPath)) {
?> if ( is_writable ( $realGpxPath ) ){
?>
<div class="tablenav top"> <div class="tablenav top">
<form enctype="multipart/form-data" method="POST"> <form enctype="multipart/form-data" method="POST">
@ -123,7 +132,21 @@ function WP_GPX_Maps_html_page() {
} }
?> ?>
</form> </form>
</div> </div>
<?php
}
?>
<?php
if ( is_readable ( $realGpxPath ) && $handle = opendir($realGpxPath)) {
?>
<table cellspacing="0" class="wp-list-table widefat plugins"> <table cellspacing="0" class="wp-list-table widefat plugins">
<thead> <thead>