diff --git a/controller/pagecontroller.php b/controller/pagecontroller.php index 168e2ed..17f58ed 100644 --- a/controller/pagecontroller.php +++ b/controller/pagecontroller.php @@ -268,7 +268,7 @@ class PageController extends Controller { * @NoAdminRequired * @NoCSRFRequired */ - public function getfoldergpxs($path) { + public function getfoldergpxs($path, $type) { $userFolder = \OC::$server->getUserFolder(); $cleanpath = str_replace(array('../', '..\\'), '', $path); $gpxs = Array(); @@ -277,14 +277,26 @@ class PageController extends Controller { if ($folder->getType() === \OCP\Files\FileInfo::TYPE_FOLDER){ foreach ($folder->getDirectoryListing() as $file) { if ($file->getType() === \OCP\Files\FileInfo::TYPE_FILE) { - if (endswith($file->getName(), '.GPX') or endswith($file->getName(), '.gpx')){ + if ( ($type === 'all' or $type === '.gpx') + and (endswith($file->getName(), '.GPX') or endswith($file->getName(), '.gpx')) + ){ $gpxContent = $file->getContent(); array_push($gpxs, $gpxContent); } else if (getProgramPath('gpsbabel') !== null and - (endswith($file->getName(), '.KML') or endswith($file->getName(), '.kml') or - endswith($file->getName(), '.JPG') or endswith($file->getName(), '.jpg') or - endswith($file->getName(), '.CSV') or endswith($file->getName(), '.csv')) + ( + ( ($type === 'all' or $type === '.kml') + and (endswith($file->getName(), '.KML') or endswith($file->getName(), '.kml')) + ) + or + ( ($type === 'all' or $type === '.jpg') + and (endswith($file->getName(), '.JPG') or endswith($file->getName(), '.jpg')) + ) + or + ( ($type === 'all' or $type === '.csv') + and (endswith($file->getName(), '.CSV') or endswith($file->getName(), '.csv')) + ) + ) ){ $gpxContent = $this->toGpx($file); array_push($gpxs, $gpxContent); diff --git a/css/gpxedit.css b/css/gpxedit.css index 8ca99b5..7724c9a 100644 --- a/css/gpxedit.css +++ b/css/gpxedit.css @@ -798,7 +798,19 @@ h2.popupTitle{ #clearButton i{ color: red; } -#saveButton, #loadButton, #loadFolderButton{ + +#divloadfolder{ + width: 80%; + margin: 0 auto; +} +select#loadtypeselect{ + float: right; +} +#loadFolderButton{ + float: left; +} + +#saveButton, #loadButton{ display:block; margin-left: auto; margin-right: auto; diff --git a/js/gpxedit.js b/js/gpxedit.js index 76bd9ef..0fa355d 100644 --- a/js/gpxedit.js +++ b/js/gpxedit.js @@ -962,8 +962,10 @@ } function loadFolder(folder) { + var type = $('select#loadtypeselect').val(); var req = { - path: folder + path: folder, + type: type }; var url = OC.generateUrl('/apps/gpxedit/getfoldergpxs'); $('#loadingpc').text('0'); @@ -989,8 +991,6 @@ if ($('#clearbeforeload').is(':checked')) { clear(); } - console.log(Object.keys(response)); - console.log('len : '+response.gpxs.length); if (response.gpxs.length === 0) { OC.dialogs.alert('The folder does not exist or does not contain any compatible file', 'Load folder error'); @@ -1514,8 +1514,9 @@ gpxedit.currentAjax.abort(); hideLoadingAnimation(); } + var type = $('select#loadtypeselect').val(); OC.dialogs.filepicker( - t('gpxedit', 'Load folder (all compatible file inside)'), + t('gpxedit', 'Load folder ('+type+')'), function(targetPath) { loadFolderAction(targetPath); }, diff --git a/templates/gpxcontent.php b/templates/gpxcontent.php index 4fddd00..36d9f30 100644 --- a/templates/gpxcontent.php +++ b/templates/gpxcontent.php @@ -25,7 +25,17 @@ p($_['gpxedit_version']);
+
+ +
+

t('Save'));?>