Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

added possibility to load gpx track files #65

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function __construct (array $urlParams=array()) {
return new PageController(
$c->query('AppName'),
$c->query('Request'),
$c->query('RootFolder'),
$c->query('UserId'),
$c->query('CacheManager'),
$c->query('LocationManager')
Expand All @@ -58,6 +59,10 @@ public function __construct (array $urlParams=array()) {
$c->query('ServerContainer')->getDb()
);
});

$container->registerService('RootFolder', function($c) {
return $this->getContainer()->getServer()->getRootFolder();
});

/**
* Core
Expand Down
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
array('name' => 'page#adresslookup', 'url' => '/adresslookup', 'verb' => 'GET'),
array('name' => 'page#geodecode', 'url' => '/geodecode', 'verb' => 'GET'),
array('name' => 'page#search', 'url' => '/search', 'verb' => 'GET'),
array('name' => 'page#getgpsfiles', 'url' => '/getgps', 'verb' => 'GET'),

array('name' => 'location#update', 'url' => '/api/1.0/location/update', 'verb' => 'GET'),
array('name' => 'location#add_device', 'url' => '/api/1.0/location/adddevice', 'verb' => 'POST'),
Expand Down
28 changes: 27 additions & 1 deletion controller/pagecontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@
use \OCP\AppFramework\Http\TemplateResponse;
use \OCP\AppFramework\Controller;
use \OCA\Maps\Db\CacheManager;
use \OCP\Files\Folder;
use \OCP\Files\IRootFolder;

class PageController extends Controller {

private $userId;
private $cacheManager;
private $locationManager;
public function __construct($appName, IRequest $request, $userId, $cacheManager,$locationManager) {
private $rootF;
public function __construct($appName, IRequest $request, $rootF, $userId, $cacheManager,$locationManager) {
parent::__construct($appName, $request);
$this -> userId = $userId;
$this -> cacheManager = $cacheManager;
$this -> locationManager = $locationManager;
$this -> rootF = $rootF;
}

/**
Expand Down Expand Up @@ -229,4 +233,26 @@ private function getURL($url, $userAgent = true) {

}

public function getGpsFiles(){
$path = '/' . $this->userId . '/files/MyTracks';
if ($this->rootF->nodeExists($path)) {
$folder = $this->rootF->get($path);
} else {
$folder = $this->rootF->newFolder($path);
}
$nodes = $folder->getDirectoryListing();
$suffix = ".gpx";
foreach($nodes as $n){
if($n->getType() == \OCP\Files\FileInfo::TYPE_FILE){
$name = $n->getName();
if(substr_compare($name, $suffix, -strlen($suffix)) === 0){
$arr = array();
$arr['dir'] = $n->getParent()->getName();
$arr['file'] = $n->getName();
$files[] = $arr;
}
}
}
return $files;
}
}
Binary file removed img/mapIcons/disused:butcher.png
Binary file not shown.
Loading