fix cadence

added avg cadence
This commit is contained in:
bastianonm 2018-12-08 09:44:28 +00:00
parent 15ad51122d
commit 27964e6587
6 changed files with 852 additions and 830 deletions

View File

@ -5,7 +5,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: maps, gpx, gps, graph, chart, leaflet, track, garmin, image, nextgen-gallery, nextgen, exif, OpenStreetMap, OpenCycleMap, Hike&Bike, heart rate, heartrate, cadence Tags: maps, gpx, gps, graph, chart, leaflet, track, garmin, image, nextgen-gallery, nextgen, exif, OpenStreetMap, OpenCycleMap, Hike&Bike, heart rate, heartrate, cadence
Requires at least: 2.0.0 Requires at least: 2.0.0
Tested up to: 4.9.8 Tested up to: 4.9.8
Stable tag: 1.6.04 Stable tag: 1.6.05
Draws a gpx track with altitude graph. You can also display your nextgen gallery images in the map. Draws a gpx track with altitude graph. You can also display your nextgen gallery images in the map.
@ -153,6 +153,9 @@ Yes!
1. Altitude & Speed & Hearth rate 1. Altitude & Speed & Hearth rate
== Changelog == == Changelog ==
= 1.6.05 =
* Added avg cadence (thanks to cyclinggeorgian)
* fix cadence in old gpx devices
= 1.6.04 = = 1.6.04 =
* NGG gallery is working * NGG gallery is working
* Getting HR, Cad and Temp working again (thanks to cyclinggeorgian) * Getting HR, Cad and Temp working again (thanks to cyclinggeorgian)

View File

@ -3,7 +3,7 @@
* Plugin Name: WP-GPX-Maps * Plugin Name: WP-GPX-Maps
* Plugin URI: http://www.devfarm.it/ * Plugin URI: http://www.devfarm.it/
* Description: Draws a GPX track with altitude chart * Description: Draws a GPX track with altitude chart
* Version: 1.6.04 * Version: 1.6.05
* Author: Bastianon Massimo * Author: Bastianon Massimo
* Author URI: http://www.devfarm.it/ * Author URI: http://www.devfarm.it/
* Text Domain: wp-gpx-maps * Text Domain: wp-gpx-maps
@ -280,6 +280,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$p_total_ele_up = wpgpxmaps_findValue($attr, "summaryeleup", "wpgpxmaps_summary_total_ele_up", false); $p_total_ele_up = wpgpxmaps_findValue($attr, "summaryeleup", "wpgpxmaps_summary_total_ele_up", false);
$p_total_ele_down = wpgpxmaps_findValue($attr, "summaryeledown", "wpgpxmaps_summary_total_ele_down", false); $p_total_ele_down = wpgpxmaps_findValue($attr, "summaryeledown", "wpgpxmaps_summary_total_ele_down", false);
$p_avg_speed = wpgpxmaps_findValue($attr, "summaryavgspeed", "wpgpxmaps_summary_avg_speed", false); $p_avg_speed = wpgpxmaps_findValue($attr, "summaryavgspeed", "wpgpxmaps_summary_avg_speed", false);
$p_avg_cad = wpgpxmaps_findValue($attr, "summaryavgcad", "wpgpxmaps_summary_avg_cad", false);
$p_total_time = wpgpxmaps_findValue($attr, "summarytotaltime", "wpgpxmaps_summary_total_time", false); $p_total_time = wpgpxmaps_findValue($attr, "summarytotaltime", "wpgpxmaps_summary_total_time", false);
$usegpsposition = wpgpxmaps_findValue($attr, "usegpsposition", "wpgpxmaps_usegpsposition", false); $usegpsposition = wpgpxmaps_findValue($attr, "usegpsposition", "wpgpxmaps_usegpsposition", false);
@ -296,7 +297,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
} else { } else {
$mtime = 0; $mtime = 0;
} }
$cacheFileName = "$gpx,$mtime,$w,$mh,$mt,$gh,$showEle,$showW,$showHr,$showAtemp,$showCad,$donotreducegpx,$pointsoffset,$showSpeed,$showGrade,$uomspeed,$uom,$distanceType,v1.3.9"; $cacheFileName = "$gpx,$mtime,$w,$mh,$mt,$gh,$showEle,$showW,$showHr,$showAtemp,$showCad,$donotreducegpx,$avg_cad,$pointsoffset,$showSpeed,$showGrade,$uomspeed,$uom,$distanceType,v1.3.9";
$cacheFileName = md5($cacheFileName); $cacheFileName = md5($cacheFileName);
@ -332,6 +333,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$total_ele_up = $cache_obj["total_ele_up"]; $total_ele_up = $cache_obj["total_ele_up"];
$total_ele_down = $cache_obj["total_ele_down"]; $total_ele_down = $cache_obj["total_ele_down"];
$avg_speed = $cache_obj["avg_speed"]; $avg_speed = $cache_obj["avg_speed"];
$avg_cad = $cache_obj["avg_cad"];
$tot_len = $cache_obj["tot_len"]; $tot_len = $cache_obj["tot_len"];
} catch (Exception $e) { } catch (Exception $e) {
@ -354,6 +356,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$total_ele_up = 0; $total_ele_up = 0;
$total_ele_down = 0; $total_ele_down = 0;
$avg_speed = 0; $avg_speed = 0;
$avg_cad = 0;
$tot_len = 0; $tot_len = 0;
} }
} }
@ -402,6 +405,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$total_ele_up = $points->totalEleUp; $total_ele_up = $points->totalEleUp;
$total_ele_down = $points->totalEleDown; $total_ele_down = $points->totalEleDown;
$avg_speed = $points->avgSpeed; $avg_speed = $points->avgSpeed;
$avg_cad = $points->avgCad;
$tot_len = $points->totalLength; $tot_len = $points->totalLength;
if (is_array ($points_x_lat)) if (is_array ($points_x_lat))
@ -637,6 +641,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
"total_ele_up" => $total_ele_up, "total_ele_up" => $total_ele_up,
"total_ele_down" => $total_ele_down, "total_ele_down" => $total_ele_down,
"avg_speed" => $avg_speed, "avg_speed" => $avg_speed,
"avg_cad" => $avg_cad,
"tot_len" => $tot_len, "tot_len" => $tot_len,
"max_time" => $max_time, "max_time" => $max_time,
"min_time" => $min_time "min_time" => $min_time
@ -744,6 +749,10 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
{ {
$output .= "<span class='avgspeed'><span class='summarylabel'>".__("Average speed", "wp-gpx-maps").":</span><span class='summaryvalue'> $avg_speed</span></span><br />"; $output .= "<span class='avgspeed'><span class='summarylabel'>".__("Average speed", "wp-gpx-maps").":</span><span class='summaryvalue'> $avg_speed</span></span><br />";
} }
if ($points_graph_cad != '' && $p_avg_cad == 'true')
{
$output .= "<span class='avgcad'><span class='summarylabel'>".__("Average cadence", "wp-gpx-maps").":</span><span class='summaryvalue'> $avg_cad</span></span><br />";
}
if ($p_total_time == 'true' && $max_time > 0) if ($p_total_time == 'true' && $max_time > 0)
{ {
$time_diff = date("H:i:s", ($max_time - $min_time)); $time_diff = date("H:i:s", ($max_time - $min_time));

View File

@ -1,159 +1,159 @@
<?php <?php
if ( is_admin() ){ if ( is_admin() ){
add_action('admin_menu', 'wpgpxmaps_admin_menu'); add_action('admin_menu', 'wpgpxmaps_admin_menu');
} }
function wpgpxmaps_admin_menu() { function wpgpxmaps_admin_menu() {
if ( current_user_can('manage_options') ){ if ( current_user_can('manage_options') ){
add_options_page('WP GPX Maps', 'WP GPX Maps', 'manage_options', 'WP-GPX-Maps', 'WP_GPX_Maps_html_page'); add_options_page('WP GPX Maps', 'WP GPX Maps', 'manage_options', 'WP-GPX-Maps', 'WP_GPX_Maps_html_page');
} }
else if ( current_user_can('publish_posts') ) { else if ( current_user_can('publish_posts') ) {
add_menu_page('WP GPX Maps', 'WP GPX Maps', 'publish_posts', 'WP-GPX-Maps', 'WP_GPX_Maps_html_page'); add_menu_page('WP GPX Maps', 'WP GPX Maps', 'publish_posts', 'WP-GPX-Maps', 'WP_GPX_Maps_html_page');
} }
} }
function wpgpxmaps_ilc_admin_tabs( $current ) { function wpgpxmaps_ilc_admin_tabs( $current ) {
if (current_user_can('manage_options')) if (current_user_can('manage_options'))
{ {
$tabs = array( 'tracks' => 'Tracks', 'settings' => 'Settings', 'help' => "help" ); $tabs = array( 'tracks' => 'Tracks', 'settings' => 'Settings', 'help' => "help" );
} }
else if ( current_user_can('publish_posts') ) { else if ( current_user_can('publish_posts') ) {
$tabs = array( 'tracks' => 'Tracks', 'help' => "help" ); $tabs = array( 'tracks' => 'Tracks', 'help' => "help" );
} }
echo '<h2 class="nav-tab-wrapper">'; echo '<h2 class="nav-tab-wrapper">';
foreach( $tabs as $tab => $name ){ foreach( $tabs as $tab => $name ){
$class = ( $tab == $current ) ? ' nav-tab-active' : ''; $class = ( $tab == $current ) ? ' nav-tab-active' : '';
echo "<a class='nav-tab$class' href='?page=WP-GPX-Maps&tab=$tab'>$name</a>"; echo "<a class='nav-tab$class' href='?page=WP-GPX-Maps&tab=$tab'>$name</a>";
} }
echo '</h2>'; echo '</h2>';
} }
function WP_GPX_Maps_html_page() { function WP_GPX_Maps_html_page() {
$realGpxPath = gpxFolderPath(); $realGpxPath = gpxFolderPath();
$cacheGpxPath = gpxCacheFolderPath(); $cacheGpxPath = gpxCacheFolderPath();
$relativeGpxPath = relativeGpxFolderPath(); $relativeGpxPath = relativeGpxFolderPath();
$relativeGpxPath = str_replace("\\","/", $relativeGpxPath); $relativeGpxPath = str_replace("\\","/", $relativeGpxPath);
$tab = $_GET['tab']; $tab = $_GET['tab'];
if ($tab == '') if ($tab == '')
$tab = 'tracks'; $tab = 'tracks';
?> ?>
<div id="icon-themes" class="icon32"><br></div> <div id="icon-themes" class="icon32"><br></div>
<h2>WP GPX Settings</h2> <h2>WP GPX Settings</h2>
<?php <?php
if(file_exists($realGpxPath) && is_dir($realGpxPath)) if(file_exists($realGpxPath) && is_dir($realGpxPath))
{ {
//dir exsist! //dir exsist!
} }
else else
{ {
if (!@mkdir($realGpxPath,0755,true)) { if (!@mkdir($realGpxPath,0755,true)) {
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!
</div>'; </div>';
} }
} }
if(file_exists($cacheGpxPath) && is_dir($cacheGpxPath)) if(file_exists($cacheGpxPath) && is_dir($cacheGpxPath))
{ {
//dir exsist! //dir exsist!
} }
else else
{ {
if (!@mkdir($cacheGpxPath,0755,true)) { if (!@mkdir($cacheGpxPath,0755,true)) {
echo '<div class="error" style="padding:10px"> echo '<div class="error" style="padding:10px">
Can\'t create <b>'.$cacheGpxPath.'</b> folder. Please create it and make it writable!<br /> Can\'t create <b>'.$cacheGpxPath.'</b> folder. Please create it and make it writable!<br />
If not, cache will not created and your site could be slower! If not, cache will not created and your site could be slower!
</div>'; </div>';
} }
} }
wpgpxmaps_ilc_admin_tabs($tab); wpgpxmaps_ilc_admin_tabs($tab);
if ($tab == "tracks") if ($tab == "tracks")
{ {
include 'wp-gpx-maps_admin_tracks.php'; include 'wp-gpx-maps_admin_tracks.php';
} }
else if ($tab == "settings") else if ($tab == "settings")
{ {
include 'wp-gpx-maps_admin_settings.php'; include 'wp-gpx-maps_admin_settings.php';
} }
else if ($tab == "help") else if ($tab == "help")
{ {
?> ?>
<div style="padding:10px;"> <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. <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 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> <p>You can also use gpx from other sites: <b>[sgpx gpx="http://www.someone.com/somewhere/somefile.gpx"]</b></p>
<hr /> <hr />
<p> <p>
<i>Full set of attributes:</i> <b>[sgpx gpx="<?php echo $relativeGpxPath; ?>&lt gpx file name &gt" </b> <i>Full set of attributes:</i> <b>[sgpx gpx="<?php echo $relativeGpxPath; ?>&lt gpx file name &gt" </b>
&nbsp;&nbsp;&nbsp;<em>&gt&gt read below all the optional attributes &lt&lt</em>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<em>&gt&gt read below all the optional attributes &lt&lt</em>&nbsp;&nbsp;&nbsp;
<b>]</b> <b>]</b>
<ul> <ul>
<li><b>gpx</b>: relative path to gpx <li><b>gpx</b>: relative path to gpx
</li><li><b>width</b>: width in pixels </li><li><b>width</b>: width in pixels
</li><li><b>mheight</b>: map height </li><li><b>mheight</b>: map height
</li><li><b>gheight</b>: graph height </li><li><b>gheight</b>: graph height
</li><li><b>mtype</b>: map available types are: HYBRID, ROADMAP, SATELLITE, TERRAIN, OSM1 (Open Street Map), OSM2 (Open Cycle Map), OSM3 (Hike & Bike), OSM4 (Open Cycle Map - Transport), OSM5 (Open Cycle Map - Landscape), OSM6 (MapToolKit - Terrain) </li><li><b>mtype</b>: map available types are: HYBRID, ROADMAP, SATELLITE, TERRAIN, OSM1 (Open Street Map), OSM2 (Open Cycle Map), OSM3 (Hike & Bike), OSM4 (Open Cycle Map - Transport), OSM5 (Open Cycle Map - Landscape), OSM6 (MapToolKit - Terrain)
</li><li><b>waypoints</b>: print the gpx waypoints inside the map (default is FALSE) </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>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>pointsoffset</b>: skip points closer than XX meters(default is 10)
</li><li><b>uom</b>: distance/altitude possible unit of measure are: 0, 1, 2, 3, 4, 5 (0 = meters, 1 = feet/miles, 2 = meters/kilometers, 3 = meters/nautical miles, 4 = meters/miles, 5 = feet/nautical miles) </li><li><b>uom</b>: distance/altitude possible unit of measure are: 0, 1, 2, 3, 4, 5 (0 = meters, 1 = feet/miles, 2 = meters/kilometers, 3 = meters/nautical miles, 4 = meters/miles, 5 = feet/nautical miles)
</li><li><b>mlinecolor</b>: map line color (default is #3366cc) </li><li><b>mlinecolor</b>: map line color (default is #3366cc)
</li><li><b>glinecolor</b>: altitude line color (default is #3366cc) </li><li><b>glinecolor</b>: altitude line color (default is #3366cc)
</li><li><b>showspeed</b>: show speed inside the chart (default is FALSE) </li><li><b>showspeed</b>: show speed inside the chart (default is FALSE)
</li><li><b>showhr</b>: show heart rate inside the chart (default is FALSE) </li><li><b>showhr</b>: show heart rate inside the chart (default is FALSE)
</li><li><b>showele</b>: show elevation data inside the chart (default is TRUE) </li><li><b>showele</b>: show elevation data inside the chart (default is TRUE)
</li><li><b>showcad</b>: show cadence inside the chart (default is FALSE) </li><li><b>showcad</b>: show cadence inside the chart (default is FALSE)
</li><li><b>showgrade</b>: show grade inside the chart (default is FALSE) </li><li><b>showgrade</b>: show grade inside the chart (default is FALSE)
</li><li><b>glinecolorspeed</b>: speed line color (default is #ff0000) </li><li><b>glinecolorspeed</b>: speed line color (default is #ff0000)
</li><li><b>glinecolorhr</b>: heart rate line color (default is #ff77bd) </li><li><b>glinecolorhr</b>: heart rate line color (default is #ff77bd)
</li><li><b>glinecolorcad</b>: cadence line color (default is #beecff) </li><li><b>glinecolorcad</b>: cadence line color (default is #beecff)
</li><li><b>glinecolorgrade</b>: grade line color (default is #beecff) </li><li><b>glinecolorgrade</b>: grade line color (default is #beecff)
</li><li><b>uomspeed</b>: unit of measure for speed are: 0, 1, 2, 3, 4, 5 (0 = m/s, 1 = km/h, 2 = miles/h, 3 = min/km, 4 = min/miles, 5 = Nautical Miles/Hour (Knots), 6 = min/100 meters) </li><li><b>uomspeed</b>: unit of measure for speed are: 0, 1, 2, 3, 4, 5 (0 = m/s, 1 = km/h, 2 = miles/h, 3 = min/km, 4 = min/miles, 5 = Nautical Miles/Hour (Knots), 6 = min/100 meters)
</li><li><b>chartFrom1</b>: minimun value for altitude chart </li><li><b>chartFrom1</b>: minimun value for altitude chart
</li><li><b>chartTo1</b>: maxumin value for altitude chart </li><li><b>chartTo1</b>: maxumin value for altitude chart
</li><li><b>chartFrom2</b>: minimun value for speed chart </li><li><b>chartFrom2</b>: minimun value for speed chart
</li><li><b>chartTo2</b>: maxumin value for speed chart </li><li><b>chartTo2</b>: maxumin value for speed chart
</li><li><b>startIcon</b>: Start track icon </li><li><b>startIcon</b>: Start track icon
</li><li><b>endIcon</b>: End track icon </li><li><b>endIcon</b>: End track icon
</li><li><b>currentIcon</b>: Current position icon (when mouse hover) </li><li><b>currentIcon</b>: Current position icon (when mouse hover)
</li><li><b>waypointicon</b>: waypoint custom icon </li><li><b>waypointicon</b>: waypoint custom icon
</li><li><b>nggalleries</b>: NextGen Gallery id or a list of Galleries id separated by a comma </li><li><b>nggalleries</b>: NextGen Gallery id or a list of Galleries id separated by a comma
</li><li><b>ngimages</b>: NextGen Image id or a list of Images id separated by a comma </li><li><b>ngimages</b>: NextGen Image id or a list of Images id separated by a comma
</li><li><b>dtoffset</b>: the difference (in seconds) between your gpx tool date and your camera date </li><li><b>dtoffset</b>: the difference (in seconds) between your gpx tool date and your camera date
</li><li><b>zoomonscrollwheel</b>: zoom on map when mouse scroll wheel </li><li><b>zoomonscrollwheel</b>: zoom on map when mouse scroll wheel
</li><li><b>download</b>: Allow users to download your GPX file </li><li><b>download</b>: Allow users to download your GPX file
</li><li><b>skipcache</b>: Do not use cache. If TRUE might be very slow (default is FALSE) </li><li><b>skipcache</b>: Do not use cache. If TRUE might be very slow (default is FALSE)
</li><li><b>summary</b>: Print summary details of your GPX (default is FALSE) </li><li><b>summary</b>: Print summary details of your GPX (default is FALSE)
</li><li><b>summarytotlen</b>: Print Total distance in summary table (default is FALSE) </li><li><b>summarytotlen</b>: Print Total distance in summary table (default is FALSE)
</li><li><b>summarymaxele</b>: Print Max Elevation in summary table (default is FALSE) </li><li><b>summarymaxele</b>: Print Max Elevation in summary table (default is FALSE)
</li><li><b>summaryminele</b>: Print Min Elevation in summary table (default is FALSE) </li><li><b>summaryminele</b>: Print Min Elevation in summary table (default is FALSE)
</li><li><b>summaryeleup</b>: Print Total climbing in summary table (default is FALSE) </li><li><b>summaryeleup</b>: Print Total climbing in summary table (default is FALSE)
</li><li><b>summaryeledown</b>: Print Total descent in summary table (default is FALSE) </li><li><b>summaryeledown</b>: Print Total descent in summary table (default is FALSE)
</li><li><b>summaryavgspeed</b>: Print Average Speed in summary table (default is FALSE) </li><li><b>summaryavgspeed</b>: Print Average Speed in summary table (default is FALSE)</li><li><b>summaryavgcad</b>: Print Average Cadence in summary table (default is FALSE)
</li><li><b>summarytotaltime</b>: Print Total time in summary table (default is FALSE) </li> </li><li><b>summarytotaltime</b>: Print Total time in summary table (default is FALSE) </li>
</ul> </ul>
<p> <p>
<a href="http://devfarm.it/forums/forum/wp-gpx-maps/">Bugs, problems, thanks and anything else here!</a> <a href="http://devfarm.it/forums/forum/wp-gpx-maps/">Bugs, problems, thanks and anything else here!</a>
</p> </p>
</p> </p>
</div> </div>
<?php <?php
} }
} }
?> ?>

View File

@ -1,459 +1,459 @@
<?php <?php
if ( !current_user_can('manage_options') ) if ( !current_user_can('manage_options') )
return; return;
$po = get_option('wpgpxmaps_pointsoffset'); $po = get_option('wpgpxmaps_pointsoffset');
$showW = get_option("wpgpxmaps_show_waypoint"); $showW = get_option("wpgpxmaps_show_waypoint");
$donotreducegpx = get_option("wpgpxmaps_donotreducegpx"); $donotreducegpx = get_option("wpgpxmaps_donotreducegpx");
$t = get_option('wpgpxmaps_map_type'); $t = get_option('wpgpxmaps_map_type');
$uom = get_option('wpgpxmaps_unit_of_measure'); $uom = get_option('wpgpxmaps_unit_of_measure');
$uomSpeed = get_option('wpgpxmaps_unit_of_measure_speed'); $uomSpeed = get_option('wpgpxmaps_unit_of_measure_speed');
$showEle = get_option("wpgpxmaps_show_elevation"); $showEle = get_option("wpgpxmaps_show_elevation");
$showSpeed = get_option('wpgpxmaps_show_speed'); $showSpeed = get_option('wpgpxmaps_show_speed');
$showHr = get_option('wpgpxmaps_show_hr'); $showHr = get_option('wpgpxmaps_show_hr');
$showAtemp = get_option('wpgpxmaps_show_atemp'); $showAtemp = get_option('wpgpxmaps_show_atemp');
$showCad = get_option('wpgpxmaps_show_cadence'); $showCad = get_option('wpgpxmaps_show_cadence');
$showGrade = get_option('wpgpxmaps_show_grade'); $showGrade = get_option('wpgpxmaps_show_grade');
$zoomonscrollwheel = get_option("wpgpxmaps_zoomonscrollwheel"); $zoomonscrollwheel = get_option("wpgpxmaps_zoomonscrollwheel");
$download = get_option("wpgpxmaps_download"); $download = get_option("wpgpxmaps_download");
$skipcache = get_option("wpgpxmaps_skipcache"); $skipcache = get_option("wpgpxmaps_skipcache");
$summary = get_option("wpgpxmaps_summary"); $summary = get_option("wpgpxmaps_summary");
$tot_len = get_option("wpgpxmaps_summary_tot_len"); $tot_len = get_option("wpgpxmaps_summary_tot_len");
$min_ele = get_option("wpgpxmaps_summary_min_ele"); $min_ele = get_option("wpgpxmaps_summary_min_ele");
$max_ele = get_option("wpgpxmaps_summary_max_ele"); $max_ele = get_option("wpgpxmaps_summary_max_ele");
$total_ele_up = get_option("wpgpxmaps_summary_total_ele_up"); $total_ele_up = get_option("wpgpxmaps_summary_total_ele_up");
$total_ele_down = get_option("wpgpxmaps_summary_total_ele_down"); $total_ele_down = get_option("wpgpxmaps_summary_total_ele_down");
$avg_speed = get_option("wpgpxmaps_summary_avg_speed"); $avg_speed = get_option("wpgpxmaps_summary_avg_speed"); $avg_cad = get_option("wpgpxmaps_summary_avg_cad");
$total_time = get_option("wpgpxmaps_summary_total_time"); $total_time = get_option("wpgpxmaps_summary_total_time");
$usegpsposition = get_option("wpgpxmaps_usegpsposition"); $usegpsposition = get_option("wpgpxmaps_usegpsposition");
$distanceType = get_option("wpgpxmaps_distance_type"); $distanceType = get_option("wpgpxmaps_distance_type");
if (empty($showEle)) if (empty($showEle))
$showEle = "true"; $showEle = "true";
if (!($t)) if (!($t))
$t = 'HYBRID'; $t = 'HYBRID';
if (!($po)) if (!($po))
$po = 10; $po = 10;
?> ?>
<form method="post" action="options.php"> <form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?> <?php wp_nonce_field('update-options') ?>
<h3 class="title">General</h3> <h3 class="title">General</h3>
<table class="form-table"> <table class="form-table">
<tr> <tr>
<th scope="row">Width:</th> <th scope="row">Width:</th>
<td> <td>
<input name="wpgpxmaps_width" type="text" id="wpgpxmaps_width" value="<?php echo get_option('wpgpxmaps_width'); ?>" style="width:50px;" /> <input name="wpgpxmaps_width" type="text" id="wpgpxmaps_width" value="<?php echo get_option('wpgpxmaps_width'); ?>" style="width:50px;" />
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Map Height:</th> <th scope="row">Map Height:</th>
<td> <td>
<input name="wpgpxmaps_height" type="text" id="wpgpxmaps_height" value="<?php echo get_option('wpgpxmaps_height'); ?>" style="width:50px;" /> <input name="wpgpxmaps_height" type="text" id="wpgpxmaps_height" value="<?php echo get_option('wpgpxmaps_height'); ?>" style="width:50px;" />
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Graph Height:</th> <th scope="row">Graph Height:</th>
<td> <td>
<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_graph_height" type="text" id="wpgpxmaps_graph_height" value="<?php echo get_option('wpgpxmaps_graph_height'); ?>" style="width:50px;" />
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Distance type:</th> <th scope="row">Distance type:</th>
<td> <td>
<select name='wpgpxmaps_distance_type'> <select name='wpgpxmaps_distance_type'>
<option value="0" <?php if ($distanceType == '0' || $distanceType == '') echo 'selected'; ?>>Normal (default)</option> <option value="0" <?php if ($distanceType == '0' || $distanceType == '') echo 'selected'; ?>>Normal (default)</option>
<option value="1" <?php if ($distanceType == '1') echo 'selected'; ?>>Flat &#8594; (Only flat distance, don't take care of altitude)</option> <option value="1" <?php if ($distanceType == '1') echo 'selected'; ?>>Flat &#8594; (Only flat distance, don't take care of altitude)</option>
<option value="2" <?php if ($distanceType == '2') echo 'selected'; ?>>Climb &#8593; (Only climb distance)</option> <option value="2" <?php if ($distanceType == '2') echo 'selected'; ?>>Climb &#8593; (Only climb distance)</option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Cache:</th> <th scope="row">Cache:</th>
<td> <td>
<input name="wpgpxmaps_skipcache" type="checkbox" value="true" <?php if($skipcache == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Do not use cache</i> <input name="wpgpxmaps_skipcache" type="checkbox" value="true" <?php if($skipcache == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Do not use cache</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">GPX Download:</th> <th scope="row">GPX Download:</th>
<td> <td>
<input name="wpgpxmaps_download" type="checkbox" value="true" <?php if($download == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Allow users to download your GPX file</i> <input name="wpgpxmaps_download" type="checkbox" value="true" <?php if($download == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Allow users to download your GPX file</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Use browser GPS position:</th> <th scope="row">Use browser GPS position:</th>
<td> <td>
<input name="wpgpxmaps_usegpsposition" type="checkbox" value="true" <?php if($usegpsposition == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Allow users to use browser GPS in order to display their current position on map</i> <input name="wpgpxmaps_usegpsposition" type="checkbox" value="true" <?php if($usegpsposition == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Allow users to use browser GPS in order to display their current position on map</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Google maps api key:</th> <th scope="row">Google maps api key:</th>
<td> <td>
<input name="wpgpxmaps_googlemapsv3_apikey" type="text" id="wpgpxmaps_googlemapsv3_apikey" value="<?php echo get_option('wpgpxmaps_googlemapsv3_apikey'); ?>" style="width:400px" /> <em> Go to the <a href="https://developers.google.com/maps/documentation/javascript/" target="_blank">Google API Console</a> and click &#8216;Get A Key&#8217; </em> <input name="wpgpxmaps_googlemapsv3_apikey" type="text" id="wpgpxmaps_googlemapsv3_apikey" value="<?php echo get_option('wpgpxmaps_googlemapsv3_apikey'); ?>" style="width:400px" /> <em> Go to the <a href="https://developers.google.com/maps/documentation/javascript/" target="_blank">Google API Console</a> and click &#8216;Get A Key&#8217; </em>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Thunderforest api key (Open Cycle Map):</th> <th scope="row">Thunderforest api key (Open Cycle Map):</th>
<td> <td>
<input name="wpgpxmaps_openstreetmap_apikey" type="text" id="wpgpxmaps_openstreetmap_apikey" value="<?php echo get_option('wpgpxmaps_openstreetmap_apikey'); ?>" style="width:400px" /> <em> Go to <a href="http://www.thunderforest.com/docs/apikeys/" target="_blank">Thunderforest API Keys</a> and click &#8216;signing in to your Thunderforest account&#8217; </em> <input name="wpgpxmaps_openstreetmap_apikey" type="text" id="wpgpxmaps_openstreetmap_apikey" value="<?php echo get_option('wpgpxmaps_openstreetmap_apikey'); ?>" style="width:400px" /> <em> Go to <a href="http://www.thunderforest.com/docs/apikeys/" target="_blank">Thunderforest API Keys</a> and click &#8216;signing in to your Thunderforest account&#8217; </em>
</td> </td>
</tr> </tr>
</table> </table>
<p class="submit"> <p class="submit">
<input type="hidden" name="action" value="update" /> <input type="hidden" name="action" value="update" />
<input name="page_options" type="hidden" value="wpgpxmaps_height,wpgpxmaps_graph_height,wpgpxmaps_width,wpgpxmaps_download,wpgpxmaps_skipcache,wpgpxmaps_distance_type,wpgpxmaps_usegpsposition,wpgpxmaps_googlemapsv3_apikey,wpgpxmaps_openstreetmap_apikey" /> <input name="page_options" type="hidden" value="wpgpxmaps_height,wpgpxmaps_graph_height,wpgpxmaps_width,wpgpxmaps_download,wpgpxmaps_skipcache,wpgpxmaps_distance_type,wpgpxmaps_usegpsposition,wpgpxmaps_googlemapsv3_apikey,wpgpxmaps_openstreetmap_apikey" />
<input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" /> <input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" />
</p> </p>
</form> </form>
<hr /> <hr />
<form method="post" action="options.php"> <form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?> <?php wp_nonce_field('update-options') ?>
<h3 class="title">Summary table</h3> <h3 class="title">Summary table</h3>
<table class="form-table"> <table class="form-table">
<tr> <tr>
<th scope="row">Summary table:</th> <th scope="row">Summary table:</th>
<td> <td>
<input name="wpgpxmaps_summary" type="checkbox" value="true" <?php if($summary == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print summary table</i> <input name="wpgpxmaps_summary" type="checkbox" value="true" <?php if($summary == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print summary table</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Total distance:</th> <th scope="row">Total distance:</th>
<td> <td>
<input name="wpgpxmaps_summary_tot_len" type="checkbox" value="true" <?php if($tot_len == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Total distance</i> <input name="wpgpxmaps_summary_tot_len" type="checkbox" value="true" <?php if($tot_len == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Total distance</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Max Elevation:</th> <th scope="row">Max Elevation:</th>
<td> <td>
<input name="wpgpxmaps_summary_max_ele" type="checkbox" value="true" <?php if($max_ele == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Max Elevation</i> <input name="wpgpxmaps_summary_max_ele" type="checkbox" value="true" <?php if($max_ele == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Max Elevation</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Min Elevation:</th> <th scope="row">Min Elevation:</th>
<td> <td>
<input name="wpgpxmaps_summary_min_ele" type="checkbox" value="true" <?php if($min_ele == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Min Elevation</i> <input name="wpgpxmaps_summary_min_ele" type="checkbox" value="true" <?php if($min_ele == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Min Elevation</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Min Elevation:</th> <th scope="row">Total climbing:</th>
<td> <td>
<input name="wpgpxmaps_summary_total_ele_up" type="checkbox" value="true" <?php if($total_ele_up == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Total climbing</i> <input name="wpgpxmaps_summary_total_ele_up" type="checkbox" value="true" <?php if($total_ele_up == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Total climbing</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Min Elevation:</th> <th scope="row">Total descent:</th>
<td> <td>
<input name="wpgpxmaps_summary_total_ele_down" type="checkbox" value="true" <?php if($total_ele_down == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Total descent</i> <input name="wpgpxmaps_summary_total_ele_down" type="checkbox" value="true" <?php if($total_ele_down == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Total descent</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Min Elevation:</th> <th scope="row">Average Speed:</th>
<td> <td>
<input name="wpgpxmaps_summary_avg_speed" type="checkbox" value="true" <?php if($avg_speed == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Average Speed</i> <input name="wpgpxmaps_summary_avg_speed" type="checkbox" value="true" <?php if($avg_speed == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Average Speed</i>
</td> </td>
</tr> </tr> <tr> <th scope="row">Average Cadence:</th> <td> <input name="wpgpxmaps_summary_avg_cad" type="checkbox" value="true" <?php if($avg_cad == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Average Cadence</i> </td> </tr>
<tr> <tr>
<th scope="row">Total time:</th> <th scope="row">Total time:</th>
<td> <td>
<input name="wpgpxmaps_summary_total_time" type="checkbox" value="true" <?php if($total_time == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Total time</i> <input name="wpgpxmaps_summary_total_time" type="checkbox" value="true" <?php if($total_time == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Total time</i>
</td> </td>
</tr> </tr>
</table> </table>
<p class="submit"> <p class="submit">
<input type="hidden" name="action" value="update" /> <input type="hidden" name="action" value="update" />
<input name="page_options" type="hidden" value="wpgpxmaps_summary,wpgpxmaps_summary_tot_len,wpgpxmaps_summary_max_ele,wpgpxmaps_summary_min_ele,wpgpxmaps_summary_total_ele_up,wpgpxmaps_summary_total_ele_down,wpgpxmaps_summary_avg_speed,wpgpxmaps_summary_total_time" /> <input name="page_options" type="hidden" value="wpgpxmaps_summary,wpgpxmaps_summary_tot_len,wpgpxmaps_summary_max_ele,wpgpxmaps_summary_min_ele,wpgpxmaps_summary_total_ele_up,wpgpxmaps_summary_total_ele_down,wpgpxmaps_summary_avg_speed,wpgpxmaps_summary_avg_cad,wpgpxmaps_summary_total_time" />
<input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" /> <input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" />
</p> </p>
</form> </form>
<hr /> <hr />
<form method="post" action="options.php"> <form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?> <?php wp_nonce_field('update-options') ?>
<h3 class="title">Map</h3> <h3 class="title">Map</h3>
<table class="form-table"> <table class="form-table">
<tr> <tr>
<th scope="row">On mouse scroll wheel:</th> <th scope="row">On mouse scroll wheel:</th>
<td> <td>
<input name="wpgpxmaps_zoomonscrollwheel" type="checkbox" value="true" <?php if($zoomonscrollwheel == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Enable zoom</i> <input name="wpgpxmaps_zoomonscrollwheel" type="checkbox" value="true" <?php if($zoomonscrollwheel == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Enable zoom</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Waypoints Support:</th> <th scope="row">Waypoints Support:</th>
<td> <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> <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>
<th scope="row">Map line color:</th> <th scope="row">Map line color:</th>
<td> <td>
<input name="wpgpxmaps_map_line_color" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_map_line_color'); ?>" /> <input name="wpgpxmaps_map_line_color" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_map_line_color'); ?>" />
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Default Map Type:</th> <th scope="row">Default Map Type:</th>
<td> <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="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="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="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 /> <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 />
--> -->
<input type="radio" name="wpgpxmaps_map_type" value="OSM1" <?php if ($t == 'OSM1') echo 'checked'; ?>> Open Street Map<br /> <input type="radio" name="wpgpxmaps_map_type" value="OSM1" <?php if ($t == 'OSM1') echo 'checked'; ?>> Open Street Map<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM2" <?php if ($t == 'OSM2') echo 'checked'; ?>> Open Cycle Map<br /> <input type="radio" name="wpgpxmaps_map_type" value="OSM2" <?php if ($t == 'OSM2') echo 'checked'; ?>> Open Cycle Map<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM4" <?php if ($t == 'OSM4') echo 'checked'; ?>> Open Cycle Map - Transport<br /> <input type="radio" name="wpgpxmaps_map_type" value="OSM4" <?php if ($t == 'OSM4') echo 'checked'; ?>> Open Cycle Map - Transport<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM5" <?php if ($t == 'OSM5') echo 'checked'; ?>> Open Cycle Map - Landscape<br /> <input type="radio" name="wpgpxmaps_map_type" value="OSM5" <?php if ($t == 'OSM5') echo 'checked'; ?>> Open Cycle Map - Landscape<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM3" <?php if ($t == 'OSM3') echo 'checked'; ?>> Hike & Bike<br /> <input type="radio" name="wpgpxmaps_map_type" value="OSM3" <?php if ($t == 'OSM3') echo 'checked'; ?>> Hike & Bike<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM6" <?php if ($t == 'OSM6') echo 'checked'; ?>> MapToolKit - Terrain<br /> <input type="radio" name="wpgpxmaps_map_type" value="OSM6" <?php if ($t == 'OSM6') echo 'checked'; ?>> MapToolKit - Terrain<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM7" <?php if ($t == 'OSM7') echo 'checked'; ?>> Open Street Map - Humanitarian map style<br /> <input type="radio" name="wpgpxmaps_map_type" value="OSM7" <?php if ($t == 'OSM7') echo 'checked'; ?>> Open Street Map - Humanitarian map style<br />
<!-- <!--
<input type="radio" name="wpgpxmaps_map_type" value="OSM8" <?php if ($t == 'OSM8') echo 'checked'; ?>> Open Ski Map<br /> <input type="radio" name="wpgpxmaps_map_type" value="OSM8" <?php if ($t == 'OSM8') echo 'checked'; ?>> Open Ski Map<br />
--> -->
<input type="radio" name="wpgpxmaps_map_type" value="OSM9" <?php if ($t == 'OSM9') echo 'checked'; ?>> Hike & Bike<br /> <input type="radio" name="wpgpxmaps_map_type" value="OSM9" <?php if ($t == 'OSM9') echo 'checked'; ?>> Hike & Bike<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM10" <?php if ($t == 'OSM10') echo 'checked'; ?>> Open Sea Map<br /> <input type="radio" name="wpgpxmaps_map_type" value="OSM10" <?php if ($t == 'OSM10') echo 'checked'; ?>> Open Sea Map<br />
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Start Icon:</th> <th scope="row">Start Icon:</th>
<td> <td>
<input name="wpgpxmaps_map_start_icon" value="<?php echo get_option('wpgpxmaps_map_start_icon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty to hide</em> <input name="wpgpxmaps_map_start_icon" value="<?php echo get_option('wpgpxmaps_map_start_icon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty to hide</em>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">End Icon:</th> <th scope="row">End Icon:</th>
<td> <td>
<input name="wpgpxmaps_map_end_icon" value="<?php echo get_option('wpgpxmaps_map_end_icon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty to hide</em> <input name="wpgpxmaps_map_end_icon" value="<?php echo get_option('wpgpxmaps_map_end_icon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty to hide</em>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Current Position Icon:</th> <th scope="row">Current Position Icon:</th>
<td> <td>
<input name="wpgpxmaps_map_current_icon" value="<?php echo get_option('wpgpxmaps_map_current_icon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty for default</em> <input name="wpgpxmaps_map_current_icon" value="<?php echo get_option('wpgpxmaps_map_current_icon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty for default</em>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Current GPS Position Icon:</th> <th scope="row">Current GPS Position Icon:</th>
<td> <td>
<input name="wpgpxmaps_currentpositioncon" value="<?php echo get_option('wpgpxmaps_currentpositioncon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty for default</em> <input name="wpgpxmaps_currentpositioncon" value="<?php echo get_option('wpgpxmaps_currentpositioncon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty for default</em>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Custom Waypoint Icon:</th> <th scope="row">Custom Waypoint Icon:</th>
<td> <td>
<input name="wpgpxmaps_map_waypoint_icon" value="<?php echo get_option('wpgpxmaps_map_waypoint_icon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty for default</em> <input name="wpgpxmaps_map_waypoint_icon" value="<?php echo get_option('wpgpxmaps_map_waypoint_icon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty for default</em>
</td> </td>
</tr> </tr>
</table> </table>
<p class="submit"> <p class="submit">
<input type="hidden" name="action" value="update" /> <input type="hidden" name="action" value="update" />
<input name="page_options" type="hidden" value="wpgpxmaps_show_waypoint,wpgpxmaps_map_line_color,wpgpxmaps_map_type,wpgpxmaps_map_start_icon,wpgpxmaps_map_end_icon,wpgpxmaps_map_current_icon,wpgpxmaps_zoomonscrollwheel,wpgpxmaps_map_waypoint_icon,wpgpxmaps_currentpositioncon" /> <input name="page_options" type="hidden" value="wpgpxmaps_show_waypoint,wpgpxmaps_map_line_color,wpgpxmaps_map_type,wpgpxmaps_map_start_icon,wpgpxmaps_map_end_icon,wpgpxmaps_map_current_icon,wpgpxmaps_zoomonscrollwheel,wpgpxmaps_map_waypoint_icon,wpgpxmaps_currentpositioncon" />
<input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" /> <input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" />
</p> </p>
</form> </form>
<hr /> <hr />
<form method="post" action="options.php"> <form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?> <?php wp_nonce_field('update-options') ?>
<h3 class="title">Chart</h3> <h3 class="title">Chart</h3>
<table class="form-table"> <table class="form-table">
<tr> <tr>
<th scope="row">Show altitude:</th> <th scope="row">Show altitude:</th>
<td> <td>
<input type="checkbox" <?php if($showEle == "true"){echo('checked');} ?> onchange="wpgpxmaps_show_elevation.value = this.checked" onload="wpgpxmaps_show_elevation.value = this.checked" /> <i>Show Altitude</i> <input type="checkbox" <?php if($showEle == "true"){echo('checked');} ?> onchange="wpgpxmaps_show_elevation.value = this.checked" onload="wpgpxmaps_show_elevation.value = this.checked" /> <i>Show Altitude</i>
<input name="wpgpxmaps_show_elevation" type="hidden" value="<?php echo $showEle; ?>"> <input name="wpgpxmaps_show_elevation" type="hidden" value="<?php echo $showEle; ?>">
</td> </td>
</tr> </tr>
<tr> <tr>
<tr> <tr>
<th scope="row">Altitude line color:</th> <th scope="row">Altitude line color:</th>
<td> <td>
<input name="wpgpxmaps_graph_line_color" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color'); ?>" /> <input name="wpgpxmaps_graph_line_color" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color'); ?>" />
</td> </td>
</tr> </tr>
<th scope="row">Unit of measure:</th> <th scope="row">Unit of measure:</th>
<td> <td>
<select name='wpgpxmaps_unit_of_measure'> <select name='wpgpxmaps_unit_of_measure'>
<option value="0" <?php if ($uom == '0') echo 'selected'; ?>>meters/meters</option> <option value="0" <?php if ($uom == '0') echo 'selected'; ?>>meters/meters</option>
<option value="1" <?php if ($uom == '1') echo 'selected'; ?>>feet/miles</option> <option value="1" <?php if ($uom == '1') echo 'selected'; ?>>feet/miles</option>
<option value="2" <?php if ($uom == '2') echo 'selected'; ?>>meters/kilometers</option> <option value="2" <?php if ($uom == '2') echo 'selected'; ?>>meters/kilometers</option>
<option value="3" <?php if ($uom == '3') echo 'selected'; ?>>meters/nautical miles</option> <option value="3" <?php if ($uom == '3') echo 'selected'; ?>>meters/nautical miles</option>
<option value="4" <?php if ($uom == '4') echo 'selected'; ?>>meters/miles</option> <option value="4" <?php if ($uom == '4') echo 'selected'; ?>>meters/miles</option>
<option value="5" <?php if ($uom == '5') echo 'selected'; ?>>feet/nautical miles</option> <option value="5" <?php if ($uom == '5') echo 'selected'; ?>>feet/nautical miles</option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Altitude display offset:</th> <th scope="row">Altitude display offset:</th>
<td> <td>
From From
<input name="wpgpxmaps_graph_offset_from1" value="<?php echo get_option('wpgpxmaps_graph_offset_from1'); ?>" style="width:50px;" /> <input name="wpgpxmaps_graph_offset_from1" value="<?php echo get_option('wpgpxmaps_graph_offset_from1'); ?>" style="width:50px;" />
To To
<input name="wpgpxmaps_graph_offset_to1" value="<?php echo get_option('wpgpxmaps_graph_offset_to1'); ?>" style="width:50px;" /> <input name="wpgpxmaps_graph_offset_to1" value="<?php echo get_option('wpgpxmaps_graph_offset_to1'); ?>" style="width:50px;" />
<em>(leave empty for auto scale)</em> <em>(leave empty for auto scale)</em>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Show speed:</th> <th scope="row">Show speed:</th>
<td> <td>
<input name="wpgpxmaps_show_speed" type="checkbox" value="true" <?php if($showSpeed == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show Speed</i> <input name="wpgpxmaps_show_speed" type="checkbox" value="true" <?php if($showSpeed == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show Speed</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Speed line color:</th> <th scope="row">Speed line color:</th>
<td> <td>
<input name="wpgpxmaps_graph_line_color_speed" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_speed'); ?>" /> <input name="wpgpxmaps_graph_line_color_speed" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_speed'); ?>" />
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Speed unit of measure:</th> <th scope="row">Speed unit of measure:</th>
<td> <td>
<select name='wpgpxmaps_unit_of_measure_speed'> <select name='wpgpxmaps_unit_of_measure_speed'>
<option value="0" <?php if ($uomSpeed == '0') echo 'selected'; ?>>m/s</option> <option value="0" <?php if ($uomSpeed == '0') echo 'selected'; ?>>m/s</option>
<option value="1" <?php if ($uomSpeed == '1') echo 'selected'; ?>>km/h</option> <option value="1" <?php if ($uomSpeed == '1') echo 'selected'; ?>>km/h</option>
<option value="2" <?php if ($uomSpeed == '2') echo 'selected'; ?>>miles/h</option> <option value="2" <?php if ($uomSpeed == '2') echo 'selected'; ?>>miles/h</option>
<option value="3" <?php if ($uomSpeed == '3') echo 'selected'; ?>>min/km</option> <option value="3" <?php if ($uomSpeed == '3') echo 'selected'; ?>>min/km</option>
<option value="4" <?php if ($uomSpeed == '4') echo 'selected'; ?>>min/miles</option> <option value="4" <?php if ($uomSpeed == '4') echo 'selected'; ?>>min/miles</option>
<option value="5" <?php if ($uomSpeed == '5') echo 'selected'; ?>>Nautical Miles/Hour (Knots)</option> <option value="6" <?php if ($uomSpeed == '6') echo 'selected'; ?>>min/100 meters</option> <option value="5" <?php if ($uomSpeed == '5') echo 'selected'; ?>>Nautical Miles/Hour (Knots)</option> <option value="6" <?php if ($uomSpeed == '6') echo 'selected'; ?>>min/100 meters</option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Speed display offset:</th> <th scope="row">Speed display offset:</th>
<td> <td>
From From
<input name="wpgpxmaps_graph_offset_from2" value="<?php echo get_option('wpgpxmaps_graph_offset_from2'); ?>" style="width:50px;" /> <input name="wpgpxmaps_graph_offset_from2" value="<?php echo get_option('wpgpxmaps_graph_offset_from2'); ?>" style="width:50px;" />
To To
<input name="wpgpxmaps_graph_offset_to2" value="<?php echo get_option('wpgpxmaps_graph_offset_to2'); ?>" style="width:50px;" /> <input name="wpgpxmaps_graph_offset_to2" value="<?php echo get_option('wpgpxmaps_graph_offset_to2'); ?>" style="width:50px;" />
<em>(leave empty for auto scale)</em> <em>(leave empty for auto scale)</em>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Show Heart Rate (where aviable):</th> <th scope="row">Show Heart Rate (where aviable):</th>
<td> <td>
<input name="wpgpxmaps_show_hr" type="checkbox" value="true" <?php if($showHr == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show heart rate</i> <input name="wpgpxmaps_show_hr" type="checkbox" value="true" <?php if($showHr == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show heart rate</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Heart rate line color:</th> <th scope="row">Heart rate line color:</th>
<td> <td>
<input name="wpgpxmaps_graph_line_color_hr" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_hr'); ?>" /> <input name="wpgpxmaps_graph_line_color_hr" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_hr'); ?>" />
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Show Temperature (where aviable):</th> <th scope="row">Show Temperature (where aviable):</th>
<td> <td>
<input name="wpgpxmaps_show_atemp" type="checkbox" value="true" <?php if($showAtemp == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show Temperature</i> <input name="wpgpxmaps_show_atemp" type="checkbox" value="true" <?php if($showAtemp == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show Temperature</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Temperature line color:</th> <th scope="row">Temperature line color:</th>
<td> <td>
<input name="wpgpxmaps_graph_line_color_atemp" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_atemp'); ?>" /> <input name="wpgpxmaps_graph_line_color_atemp" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_atemp'); ?>" />
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Show Cadence (where aviable):</th> <th scope="row">Show Cadence (where aviable):</th>
<td> <td>
<input name="wpgpxmaps_show_cadence" type="checkbox" value="true" <?php if($showCad == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show Cadence</i> <input name="wpgpxmaps_show_cadence" type="checkbox" value="true" <?php if($showCad == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show Cadence</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Cadence line color:</th> <th scope="row">Cadence line color:</th>
<td> <td>
<input name="wpgpxmaps_graph_line_color_cad" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_cad'); ?>" /> <input name="wpgpxmaps_graph_line_color_cad" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_cad'); ?>" />
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Show Grade:</th> <th scope="row">Show Grade:</th>
<td> <td>
<input name="wpgpxmaps_show_grade" type="checkbox" value="true" <?php if($showGrade == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show Grade - BETA</i> <input name="wpgpxmaps_show_grade" type="checkbox" value="true" <?php if($showGrade == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show Grade - BETA</i>
<br /> <br />
<i>(Grade values depends on your gps accuracy. If you have a poor gps accuracy they might be totally wrong!)</i> <i>(Grade values depends on your gps accuracy. If you have a poor gps accuracy they might be totally wrong!)</i>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">Grade line color:</th> <th scope="row">Grade line color:</th>
<td> <td>
<input name="wpgpxmaps_graph_line_color_grade" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_grade'); ?>" /> <input name="wpgpxmaps_graph_line_color_grade" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_grade'); ?>" />
</td> </td>
</tr> </tr>
</table> </table>
<p class="submit"> <p class="submit">
<input type="hidden" name="action" value="update" /> <input type="hidden" name="action" value="update" />
<input name="page_options" type="hidden" value="wpgpxmaps_unit_of_measure,wpgpxmaps_graph_line_color,wpgpxmaps_show_elevation,wpgpxmaps_show_speed,wpgpxmaps_graph_line_color_speed,wpgpxmaps_show_hr,wpgpxmaps_graph_line_color_hr,wpgpxmaps_unit_of_measure_speed,wpgpxmaps_graph_offset_from1,wpgpxmaps_graph_offset_to1,wpgpxmaps_graph_offset_from2,wpgpxmaps_graph_offset_to2,wpgpxmaps_graph_line_color_cad,wpgpxmaps_show_cadence,wpgpxmaps_show_grade,wpgpxmaps_graph_line_color_grade,wpgpxmaps_show_atemp,wpgpxmaps_graph_line_color_atemp" /> <input name="page_options" type="hidden" value="wpgpxmaps_unit_of_measure,wpgpxmaps_graph_line_color,wpgpxmaps_show_elevation,wpgpxmaps_show_speed,wpgpxmaps_graph_line_color_speed,wpgpxmaps_show_hr,wpgpxmaps_graph_line_color_hr,wpgpxmaps_unit_of_measure_speed,wpgpxmaps_graph_offset_from1,wpgpxmaps_graph_offset_to1,wpgpxmaps_graph_offset_from2,wpgpxmaps_graph_offset_to2,wpgpxmaps_graph_line_color_cad,wpgpxmaps_show_cadence,wpgpxmaps_show_grade,wpgpxmaps_graph_line_color_grade,wpgpxmaps_show_atemp,wpgpxmaps_graph_line_color_atemp" />
<input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" /> <input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" />
</p> </p>
</form> </form>
<hr /> <hr />
<form method="post" action="options.php"> <form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?> <?php wp_nonce_field('update-options') ?>
<h3 class="title">Advanced options <small>(Do not edit if you don't know what you are doing!)</small></h3> <h3 class="title">Advanced options <small>(Do not edit if you don't know what you are doing!)</small></h3>
<table class="form-table"> <table class="form-table">
<tr> <tr>
<th scope="row"></th> <th scope="row"></th>
<td> <td>
<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>. <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>.
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row"></th> <th scope="row"></th>
<td> <td>
<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>. <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> </td>
</tr> </tr>
</table> </table>
<input type="hidden" name="action" value="update" /> <input type="hidden" name="action" value="update" />
<input name="page_options" type="hidden" value="wpgpxmaps_pointsoffset,wpgpxmaps_donotreducegpx" /> <input name="page_options" type="hidden" value="wpgpxmaps_pointsoffset,wpgpxmaps_donotreducegpx" />
<p class="submit"> <p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" /> <input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" />
</p> </p>
</form> </form>
<hr /> <hr />

View File

@ -1,206 +1,206 @@
<?php <?php
if ( !(is_admin()) ) if ( !(is_admin()) )
return; return;
$is_admin = current_user_can( 'manage_options' ); $is_admin = current_user_can( 'manage_options' );
if ( $is_admin != 1 ) if ( $is_admin != 1 )
return; return;
$gpxRegEx = '/.gpx$/i'; $gpxRegEx = '/.gpx$/i';
if ( isset($_POST['clearcache']) ) if ( isset($_POST['clearcache']) )
{ {
if ( isset($_GET['_wpnonce']) if ( isset($_GET['_wpnonce'])
&& &&
wp_verify_nonce( $_GET['_wpnonce'], 'wpgpx_clearcache_nonce' . $entry ) wp_verify_nonce( $_GET['_wpnonce'], 'wpgpx_clearcache_nonce' . $entry )
) )
{ {
echo "Cache is now empty!"; echo "Cache is now empty!";
wpgpxmaps_recursive_remove_directory($cacheGpxPath, true); wpgpxmaps_recursive_remove_directory($cacheGpxPath, true);
} }
} }
if ( is_writable ( $realGpxPath ) ){ if ( is_writable ( $realGpxPath ) ){
?> ?>
<div class="tablenav top"> <div class="tablenav top">
<form enctype="multipart/form-data" method="POST" style="float:left; margin:5px 20px 0 0" action="/wp-admin/options-general.php?page=WP-GPX-Maps"> <form enctype="multipart/form-data" method="POST" style="float:left; margin:5px 20px 0 0" action="/wp-admin/options-general.php?page=WP-GPX-Maps">
Choose a file to upload: <input name="uploadedfile[]" type="file" onchange="submitgpx(this);" multiple /> Choose a file to upload: <input name="uploadedfile[]" type="file" onchange="submitgpx(this);" multiple />
<?php <?php
if ( isset($_FILES['uploadedfile']) ) if ( isset($_FILES['uploadedfile']) )
{ {
$total = count($_FILES['uploadedfile']['name']); $total = count($_FILES['uploadedfile']['name']);
for($i=0; $i<$total; $i++) { for($i=0; $i<$total; $i++) {
$uploadingFileName = basename( $_FILES['uploadedfile']['name'][$i]); $uploadingFileName = basename( $_FILES['uploadedfile']['name'][$i]);
$target_path = $realGpxPath ."/". $uploadingFileName; $target_path = $realGpxPath ."/". $uploadingFileName;
if (preg_match($gpxRegEx, $target_path)) if (preg_match($gpxRegEx, $target_path))
{ {
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'][$i], $target_path)) { if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'][$i], $target_path)) {
echo "<br />File <b>". $uploadingFileName . "</b> has been uploaded"; echo "<br />File <b>". $uploadingFileName . "</b> has been uploaded";
} else{ } else{
echo "<br />There was an error uploading the file, please try again!"; echo "<br />There was an error uploading the file, please try again!";
} }
} }
else else
{ {
echo "file not supported!"; echo "file not supported!";
} }
} }
} }
?> ?>
</form> </form>
<form method="POST" style="float:left; margin:5px 20px 0 0" action="/wp-admin/options-general.php?page=WP-GPX-Maps&_wpnonce=<?php echo wp_create_nonce( 'wpgpx_clearcache_nonce' ) ?>" > <form method="POST" style="float:left; margin:5px 20px 0 0" action="/wp-admin/options-general.php?page=WP-GPX-Maps&_wpnonce=<?php echo wp_create_nonce( 'wpgpx_clearcache_nonce' ) ?>" >
<input type="submit" name="clearcache" value="Clear Cache" /> <input type="submit" name="clearcache" value="Clear Cache" />
</form> </form>
</div> </div>
<?php <?php
} }
else else
{ {
?> ?>
<br /> <br />
<br /> <br />
<p style='font-size:2em;'>please make <b><?php echo $realGpxPath ?></b> folder writable. </p> <p style='font-size:2em;'>please make <b><?php echo $realGpxPath ?></b> folder writable. </p>
<br /> <br />
<br /> <br />
<?php <?php
} }
$myGpxFileNames = array(); $myGpxFileNames = array();
if ( is_readable ( $realGpxPath ) && $handle = opendir($realGpxPath)) { if ( is_readable ( $realGpxPath ) && $handle = opendir($realGpxPath)) {
while (false !== ($entry = readdir($handle))) { while (false !== ($entry = readdir($handle))) {
if (preg_match($gpxRegEx, $entry )) if (preg_match($gpxRegEx, $entry ))
{ {
if ( isset($_GET['_wpnonce']) if ( isset($_GET['_wpnonce'])
&& &&
wp_verify_nonce( $_GET['_wpnonce'], 'wpgpx_deletefile_nonce_' . $entry ) wp_verify_nonce( $_GET['_wpnonce'], 'wpgpx_deletefile_nonce_' . $entry )
) { ) {
if ( file_exists($realGpxPath ."/". $entry) ) if ( file_exists($realGpxPath ."/". $entry) )
{ {
unlink($realGpxPath ."/". $entry); unlink($realGpxPath ."/". $entry);
echo "<br/><b>$entry has been deleted.</b>"; echo "<br/><b>$entry has been deleted.</b>";
} }
else { else {
echo "<br/><b>Can't delete $entry.</b>"; echo "<br/><b>Can't delete $entry.</b>";
} }
} }
else else
{ {
$myFile = $realGpxPath . "/" . $entry; $myFile = $realGpxPath . "/" . $entry;
$myGpxFileNames[] = array( $myGpxFileNames[] = array(
'name' => $entry, 'name' => $entry,
'size' => filesize( $myFile ), 'size' => filesize( $myFile ),
'lastedit' => filemtime( $myFile ), 'lastedit' => filemtime( $myFile ),
'nonce' => wp_create_nonce( 'wpgpx_deletefile_nonce_' . $entry ), 'nonce' => wp_create_nonce( 'wpgpx_deletefile_nonce_' . $entry ),
); );
} }
} }
} }
closedir($handle); closedir($handle);
} }
if ( is_readable ( $realGpxPath ) && $handle = opendir($realGpxPath)) { if ( is_readable ( $realGpxPath ) && $handle = opendir($realGpxPath)) {
while (false !== ($entry = readdir($handle))) { while (false !== ($entry = readdir($handle))) {
if (preg_match($gpxRegEx,$entry )) if (preg_match($gpxRegEx,$entry ))
{ {
$filenames[] = $realGpxPath . "/" . $entry; $filenames[] = $realGpxPath . "/" . $entry;
} }
} }
closedir($handle); closedir($handle);
} }
$wpgpxmaps_gpxRelativePath = get_site_url(null, '/wp-content/uploads/gpx/'); $wpgpxmaps_gpxRelativePath = get_site_url(null, '/wp-content/uploads/gpx/');
?> ?>
<table id="table" class="wp-list-table widefat plugins"></table> <table id="table" class="wp-list-table widefat plugins"></table>
<script type="text/javascript"> <script type="text/javascript">
function submitgpx(el) function submitgpx(el)
{ {
var newEl = document.createElement('span'); var newEl = document.createElement('span');
newEl.innerHTML = 'Uploading file...'; newEl.innerHTML = 'Uploading file...';
el.parentNode.insertBefore(newEl,el.nextSibling); el.parentNode.insertBefore(newEl,el.nextSibling);
el.parentNode.submit() el.parentNode.submit()
} }
jQuery('#table').bootstrapTable({ jQuery('#table').bootstrapTable({
columns: [{ columns: [{
field: 'name', field: 'name',
title: 'File', title: 'File',
sortable: true, sortable: true,
formatter: function(value, row, index) { formatter: function(value, row, index) {
return [ return [
'<b>' + row.name + '</b><br />', '<b>' + row.name + '</b><br />',
'<a class="delete_gpx_row" href="/wp-admin/options-general.php?page=WP-GPX-Maps&_wpnonce=' + row.nonce + '" >Delete</a>', '<a class="delete_gpx_row" href="/wp-admin/options-general.php?page=WP-GPX-Maps&_wpnonce=' + row.nonce + '" >Delete</a>',
' | ', ' | ',
'<a href="<?php echo $wpgpxmaps_gpxRelativePath ?>' + row.name + '">Download</a>', '<a href="<?php echo $wpgpxmaps_gpxRelativePath ?>' + row.name + '">Download</a>',
' | ', ' | ',
'Shortcode: [sgpx gpx="<?php echo $relativeGpxPath ?>' + row.name + '"]', 'Shortcode: [sgpx gpx="<?php echo $relativeGpxPath ?>' + row.name + '"]',
].join('') ].join('')
} }
}, { }, {
field: 'lastedit', field: 'lastedit',
title: 'Last modified', title: 'Last modified',
sortable: true, sortable: true,
formatter: function(value, row, index) { formatter: function(value, row, index) {
var d = new Date(value*1000); var d = new Date(value*1000);
return d.toLocaleDateString() + " " + d.toLocaleTimeString(); return d.toLocaleDateString() + " " + d.toLocaleTimeString();
} }
}, { }, {
field: 'size', field: 'size',
title: 'File size', title: 'File size',
sortable: true, sortable: true,
formatter: function(value, row, index) { return humanFileSize(value); } formatter: function(value, row, index) { return humanFileSize(value); }
}], }],
sortName : 'lastedit', sortName : 'lastedit',
sortOrder : 'desc', sortOrder : 'desc',
data: <?php echo json_encode( $myGpxFileNames ) ?> data: <?php echo json_encode( $myGpxFileNames ) ?>
}); });
jQuery('.delete_gpx_row').click(function(){ jQuery('.delete_gpx_row').click(function(){
return confirm("Are you sure you want to delete?"); return confirm("Are you sure you want to delete?");
}) })
function humanFileSize(bytes, si) { function humanFileSize(bytes, si) {
var thresh = si ? 1000 : 1024; var thresh = si ? 1000 : 1024;
if(Math.abs(bytes) < thresh) { if(Math.abs(bytes) < thresh) {
return bytes + ' B'; return bytes + ' B';
} }
var units = si var units = si
? ['kB','MB','GB','TB','PB','EB','ZB','YB'] ? ['kB','MB','GB','TB','PB','EB','ZB','YB']
: ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB']; : ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB'];
var u = -1; var u = -1;
do { do {
bytes /= thresh; bytes /= thresh;
++u; ++u;
} while(Math.abs(bytes) >= thresh && u < units.length - 1); } while(Math.abs(bytes) >= thresh && u < units.length - 1);
return bytes.toFixed(1)+' '+units[u]; return bytes.toFixed(1)+' '+units[u];
} }
</script> </script>
<style> <style>
#table tr:hover { #table tr:hover {
background:#eeeeee; background:#eeeeee;
} }
</style> </style>

View File

@ -211,6 +211,7 @@
$points->totalEleUp = 0; $points->totalEleUp = 0;
$points->totalEleDown = 0; $points->totalEleDown = 0;
$points->avgSpeed = 0; $points->avgSpeed = 0;
$points->avgCad = 0;
$points->totalLength = 0; $points->totalLength = 0;
$gpx = simplexml_load_file($filePath); $gpx = simplexml_load_file($filePath);
@ -235,7 +236,6 @@
$trk->registerXPathNamespace('a', 'http://www.topografix.com/GPX/1/0'); $trk->registerXPathNamespace('a', 'http://www.topografix.com/GPX/1/0');
$trk->registerXPathNamespace('b', 'http://www.topografix.com/GPX/1/1'); $trk->registerXPathNamespace('b', 'http://www.topografix.com/GPX/1/1');
$trk->registerXPathNamespace('ns3', 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1');
$trkpts = $trk->xpath('//trkpt | //a:trkpt | //b:trkpt'); $trkpts = $trk->xpath('//trkpt | //a:trkpt | //b:trkpt');
@ -272,6 +272,13 @@
$atemp = @$tpe["ns3:atemp"]; $atemp = @$tpe["ns3:atemp"];
$cad = @$tpe["ns3:cad"]; $cad = @$tpe["ns3:cad"];
} }
else if (isset($arr['gpxtpx:TrackPointExtension']))
{
$tpe = $arr['gpxtpx:TrackPointExtension'];
$hr = @$tpe["gpxtpx:hr"];
$atemp = @$tpe["gpxtpx:atemp"];
$cad = @$tpe["gpxtpx:cad"];
}
else if (isset($arr['TrackPointExtension'])) else if (isset($arr['TrackPointExtension']))
{ {
$tpe = $arr['TrackPointExtension']; $tpe = $arr['TrackPointExtension'];
@ -361,10 +368,8 @@
array_push($points->dist, (float)round($dist, 2) ); array_push($points->dist, (float)round($dist, 2) );
array_push($points->speed, (float)round($avgSpeed, 1) ); array_push($points->speed, (float)round($avgSpeed, 1) );
array_push($points->hr, $hr); array_push($points->hr, $hr);
array_push($points->atemp, $atemp); array_push($points->atemp, $atemp);
array_push($points->cad, $cad);
array_push($points->cad, $cad);
array_push($points->grade, (float)round($grade, 2) ); array_push($points->grade, (float)round($grade, 2) );
} }
@ -415,13 +420,18 @@
$_ele = array_filter($points->ele); $_ele = array_filter($points->ele);
$_dist = array_filter($points->dist); $_dist = array_filter($points->dist);
$_speed = array_filter($points->speed); $_speed = array_filter($points->speed);
$_cad = array_filter($points->cad);
$points->maxEle = max($_ele); $points->maxEle = max($_ele);
$points->minEle = min($_ele); $points->minEle = min($_ele);
$points->totalLength = max($_dist); $points->totalLength = max($_dist);
$points->maxTime = max($_time); $points->maxTime = max($_time);
$points->minTime = min($_time); $points->minTime = min($_time);
$points->avgCad = (float)round(array_sum($_cad) / count($_cad), 0);
$points->avgSpeed = array_sum($_speed) / count($_speed); $points->avgSpeed = array_sum($_speed) / count($_speed);
} catch (Exception $e) { } } catch (Exception $e) { }
} }