This commit is contained in:
bastianonm 2012-01-28 11:56:52 +00:00
parent 4d1ef1e7c3
commit f068278fe0
11 changed files with 359 additions and 213 deletions

View File

@ -26,9 +26,9 @@ var wrapFunction = function(fn, context, params) {
};
}
function wpgpxmaps(targhetId,mapType,mapData,graphData,waypoints)
function wpgpxmaps(targhetId,mapType,mapData,graphData,waypoints,unit,color1,color2)
{
funqueue.push( wrapFunction(_wpgpxmaps, this, [targhetId,mapType,mapData,graphData,waypoints]));
funqueue.push( wrapFunction(_wpgpxmaps, this, [targhetId,mapType,mapData,graphData,waypoints,unit,color1,color2]));
unqueue();
}
@ -46,7 +46,7 @@ function unqueue()
}
}
function _wpgpxmaps(targhetId,mapType,mapData,graphData,waypoints)
function _wpgpxmaps(targhetId,mapType,mapData,graphData,waypoints,unit,color1,color2)
{
var el = document.getElementById("wpgpxmaps_" + targhetId);
var el_map = document.getElementById("map_" + targhetId);
@ -96,7 +96,7 @@ function _wpgpxmaps(targhetId,mapType,mapData,graphData,waypoints)
}
var poly = new google.maps.Polyline({
path: points,
strokeColor: "#3366cc",
strokeColor: color1,
strokeOpacity: .7,
strokeWeight: 4
});
@ -126,7 +126,13 @@ function _wpgpxmaps(targhetId,mapType,mapData,graphData,waypoints)
marker.setTitle("Current Position");
if ( chart )
{
var ci = getClosestIndex(mapData,event.latLng.Qa,event.latLng.Ra);
var l1 = event.latLng.Qa;
if (!(l1))
l1 = event.latLng.Oa;
var l2 = event.latLng.Ra;
if (!(l2))
l2 = event.latLng.Pa;
var ci = getClosestIndex(mapData,l1,l2);
var r = chart.setSelection([{'row': parseInt(ci) + 1}]);
}
}
@ -136,6 +142,16 @@ function _wpgpxmaps(targhetId,mapType,mapData,graphData,waypoints)
// Print Graph
if (graphData!= '')
{
var numberFormat1 = "#,###m";
var numberFormat2 = "#,###m";
if (unit=="1")
{
var numberFormat1 = "#,##0.#mi";
var numberFormat2 = "#,###ft";
}
var data = new google.visualization.DataTable();
data.addColumn('number', loc['length']);
data.addColumn('number', loc['altitude']);
@ -143,10 +159,11 @@ function _wpgpxmaps(targhetId,mapType,mapData,graphData,waypoints)
var chart = new google.visualization.AreaChart(el_chart);
var options = { curveType: "function",
strictFirstColumnType: true,
hAxis : {format : '#,###m', title : loc['length']},
vAxis : {format : '#,###m', title : loc['altitude']},
hAxis : {format : numberFormat1, title : loc['length']},
vAxis : {format : numberFormat2, title : loc['altitude']},
legend : {position : 'none'},
chartArea: {left:70,top:10,width:"100%",height:"75%"}
chartArea: {left:70,top:10,width:"100%",height:"75%"},
colors:[color2]
};
chart.draw(data, options);
@ -163,7 +180,6 @@ function _wpgpxmaps(targhetId,mapType,mapData,graphData,waypoints)
//google.visualization.events.addListener(chart, 'onmouseout', function (e) {
//chart.setSelection([e]);
//});
}
else
{

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
Requires at least: 2.0.0
Tested up to: 3.3
Stable tag: 1.1.3
Stable tag: 1.1.4
License: GPLv2 or later
Draws a gpx track with altitude graph
@ -58,6 +58,12 @@ The attributes are:
1. pointsoffset: Skip points closer than XX meters(default is 10)
1. uom: the unit of measure values are: 0, 1 (0 = meters, 1 = miles/feet)
1. mlinecolor: map line color (default is #3366cc)
1. glinecolor: graph line color (default is #3366cc)
shortcode with all the attributes : [sgpx gpx=">relative path to your gpx<" width=100% mheight=300px gheight=200px mtype=SATELLITE waypoints=true]
= What happening if I've a very large gpx? =
@ -69,9 +75,15 @@ Yes!
== Screenshots ==
1. Simple Gpx
1. Gpx with waypoints
2. Admin area
2. Admin area - List of tracks
2. Admin area - Settings
== Changelog ==
= 1.1.4 =
* improved admin area
* added miles/feet unit of measure
* added map line color and graph line color
* minor bug fixes
= 1.1.3 =
* Allowed gpx files from http url
= 1.1.2 =
@ -109,6 +121,7 @@ Yes!
* Initial release.
== Upgrade Notice ==
= 1.1.4 =
= 1.1.3 =
= 1.1.2 =
= 1.1.1 =

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 70 KiB

BIN
screenshot-4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -3,7 +3,7 @@
Plugin Name: WP-GPX-Maps
Plugin URI: http://www.darwinner.it/
Description: Draws a gpx track with altitude graph
Version: 1.1.3
Version: 1.1.4
Author: Bastianon Massimo
Author URI: http://www.pedemontanadelgrappa.it/
License: GPL
@ -79,6 +79,9 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$showW = findValue($attr, "waypoints", "wpgpxmaps_show_waypoint", false);
$donotreducegpx = findValue($attr, "donotreducegpx", "wpgpxmaps_donotreducegpx", false);
$pointsoffset = findValue($attr, "pointsoffset", "wpgpxmaps_pointsoffset", 10);
$uom = findValue($attr, "uom", "wpgpxmaps_unit_of_measure", "0");
$color_map = findValue($attr, "mlinecolor", "wpgpxmaps_map_line_color", "#3366cc");
$color_graph = findValue($attr, "glinecolor", "wpgpxmaps_graph_line_color", "#3366cc");
$r = rand(1,5000000);
@ -105,8 +108,17 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
foreach ($points as $p) {
$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 ($uom == '1')
{
// Miles and feet
$points_graph .= '['.((float)$p[3]*0.000621371192).','.((float)$p[2]*3.2808399).'],';
}
else
{
$points_graph .= '['.(float)$p[3].','.(float)$p[2].'],';
}
}
if ($showW == true)
{
@ -135,7 +147,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
var m_'.$r.' = ['.$points_maps.'];
var c_'.$r.' = ['.$points_graph.'];
var w_'.$r.' = ['.$waypoints.'];
wpgpxmaps("'.$r.'","'.$mt.'",m_'.$r.',c_'.$r.', w_'.$r.');
wpgpxmaps("'.$r.'","'.$mt.'",m_'.$r.',c_'.$r.', w_'.$r.', "'.$uom.'", "'.$color_map.'", "'.$color_graph.'");
</script>';
return $output;
@ -174,6 +186,9 @@ function WP_GPX_Maps_install() {
add_option('wpgpxmaps_show_waypoint','','','yes');
add_option('wpgpxmaps_pointsoffset','10','','yes');
add_option('wpgpxmaps_donotreducegpx','true','','yes');
add_option("wpgpxmaps_unit_of_measure", 'mt', '', 'yes');
add_option("wpgpxmaps_graph_line_color", '#3366cc', '', 'yes');
add_option("wpgpxmaps_map_line_color", '#3366cc', '', 'yes');
}
function WP_GPX_Maps_remove() {
@ -184,6 +199,10 @@ function WP_GPX_Maps_remove() {
delete_option('wpgpxmaps_show_waypoint');
delete_option('wpgpxmaps_pointsoffset');
delete_option('wpgpxmaps_donotreducegpx');
delete_option('wpgpxmaps_unit_of_measure');
delete_option('wpgpxmaps_graph_line_color');
delete_option('wpgpxmaps_map_line_color');
}
?>

View File

@ -93,7 +93,7 @@
if ($lastLat == 0 && $lastLon == 0)
{
//Base Case
array_push($points, array((float)$lat,(float)$lon,(float)round($ele,1),(float)round($dist,1)));
array_push($points, array((float)$lat,(float)$lon,(float)round($ele,2),(float)round($dist,2)));
$lastLat=$lat;
$lastLon=$lon;
$lastEle=$ele;
@ -101,7 +101,7 @@
else
{
//Normal Case
$offset = calculateDistance($lat, $lon, $ele,$lastLat, $lastLon, $lastEle);
$offset = calculateDistance((float)$lat, (float)$lon, (float)$ele, (float)$lastLat, (float)$lastLon, (float)$lastEle);
$dist = $dist + $offset;
if (((float) $offset + (float) $lastOffset) > $gpxOffset)
{
@ -213,17 +213,18 @@
function toRadians($degrees)
{
return $degrees * 3.1415926535897932385 / 180;
return (float)($degrees * 3.1415926535897932385 / 180);
}
function calculateDistance($lat1,$lon1,$ele1,$lat2,$lon2,$ele2)
{
$alpha = (float)sin((float)toRadians((float) $lat2 - (float) $lat1) / 2);
$beta = (float)sin((float)toRadians((float) $lon2 - (float) $lon1) / 2);
//Distance in meters
$dLat = toRadians((float) $lat2 - (float) $lat1);
$dLng = toRadians((float) $lon2 - (float) $lon1);
$a = (float) ( sin($dLat / 2) * sin($dLat / 2)) + (float) ( cos( toRadians($lat1)) * cos( toRadians($lat2)) * sin($dLng / 2) * sin($dLng / 2) );
$dist = 2 * 3958.75 * atan2(sqrt($a), sqrt(1 - (float) $a));
return sqrt(pow($dist * 1609.00, 2) + pow((float) $lat1 - (float)$lat2, 2));
$a = (float) ( (float)$alpha * (float)$alpha) + (float) ( (float)cos( (float)toRadians($lat1)) * (float)cos( (float)toRadians($lat2)) * (float)$beta * (float)$beta );
$dist = 2 * 6369628.75 * (float)atan2((float)sqrt((float)$a), (float)sqrt(1 - (float) $a));
$d = (float)sqrt((float)pow((float)$dist, 2) + pow((float) $lat1 - (float)$lat2, 2));
return sqrt((float)pow((float)$ele1-(float)$ele2,2)+(float)pow((float)$d,2));
}

View File

@ -9,18 +9,33 @@ if ( is_admin() ){
}
}
function ilc_admin_tabs( $current ) {
$tabs = array( 'tracks' => 'Tracks', 'settings' => 'Settings', 'help' => "help" );
echo '<h2 class="nav-tab-wrapper">';
foreach( $tabs as $tab => $name ){
$class = ( $tab == $current ) ? ' nav-tab-active' : '';
echo "<a class='nav-tab$class' href='?page=WP-GPX-Maps&tab=$tab'>$name</a>";
}
echo '</h2>';
}
function WP_GPX_Maps_html_page() {
$realGpxPath = gpxFolderPath();
$relativeGpxPath = relativeGpxFolderPath();
$relativeGpxPath = str_replace("\\","/", $relativeGpxPath);
$gpxRegEx = '/.gpx$/';
?>
<div>
<h2>WP GPX Settings</h2>
<?php
$tab = $_GET['tab'];
if ($tab == '')
$tab = 'tracks';
?>
<div id="icon-themes" class="icon32"><br></div>
<h2>WP GPX Settings</h2>
<?php
if(file_exists($realGpxPath) && is_dir($realGpxPath))
{
//dir exsist!
@ -34,196 +49,63 @@ function WP_GPX_Maps_html_page() {
</div>';
}
}
$po = get_option('wpgpxmaps_pointsoffset');
$showW = get_option("wpgpxmaps_show_waypoint");
$donotreducegpx = get_option("wpgpxmaps_donotreducegpx");
$t = get_option('wpgpxmaps_map_type');
if (!($t))
$t = 'HYBRID';
if (!($po))
$po = 10;
ilc_admin_tabs($tab);
if ($tab == "tracks")
{
include 'wp-gpx-maps_admin_tracks.php';
}
else if ($tab == "settings")
{
include 'wp-gpx-maps_admin_settings.php';
}
else if ($tab == "help")
{
?>
<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="<?php echo $relativeGpxPath; ?>&lt gpx file name &gt"]</b> in the pages/posts.
<p>
<i>Full set of attributes:</i> <b>[sgpx gpx="<?php echo $relativeGpxPath; ?>&lt gpx file name &gt" width=100% mheight=450px gheight=200px mtype=SATELLITE waypoints=true donotreducegpx=false pointsoffset=10]</b>
</p>
</div>
<div style="padding:10px;">
<b>The fastest way to use this plugin:</b><br /> upload the file using the uploader in the first tab, than copy the shortcode from the list and paste it in the pages/posts.
<p>You can manually set the relative path to your gpx: <b>[sgpx gpx="<?php echo $relativeGpxPath; ?>&lt gpx file name &gt"]</b>.</p>
<p>You can also use gpx from other sites: <b>[sgpx gpx="http://www.someone.com/somewhere/somefile.gpx"]</b></p>
<hr />
<p>
<i>Full set of attributes:</i> <b>[sgpx
gpx="<?php echo $relativeGpxPath; ?>&lt gpx file name &gt"
width=100%
mheight=450px
gheight=200px
mtype=SATELLITE
waypoints=true
donotreducegpx=false
pointsoffset=10
uom=0
mlinecolor=#3366cc
glinecolor=#3366cc]</b>
<form method="post" action="options.php">
<ul>
<li><b>gpx</b>: relative path to gpx</li>
<li><b>width</b>: width in pixels</li>
<li><b>mheight</b>: map height</li>
<li><b>gheight</b>: graph height</li>
<li><b>mtype</b>: map aviable types are: HYBRID, ROADMAP, SATELLITE, TERRAIN</li>
<li><b>waypoints</b>: print the gpx waypoints inside the map (default is FALSE)</li>
<li><b>donotreducegpx</b>: Print all the point without reduce it (default is FALSE)</li>
<li><b>pointsoffset</b>: Skip points closer than XX meters(default is 10)</li>
<li><b>uom</b>: the unit of measure values are: 0, 1 (0 = meters, 1 = miles/feet)</li>
<li><b>mlinecolor</b>: map line color (default is #3366cc)</li>
<li><b>glinecolor</b>: graph line color (default is #3366cc)</li>
</ul>
<?php wp_nonce_field('update-options') ?>
<table width="100%">
<tr>
<th width="150" scope="row">Default Options:</th>
<td>
<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>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>
</td>
</tr>
<tr>
<th scope="row">Default Map Type:</th>
<td>
<br />
<input type="radio" name="wpgpxmaps_map_type" value="HYBRID" <?php if ($t == 'HYBRID') echo 'checked'; ?> > HYBRID: transparent layer of major streets on satellite images.<br />
<input type="radio" name="wpgpxmaps_map_type" value="ROADMAP" <?php if ($t == 'ROADMAP') echo 'checked'; ?>> ROADMAP: normal street map.<br />
<input type="radio" name="wpgpxmaps_map_type" value="SATELLITE" <?php if ($t == 'SATELLITE') echo 'checked'; ?>> SATELLITE: satellite images.<br />
<input type="radio" name="wpgpxmaps_map_type" value="TERRAIN" <?php if ($t == 'TERRAIN') echo 'checked'; ?>> TERRAIN: maps with physical features such as terrain and vegetation.<br />
</td>
</tr>
<tr>
<th scope="row">Advanced options:</th>
<td>
<br />
<b>Do not edit if you don't know what you are doing!</b><br />
<i>Skip points closer than </i> <input name="wpgpxmaps_pointsoffset" type="text" id="wpgpxmaps_pointsoffset" value="<?php echo $po ?>" style="width:50px;" /><i>meters</i>.
<input name="wpgpxmaps_donotreducegpx" type="checkbox" value="true" <?php if($donotreducegpx == true){echo('checked');} ?> onchange="this.value = (this.checked)" /><i>Do not reduce gpx</i>.
</td>
</tr>
</table>
<input type="hidden" name="action" value="update" />
<input name="page_options" type="hidden" value="wpgpxmaps_map_type,wpgpxmaps_height,wpgpxmaps_graph_height,wpgpxmaps_width,wpgpxmaps_show_waypoint,wpgpxmaps_pointsoffset,wpgpxmaps_donotreducegpx" />
<p>
<input type="submit" value="<?php _e('Save Changes') ?>" />
</p>
</form>
<?php
if ( isset($_POST['delete']) )
{
$del = $_POST['delete'];
if (preg_match($gpxRegEx, $del ) && file_exists($realGpxPath ."/". $del))
{
unlink($realGpxPath ."/". $del);
}
}
if ( is_writable ( $realGpxPath ) ){
?>
<div class="tablenav top">
<form enctype="multipart/form-data" method="POST">
Choose a file to upload: <input name="uploadedfile" type="file" onchange="submitgpx(this);" />
<?php
if ( isset($_FILES['uploadedfile']) )
{
$target_path = $realGpxPath ."/". basename( $_FILES['uploadedfile']['name']);
if (preg_match($gpxRegEx, $target_path))
{
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "File <b>". basename( $_FILES['uploadedfile']['name']). "</b> has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
}
else
{
echo "file not supported!";
}
}
?>
</form>
</div>
<?php
}
if ( is_readable ( $realGpxPath ) && $handle = opendir($realGpxPath)) {
?>
<table cellspacing="0" class="wp-list-table widefat plugins">
<thead>
<tr>
<th style="" class="manage-column" id="name" scope="col">File</th>
<th style="" class="manage-column" id="name" scope="col">Last modified</th>
<th style="" class="manage-column" id="name" scope="col">File size (Byte)</th>
</tr>
</thead>
<tfoot>
<tr>
<th style="" class="manage-column" id="name" scope="col">File</th>
<th style="" class="manage-column" id="name" scope="col">Last modified</th>
<th style="" class="manage-column" id="name" scope="col">File size (Byte)</th>
</tr>
</tfoot>
<tbody id="the-list">
<p>
<a href="http://www.darwinner.it/featured/wp-gpx-maps/">Bugs, problems, thanks and anything else here!</a>
</p>
<?php
while (false !== ($entry = readdir($handle))) {
if (preg_match($gpxRegEx,$entry ))
{
$file = $realGpxPath . "/" . $entry;
?>
<tr>
<td style="border:none; padding-bottom:0;">
<strong><?php echo $entry; ?></strong>
</td>
<td style="border:none; padding-bottom:0;">
<?php echo date ("F d Y H:i:s.", filemtime( $file ) ) ?>
</td>
<td style="border:none; padding-bottom:0;">
<?php echo number_format ( filesize( $file ) , 0, '.', ',' ) ?>
</td>
</tr>
<tr>
<td colspan=3 style="padding: 0px 7px 7px 7px;">
<a href="#" onclick="delgpx('<?php echo $entry ?>'); return false;">Delete</a>
|
<a href="../wp-content/uploads/gpx/<?php echo $entry?>">Download</a>
|
Shortcode: [sgpx gpx="<?php echo $relativeGpxPath . $entry; ?>"]
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</p>
</div>
<?php
closedir($handle);
} ?>
</div>
<script type="text/javascript">
function submitgpx(el)
{
var newEl = document.createElement('span');
newEl.innerHTML = 'Uploading file...';
el.parentNode.insertBefore(newEl,el.nextSibling);
el.parentNode.submit()
}
function delgpx(file)
{
if (confirm('Delete this file: ' + file + '?'))
{
document.formdelgpx.delete.value = file;
document.formdelgpx.submit();
}
}
</script>
<form method="post" name="formdelgpx" style="display:none;">
<input type="hidden" name="delete" />
</form>
<?php
}
}
?>

View File

@ -0,0 +1,89 @@
<script type="text/javascript" src="http://meta100.github.com/mColorPicker/javascripts/mColorPicker_min.js" charset="UTF-8"></script>
<?php
$po = get_option('wpgpxmaps_pointsoffset');
$showW = get_option("wpgpxmaps_show_waypoint");
$donotreducegpx = get_option("wpgpxmaps_donotreducegpx");
$t = get_option('wpgpxmaps_map_type');
$uom = get_option('wpgpxmaps_unit_of_measure');
if (!($t))
$t = 'HYBRID';
if (!($po))
$po = 10;
?>
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<table width="100%">
<tr>
<th width="150" scope="row">Map and Graph size:</th>
<td>
<i>Width:</i> <input name="wpgpxmaps_width" type="text" id="wpgpxmaps_width" value="<?php echo get_option('wpgpxmaps_width'); ?>" style="width:50px;" />,
<i>Map 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;" />
</td>
</tr>
<tr><td></td><td></td></tr>
<tr>
<th scope="row">Waypoints Support:</th>
<td>
<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>
</tr>
<tr><td></td><td></td></tr>
<tr>
<th scope="row">Default Map Type:</th>
<td>
<input type="radio" name="wpgpxmaps_map_type" value="HYBRID" <?php if ($t == 'HYBRID') echo 'checked'; ?> > HYBRID: transparent layer of major streets on satellite images.<br />
<input type="radio" name="wpgpxmaps_map_type" value="ROADMAP" <?php if ($t == 'ROADMAP') echo 'checked'; ?>> ROADMAP: normal street map.<br />
<input type="radio" name="wpgpxmaps_map_type" value="SATELLITE" <?php if ($t == 'SATELLITE') echo 'checked'; ?>> SATELLITE: satellite images.<br />
<input type="radio" name="wpgpxmaps_map_type" value="TERRAIN" <?php if ($t == 'TERRAIN') echo 'checked'; ?>> TERRAIN: maps with physical features such as terrain and vegetation.<br />
</td>
</tr>
<tr><td></td><td></td></tr>
<tr>
<th scope="row">Unit of measure:</th>
<td>
<select name='wpgpxmaps_unit_of_measure'>
<option value="0" <?php if ($uom == '0') echo 'selected'; ?>>meters</option>
<option value="1" <?php if ($uom == '1') echo 'selected'; ?>>miles/feet</option>
</select>
</td>
</tr>
<tr>
<th scope="row">Map line color:</th>
<td>
<input name="wpgpxmaps_map_line_color" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_map_line_color'); ?>" />
</td>
</tr>
<tr>
<th scope="row">Graph line color:</th>
<td>
<input name="wpgpxmaps_graph_line_color" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color'); ?>" />
</td>
</tr>
<tr>
<th scope="row">Advanced options:</th>
<td>
<br />
<b>Do not edit if you don't know what you are doing!</b><br />
<i>Skip points closer than </i> <input name="wpgpxmaps_pointsoffset" type="text" id="wpgpxmaps_pointsoffset" value="<?php echo $po ?>" style="width:50px;" /><i>meters</i>.
<input name="wpgpxmaps_donotreducegpx" type="checkbox" value="true" <?php if($donotreducegpx == true){echo('checked');} ?> onchange="this.value = (this.checked)" /><i>Do not reduce gpx</i>.
</td>
</tr>
</table>
<input type="hidden" name="action" value="update" />
<input name="page_options" type="hidden" value="wpgpxmaps_map_type,wpgpxmaps_height,wpgpxmaps_graph_height,wpgpxmaps_width,wpgpxmaps_show_waypoint,wpgpxmaps_pointsoffset,wpgpxmaps_donotreducegpx,wpgpxmaps_unit_of_measure,wpgpxmaps_map_line_color,wpgpxmaps_graph_line_color" />
<p>
<input type="submit" value="<?php _e('Save Changes') ?>" />
</p>
</form>

View File

@ -0,0 +1,126 @@
<?php
if ( isset($_POST['delete']) )
{
$del = $_POST['delete'];
if (preg_match($gpxRegEx, $del ) && file_exists($realGpxPath ."/". $del))
{
unlink($realGpxPath ."/". $del);
}
}
if ( is_writable ( $realGpxPath ) ){
?>
<div class="tablenav top">
<form enctype="multipart/form-data" method="POST">
Choose a file to upload: <input name="uploadedfile" type="file" onchange="submitgpx(this);" />
<?php
if ( isset($_FILES['uploadedfile']) )
{
$target_path = $realGpxPath ."/". basename( $_FILES['uploadedfile']['name']);
if (preg_match($gpxRegEx, $target_path))
{
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "File <b>". basename( $_FILES['uploadedfile']['name']). "</b> has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
}
else
{
echo "file not supported!";
}
}
?>
</form>
</div>
<?php
}
if ( is_readable ( $realGpxPath ) && $handle = opendir($realGpxPath)) {
?>
<table cellspacing="0" class="wp-list-table widefat plugins">
<thead>
<tr>
<th style="" class="manage-column" id="name" scope="col">File</th>
<th style="" class="manage-column" id="name" scope="col">Last modified</th>
<th style="" class="manage-column" id="name" scope="col">File size (Byte)</th>
</tr>
</thead>
<tfoot>
<tr>
<th style="" class="manage-column" id="name" scope="col">File</th>
<th style="" class="manage-column" id="name" scope="col">Last modified</th>
<th style="" class="manage-column" id="name" scope="col">File size (Byte)</th>
</tr>
</tfoot>
<tbody id="the-list">
<?php
while (false !== ($entry = readdir($handle))) {
if (preg_match($gpxRegEx,$entry ))
{
$file = $realGpxPath . "/" . $entry;
?>
<tr>
<td style="border:none; padding-bottom:0;">
<strong><?php echo $entry; ?></strong>
</td>
<td style="border:none; padding-bottom:0;">
<?php echo date ("F d Y H:i:s.", filemtime( $file ) ) ?>
</td>
<td style="border:none; padding-bottom:0;">
<?php echo number_format ( filesize( $file ) , 0, '.', ',' ) ?>
</td>
</tr>
<tr>
<td colspan=3 style="padding: 0px 7px 7px 7px;">
<a href="#" onclick="delgpx('<?php echo $entry ?>'); return false;">Delete</a>
|
<a href="../wp-content/uploads/gpx/<?php echo $entry?>">Download</a>
|
Shortcode: [sgpx gpx="<?php echo $relativeGpxPath . $entry; ?>"]
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<?php
closedir($handle);
} ?>
<script type="text/javascript">
function submitgpx(el)
{
var newEl = document.createElement('span');
newEl.innerHTML = 'Uploading file...';
el.parentNode.insertBefore(newEl,el.nextSibling);
el.parentNode.submit()
}
function delgpx(file)
{
if (confirm('Delete this file: ' + file + '?'))
{
document.formdelgpx.delete.value = file;
document.formdelgpx.submit();
}
}
</script>
<form method="post" name="formdelgpx" style="display:none;">
<input type="hidden" name="delete" />
</form>