code reorganization

This commit is contained in:
bastianonm 2019-07-02 06:39:27 +00:00
parent b684a1031e
commit 3308c70299
14 changed files with 4310 additions and 624 deletions

View File

@ -7,6 +7,7 @@
* 2. Tab: Tracks
* 3. Tab: Settings
* 4. Tab: Help
*
*/
/**
@ -16,15 +17,31 @@
/**
* 2.0 Tab: Tracks
*/
#table tbody tr:hover {
background: #eee;
}
/**
* 3.0 Tab: Settings
*/
.wpgpxmaps-container-tab-settings {
.wpgpxmaps-container-tab-settings {
display: block;
padding: 5px 20px 1px 20px;
}
.wpgpxmaps-container-tab-settings table.form-table input[type="checkbox"] {
margin-top: -4px;
margin-right: 4px;
}
.wpgpxmaps-container-tab-settings table.form-table input[type="radio"] {
margin-right: 4px;
}
.wpgpxmaps-container-tab-settings table.form-table input[type="text"] {
margin-right: 4px;
}
/**
* 4.0 Tab: Tracks
*/
@ -44,8 +61,12 @@
border-radius: 6px;
}
.wpgpxmaps-container-tab-faq table.widefat tbody tr:hover {
background:#eeeeee;
.wpgpxmaps-container-tab-faq table.widefat thead th.title {
font-weight: 650;
}
.wpgpxmaps-container-tab-faq table.widefat td {
width: 200px;
}
.wpgpxmaps-container-tab-faq table.widefat th,
@ -53,10 +74,11 @@
padding: 4px 10px;
}
.wpgpxmaps-container-tab-faq table.widefat thead tr th {
font-size: 14px;
.wpgpxmaps-container-tab-faq table.widefat tbody tr:hover {
background: #eee;
}
.wpgpxmaps-container-tab-faq table.widefat td {
width: 200px;
.wpgpxmaps-container-tab-faq table.widefat thead th {
font-size: 14px;
}

337
css/bootstrap-table.css vendored Normal file
View File

@ -0,0 +1,337 @@
/**
* @author zhixin wen <wenzhixin2010@gmail.com>
* version: 1.13.2
* https://github.com/wenzhixin/bootstrap-table/
*/
.bootstrap-table .table {
margin-bottom: 0 !important;
border-bottom: 1px solid #dddddd;
border-collapse: collapse !important;
border-radius: 1px;
}
.bootstrap-table .table:not(.table-condensed),
.bootstrap-table .table:not(.table-condensed) > tbody > tr > th,
.bootstrap-table .table:not(.table-condensed) > tfoot > tr > th,
.bootstrap-table .table:not(.table-condensed) > thead > tr > td,
.bootstrap-table .table:not(.table-condensed) > tbody > tr > td,
.bootstrap-table .table:not(.table-condensed) > tfoot > tr > td {
padding: 8px;
}
.bootstrap-table .table.table-no-bordered > thead > tr > th {
border-top: none;
}
.bootstrap-table .table.table-no-bordered > thead > tr > th,
.bootstrap-table .table.table-no-bordered > tbody > tr > td {
border-right: 2px solid transparent;
}
.bootstrap-table .table.table-no-bordered > tbody > tr > td:last-child {
border-right: none;
}
.fixed-table-container {
position: relative;
clear: both;
border: 1px solid #dddddd;
border-radius: 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
}
.fixed-table-container.table-no-bordered {
border: 1px solid transparent;
}
.fixed-table-footer,
.fixed-table-header {
overflow: hidden;
}
.fixed-table-footer {
border-top: 1px solid #dddddd;
}
.fixed-table-body {
overflow-x: auto;
overflow-y: auto;
height: 100%;
}
.fixed-table-container table {
width: 100%;
}
.fixed-table-container thead th {
height: 0;
padding: 0;
margin: 0;
border-left: 1px solid #dddddd;
}
.fixed-table-container thead th:focus {
outline: 0 solid transparent;
}
.fixed-table-container thead th:first-child:not([data-not-first-th]) {
border-left: none;
border-top-left-radius: 4px;
-webkit-border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px;
}
.fixed-table-container thead th .th-inner,
.fixed-table-container tbody td .th-inner {
padding: 8px;
line-height: 24px;
vertical-align: top;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.fixed-table-container thead th .sortable {
cursor: pointer;
background-position: right;
background-repeat: no-repeat;
padding-right: 30px;
}
.fixed-table-container thead th .both {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7X QMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC');
}
.fixed-table-container thead th .asc {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==');
}
.fixed-table-container thead th .desc {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII= ');
}
.fixed-table-container th.detail {
width: 30px;
}
.fixed-table-container tbody td {
border-left: 1px solid #dddddd;
}
.fixed-table-container tbody tr:first-child td {
border-top: none;
}
.fixed-table-container tbody td:first-child {
border-left: none;
}
/* the same color with .active */
.fixed-table-container tbody .selected td {
background-color: #f5f5f5;
}
.fixed-table-container .bs-checkbox {
text-align: center;
}
.fixed-table-container input[type="radio"],
.fixed-table-container input[type="checkbox"] {
margin: 0 auto !important;
}
.fixed-table-container .no-records-found {
text-align: center;
}
.fixed-table-pagination div.pagination,
.fixed-table-pagination .pagination-detail {
margin-top: 10px;
margin-bottom: 10px;
}
.fixed-table-pagination div.pagination .pagination {
margin: 0;
}
.fixed-table-pagination .pagination a {
padding: 6px 12px;
line-height: 1.428571429;
}
.fixed-table-pagination ul.pagination li.page-intermediate a {
color:#c8c8c8;
}
.fixed-table-pagination ul.pagination li.page-intermediate a:before {
content: '\2B05';
}
.fixed-table-pagination ul.pagination li.page-intermediate a:after {
content: '\27A1';
}
.fixed-table-pagination .pagination-info {
line-height: 34px;
margin-right: 5px;
}
.fixed-table-pagination .btn-group {
position: relative;
display: inline-block;
vertical-align: middle;
}
.fixed-table-pagination .dropup .dropdown-menu {
margin-bottom: 0;
}
.fixed-table-pagination .page-list {
display: inline-block;
}
.fixed-table-toolbar .columns-left {
margin-right: 5px;
}
.fixed-table-toolbar .columns-right {
margin-left: 5px;
}
.fixed-table-toolbar .columns label {
display: block;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 1.428571429;
}
.fixed-table-toolbar .bs-bars,
.fixed-table-toolbar .search,
.fixed-table-toolbar .columns {
position: relative;
margin-top: 10px;
margin-bottom: 10px;
}
.fixed-table-pagination li.disabled a {
pointer-events: none;
cursor: default;
}
.fixed-table-loading {
display: none;
position: absolute;
top: 42px;
right: 0;
bottom: 0;
left: 0;
z-index: 99;
background-color: #fff;
text-align: center;
}
.fixed-table-body .card-view .title {
font-weight: bold;
display: inline-block;
min-width: 30%;
text-align: left !important;
}
/* support bootstrap 2 */
.fixed-table-body thead th .th-inner {
box-sizing: border-box;
}
.table th, .table td {
vertical-align: middle;
box-sizing: border-box;
}
.fixed-table-toolbar .dropdown-menu {
text-align: left;
max-height: 300px;
overflow: auto;
}
.fixed-table-toolbar .btn-group > .btn-group {
display: inline-block;
margin-left: -1px !important;
}
.fixed-table-toolbar .btn-group > .btn-group > .btn {
border-radius: 0;
}
.fixed-table-toolbar .btn-group > .btn-group:first-child > .btn {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.fixed-table-toolbar .btn-group > .btn-group:last-child > .btn {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.bootstrap-table .table > thead > tr > th {
vertical-align: bottom;
border-bottom: 1px solid #ddd;
}
.bootstrap-table .table > thead.thead-dark > tr > th {
border-bottom: 1px solid #212529;
}
/* support bootstrap 3 */
.bootstrap-table .table thead > tr > th {
padding: 0;
margin: 0;
}
.bootstrap-table .fixed-table-footer tbody > tr > td {
padding: 0 !important;
}
.bootstrap-table .fixed-table-footer .table {
border-bottom: none;
border-radius: 0;
padding: 0 !important;
}
.bootstrap-table .pull-right .dropdown-menu {
right: 0;
left: auto;
}
/* calculate scrollbar width */
p.fixed-table-scroll-inner {
width: 100%;
height: 200px;
}
div.fixed-table-scroll-outer {
top: 0;
left: 0;
visibility: hidden;
width: 200px;
height: 150px;
overflow: hidden;
}
/* for get correct heights */
.fixed-table-toolbar:after, .fixed-table-pagination:after {
content: "";
display: block;
clear: both;
}
.bootstrap-table.fullscreen {
position: fixed;
top: 0;
left: 0;
z-index: 1050;
width: 100%!important;
background: #FFF;
}

65
css/output-style.css Normal file
View File

@ -0,0 +1,65 @@
/**
* This file contains the style definitions for the output
*
*/
.wpgpxmaps img,
.entry-content .wpgpxmaps img,
#content .wpgpxmaps img {
width: none;
max-width: none;
margin: 0;
padding: 0;
border: none;
background: none;
}
.wpgpxmaps {
clear: both;
}
.wpgpxmaps .ngimages {
display: none;
}
.wpgpxmaps .myngimages {
position: absolute;
z-index :1;
margin:0;
border: 1px solid #fff;
cursor: pointer;
}
.wpgpxmaps_summary .summarylabel {
font-weight: 400;
}
.wpgpxmaps_summary .summaryvalue {
font-weight: 600;
}
.wpgpxmaps .report {
line-height :120;
}
.wpgpxmaps .gmnoprint div:first-child { }
.wpgpxmaps .wpgpxmaps_osm_footer {
position: absolute;
z-index: 999;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 13px;
margin: 0;
background: #fff;
font-size: 12px;
}
.wpgpxmaps .wpgpxmaps_osm_footer span {
position: absolute;
bottom: 0;
padding: 0 6px 6px 6px;
background: #fff;
vertical-align: baseline;
}

View File

@ -48,7 +48,7 @@ var WPGPXMAPS = {
MapEngines: {
/* NOT WORKING AND TESTED! old code copy&pate */
/* NOT WORKING AND TESTED! old code copy&paste */
GoogleMaps: function() {
this.map = null,
this.EventSelectChart = null,

3223
js/bootstrap-table.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,11 @@
=== WP GPX Maps ===
Contributors: bastianonm, Stephan Klein, Michel Selerin, TosattoSimonePio, Kniebremser
Contributors: bastianonm, Stephan Klein, Michel Selerin, TosattoSimonePio, Kniebremser
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8VHWLRW6JBTML
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: 4.6.0
Tested up to: 5.2.1
Tested up to: 5.2.2
Requires PHP: 5.6.20
Stable tag: 1.7.00
Draws a GPX track with altitude graph. You can also display your nextgen gallery images in the map.
@ -42,19 +43,19 @@ Try this plugin: <a href="https://devfarm.it/wp-gpx-maps-demo/" target="_blank"
Support:
If you need help, please use: <a href="http://www.devfarm.it/forums/forum/wp-gpx-maps/" target="_blank" rel="noopener noreferrer">www.devfarm.it Support Forum</a>
Would you like to help fix bugs or further develop the plugin? On <a href="https://github.com/devfarm-it/wp-gpx-maps" target="_blank" rel="noopener noreferrer">Github</a> you can contribuite easly with your code.
Translations:
Translators are welcome to contribute to the plugin. Please use the <a href="https://translate.wordpress.org/projects/wp-plugins/wp-gpx-maps/)" target="_blank" rel="noopener noreferrer">WordPress translation website</a>.
The language files in the plugin contain 19 translatable texts for 14 languages:
The language files in the plugin contain 18 translatable texts for 13 languages:
- Catalan ca
- Dutch nl_NL
- English (default)
- French fr_FR
- German de_DE
- Hungarian hu_HU
- Italian it_IT
- Norwegian nb_NO
@ -71,7 +72,7 @@ The language files in the plugin contain 19 translatable texts for 14 languages:
(Many thanks to all guys who helped me with the translations)
Currently are 222 texts are translatable in the plugin.
Currently are 230 texts are translatable in the plugin.
With your help, the plugin can be translated into any language. For updating the language file you no longer need to wait for a new version of the plugin.
Are 95% WordPress generates a new language file for your language.
@ -107,9 +108,9 @@ Icons made by <a href="https://www.freepik.com/" target="_blank" rel="noopener n
You can use the following shortcodes:
1. gpx: Relative path to the GPX file
1. width: Width in pixels
1. mheight: Map height
1. gheight: Graph height
1. width: Map width (value in percent)
1. mheight: Map height (value in pixeln)
1. gheight: Graph height (value in pixeln)
1. skipcache: Do not use cache. If TRUE might be very slow (default is false)
1. download: Allow users to download your GPX file (default is false)
1. summary: Print summary details of your GPX track (default is false)
@ -127,7 +128,7 @@ You can use the following shortcodes:
1. startIcon: Start track icon
1. endIcon: End track icon
1. currentIcon: Current position icon (when mouse hover)
1. waypointicon: Waypoint custom icon
1. waypointicon: Custom waypoint icon
1. showele: Show elevation data inside the chart (default is true)
1. uom: Distance/altitude possible unit of measure (0 = meters, 1 = feet/miles, 2 = meters/kilometers, 3 = meters/nautical miles, 4 = meters/miles, 5 = feet/nautical miles)
1. glinecolor: Altitude line color (default is #3366cc)
@ -162,8 +163,8 @@ This plugin will print a small amout of points to speedup javascript and pageloa
Yes!
== Screenshots ==
1. Simple Gpx
1. Gpx with waypoints
1. Simple GPX
1. GPX with waypoints
1. Admin area - List of tracks
1. Admin area - Settings
1. Altitude & Speed
@ -171,6 +172,14 @@ Yes!
== Changelog ==
= X.X.XX
* Added: PHP version notices, WordPress 5.3 requires PHP 5.6.20
* Added: Missing entries for add and delete options
* Changed: Style for output moved in a seperate file
* Tweak: Small design optimizations in the admin area
* Tweak: Small code adjustments (WPCS)
* Upgrade: bootstrap-table to 1.13.2
* Removed: german language file (now over translate.wordpress.org)
= 1.7.00 =
* Added: Authors can upload GPX tracks in a folder called as *your user name*, inside [../wp-upload dir/gpx/[*your user name*] (thanks to wildcomputations)
* Added: Authors an Admins can see the current values for shortcodes in help tab

View File

@ -22,7 +22,6 @@ add_shortcode( 'sgpxf', 'handle_WP_GPX_Maps_folder_Shortcodes' );
register_activation_hook( __FILE__, 'WP_GPX_Maps_install' );
register_deactivation_hook( __FILE__, 'WP_GPX_Maps_remove' );
add_filter( 'plugin_action_links', 'WP_GPX_Maps_action_links', 10, 2 );
add_action( 'wp_print_styles', 'print_WP_GPX_Maps_styles' );
add_action( 'wp_enqueue_scripts', 'enqueue_WP_GPX_Maps_scripts' );
add_action( 'admin_enqueue_scripts', 'enqueue_WP_GPX_Maps_scripts_admin' );
add_action( 'plugins_loaded', 'WP_GPX_Maps_lang_init' );
@ -64,29 +63,38 @@ function enqueue_WP_GPX_Maps_scripts_admin( $hook ) {
if ( strpos( $hook, 'WP-GPX-Maps' ) !== false ) {
/* Admin Style CSS */
wp_register_style( 'admin-stye', plugins_url( 'css/admin-style.css', __FILE__ ), array(), '1.0.0' );
wp_enqueue_style( 'admin-stye' );
wp_register_style( 'admin-style', plugins_url( 'css/admin-style.css', __FILE__ ), array(), '1.0.0' );
wp_enqueue_style( 'admin-style' );
/* mColorPicker */
wp_register_script( 'mColorPicker', plugins_url( '/js/mColorPicker_min.js', __FILE__ ), array(), '1.0 r39' );
wp_enqueue_script( 'mColorPicker' );
/* bootstrap-table */
wp_register_script( 'bootstrap-table', plugins_url( '/js/bootstrap-table.min.js', __FILE__ ), array(), '1.11.1' );
wp_register_script( 'bootstrap-table', plugins_url( '/js/bootstrap-table.js', __FILE__ ), array(), '1.13.2' );
wp_enqueue_script( 'bootstrap-table' );
wp_register_style( 'bootstrap-table', plugins_url( '/css/bootstrap-table.min.css', __FILE__ ), array(), '1.11.1' );
wp_register_style( 'bootstrap-table', plugins_url( '/css/bootstrap-table.css', __FILE__ ), array(), '1.13.2' );
wp_enqueue_style( 'bootstrap-table' );
}
}
function enqueue_WP_GPX_Maps_scripts() {
/* leaflet */
/* Output Style CSS */
wp_register_style( 'output-style', plugins_url( 'css/output-style.css', __FILE__ ), array(), '1.0.0' );
wp_enqueue_style( 'output-style' );
/* Leaflet */
wp_register_style( 'leaflet', plugins_url( '/ThirdParties/Leaflet_1.5.1/leaflet.css', __FILE__ ), array(), '1.5.1' );
wp_enqueue_style( 'leaflet' );
/* Leaflet.markercluster */
wp_register_style( 'leaflet.markercluster', plugins_url( '/ThirdParties/Leaflet.markercluster-1.4.1/MarkerCluster.css', __FILE__ ), array(), '1.4.1,' );
wp_enqueue_style( 'leaflet.markercluster' );
/* Leaflet.Photo */
wp_register_style( 'leaflet.Photo', plugins_url( '/ThirdParties/Leaflet.Photo/Leaflet.Photo.css', __FILE__ ), array(), '0' );
wp_enqueue_style( 'leaflet.Photo' );
/* Leaflet.fullscreen */
wp_register_style( 'leaflet.fullscreen', plugins_url( '/ThirdParties/leaflet.fullscreen-1.4.5/Control.FullScreen.css', __FILE__ ), array(), '1.5.1' );
wp_enqueue_style( 'leaflet.fullscreen' );
@ -95,11 +103,12 @@ function enqueue_WP_GPX_Maps_scripts() {
wp_register_script( 'leaflet.Photo', plugins_url( '/ThirdParties/Leaflet.Photo/Leaflet.Photo.js', __FILE__ ), array( 'leaflet', 'leaflet.markercluster' ), '0' );
wp_register_script( 'leaflet.fullscreen', plugins_url( '/ThirdParties/leaflet.fullscreen-1.4.5/Control.FullScreen.js', __FILE__ ), array( 'leaflet' ), '1.4.5' );
/* chartjs */
/* Chartjs */
wp_register_script( 'chartjs', plugins_url( '/js/Chart.min.js', __FILE__ ), array(), '2.8.0' );
wp_register_script( 'WP-GPX-Maps', plugins_url( '/js/WP-GPX-Maps.js', __FILE__ ), array( 'jquery', 'leaflet', 'chartjs' ), '1.6.02' );
wp_enqueue_script( 'output-style' );
wp_enqueue_script( 'leaflet' );
wp_enqueue_script( 'leaflet.markercluster' );
wp_enqueue_script( 'leaflet.Photo' );
@ -109,72 +118,6 @@ function enqueue_WP_GPX_Maps_scripts() {
wp_enqueue_script( 'WP-GPX-Maps' );
}
function print_WP_GPX_Maps_styles() {
?>
<style type="text/css">
.wpgpxmaps {
clear: both;
}
#content .wpgpxmaps img,
.entry-content .wpgpxmaps img,
.wpgpxmaps img {
max-width: none;
width: none;
padding: 0;
background: none;
margin: 0;
border: none;
}
.wpgpxmaps .ngimages {
display: none;
}
.wpgpxmaps .myngimages {
border: 1px solid #fff;
position: absolute;
cursor: pointer;
margin:0;
z-index :1;
}
.wpgpxmaps_summary .summarylabel { }
.wpgpxmaps_summary .summaryvalue {
font-weight: bold;
}
.wpgpxmaps .report {
line-height :120%;
}
.wpgpxmaps .gmnoprint div:first-child { }
.wpgpxmaps .wpgpxmaps_osm_footer {
position: absolute;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 13px;
margin: 0;
z-index: 999;
background: WHITE;
font-size: 12px;
}
.wpgpxmaps .wpgpxmaps_osm_footer span {
background: WHITE;
padding: 0 6px 6px 6px;
vertical-align: baseline;
position: absolute;
bottom: 0;
}
</style>
<?php
}
function wpgpxmaps_findValue( $attr, $attributeName, $optionName, $defaultValue ) {
$val = '';
@ -216,20 +159,20 @@ function handle_WP_GPX_Maps_folder_Shortcodes( $attr, $content = '' ) {
$gpx = $folder . DIRECTORY_SEPARATOR . $file;
$points = wpgpxmaps_getPoints( $gpx, $pointsoffset, $donotreducegpx, $distanceType );
$points_maps = '';
$points_maps = '';
$points_graph_dist = '';
$points_graph_ele = '';
$points_graph_ele = '';
if ( is_array ( $points_x_lat ) )
if ( is_array( $points_x_lat ) )
foreach ( array_keys( $points_x_lat ) as $i ) {
$_lat = (float) $points_x_lat[$i];
$_lon = (float) $points_x_lon[$i];
if ( $_lat == 0 && $_lon == 0 ) {
$points_maps .= 'null,';
$points_maps .= 'null,';
$points_graph_dist .= 'null,';
$points_graph_ele .= 'null,';
$points_graph_ele .= 'null,';
} else {
$points_maps .= '[' . number_format( (float) $points_x_lat[$i], 7, '.', '' ) . ',' . number_format( (float) $points_x_lon[$i], 7, '.', '' ) . '],';
@ -238,7 +181,7 @@ function handle_WP_GPX_Maps_folder_Shortcodes( $attr, $content = '' ) {
$_dist = (float) $points->dist[$i];
if ( $uom == '1' ) {
/* miles and feet */
/* feet / miles */
$_dist *= 0.000621371192;
$_ele *= 3.2808399;
@ -247,7 +190,7 @@ function handle_WP_GPX_Maps_folder_Shortcodes( $attr, $content = '' ) {
$_dist = (float) ( $_dist / 1000 );
} elseif ( $uom == '3' ) {
/* meters / kilometers / nautical miles */
/* meters / nautical miles */
$_dist = (float) ( $_dist / 1000 / 1.852 );
} elseif ( $uom == '4' ) {
@ -255,7 +198,7 @@ function handle_WP_GPX_Maps_folder_Shortcodes( $attr, $content = '' ) {
$_dist *= 0.000621371192;
} elseif ( $uom == '5' ) {
/* meters / kilometers / nautical miles and feet */
/* feet / nautical miles */
$_dist = (float) ( $_dist / 1000 / 1.852 );
$_ele *= 3.2808399;
}
@ -283,7 +226,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$download = wpgpxmaps_findValue( $attr, 'download', 'wpgpxmaps_download', '' );
$usegpsposition = wpgpxmaps_findValue( $attr, 'usegpsposition', 'wpgpxmaps_usegpsposition', false );
/* Print Summary Table */
$summary = wpgpxmaps_findValue( $attr, 'summary', 'wpgpxmaps_summary', '' );
$summary = wpgpxmaps_findValue( $attr, 'summary', 'wpgpxmaps_summary', false );
$p_tot_len = wpgpxmaps_findValue( $attr, 'summarytotlen', 'wpgpxmaps_summary_tot_len', false );
$p_max_ele = wpgpxmaps_findValue( $attr, 'summarymaxele', 'wpgpxmaps_summary_max_ele', false );
$p_min_ele = wpgpxmaps_findValue( $attr, 'summaryminele', 'wpgpxmaps_summary_min_ele', false );
@ -305,7 +248,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$currentIcon = wpgpxmaps_findValue( $attr, 'currenticon', 'wpgpxmaps_map_current_icon', '' );
$waypointIcon = wpgpxmaps_findValue( $attr, 'waypointicon', 'wpgpxmaps_map_waypoint_icon', '' );
/* Diagram - Elevation */
$showEle = wpgpxmaps_findValue( $attr, 'showele', 'wpgpxmaps_show_elevation', 'true' );
$showEle = wpgpxmaps_findValue( $attr, 'showele', 'wpgpxmaps_show_elevation', true );
$color_graph = wpgpxmaps_findValue( $attr, 'glinecolor', 'wpgpxmaps_graph_line_color', '#3366cc' );
$uom = wpgpxmaps_findValue( $attr, 'uom', 'wpgpxmaps_unit_of_measure', '0' );
$chartFrom1 = wpgpxmaps_findValue( $attr, 'chartfrom1', 'wpgpxmaps_graph_offset_from1', '' );
@ -323,8 +266,8 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$showAtemp = wpgpxmaps_findValue( $attr, 'showatemp', 'wpgpxmaps_show_atemp', false );
$color_graph_atemp = wpgpxmaps_findValue( $attr, 'glinecoloratemp', 'wpgpxmaps_graph_line_color_atemp', '#ff77bd' );
/* Diagram - Cadence */
$showCad = wpgpxmaps_findValue( $attr, 'showcad', 'wpgpxmaps_show_cadence', false );
$color_graph_cad = wpgpxmaps_findValue( $attr, 'glinecolorcad', 'wpgpxmaps_graph_line_color_cad', '#beecff' );
$showCad = wpgpxmaps_findValue( $attr, 'showcad', 'wpgpxmaps_show_cadence', false );
$color_graph_cad = wpgpxmaps_findValue( $attr, 'glinecolorcad', 'wpgpxmaps_graph_line_color_cad', '#beecff' );
/* Diagram - Grade */
$showGrade = wpgpxmaps_findValue( $attr, 'showgrade', 'wpgpxmaps_show_grade', false );
$color_graph_grade = wpgpxmaps_findValue( $attr, 'glinecolorgrade', 'wpgpxmaps_graph_line_color_grade', '#beecff' );
@ -338,7 +281,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$donotreducegpx = wpgpxmaps_findValue( $attr, 'donotreducegpx', 'wpgpxmaps_donotreducegpx', false );
$allow_users_upload = wpgpxmaps_findValue( $attr, 'wpgpxmaps_allow_users_upload', 'wpgpxmaps_allow_users_view', false );
$colors_map = "\"" . implode( "\",\"", ( explode( " ", $color_map ) ) ) . "\"";
$colors_map = "\"" . implode( "\",\"", ( explode( ' ', $color_map ) ) ) . "\"";
$gpxurl = $gpx;
@ -417,7 +360,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
}
}
$isGpxUrl = ( preg_match( '/^(http(s)?\:\/\/)/', trim( $gpx ) ) == 1);
$isGpxUrl = ( preg_match( '/^(http(s)?\:\/\/)/', trim( $gpx ) ) == 1 );
if ( ( ! isset( $points_maps ) || $points_maps == '' ) && $gpx != '' ) {
// if (true) {
@ -495,7 +438,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$_dist = (float) $points->dist[$i];
if ( $uom == '1') {
/* miles and feet */
/* feet / miles */
$_dist *= 0.000621371192;
$_ele *= 3.2808399;
@ -504,7 +447,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$_dist = (float) ( $_dist / 1000 );
} elseif ( $uom == '3') {
/* meters / kilometers / nautical miles */
/* meters / nautical miles */
$_dist = (float) ( $_dist / 1000 / 1.852 );
} elseif ( $uom == '4' ) {
@ -512,7 +455,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$_dist *= 0.000621371192;
} elseif ( $uom == '5' ) {
/* meters / kilometers / nautical miles and feet */
/* feet / nautical miles */
$_dist = (float) ( $_dist / 1000 / 1.852 );
$_ele *= 3.2808399;
}
@ -526,25 +469,25 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
}
if ( $showHr == true ) {
$points_graph_hr .= number_format( $points->hr[$i], 2, '.', '' ).',';
$points_graph_hr .= number_format( $points->hr[$i], 2, '.', '' ) . ',';
}
if ( $showAtemp == true ) {
$points_graph_atemp .= number_format( $points->atemp[$i], 1, '.', '' ).',';
$points_graph_atemp .= number_format( $points->atemp[$i], 1, '.', '' ) . ',';
}
if ( $showCad == true ) {
$points_graph_cad .= number_format( $points->cad[$i], 2, '.', '' ).',';
$points_graph_cad .= number_format( $points->cad[$i], 2, '.', '' ) . ',';
}
if ( $showGrade == true ) {
$points_graph_grade .= number_format( $points->grade[$i], 2, '.', '' ).',';
$points_graph_grade .= number_format( $points->grade[$i], 2, '.', '' ) . ',';
}
}
}
if ( $uom == '1' ) {
/* miles and feet */
/* feet / miles */
$tot_len = round( $tot_len * 0.000621371192, 2 ) . ' mi';
$max_ele = round( $max_ele * 3.2808399, 0 ) . ' ft';
$min_ele = round( $min_ele * 3.2808399, 0 ) . ' ft';
@ -560,15 +503,15 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$total_ele_down = round( $total_ele_down, 0 ) . ' m';
} elseif ( $uom == '3' ) {
/* meters / kilometers / nautical miles */
$tot_len = round( $tot_len / 1000/1.852, 2 ) . ' NM';
/* meters / nautical miles */
$tot_len = round( $tot_len / 1000 / 1.852, 2 ) . ' NM';
$max_ele = round( $max_ele, 0 ) . ' m';
$min_ele = round( $min_ele, 0 ) . ' m';
$total_ele_up = round( $total_ele_up, 0 ) . ' m';
$total_ele_down = round( $total_ele_down, 0 ) . ' m';
} elseif ( $uom == '4' ) {
/* meters / kilometers / nautical miles */
/* meters / miles */
$tot_len = round( $tot_len * 0.000621371192, 2 ) . ' mi';
$max_ele = round( $max_ele, 0 ) . ' m';
$min_ele = round( $min_ele, 0 ) . ' m';
@ -576,8 +519,8 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$total_ele_down = round( $total_ele_down, 0 ) . ' m';
} elseif ( $uom == '5' ) {
/* meters / kilometers / nautical miles and feet */
$tot_len = round( $tot_len / 1000/1.852, 2 ) . ' NM';
/* feet / nautical miles */
$tot_len = round( $tot_len / 1000 / 1.852, 2 ) . ' NM';
$max_ele = round( $max_ele * 3.2808399, 0 ) . ' ft';
$min_ele = round( $min_ele * 3.2808399, 0 ) . ' ft';
$total_ele_up = round( $total_ele_up * 3.2808399, 0 ) . ' ft';
@ -599,11 +542,11 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$wpoints = wpgpxmaps_getWayPoints( $gpx );
$waypoints = wp_json_encode( $wpoints );
}
if ( $showEle == 'false' ) {
$points_graph_ele = "";
if ( $showEle == false ) {
$points_graph_ele = '';
}
$p = "/(,|,null,)$/";
$p = '/(,|,null,)$/';
$points_maps = preg_replace( $p, '', $points_maps );
@ -643,11 +586,11 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$ngimgs_data = '';
if ( $ngGalleries != '' || $ngImages != '' ) {
$ngimgs = getNGGalleryImages( $ngGalleries, $ngImages, $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error );
$ngimgs_data ='';
$ngimgs_data = '';
foreach ( $ngimgs as $img ) {
$data = $img['data'];
$data = str_replace( "\n", "", $data );
$data = str_replace( '\n', '', $data );
$ngimgs_data .= '<span lat="' . $img['lat'] . '" lon="' . $img['lon'] . '">' . $data . '</span>';
}
}
@ -656,7 +599,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$attimgs = wpgpxmaps_getAttachedImages( $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error );
foreach ( $attimgs as $img ) {
$data = $img['data'];
$data = str_replace( "\n", "", $data );
$data = str_replace( '\n', '', $data );
$ngimgs_data .= '<span lat="' . $img['lat'] . '" lon="' . $img['lon'] . '">' . $data . '</span>';
}
}
@ -713,55 +656,56 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
jQuery(document).ready(function() {
jQuery("#wpgpxmaps_' . $r . '").wpgpxmaps({
targetId : "' . $r . '",
mapType : "' . $mt . '",
mapData : [' . $points_maps . '],
graphDist : [' . ( $hideGraph ? '' : $points_graph_dist ) . '],
graphEle : [' . ( $hideGraph ? '' : $points_graph_ele ) . '],
graphSpeed : [' . ( $hideGraph ? '' : $points_graph_speed ) . '],
graphHr : [' . ( $hideGraph ? '' : $points_graph_hr ) . '],
graphAtemp : [' . ( $hideGraph ? '' : $points_graph_atemp ) . '],
graphCad : [' . ( $hideGraph ? '' : $points_graph_cad ) . '],
graphGrade : [' . ( $hideGraph ? '' : $points_graph_grade ) . '],
waypoints : ' . $waypoints . ',
unit : "' . $uom . '",
unitspeed : "' . $uomspeed . '",
color1 : [' . $colors_map . '],
color2 : "' . $color_graph . '",
color3 : "' . $color_graph_speed . '",
color4 : "' . $color_graph_hr . '",
color5 : "' . $color_graph_cad . '",
color6 : "' . $color_graph_grade . '",
color7 : "' . $color_graph_atemp . '",
chartFrom1 : "' . $chartFrom1 . '",
chartTo1 : "' . $chartTo1 . '",
chartFrom2 : "' . $chartFrom2 . '",
chartTo2 : "' . $chartTo2 . '",
startIcon : "' . $startIcon . '",
endIcon : "' . $endIcon . '",
currentIcon : "' . $currentIcon . '",
waypointIcon : "' . $waypointIcon . '",
jQuery( "#wpgpxmaps_' . $r . '" ).wpgpxmaps( {
targetId : "' . $r . '",
mapType : "' . $mt . '",
mapData : [' . $points_maps . '],
graphDist : [' . ( $hideGraph ? '' : $points_graph_dist ) . '],
graphEle : [' . ( $hideGraph ? '' : $points_graph_ele ) . '],
graphSpeed : [' . ( $hideGraph ? '' : $points_graph_speed ) . '],
graphHr : [' . ( $hideGraph ? '' : $points_graph_hr ) . '],
graphAtemp : [' . ( $hideGraph ? '' : $points_graph_atemp ) . '],
graphCad : [' . ( $hideGraph ? '' : $points_graph_cad ) . '],
graphGrade : [' . ( $hideGraph ? '' : $points_graph_grade ) . '],
waypoints : ' . $waypoints . ',
unit : "' . $uom . '",
unitspeed : "' . $uomspeed . '",
color1 : [' . $colors_map . '],
color2 : "' . $color_graph . '",
color3 : "' . $color_graph_speed . '",
color4 : "' . $color_graph_hr . '",
color5 : "' . $color_graph_cad . '",
color6 : "' . $color_graph_grade . '",
color7 : "' . $color_graph_atemp . '",
chartFrom1 : "' . $chartFrom1 . '",
chartTo1 : "' . $chartTo1 . '",
chartFrom2 : "' . $chartFrom2 . '",
chartTo2 : "' . $chartTo2 . '",
startIcon : "' . $startIcon . '",
endIcon : "' . $endIcon . '",
currentIcon : "' . $currentIcon . '",
waypointIcon : "' . $waypointIcon . '",
currentpositioncon : "' . $currentpositioncon . '",
usegpsposition : "' . $usegpsposition . '",
zoomOnScrollWheel : "' . $zoomOnScrollWheel . '",
ngGalleries : [' . $ngGalleries . '],
ngImages : [' . $ngImages . '],
pluginUrl : "' . plugins_url() . '",
TFApiKey : "' . get_option( 'wpgpxmaps_openstreetmap_apikey' ) . '",
langs : { altitude : "' . __( 'Altitude', 'wp-gpx-maps' ) . '",
currentPosition : "' . __( 'Current position', 'wp-gpx-maps' ) . '",
speed : "' . __( 'Speed', 'wp-gpx-maps' ) . '",
grade : "' . __( 'Grade', 'wp-gpx-maps' ) . '",
heartRate : "' . __( 'Heart rate', 'wp-gpx-maps' ) . '",
atemp : "' . __( 'Temperature', 'wp-gpx-maps' ) . '",
cadence : "' . __( 'Cadence', 'wp-gpx-maps' ) . '",
goFullScreen : "' . __( 'Go full screen', 'wp-gpx-maps' ) . '",
exitFullFcreen : "' . __( 'Exit full screen', 'wp-gpx-maps' ) . '",
hideImages : "' . __( 'Hide images', 'wp-gpx-maps' ) . '",
showImages : "' . __( 'Show images', 'wp-gpx-maps' ) . '",
backToCenter : "' . __( 'Back to center', 'wp-gpx-maps' ) . '"
}
usegpsposition : "' . $usegpsposition . '",
zoomOnScrollWheel : "' . $zoomOnScrollWheel . '",
ngGalleries : [' . $ngGalleries . '],
ngImages : [' . $ngImages . '],
pluginUrl : "' . plugins_url() . '",
TFApiKey : "' . get_option( 'wpgpxmaps_openstreetmap_apikey' ) . '",
langs : {
altitude : "' . __( 'Altitude', 'wp-gpx-maps' ) . '",
currentPosition : "' . __( 'Current position', 'wp-gpx-maps' ) . '",
speed : "' . __( 'Speed', 'wp-gpx-maps' ) . '",
grade : "' . __( 'Grade', 'wp-gpx-maps' ) . '",
heartRate : "' . __( 'Heart rate', 'wp-gpx-maps' ) . '",
atemp : "' . __( 'Temperature', 'wp-gpx-maps' ) . '",
cadence : "' . __( 'Cadence', 'wp-gpx-maps' ) . '",
goFullScreen : "' . __( 'Go full screen', 'wp-gpx-maps' ) . '",
exitFullFcreen : "' . __( 'Exit full screen', 'wp-gpx-maps' ) . '",
hideImages : "' . __( 'Hide images', 'wp-gpx-maps' ) . '",
showImages : "' . __( 'Show images', 'wp-gpx-maps' ) . '",
backToCenter : "' . __( 'Back to center', 'wp-gpx-maps' ) . '"
}
});
});
@ -769,43 +713,43 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
</script>';
/* Print summary */
if ( $summary == 'true' && ( $points_graph_speed != '' || $points_graph_ele != '' || $points_graph_dist != '') ) {
if ( $summary == true && ( $points_graph_speed != '' || $points_graph_ele != '' || $points_graph_dist != '' ) ) {
$output .= "<div id='wpgpxmaps_summary_" . $r . "' class='wpgpxmaps_summary'>";
if ( $points_graph_dist != '' && $p_tot_len == 'true' ) {
$output .= "<span class='totlen'><span class='summarylabel'>" . __( 'Total distance', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $tot_len</span></span><br />";
if ( $points_graph_dist != '' && $p_tot_len == true ) {
$output .= "<span class='totlen'><span class='summarylabel'>" . __( 'Total distance:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $tot_len</span></span><br />";
}
if ( $points_graph_ele != ' ' ) {
if ( $p_max_ele == 'true' )
$output .= "<span class='maxele'><span class='summarylabel'>" . __( 'Max elevation', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $max_ele</span></span><br />";
if ( $p_min_ele == 'true' )
$output .= "<span class='minele'><span class='summarylabel'>" . __( 'Min elevation', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $min_ele</span></span><br />";
if ( $p_total_ele_up == 'true' )
$output .= "<span class='totaleleup'><span class='summarylabel'>" . __( 'Total climbing', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $total_ele_up</span></span><br />";
if ( $p_total_ele_down == 'true' )
$output .= "<span class='totaleledown'><span class='summarylabel'>" . __( 'Total descent', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $total_ele_down</span></span><br />";
if ( $p_max_ele == true )
$output .= "<span class='maxele'><span class='summarylabel'>" . __( 'Max elevation:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $max_ele</span></span><br />";
if ( $p_min_ele == true )
$output .= "<span class='minele'><span class='summarylabel'>" . __( 'Min elevation:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $min_ele</span></span><br />";
if ( $p_total_ele_up == true )
$output .= "<span class='totaleleup'><span class='summarylabel'>" . __( 'Total climbing:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $total_ele_up</span></span><br />";
if ( $p_total_ele_down == true )
$output .= "<span class='totaleledown'><span class='summarylabel'>" . __( 'Total descent:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $total_ele_down</span></span><br />";
}
if ( $points_graph_speed != '' && $p_avg_speed == 'true' ) {
$output .= "<span class='avgspeed'><span class='summarylabel'>" . __( 'Average speed', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $avg_speed</span></span><br />";
if ( $points_graph_speed != '' && $p_avg_speed == true ) {
$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 ( $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 ( $points_graph_hr != '' && $p_avg_hr == 'true' ) {
$output .= "<span class='avghr'><span class='summarylabel'>" . __( 'Average heart rate', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $avg_hr</span></span><br />";
if ( $points_graph_hr != '' && $p_avg_hr == true ) {
$output .= "<span class='avghr'><span class='summarylabel'>" . __( 'Average heart rate:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $avg_hr</span></span><br />";
}
if ( $points_graph_atemp != '' && $p_avg_temp == 'true' ) {
$output .= "<span class='avgtemp'><span class='summarylabel'>" . __( 'Average temperature', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $avg_temp</span></span><br />";
if ( $points_graph_atemp != '' && $p_avg_temp == true ) {
$output .= "<span class='avgtemp'><span class='summarylabel'>" . __( 'Average temperature:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $avg_temp</span></span><br />";
}
if ( $p_total_time == 'true' && $max_time > 0 ) {
$time_diff = date( "H:i:s", ( $max_time - $min_time ) );
$output .= "<span class='totaltime'><span class='summarylabel'>" . __( 'Total time', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $time_diff</span></span><br />";
if ( $p_total_time == true && $max_time > 0 ) {
$time_diff = date( 'H:i:s', ( $max_time - $min_time ) );
$output .= "<span class='totaltime'><span class='summarylabel'>" . __( 'Total time:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $time_diff</span></span><br />";
}
$output .= "</div>";
$output .= '</div>';
}
/* Print download link */
if ( $download == 'true' && $gpxurl != '' ) {
if ( $download == true && $gpxurl != '' ) {
if ( $isGpxUrl == true ) {
} else {
@ -813,25 +757,28 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$dummy = ( defined( 'WP_SITEURL' ) ) ? WP_SITEURL : get_bloginfo( 'url' );
$gpxurl = $dummy . $gpxurl;
}
$output .= "<a href='$gpxurl' target='_new' download>" . __( 'Download', 'wp-gpx-maps' ) . "</a>";
$output .= "<a href='$gpxurl' target='_new' download>" . __( 'Download', 'wp-gpx-maps' ) . '</a>';
}
return $output;
}
function convertSeconds( $s ) {
if ( $s == 0 )
return 0;
$s = 1.0 / $s;
$_sSecT = $s * 60; // sec/km
$_sMin = floor ( $_sSecT / 60 );
$_sMin = floor( $_sSecT / 60 );
$_sSec = $_sSecT - $_sMin * 60;
return $_sMin + $_sSec / 100;
}
function convertSpeed( $speed, $uomspeed, $addUom = false ) {
$uom = '';
if ( $uomspeed == '6' ) {
if ( $uomspeed == '6' ) {
/* min/100 meters */
$speed = 1 / $speed * 100 / 60;
$uom = ' min/100m';
@ -860,6 +807,7 @@ function convertSpeed( $speed, $uomspeed, $addUom = false ) {
/* km/h */
$speed *= 3.6;
$uom = ' km/h';
} else {
/* dafault m/s */
$uom = ' m/s';
@ -873,38 +821,31 @@ function convertSpeed( $speed, $uomspeed, $addUom = false ) {
}
function downloadRemoteFile( $remoteFile ) {
try {
$newfname = tempnam( '/tmp', 'gpx' );
if ( function_exists ( 'file_put_contents' ) ) {
if ( function_exists( 'file_put_contents' ) ) {
file_put_contents( $newfname, fopen( $remoteFile, 'r' ) );
return $newfname;
}
$file = fopen ( $remoteFile, 'rb' );
$file = fopen( $remoteFile, 'rb' );
if ( $file ) {
$newf = fopen ( $newfname, 'wb' );
$newf = fopen( $newfname, 'wb' );
if ( $newf )
while ( ! feof( $file ) ) {
fwrite( $newf, fread( $file, 1024 * 8 ), 1024 * 8 );
}
}
if ( $file ) {
fclose( $file );
}
if ( $newf ) {
fclose( $newf );
}
return $newfname;
} catch ( Exception $e ) {
print_r( $e );
return '';
}
}
@ -912,7 +853,7 @@ function downloadRemoteFile( $remoteFile ) {
function unescape( $value ) {
$value = str_replace( "'", "\'", $value );
$value = str_replace( array( "\n", "\r" ), "", $value );
$value = str_replace( array( '\n', '\r' ), '', $value );
return $value;
}
@ -922,10 +863,22 @@ function WP_GPX_Maps_install() {
add_option( 'wpgpxmaps_width', '100%', '', 'yes' );
add_option( 'wpgpxmaps_height', '450px', '', 'yes' );
add_option( 'wpgpxmaps_graph_height', '200px', '', 'yes' );
add_option( 'wpgpxmaps_distance_type', '0', '', 'yes' );
add_option( 'wpgpxmaps_skipcache', '', '', 'yes' );
add_option( 'wpgpxmaps_download', '', '', 'yes' );
add_option( 'wpgpxmaps_usegpsposition', '', '', 'yes' );
/* Print Summary Table */
add_option( 'wpgpxmaps_summary', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_tot_len', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_max_ele', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_min_ele', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_total_ele_up', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_total_ele_down', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_avg_speed', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_avg_cad', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_avg_hr', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_avg_temp', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_total_time', '', '', 'yes' );
/* Map */
add_option( 'wpgpxmaps_map_type', 'HYBRID', '', 'yes' );
add_option( 'wpgpxmaps_map_line_color', '#3366cc', '', 'yes' );
@ -933,9 +886,11 @@ function WP_GPX_Maps_install() {
add_option( 'wpgpxmaps_show_waypoint', '', '', 'yes' );
add_option( 'wpgpxmaps_map_start_icon', '', '', 'yes' );
add_option( 'wpgpxmaps_map_end_icon', '', '', 'yes' );
add_option( 'wpgpxmaps_currentpositioncon', '', '', 'yes' );
add_option( 'wpgpxmaps_map_current_icon', '', '', 'yes' );
add_option( 'wpgpxmaps_map_waypoint_icon', '', '', 'yes' );
/* Diagram - Elevation */
add_option( 'wpgpxmaps_show_elevation', 'true', '', 'yes' );
add_option( 'wpgpxmaps_graph_line_color', '#3366cc', '', 'yes' );
add_option( 'wpgpxmaps_unit_of_measure', '0', '', 'yes' );
add_option( 'wpgpxmaps_graph_offset_from1', '', '', 'yes' );
@ -956,7 +911,8 @@ function WP_GPX_Maps_install() {
add_option( 'wpgpxmaps_show_cadence', '', '', 'yes' );
add_option( 'wpgpxmaps_graph_line_color_cad', '#beecff', '', 'yes' );
/* Diagram - Grade */
add_option( 'wpgpxmaps_show_grade', '', '', 'yes' );
add_option( 'wpgpxmaps_graph_line_color_grade', '#beecff', '', 'yes' );
/* Pictures */
add_option( 'wpgpxmaps_map_nggallery', '', '', 'yes' );
/* Advanced */
@ -970,10 +926,22 @@ function WP_GPX_Maps_remove() {
delete_option( 'wpgpxmaps_width' );
delete_option( 'wpgpxmaps_graph_height' );
delete_option( 'wpgpxmaps_height' );
delete_option( 'wpgpxmaps_distance_type' );
delete_option( 'wpgpxmaps_skipcache' );
delete_option( 'wpgpxmaps_download' );
delete_option( 'wpgpxmaps_usegpsposition' );
/* Print Summary Table */
delete_option( 'wpgpxmaps_summary' );
delete_option( 'wpgpxmaps_summary_tot_len' );
delete_option( 'wpgpxmaps_summary_max_ele' );
delete_option( 'wpgpxmaps_summary_min_ele' );
delete_option( 'wpgpxmaps_summary_total_ele_up' );
delete_option( 'wpgpxmaps_summary_total_ele_down' );
delete_option( 'wpgpxmaps_summary_avg_speed' );
delete_option( 'wpgpxmaps_summary_avg_cad' );
delete_option( 'wpgpxmaps_summary_avg_hr' );
delete_option( 'wpgpxmaps_summary_avg_temp' );
delete_option( 'wpgpxmaps_summary_total_time' );
/* Map */
delete_option( 'wpgpxmaps_map_type' );
delete_option( 'wpgpxmaps_map_line_color' );
@ -981,9 +949,11 @@ function WP_GPX_Maps_remove() {
delete_option( 'wpgpxmaps_show_waypoint' );
delete_option( 'wpgpxmaps_map_start_icon' );
delete_option( 'wpgpxmaps_map_end_icon' );
delete_option( 'wpgpxmaps_currentpositioncon' );
delete_option( 'wpgpxmaps_map_current_icon' );
delete_option( 'wpgpxmaps_map_waypoint_icon' );
/* Diagram - Elevation */
delete_option( 'wpgpxmaps_show_elevation' );
delete_option( 'wpgpxmaps_graph_line_color' );
delete_option( 'wpgpxmaps_unit_of_measure' );
delete_option( 'wpgpxmaps_graph_offset_from1' );
@ -1004,12 +974,11 @@ function WP_GPX_Maps_remove() {
delete_option( 'wpgpxmaps_show_cadence' );
delete_option( 'wpgpxmaps_graph_line_color_cad' );
/* Diagram - Grade */
delete_option( 'wpgpxmaps_show_grade' );
delete_option( 'wpgpxmaps_graph_line_color_grade' );
/* Pictures */
delete_option( 'wpgpxmaps_map_nggallery' );
/* Advanced */
delete_option( 'wpgpxmaps_pointsoffset' );
delete_option( 'wpgpxmaps_donotreducegpx' );
}
?>

View File

@ -1,57 +1,53 @@
<?php
if ( is_admin() ) {
add_action( 'admin_menu', 'wpgpxmaps_admin_menu' );
}
/**
* Roles and capabilities
*
* Capabilities for each user role that are relevant to this plugin:
*
* Super Admin: can manage settings; can publish, edit and delete all posts; can upload and delete all GPX files
* Admin: can manage settings; can publish, edit and delete all posts; can upload and delete all GPX files
* Editor: can not manage settings; can publish, edit and delete all posts; can upload and delete all GPX files
* Author: can not manage settings; can publish, edit and delete his own posts; can upload and delete his own files
* Contributor: can not manage settings; can edit and delete his own posts; can not manage GPX files
* Subscriber: can not manage settings; can not manage posts; can not manage GPX files (has read status everywhere)
*
* @see https://wordpress.org/support/article/roles-and-capabilities/
*/
function wpgpxmaps_admin_menu() {
/*
All roles/capabilities:
https://wordpress.org/support/article/roles-and-capabilities/
*/
if ( current_user_can( 'manage_options' ) ) {
/* Only Administrators and Super Administrators */
/* Access only for Super Administrators and Administrators */
add_options_page( 'WP GPX Maps', 'WP GPX Maps', 'manage_options', 'WP-GPX-Maps', 'WP_GPX_Maps_html_page' );
}
elseif ( current_user_can( 'publish_posts' ) ) {
} elseif ( current_user_can( 'publish_posts' ) ) {
/* Access for Editors and Authors */
/* Contributor Authors and */
$allow_users_upload = get_option( 'wpgpxmaps_allow_users_view' ) === 'true';
$allow_users_upload = get_option( 'wpgpxmaps_allow_users_view' ) === "true";
if ($allow_users_upload == 1)
{
if ( $allow_users_upload == 1 ) {
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' ) ) {
/* Access for Super Administrators and Administrators */
$tabs = array(
'tracks' => __( 'Tracks', 'wp-gpx-maps' ),
'settings' => __( 'Settings', 'wp-gpx-maps' ),
'help' => __( 'Help', 'wp-gpx-maps' ),
);
} elseif ( current_user_can( 'publish_posts' ) ) {
} elseif ( current_user_can( 'publish_posts' ) ) {
/* Access for Editors and Authors */
$tabs = array(
'tracks' => __( 'Tracks', 'wp-gpx-maps' ),
'help' => __( 'Help', 'wp-gpx-maps' ),
@ -61,54 +57,40 @@ function wpgpxmaps_ilc_admin_tabs( $current ) {
echo '<h2 class="nav-tab-wrapper">';
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 '</h2>';
}
function WP_GPX_Maps_html_page() {
$realGpxPath = gpxFolderPath();
$cacheGpxPath = gpxCacheFolderPath();
$relativeGpxPath = relativeGpxFolderPath();
$relativeGpxPath = str_replace( "\\","/", $relativeGpxPath );
$realGpxPath = gpxFolderPath();
$cacheGpxPath = gpxCacheFolderPath();
$relativeGpxPath = relativeGpxFolderPath();
$relativeGpxPath = str_replace( '\\', '/', $relativeGpxPath );
$relativeGpxCachePath = relativeGpxCacheFolderPath();
$relativeGpxCachePath = str_replace( "\\","/", $relativeGpxCachePath );
$tab = $_GET['tab'];
$relativeGpxCachePath = str_replace( '\\', '/', $relativeGpxCachePath );
$tab = $_GET['tab'];
if ( $tab == '' )
$tab = 'tracks';
?>
<div id="icon-themes" class="icon32"><br></div>
<h2><?php _e( 'Settings', 'wp-gpx-maps' ); ?></h2>
<h2>
<?php _e( 'Settings', 'wp-gpx-maps' ); ?>
</h2>
<?php
if ( file_exists( $realGpxPath ) && is_dir( $realGpxPath ) ) {
/* Directory exist! */
} else {
if ( ! @mkdir( $realGpxPath, 0755, true ) ) {
echo '<div class=" notice notice-error"><p>';
printf(
@ -119,13 +101,11 @@ function WP_GPX_Maps_html_page() {
echo '</p></div>';
}
}
if ( file_exists( $cacheGpxPath ) && is_dir( $cacheGpxPath ) ) {
/* Directory exist! */
} else {
if ( ! @mkdir( $cacheGpxPath, 0755, true ) ) {
echo '<div class=" notice notice-error"><p>';
printf(

View File

@ -96,9 +96,15 @@
</th>
<td>
<select name='wpgpxmaps_distance_type'>
<option value="0" <?php if ( $distanceType == '0' || $distanceType == '' ) echo 'selected'; ?>><?php _e( 'Normal (default)', 'wp-gpx-maps' ); ?></option>
<option value="1" <?php if ( $distanceType == '1' ) echo 'selected'; ?>><?php _e( 'Flat &#8594; (Only flat distance, don&#8217;t take care of altitude)', 'wp-gpx-maps' ); ?></option>
<option value="2" <?php if ( $distanceType == '2' ) echo 'selected'; ?>><?php _e( 'Climb &#8593; (Only climb distance)', 'wp-gpx-maps' ); ?></option>
<option value="0" <?php if ( $distanceType == '0' || $distanceType == '' ) echo 'selected'; ?>>
<?php _e( 'Normal (default)', 'wp-gpx-maps' ); ?>
</option>
<option value="1" <?php if ( $distanceType == '1' ) echo 'selected'; ?>>
<?php _e( 'Flat &#8594; (Only flat distance, don&#8217;t take care of altitude)', 'wp-gpx-maps' ); ?>
</option>
<option value="2" <?php if ( $distanceType == '2' ) echo 'selected'; ?>>
<?php _e( 'Climb &#8593; (Only climb distance)', 'wp-gpx-maps' ); ?>
</option>
</select>
</td>
</tr>
@ -110,10 +116,7 @@
<td>
<input name="wpgpxmaps_skipcache" type="checkbox" value="true" <?php if ( $skipcache == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Do not use cache', 'wp-gpx-maps' );
?>
<?php _e( 'Do not use cache', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -125,10 +128,7 @@
<td>
<input name="wpgpxmaps_download" type="checkbox" value="true" <?php if ( $download == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Allow users to download your GPX file', 'wp-gpx-maps' );
?>
<?php _e( 'Allow users to download your GPX file', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -140,10 +140,7 @@
<td>
<input name="wpgpxmaps_usegpsposition" type="checkbox" value="true" <?php if ( $usegpsposition == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Allow users to use browser GPS in order to display their current position on map', 'wp-gpx-maps' );
?>
<?php _e( 'Allow users to use browser GPS in order to display their current position on map', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -194,10 +191,7 @@
<td>
<input name="wpgpxmaps_summary" type="checkbox" value="true" <?php if ( $summary == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Print summary details of your GPX track', 'wp-gpx-maps' );
?>
<?php _e( 'Print summary details of your GPX track', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -209,10 +203,7 @@
<td>
<input name="wpgpxmaps_summary_tot_len" type="checkbox" value="true" <?php if ( $tot_len == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Print total distance', 'wp-gpx-maps' );
?>
<?php _e( 'Print total distance', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -224,10 +215,7 @@
<td>
<input name="wpgpxmaps_summary_max_ele" type="checkbox" value="true" <?php if ( $max_ele == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Print max elevation', 'wp-gpx-maps' );
?>
<?php _e( 'Print max elevation', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -239,10 +227,7 @@
<td>
<input name="wpgpxmaps_summary_min_ele" type="checkbox" value="true" <?php if ( $min_ele == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Print min elevation', 'wp-gpx-maps' );
?>
<?php _e( 'Print min elevation', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -254,10 +239,7 @@
<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>
<?php
echo ' ';
_e( 'Print total climbing', 'wp-gpx-maps' );
?>
<?php _e( 'Print total climbing', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -269,10 +251,7 @@
<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>
<?php
echo ' ';
_e( 'Print total descent', 'wp-gpx-maps' );
?>
<?php _e( 'Print total descent', 'wp-gpx-maps' ); ?>
</i>
</tr>
@ -283,10 +262,7 @@
<td>
<input name="wpgpxmaps_summary_avg_speed" type="checkbox" value="true" <?php if ( $avg_speed == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Print average speed', 'wp-gpx-maps' );
?>
<?php _e( 'Print average speed', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -298,10 +274,7 @@
<td>
<input name="wpgpxmaps_summary_avg_cad" type="checkbox" value="true" <?php if ( $avg_cad == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Print average cadence', 'wp-gpx-maps' );
?>
<?php _e( 'Print average cadence', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -313,10 +286,7 @@
<td>
<input name="wpgpxmaps_summary_avg_hr" type="checkbox" value="true" <?php if ( $avg_hr == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Print average heart rate', 'wp-gpx-maps' );
?>
<?php _e( 'Print average heart rate', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -328,10 +298,7 @@
<td>
<input name="wpgpxmaps_summary_avg_temp" type="checkbox" value="true" <?php if ( $avg_temp == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Print average temperature', 'wp-gpx-maps' );
?>
<?php _e( 'Print average temperature', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -343,10 +310,7 @@
<td>
<input name="wpgpxmaps_summary_total_time" type="checkbox" value="true" <?php if ( $total_time == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Print total time', 'wp-gpx-maps' );
?>
<?php _e( 'Print total time', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -379,49 +343,49 @@
<td>
<input type="radio" name="wpgpxmaps_map_type" value="OSM1" <?php if ( $t == 'OSM1' ) echo 'checked'; ?>>
<?php
echo ' ';
/* translators: map type */
_e( 'Open Street Map', 'wp-gpx-maps' );
?>
<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM2" <?php if ( $t == 'OSM2' ) echo 'checked'; ?>>
<?php
echo ' ';
/* translators: map provider / map type */
_e( 'Open Cycle Map', 'wp-gpx-maps' );
?>
<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM4" <?php if ( $t == 'OSM4' ) echo 'checked'; ?>>
<?php
echo ' ';
/* translators: map provider / map type */
_e( 'Open Cycle Map - Transport', 'wp-gpx-maps' );
?>
<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM5" <?php if ( $t == 'OSM5' ) echo 'checked'; ?>>
<?php
echo ' ';
/* translators: map provider / map type */
_e( 'Open Cycle Map - Landscape', 'wp-gpx-maps' );
?>
<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM6" <?php if ( $t == 'OSM6' ) echo 'checked'; ?>>
<?php
echo ' ';
/* translators: map provider / map type */
_e( 'MapToolKit - Terrain', 'wp-gpx-maps' );
?>
<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM7" <?php if ( $t == 'OSM7' ) echo 'checked'; ?>>
<?php
echo ' ';
/* translators: map provider / map type */
_e( 'Open Street Map - Humanitarian map style', 'wp-gpx-maps' );
?>
<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM9" <?php if ( $t == 'OSM9' ) echo 'checked'; ?>>
<?php
echo ' ';
/* translators: map provider / map type */
_e( 'Hike & Bike', 'wp-gpx-maps' );
?>
<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM10" <?php if ( $t == 'OSM10' ) echo 'checked'; ?>>
<?php
echo ' ';
/* translators: map provider / map type */
_e( 'Open Sea Map', 'wp-gpx-maps' );
?>
<br />
@ -444,10 +408,7 @@
<td>
<input name="wpgpxmaps_zoomonscrollwheel" type="checkbox" value="true" <?php if ( $zoomonscrollwheel == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Enable zoom', 'wp-gpx-maps' );
?>
<?php _e( 'Enable zoom', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -459,10 +420,7 @@
<td>
<input name="wpgpxmaps_show_waypoint" type="checkbox" value="true" <?php if ( $showW == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Show waypoints', 'wp-gpx-maps' );
?>
<?php _e( 'Show waypoints', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -472,7 +430,7 @@
<?php _e( 'Start track icon:', 'wp-gpx-maps' ); ?>
</th>
<td>
<input name="wpgpxmaps_map_start_icon" value="<?php echo get_option( 'wpgpxmaps_map_start_icon' ); ?>" style="width:400px" />
<input name="wpgpxmaps_map_start_icon" type="text" value="<?php echo get_option( 'wpgpxmaps_map_start_icon' ); ?>" style="width:400px" />
<em>
<?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?>
</em>
@ -484,7 +442,7 @@
<?php _e( 'End track icon:', 'wp-gpx-maps' ); ?>
</th>
<td>
<input name="wpgpxmaps_map_end_icon" value="<?php echo get_option( 'wpgpxmaps_map_end_icon' ); ?>" style="width:400px" />
<input name="wpgpxmaps_map_end_icon" type="text" value="<?php echo get_option( 'wpgpxmaps_map_end_icon' ); ?>" style="width:400px" />
<em>
<?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?>
</em>
@ -496,7 +454,7 @@
<?php _e( 'Current position icon:', 'wp-gpx-maps' ); ?>
</th>
<td>
<input name="wpgpxmaps_map_current_icon" value="<?php echo get_option( 'wpgpxmaps_map_current_icon' ); ?>" style="width:400px" />
<input name="wpgpxmaps_map_current_icon" type="text" value="<?php echo get_option( 'wpgpxmaps_map_current_icon' ); ?>" style="width:400px" />
<em>
<?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?>
</em>
@ -508,7 +466,7 @@
<?php _e( 'Current GPS position icon:', 'wp-gpx-maps' ); ?>
</th>
<td>
<input name="wpgpxmaps_currentpositioncon" value="<?php echo get_option( 'wpgpxmaps_currentpositioncon' ); ?>" style="width:400px" />
<input name="wpgpxmaps_currentpositioncon" type="text" value="<?php echo get_option( 'wpgpxmaps_currentpositioncon' ); ?>" style="width:400px" />
<em>
<?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?>
</em>
@ -520,7 +478,7 @@
<?php _e( 'Custom waypoint icon:', 'wp-gpx-maps' ); ?>
</th>
<td>
<input name="wpgpxmaps_map_waypoint_icon" value="<?php echo get_option( 'wpgpxmaps_map_waypoint_icon' ); ?>" style="width:400px" />
<input name="wpgpxmaps_map_waypoint_icon" type="text" value="<?php echo get_option( 'wpgpxmaps_map_waypoint_icon' ); ?>" style="width:400px" />
<em>
<?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?>
</em>
@ -553,12 +511,9 @@
<?php _e( 'Altitude:', 'wp-gpx-maps' ); ?>
</th>
<td>
<input type="checkbox" <?php if ( $showEle == true ){ echo( 'checked' ); } ?> onchange="wpgpxmaps_show_elevation.value = this.checked" onload="wpgpxmaps_show_elevation.value = this.checked" />
<input type="checkbox" <?php if ( $showEle == true ) { echo( 'checked' ); } ?> onchange="wpgpxmaps_show_elevation.value = this.checked" onload="wpgpxmaps_show_elevation.value = this.checked" />
<i>
<?php
echo ' ';
_e( 'Show altitude', 'wp-gpx-maps' );
?>
<?php _e( 'Show altitude', 'wp-gpx-maps' ); ?>
</i>
<input name="wpgpxmaps_show_elevation" type="hidden" value="<?php echo $showEle; ?>">
</td>
@ -579,12 +534,42 @@
</th>
<td>
<select name='wpgpxmaps_unit_of_measure'>
<option value="0" <?php if ( $uom == '0' ) echo 'selected'; ?>><?php _e( 'meters / meters', 'wp-gpx-maps' ); ?></option>
<option value="1" <?php if ( $uom == '1' ) echo 'selected'; ?>><?php _e( 'feet / miles', 'wp-gpx-maps' ); ?></option>
<option value="2" <?php if ( $uom == '2' ) echo 'selected'; ?>><?php _e( 'meters / kilometers', 'wp-gpx-maps' ); ?></option>
<option value="3" <?php if ( $uom == '3' ) echo 'selected'; ?>><?php _e( 'meters / nautical miles', 'wp-gpx-maps' ); ?></option>
<option value="4" <?php if ( $uom == '4' ) echo 'selected'; ?>><?php _e( 'meters / miles', 'wp-gpx-maps' ); ?></option>
<option value="5" <?php if ( $uom == '5' ) echo 'selected'; ?>><?php _e( 'feet / nautical miles', 'wp-gpx-maps' ); ?></option>
<option value="0" <?php if ( $uom == '0' ) echo 'selected'; ?>>
<?php
/* translators: chart axis labels */
_e( 'meters / meters', 'wp-gpx-maps' );
?>
</option>
<option value="1" <?php if ( $uom == '1' ) echo 'selected'; ?>>
<?php
/* translators: chart axis labels */
_e( 'feet / miles', 'wp-gpx-maps' );
?>
</option>
<option value="2" <?php if ( $uom == '2' ) echo 'selected'; ?>>
<?php
/* translators: chart axis labels */
_e( 'meters / kilometers', 'wp-gpx-maps' );
?>
</option>
<option value="3" <?php if ( $uom == '3' ) echo 'selected'; ?>>
<?php
/* translators: chart axis labels */
_e( 'meters / nautical miles', 'wp-gpx-maps' );
?>
</option>
<option value="4" <?php if ( $uom == '4' ) echo 'selected'; ?>>
<?php
/* translators: chart axis labels */
_e( 'meters / miles', 'wp-gpx-maps' );
?>
</option>
<option value="5" <?php if ( $uom == '5' ) echo 'selected'; ?>>
<?php
/* translators: chart axis labels */
_e( 'feet / nautical miles', 'wp-gpx-maps' );
?>
</option>
</select>
</td>
</tr>
@ -595,10 +580,12 @@
</th>
<td>
<?php _e( 'From', 'wp-gpx-maps' ); ?>
<input name="wpgpxmaps_graph_offset_from1" value="<?php echo get_option( 'wpgpxmaps_graph_offset_from1' ); ?>" style="width:50px;" />
<input name="wpgpxmaps_graph_offset_from1" type="text" value="<?php echo get_option( 'wpgpxmaps_graph_offset_from1' ); ?>" style="width:50px;" />
<?php _e( 'to', 'wp-gpx-maps' ); ?>
<input name="wpgpxmaps_graph_offset_to1" value="<?php echo get_option( 'wpgpxmaps_graph_offset_to1' ); ?>" style="width:50px;" />
<em><?php _e( '(leave empty for auto scale)', 'wp-gpx-maps' ); ?></em>
<input name="wpgpxmaps_graph_offset_to1" type="text" value="<?php echo get_option( 'wpgpxmaps_graph_offset_to1' ); ?>" style="width:50px;" />
<em>
<?php _e( '(leave empty for auto scale)', 'wp-gpx-maps' ); ?>
</em>
</td>
</tr>
@ -607,7 +594,10 @@
<?php _e( 'Speed:', 'wp-gpx-maps' ); ?>
</th>
<td>
<input name="wpgpxmaps_show_speed" type="checkbox" value="true" <?php if ( $showSpeed == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /><i><?php echo ' ' ; _e( 'Show speed', 'wp-gpx-maps' ); ?></i>
<input name="wpgpxmaps_show_speed" type="checkbox" value="true" <?php if ( $showSpeed == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php _e( 'Show speed', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -626,13 +616,48 @@
</th>
<td>
<select name='wpgpxmaps_unit_of_measure_speed'>
<option value="0" <?php if ( $uomSpeed == '0' ) echo 'selected'; ?>><?php _e( 'm/s', 'wp-gpx-maps' ); ?></option>
<option value="1" <?php if ( $uomSpeed == '1' ) echo 'selected'; ?>><?php _e( 'km/h', 'wp-gpx-maps' ); ?></option>
<option value="2" <?php if ( $uomSpeed == '2' ) echo 'selected'; ?>><?php _e( 'miles/h', 'wp-gpx-maps' ); ?></option>
<option value="3" <?php if ( $uomSpeed == '3' ) echo 'selected'; ?>><?php _e( 'min/km', 'wp-gpx-maps' ); ?></option>
<option value="4" <?php if ( $uomSpeed == '4' ) echo 'selected'; ?>><?php _e( 'min/miles', 'wp-gpx-maps' ); ?></option>
<option value="5" <?php if ( $uomSpeed == '5' ) echo 'selected'; ?>><?php _e( 'Knots (nautical miles / hour)', 'wp-gpx-maps' ); ?></option>
<option value="6" <?php if ( $uomSpeed == '6' ) echo 'selected'; ?>><?php _e( 'min/100 meters', 'wp-gpx-maps' ); ?></option>
<option value="0" <?php if ( $uomSpeed == '0' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'm/s', 'wp-gpx-maps' );
?>
</option>
<option value="1" <?php if ( $uomSpeed == '1' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'km/h', 'wp-gpx-maps' );
?>
</option>
<option value="2" <?php if ( $uomSpeed == '2' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'miles/h', 'wp-gpx-maps' );
?>
</option>
<option value="3" <?php if ( $uomSpeed == '3' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'min/km', 'wp-gpx-maps' );
?>
</option>
<option value="4" <?php if ( $uomSpeed == '4' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'min/miles', 'wp-gpx-maps' );
?>
</option>
<option value="5" <?php if ( $uomSpeed == '5' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'Knots (nautical miles / hour)', 'wp-gpx-maps' );
?>
</option>
<option value="6" <?php if ( $uomSpeed == '6' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'min/100 meters', 'wp-gpx-maps' );
?>
</option>
</select>
</td>
</tr>
@ -643,10 +668,12 @@
</th>
<td>
<?php _e( 'From', 'wp-gpx-maps' ); ?>
<input name="wpgpxmaps_graph_offset_from2" value="<?php echo get_option( 'wpgpxmaps_graph_offset_from2' ); ?>" style="width:50px;" />
<input name="wpgpxmaps_graph_offset_from2" type="text" value="<?php echo get_option( 'wpgpxmaps_graph_offset_from2' ); ?>" style="width:50px;" />
<?php _e( 'to', 'wp-gpx-maps' ); ?>
<input name="wpgpxmaps_graph_offset_to2" value="<?php echo get_option( 'wpgpxmaps_graph_offset_to2' ); ?>" style="width:50px;" />
<em><?php _e( '(leave empty for auto scale)', 'wp-gpx-maps' ); ?></em>
<input name="wpgpxmaps_graph_offset_to2" type="text" value="<?php echo get_option( 'wpgpxmaps_graph_offset_to2' ); ?>" style="width:50px;" />
<em>
<?php _e( '(leave empty for auto scale)', 'wp-gpx-maps' ); ?>
</em>
</td>
</tr>
@ -657,10 +684,7 @@
<td>
<input name="wpgpxmaps_show_hr" type="checkbox" value="true" <?php if ( $showHr == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Show heart rate', 'wp-gpx-maps' );
?>
<?php _e( 'Show heart rate', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -681,10 +705,7 @@
<td>
<input name="wpgpxmaps_show_atemp" type="checkbox" value="true" <?php if ( $showAtemp == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Show temperature', 'wp-gpx-maps' );
?>
<?php _e( 'Show temperature', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -705,10 +726,7 @@
<td>
<input name="wpgpxmaps_show_cadence" type="checkbox" value="true" <?php if ( $showCad == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Show cadence', 'wp-gpx-maps' );
?>
<?php _e( 'Show cadence', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -729,10 +747,7 @@
<td>
<input name="wpgpxmaps_show_grade" type="checkbox" value="true" <?php if ( $showGrade == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Show grade - BETA (Grade values depends on your GPS accuracy. If you have a poor GPS accuracy they might be totally wrong!)', 'wp-gpx-maps' );
?>
<?php _e( 'Show grade - BETA (Grade values depends on your GPS accuracy. If you have a poor GPS accuracy they might be totally wrong!)', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -777,10 +792,7 @@
<td>
<input name="wpgpxmaps_pointsoffset" type="text" id="wpgpxmaps_pointsoffset" value="<?php echo $po ?>" style="width:50px;" />
<i>
<?php
echo ' ';
_e( 'meters', 'wp-gpx-maps' );
?>
<?php _e( 'meters', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -792,10 +804,7 @@
<td>
<input name="wpgpxmaps_donotreducegpx" type="checkbox" value="true" <?php if ( $donotreducegpx == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php
echo ' ';
_e( 'Do not reduce GPX', 'wp-gpx-maps' );
?>
<?php _e( 'Do not reduce GPX', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>
@ -805,12 +814,9 @@
<?php _e( 'User upload:', 'wp-gpx-maps' ); ?>
</th>
<td>
<input name="wpgpxmaps_allow_users_view" type="checkbox" value="true" onchange="this.value = (this.checked)" <?php if ( $allow_users_upload === "true" ) { echo( 'checked' ); } ?>>
<input name="wpgpxmaps_allow_users_view" type="checkbox" value="true" onchange="this.value = (this.checked)" <?php if ( $allow_users_upload === "true" ) { echo( 'checked' ); } ?> />
<i>
<?php
echo ' ';
_e( 'Allow registered user to upload GPX files', 'wp-gpx-maps' );
?>
<?php _e( 'Allow registered user to upload GPX files', 'wp-gpx-maps' ); ?>
</i>
</td>
</tr>

View File

@ -8,47 +8,39 @@ $is_admin = current_user_can( 'publish_posts' );
if ( $is_admin != 1 )
return;
$allow_users_upload = get_option( 'wpgpxmaps_allow_users_view' ) === "true";
$wpgpxmapsUrl = get_admin_url() . "admin.php?page=WP-GPX-Maps";
$gpxRegEx = '/.gpx$/i';
$allow_users_upload = get_option( 'wpgpxmaps_allow_users_view' ) === 'true';
$wpgpxmapsUrl = get_admin_url() . 'admin.php?page=WP-GPX-Maps';
$gpxRegEx = '/.gpx$/i';
if ( current_user_can( 'manage_options' ) ) {
$menu_root = 'options-general.php';
$menu_root = 'options-general.php';
} elseif ( current_user_can( 'publish_posts' ) ) {
$menu_root = 'admin.php';
$menu_root = 'admin.php';
}
if ( isset( $_POST['clearcache'] ) ) {
if ( isset( $_GET['_wpnonce'] )
&&
wp_verify_nonce( $_GET['_wpnonce'], 'wpgpx_clearcache_nonce' . $entry )
) {
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'wpgpx_clearcache_nonce' . $entry ) ) {
echo '<div class="notice notice-success"><p>';
_e( 'Cache is now empty!', 'wp-gpx-maps' );
echo '</p></div>';
wpgpxmaps_recursive_remove_directory( $cacheGpxPath, true );
}
}
if ( is_writable( $realGpxPath ) ) {
?>
<div class="tablenav top">
<?php
<?php
echo '<form enctype="multipart/form-data" method="POST" style="float:left; margin:5px 20px 0 0" action="' . get_bloginfo( 'wpurl' ) . '/wp-admin/' . $menu_root . '?page=WP-GPX-Maps">';
?>
?>
<?php _e( 'Choose a file to upload:', 'wp-gpx-maps' ); ?> <input name="uploadedfile[]" type="file" onchange="submitgpx(this);" multiple />
<?php
if ( isset( $_FILES['uploadedfile'] ) ) {
$total = count( $_FILES['uploadedfile']['name'] );
for ( $i = 0; $i < $total; $i++ ) {
$uploadingFileName = basename( $_FILES['uploadedfile']['name'][$i] );
$target_path = $realGpxPath . "/" . $uploadingFileName;
$target_path = $realGpxPath . '/' . $uploadingFileName;
if ( preg_match( $gpxRegEx, $target_path ) ) {
if ( move_uploaded_file( $_FILES['uploadedfile']['tmp_name'][$i], $target_path ) ) {
echo '<div class="notice notice-success"><p>';
@ -57,19 +49,19 @@ if ( is_writable( $realGpxPath ) ) {
__( 'The file %1s has been successfully uploaded.', 'wp-gpx-maps' ),
'<span class="code"><strong>' . esc_html( $uploadingFileName ) . '</strong></span>'
);
echo '</p></div>';
echo '</p></div>';
} else {
echo '<div class=" notice notice-error"><p>';
_e( 'There was an error uploading the file, please try again!', 'wp-gpx-maps' );
echo '</p></div>';
}
} else {
echo '<div class=" notice notice-error"><p>';
_e( 'There was an error uploading the file, please try again!', 'wp-gpx-maps' );
echo '<div class="notice notice-warning"><p>';
_e( 'The file type is not supported!', 'wp-gpx-maps' );
echo '</p></div>';
}
} else {
echo '<div class="notice notice-warning"><p>';
_e( 'The file type is not supported!', 'wp-gpx-maps' );
echo '</p></div>';
}
}
}
?>
</form>
@ -105,21 +97,16 @@ if ( is_writable( $realGpxPath ) ) {
$myGpxFileNames = array();
if ( is_readable ( $realGpxPath ) && $handle = opendir( $realGpxPath ) ) {
while ( false !== ( $entry = readdir( $handle ) ) ) {
while ( false !== ( $entry = readdir( $handle ) ) ) {
if ( preg_match( $gpxRegEx, $entry ) ) {
if ( isset($_GET['_wpnonce'])
&&
wp_verify_nonce( $_GET['_wpnonce'], 'wpgpx_deletefile_nonce_' . $entry )
) {
if ( file_exists( $realGpxPath . "/" . $entry ) ) {
unlink( $realGpxPath . "/" . $entry );
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'wpgpx_deletefile_nonce_' . $entry ) ) {
if ( file_exists( $realGpxPath . '/' . $entry ) ) {
unlink( $realGpxPath . '/' . $entry );
echo '<div class="notice notice-success"><p>';
printf(
/* translators: GPX file name */
__( 'The file %1s has been successfully deleted.', 'wp-gpx-maps' ),
'<span class="code"><strong>' . esc_html ( $entry ) . '</strong></span>'
'<span class="code"><strong>' . esc_html( $entry ) . '</strong></span>'
);
echo '</p></div>';
} else {
@ -127,13 +114,12 @@ if ( is_writable( $realGpxPath ) ) {
printf(
/* translators: GPX file name */
__( 'The file %1s could not be deleted.', 'wp-gpx-maps' ),
'<span class="code"><strong>' . esc_html ( $entry ) . '</strong></span>'
'<span class="code"><strong>' . esc_html( $entry ) . '</strong></span>'
);
echo '</p></div>';
echo '</p></div>';
}
} else {
$myFile = $realGpxPath . "/" . $entry;
$myFile = $realGpxPath . '/' . $entry;
$myGpxFileNames[] = array(
'name' => $entry,
'size' => filesize( $myFile ),
@ -146,13 +132,13 @@ if ( is_writable( $realGpxPath ) ) {
closedir( $handle );
}
if ( is_readable ( $realGpxPath ) && $handle = opendir( $realGpxPath ) ) {
while ( false !== ($entry = readdir( $handle ) ) ) {
if ( is_readable( $realGpxPath ) && $handle = opendir( $realGpxPath ) ) {
while ( false !== ( $entry = readdir( $handle ) ) ) {
if ( preg_match( $gpxRegEx, $entry ) ) {
$filenames[] = $realGpxPath . "/" . $entry;
$filenames[] = $realGpxPath . '/' . $entry;
}
}
closedir( $handle );
closedir( $handle );
}
?>
@ -237,11 +223,4 @@ if ( is_readable ( $realGpxPath ) && $handle = opendir( $realGpxPath ) ) {
});
</script>
<style>
#table tr:hover {
background:#eeeeee;
}
</style>

View File

@ -59,14 +59,15 @@
?>
<code><strong>[sgpx gpx="<?php echo $relativeGpxPath; ?>yourgpxfile.gpx &lt; <?php _e( 'read below all the optional attributes', 'wp-gpx-maps' ); ?> &gt;"]</strong></code>
</p>
<strong><?php _e( 'Note: If no value is displayed in the "Current value" column, the value is "false".', 'wp-gpx-maps' ); ?></strong>
</div>
<table class="widefat">
<thead>
<tr>
<th colspan="4">
<strong><?php _e( 'General', 'wp-gpx-maps' ); ?></strong>
<th class="title" colspan="4">
<?php _e( 'General', 'wp-gpx-maps' ); ?>
</th>
</tr>
<tr>
@ -104,6 +105,12 @@
</td>
<td>
<?php _e( 'Value in percent', 'wp-gpx-maps' ); ?>
<br />
<?php
_e( 'Default is:', 'wp-gpx-maps' );
echo ' ';
?>
<strong>100%</strong>
</td>
<td>
<?php echo get_option( 'wpgpxmaps_width' ); ?>
@ -116,6 +123,12 @@
</td>
<td>
<?php _e( 'Value in pixels', 'wp-gpx-maps' ); ?>
<br />
<?php
_e( 'Default is:', 'wp-gpx-maps' );
echo ' ';
?>
<strong>450px</strong>
</td>
<td>
<?php echo get_option( 'wpgpxmaps_height' ); ?>
@ -128,6 +141,12 @@
</td>
<td>
<?php _e( 'Value in pixels', 'wp-gpx-maps' ); ?>
<br />
<?php
_e( 'Default is:', 'wp-gpx-maps' );
echo ' ';
?>
<strong>200px</strong>
</td>
<td>
<?php echo get_option( 'wpgpxmaps_graph_height' ); ?>
@ -173,8 +192,8 @@
<table class="widefat">
<thead>
<tr>
<th colspan="4">
<strong><?php _e( 'Map', 'wp-gpx-maps' ); ?></strong>
<th class="title" colspan="4">
<?php _e( 'Map', 'wp-gpx-maps' ); ?>
</th>
</tr>
<tr>
@ -199,23 +218,56 @@
<?php _e( 'Map type', 'wp-gpx-maps' ); ?>
</td>
<td>
<strong>HYBRID, ROADMAP, SATELLITE, TERRAIN</strong>
<?php
/* translators: map type */
_e( 'HYBRID, ROADMAP, SATELLITE, TERRAIN', 'wp-gpx-maps' );
?>
<br />
<strong>OSM1</strong> = <?php _e( 'Open Street Map', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = map provider / map type */
_e( 'OSM1 = Open Street Map', 'wp-gpx-maps' );
?>
<br />
<strong>OSM2</strong> = <?php _e( 'Open Cycle Map', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = map provider / map type */
_e( 'OSM2 = Open Cycle Map', 'wp-gpx-maps' );
?>
<br />
<strong>OSM4</strong> = <?php _e( 'Open Cycle Map - Transport', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = map provider / map type */
_e( 'OSM4 = Open Cycle Map - Transport', 'wp-gpx-maps' );
?>
<br />
<strong>OSM5</strong> = <?php _e( 'Open Cycle Map - Landscape', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = map provider / map type */
_e( 'OSM5 = Open Cycle Map - Landscape', 'wp-gpx-maps' );
?>
<br />
<strong>OSM6</strong> = <?php _e( 'MapToolKit - Terrain', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = map provider / map type */
_e( 'OSM6 = MapToolKit - Terrain', 'wp-gpx-maps' );
?>
<br />
<strong>OSM7</strong> = <?php _e( 'Open Street Map - Humanitarian map style', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = map provider / map type */
_e( 'OSM7 = Open Street Map - Humanitarian map style', 'wp-gpx-maps' );
?>
<br />
<strong>OSM9</strong> = <?php _e( 'Hike & Bike', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = map provider / map type */
_e( 'OSM9 = Hike & Bike', 'wp-gpx-maps' );
?>
<br />
<strong>OSM10</strong> = <?php _e( 'Open Sea Map', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = map provider / map type */
_e( 'OSM10 = Open Sea Map', 'wp-gpx-maps' );
?>
<br />
<?php
_e( 'Default is:', 'wp-gpx-maps' );
echo ' ';
?>
<strong>HYBRID</strong>
</td>
<td>
<?php echo get_option( 'wpgpxmaps_map_type' ); ?>
@ -317,8 +369,8 @@
<table class="widefat">
<thead>
<tr>
<th colspan="4">
<strong><?php _e( 'Diagram', 'wp-gpx-maps' ); ?></strong>
<th class="title" colspan="4">
<?php _e( 'Diagram', 'wp-gpx-maps' ); ?>
</th>
</tr>
<tr>
@ -375,18 +427,41 @@
<?php _e( 'Distance / Altitude unit of measure', 'wp-gpx-maps' ); ?>
</td>
<td>
<strong>0</strong> = <?php _e( 'meters / meters', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = chart axis labels */
_e( '0 = meters / meters', 'wp-gpx-maps' );
?>
<br />
<strong>1</strong> = <?php _e( 'feet / miles', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = chart axis labels */
_e( '1 = feet / miles', 'wp-gpx-maps' );
?>
<br />
<strong>2</strong> = <?php _e( 'meters / kilometers', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = chart axis labels */
_e( '2 = meters / kilometers', 'wp-gpx-maps' );
?>
<br />
<strong>3</strong> = <?php _e( 'meters / nautical miles', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = chart axis labels */
_e( '3 = meters / nautical miles', 'wp-gpx-maps' );
?>
<br />
<strong>4</strong> = <?php _e( 'meters / miles', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = chart axis labels */
_e( '4 = meters / miles', 'wp-gpx-maps' );
?>
<br />
<strong>5</strong> = <?php _e( 'feet / nautical miles', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = chart axis labels */
_e( '5 = feet / nautical miles', 'wp-gpx-maps' );
?>
<br />
<?php
_e( 'Default is:', 'wp-gpx-maps' );
echo ' ';
?>
<strong>0</strong>
</td>
<td>
<?php echo get_option( 'wpgpxmaps_unit_of_measure' ); ?>
@ -450,20 +525,46 @@
<?php _e( 'Speed unit of measure', 'wp-gpx-maps' ); ?>
</td>
<td>
<strong>0</strong> = <?php _e( 'm/s', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = speed unit of measure */
_e( '0 = m/s', 'wp-gpx-maps' );
?>
<br />
<strong>1</strong> = <?php _e( 'km/h', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = speed unit of measure */
_e( '1 = km/h', 'wp-gpx-maps' );
?>
<br />
<strong>2</strong> = <?php _e( 'miles/h', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = speed unit of measure */
_e( '2 = miles/h', 'wp-gpx-maps' );
?>
<br />
<strong>3</strong> = <?php _e( 'min/km', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = speed unit of measure */
_e( '3 = min/km', 'wp-gpx-maps' );
?>
<br />
<strong>4</strong> = <?php _e( 'min/miles', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = speed unit of measure */
_e( '4 = min/miles', 'wp-gpx-maps' );
?>
<br />
<strong>5</strong> = <?php _e( 'Knots (nautical miles / hour)', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = speed unit of measure */
_e( '5 = Knots (nautical miles / hour)', 'wp-gpx-maps' );
?>
<br />
<strong>6</strong> = <?php _e( 'min/100 meters', 'wp-gpx-maps' ); ?>
<?php
/* translators: selection = speed unit of measure */
_e( '6 = min/100 meters', 'wp-gpx-maps' );
?>
<br />
<?php
_e( 'Default is:', 'wp-gpx-maps' );
echo ' ';
?>
<strong>0</strong>
</td>
<td>
<?php echo get_option( 'wpgpxmaps_unit_of_measure_speed' ); ?>
@ -624,8 +725,8 @@
<table class="widefat">
<thead>
<tr>
<th colspan="3">
<strong><?php _e( 'Pictures', 'wp-gpx-maps' ); ?></strong>
<th class="title" colspan="3">
<?php _e( 'Pictures', 'wp-gpx-maps' ); ?>
</th>
</tr>
<tr>
@ -689,8 +790,8 @@
<table class="widefat">
<thead>
<tr>
<th colspan="4">
<strong><?php _e( 'Summary table', 'wp-gpx-maps' ); ?></strong>
<th class="title" colspan="4">
<?php _e( 'Summary table', 'wp-gpx-maps' ); ?>
</th>
</tr>
<tr>
@ -893,8 +994,8 @@
<table class="widefat">
<thead>
<tr>
<th colspan="4">
<strong><?php _e( 'Advanced', 'wp-gpx-maps' ); ?></strong>
<th class="title" colspan="4">
<?php _e( 'Advanced', 'wp-gpx-maps' ); ?>
</th>
</tr>
<tr>

View File

@ -18,7 +18,8 @@ function wpgpxmaps_getAttachedImages( $dt, $lat, $lon, $dtoffset, &$error ) {
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ASC',
));
)
);
foreach ( $attachments as $attachment_id => $attachment ) {
@ -27,27 +28,27 @@ function wpgpxmaps_getAttachedImages( $dt, $lat, $lon, $dtoffset, &$error ) {
$img_metadata = wp_get_attachment_metadata( $attachment_id );
$item = array();
$item["data"] = wp_get_attachment_link( $attachment_id, array( 105, 105 ) );
$item['data'] = wp_get_attachment_link( $attachment_id, array( 105, 105 ) );
if ( is_callable( 'exif_read_data' ) ) {
$exif = @exif_read_data( $img_src[0] );
if ( $exif !== false ) {
$item["lon"] = getExifGps( $exif["GPSLongitude"], $exif['GPSLongitudeRef'] );
$item["lat"] = getExifGps( $exif["GPSLatitude"], $exif['GPSLatitudeRef'] );
if ( ( $item["lat"] != 0 ) || ( $item["lon"] != 0 ) ) {
$result[] = $item;
} elseif ( isset( $p->imagedate ) ) {
$_dt = strtotime( $p->imagedate ) + $dtoffset;
$_item = findItemCoordinate( $_dt, $dt, $lat, $lon );
$item['lon'] = getExifGps( $exif['GPSLongitude'], $exif['GPSLongitudeRef'] );
$item['lat'] = getExifGps( $exif['GPSLatitude'], $exif['GPSLatitudeRef'] );
if ( ( $item['lat'] != 0 ) || ( $item['lon'] != 0 ) ) {
$result[] = $item;
} elseif ( isset( $p->imagedate ) ) {
$_dt = strtotime( $p->imagedate ) + $dtoffset;
$_item = findItemCoordinate( $_dt, $dt, $lat, $lon );
if ( $_item != null ) {
$item["lat"] = $_item["lat"];
$item["lon"] = $_item["lon"];
$item['lat'] = $_item['lat'];
$item['lon'] = $_item['lon'];
$result[] = $item;
}
}
}
} else {
$error .= "Sorry, <a href='http://php.net/manual/en/function.exif-read-data.php' target='_blank' >exif_read_data</a> function not found! check your hosting..<br />";
$error .= "Sorry, <a href='http://php.net/manual/en/function.exif-read-data.php' target='_blank' >exif_read_data</a> function not found! check your hosting.<br />";
}
}
} catch ( Exception $e ) {
@ -106,8 +107,7 @@ function relativeGpxCacheFolderPath() {
function wpgpxmaps_recursive_remove_directory( $directory, $empty = false ) {
if ( substr( $directory, -1 ) == '/' )
{
if ( substr( $directory, -1 ) == '/' ) {
$directory = substr( $directory, 0, -1 );
}
if ( ! file_exists( $directory ) || ! is_dir( $directory ) ) {
@ -262,31 +262,31 @@ function wpgpxmaps_parseXml( $filePath, $gpxOffset, $distancetype ) {
}
}
if ( $lastLat == 0 && $lastLon == 0 ) {
if ( $lastLat == 0 && $lastLon == 0 ) {
/* Base Case */
array_push( $points->dt, strtotime( $time ) );
array_push( $points->lat, (float) $lat );
array_push( $points->lon, (float) $lon );
array_push( $points->ele, (float) round( $ele, 2 ) );
array_push( $points->dist, (float) round( $dist, 2 ) );
array_push( $points->speed, 0 );
array_push( $points->hr, (float) $hr );
array_push( $points->atemp, (float) $atemp );
array_push( $points->cad, (float) $cad );
array_push( $points->grade, $grade );
/* Base Case */
array_push( $points->dt, strtotime( $time ) );
array_push( $points->lat, (float) $lat );
array_push( $points->lon, (float) $lon );
array_push( $points->ele, (float) round( $ele, 2 ) );
array_push( $points->dist, (float) round( $dist, 2 ) );
array_push( $points->speed, 0 );
array_push( $points->hr, (float) $hr );
array_push( $points->atemp, (float) $atemp );
array_push( $points->cad, (float) $cad );
array_push( $points->grade, $grade );
$lastLat = $lat;
$lastLon = $lon;
$lastEle = $ele;
$lastTime = $time;
$lastLat = $lat;
$lastLon = $lon;
$lastEle = $ele;
$lastTime = $time;
} else {
/* Normal Case */
$offset = calculateDistance( (float) $lat, (float) $lon, (float) $ele, (float) $lastLat, (float) $lastLon, (float) $lastEle, $distancetype );
$dist = $dist + $offset;
/* Normal Case */
$offset = calculateDistance( (float) $lat, (float) $lon, (float) $ele, (float) $lastLat, (float) $lastLon, (float) $lastEle, $distancetype );
$dist = $dist + $offset;
$points->totalLength = $dist;
$points->totalLength = $dist;
if ( $speed == 0 ) {
$datediff = (float) my_date_diff( $lastTime, $time );
@ -295,8 +295,8 @@ function wpgpxmaps_parseXml( $filePath, $gpxOffset, $distancetype ) {
}
}
if ( $ele != 0 && $lastEle != 0 ) {
$deltaEle = (float) ( $ele - $lastEle );
if ( $ele != 0 && $lastEle != 0 ) {
$deltaEle = (float) ( $ele - $lastEle );
if ( (float) $ele > (float) $lastEle ) {
$points->totalEleUp += $deltaEle;
@ -306,98 +306,92 @@ function wpgpxmaps_parseXml( $filePath, $gpxOffset, $distancetype ) {
$grade = $deltaEle / $offset * 100;
}
array_push( $speedBuffer, $speed );
array_push( $speedBuffer, $speed );
if ( ( (float) $offset + (float) $lastOffset ) > $gpxOffset ) {
/* Bigger Offset -> write coordinate */
$avgSpeed = 0;
if ( ( (float) $offset + (float) $lastOffset ) > $gpxOffset ) {
/* Bigger Offset -> write coordinate */
$avgSpeed = 0;
foreach ( $speedBuffer as $s ) {
$avgSpeed += $s;
$avgSpeed += $s;
}
$avgSpeed = $avgSpeed / count( $speedBuffer );
$speedBuffer = array();
$avgSpeed = $avgSpeed / count( $speedBuffer );
$speedBuffer = array();
$lastOffset = 0;
array_push( $points->dt, strtotime( $time ) );
array_push( $points->lat, (float) $lat );
array_push( $points->lon, (float) $lon );
array_push( $points->ele, (float) round( $ele, 2 ) );
array_push( $points->dist, (float) round( $dist, 2 ) );
array_push( $points->speed, (float) round( $avgSpeed, 1 ) );
array_push( $points->hr, $hr );
array_push( $points->atemp, $atemp );
array_push( $points->cad, $cad );
array_push( $points->grade, (float) round( $grade, 2 ) );
$lastOffset = 0;
array_push( $points->dt, strtotime( $time ) );
array_push( $points->lat, (float) $lat );
array_push( $points->lon, (float) $lon );
array_push( $points->ele, (float) round( $ele, 2 ) );
array_push( $points->dist, (float) round( $dist, 2 ) );
array_push( $points->speed, (float) round( $avgSpeed, 1 ) );
array_push( $points->hr, $hr );
array_push( $points->atemp, $atemp );
array_push( $points->cad, $cad );
array_push( $points->grade, (float) round( $grade, 2 ) );
} else {
/* Smoller Offset -> continue.. */
$lastOffset = (float) $lastOffset + (float) $offset;
/* Smoller Offset -> continue.. */
$lastOffset = (float) $lastOffset + (float) $offset;
}
}
$lastLat = $lat;
$lastLon = $lon;
$lastEle = $ele;
$lastTime = $time;
$lastLat = $lat;
$lastLon = $lon;
$lastEle = $ele;
$lastTime = $time;
}
array_push( $points->dt, null );
array_push( $points->lat, null );
array_push( $points->lon, null );
array_push( $points->ele, null );
array_push( $points->dist, null );
array_push( $points->speed, null );
array_push( $points->hr, null );
array_push( $points->atemp, null );
array_push( $points->cad, null );
array_push( $points->grade, null );
array_push( $points->dt, null );
array_push( $points->lat, null );
array_push( $points->lon, null );
array_push( $points->ele, null );
array_push( $points->dist, null );
array_push( $points->speed, null );
array_push( $points->hr, null );
array_push( $points->atemp, null );
array_push( $points->cad, null );
array_push( $points->grade, null );
unset( $trkpts );
unset( $trkpts );
}
unset( $nodes );
unset( $nodes );
try {
array_pop( $points->dt, null );
array_pop( $points->lat, null );
array_pop( $points->lon, null );
array_pop( $points->ele, null );
array_pop( $points->dist, null );
array_pop( $points->speed, null );
array_pop( $points->hr, null );
array_pop( $points->atemp, null );
array_pop( $points->cad, null );
array_pop( $points->grade, null );
array_pop( $points->dt, null );
array_pop( $points->lat, null );
array_pop( $points->lon, null );
array_pop( $points->ele, null );
array_pop( $points->dist, null );
array_pop( $points->speed, null );
array_pop( $points->hr, null );
array_pop( $points->atemp, null );
array_pop( $points->cad, null );
array_pop( $points->grade, null );
$_time = array_filter( $points->dt );
$_ele = array_filter( $points->ele );
$_dist = array_filter( $points->dist );
$points->maxEle = max( $_ele );
$points->minEle = min( $_ele );
$points->totalLength = max( $_dist );
$points->maxTime = max( $_time );
$points->minTime = min( $_time );
$_time = array_filter( $points->dt );
$_ele = array_filter( $points->ele );
$_dist = array_filter( $points->dist );
$points->maxEle = max( $_ele );
$points->minEle = min( $_ele );
$points->totalLength = max( $_dist );
$points->maxTime = max( $_time );
$points->minTime = min( $_time );
/* Calculating Average Speed */
$_speed = array_filter( $points->speed );
$points->avgSpeed = array_sum( $_speed ) / count( $_speed );
/* Calculating Average Speed */
$_speed = array_filter( $points->speed );
$points->avgSpeed = array_sum( $_speed ) / count( $_speed );
/* Calculating Average Cadence */
$_cad = array_filter( $points->cad );
$points->avgCad = (float) round( array_sum( $_cad ) / count( $_cad ), 0 );
/* Calculating Average Cadence */
$_cad = array_filter( $points->cad );
$points->avgCad = (float) round( array_sum( $_cad ) / count( $_cad ), 0 );
/* Calculating Average Heart Rate */
$_hr = array_filter( $points->hr );
$points->avgHr = (float) round( array_sum( $_hr ) / count( $_hr ), 0 );
/* Calculating Average Heart Rate */
$_hr = array_filter( $points->hr );
$points->avgHr = (float) round( array_sum( $_hr ) / count( $_hr ), 0 );
/* Calculating Average Temperature */
$_temp = array_filter( $points->atemp );
$points->avgTemp = (float) round( array_sum( $_temp ) / count( $_temp ), 1 );
/* Calculating Average Temperature */
$_temp = array_filter( $points->atemp );
$points->avgTemp = (float) round( array_sum( $_temp ) / count( $_temp ), 1 );
} catch ( Exception $e ) {
}
@ -568,15 +562,15 @@ function wpgpxmaps_getWayPoints( $gpxPath ) {
}
array_push($points, array(
"lat" => (float) $lat,
"lon" => (float) $lon,
"ele" => (float) $ele,
"time" => $time,
"name" => $name,
"desc" => $desc,
"sym" => $sym,
"type" => $type,
"img" => $img,
'lat' => (float) $lat,
'lon' => (float) $lon,
'ele' => (float) $ele,
'time' => $time,
'name' => $name,
'desc' => $desc,
'sym' => $sym,
'type' => $type,
'img' => $img,
));
}
}
@ -638,4 +632,3 @@ function date_getDecimals( $date ) {
return 0;
}
}
?>

View File

@ -54,7 +54,7 @@ function getNGGalleryImages( $ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset
}
}
} else {
$error .= "Sorry, <a href='https://php.net/manual/en/function.exif-read-data.php' target='_blank' rel='noopener noreferrer'>exif_read_data</a> function not found! check your hosting..<br />";
$error .= "Sorry, <a href='https://php.net/manual/en/function.exif-read-data.php' target='_blank' rel='noopener noreferrer'>exif_read_data</a> function not found! check your hosting.<br />";
}
}
/* START FIX NEXT GEN GALLERY 2.x */
@ -72,7 +72,7 @@ function getNGGalleryImages( $ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset
if ( preg_match( "/data-nplmodal-gallery-id=[\"'](.*?)[\"']/", $dummy, $m ) ) {
$galid = $m[1];
if ( $galid ) {
for( $i = 0; $i < count( $result ); ++$i ) {
for ( $i = 0; $i < count( $result ); ++$i ) {
$result[$i]['data'] = str_replace( '%PRO_LIGHTBOX_GALLERY_ID%', $galid, $result[$i]['data'] );
}
}
@ -90,9 +90,12 @@ function getNGGalleryImages( $ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset
function findItemCoordinate( $imgdt, $dt, $lat, $lon ) {
foreach ( array_keys( $dt ) as $i ) {
if ( $i!=0 && $imgdt >= $dt[$i-1] && $imgdt <= $dt[$i] ) {
if ( $i != 0 && $imgdt >= $dt[$i - 1] && $imgdt <= $dt[$i] ) {
if ( $lat[$i] != 0 && $lon[$i] != 0 )
return array( 'lat' => $lat[$i], 'lon' => $lon[$i] );
return array(
'lat' => $lat[$i],
'lon' => $lon[$i],
);
}
}
return null;
@ -105,7 +108,7 @@ function getExifGps( $exifCoord, $hemi ) {
$seconds = count( $exifCoord ) > 2 ? gps2Num( $exifCoord[2] ) : 0;
$flip = ( $hemi == 'W' or $hemi == 'S' ) ? -1 : 1;
return $flip * ( $degrees + $minutes / 60 + $seconds / 3600);
return $flip * ( $degrees + $minutes / 60 + $seconds / 3600 );
}
function gps2Num( $coordPart ) {
@ -121,8 +124,7 @@ function gps2Num( $coordPart ) {
$lat = floatval( $parts[0] );
$lon = floatval( $parts[1] );
if ($lon == 0 )
if ($lon == 0 )
return $lat;
return $lat / $lon;
}
?>