Skip to content

Commit 14fa987

Browse files
committed
chore: adjust code for updated codestyle
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 58e0d83 commit 14fa987

11 files changed

+84
-84
lines changed

lib/Controller/ContactsController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ public function getContacts($myMapId = null): DataResponse {
151151
$url = $this->directUrlToContact($uid, $addressBookUri);
152152

153153
// we don't give users, just contacts
154-
if (strcmp($c['URI'], 'Database:' . $c['UID'] . '.vcf') !== 0 and
155-
strcmp($uid, $userid) !== 0
154+
if (strcmp($c['URI'], 'Database:' . $c['UID'] . '.vcf') !== 0
155+
and strcmp($uid, $userid) !== 0
156156
) {
157157
// if the contact has a geo attibute use it
158158
if (key_exists('GEO', $c)) {
@@ -404,8 +404,8 @@ public function searchContacts(string $query = ''): DataResponse {
404404
foreach ($contacts as $c) {
405405
$uid = trim($c['UID']);
406406
// we don't give users, just contacts
407-
if (strcmp($c['URI'], 'Database:' . $c['UID'] . '.vcf') !== 0 and
408-
strcmp($uid, $userid) !== 0
407+
if (strcmp($c['URI'], 'Database:' . $c['UID'] . '.vcf') !== 0
408+
and strcmp($uid, $userid) !== 0
409409
) {
410410
$addressBookUri = $addressBooks[$c['addressbook-key']]->getUri();
411411
$result[] = [
@@ -465,8 +465,8 @@ public function placeContact(
465465
?int $myMapId = null): DataResponse {
466466
if (is_null($myMapId) || $myMapId === '') {
467467
// do not edit 'user' contact even myself
468-
if (strcmp($uri, 'Database:' . $uid . '.vcf') === 0 or
469-
strcmp($uid, $this->userId) === 0
468+
if (strcmp($uri, 'Database:' . $uid . '.vcf') === 0
469+
or strcmp($uid, $this->userId) === 0
470470
) {
471471
return new DataResponse('Can\'t edit users', 400);
472472
} else {

lib/Controller/DevicesController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ public function addDevicePoint($lat, $lng, $timestamp = null, $user_agent = null
188188
public function editDevice($id, $color, $name): DataResponse {
189189
$device = $this->devicesService->getDeviceFromDB($id, $this->userId);
190190
if ($device !== null) {
191-
if ((is_string($color) && strlen($color) > 0) ||
192-
(is_string($name) && strlen($name) > 0)
191+
if ((is_string($color) && strlen($color) > 0)
192+
|| (is_string($name) && strlen($name) > 0)
193193
) {
194194
$this->devicesService->editDeviceInDB($id, $color, $name);
195195
$editedDevice = $this->devicesService->getDeviceFromDB($id, $this->userId);
@@ -288,8 +288,8 @@ public function importDevices($path): DataResponse {
288288

289289
if ($userFolder->nodeExists($cleanpath)) {
290290
$file = $userFolder->get($cleanpath);
291-
if ($file->getType() === \OCP\Files\FileInfo::TYPE_FILE and
292-
$file->isReadable()) {
291+
if ($file->getType() === \OCP\Files\FileInfo::TYPE_FILE
292+
and $file->isReadable()) {
293293
$lowerFileName = strtolower($file->getName());
294294
if ($this->endsWith($lowerFileName, '.gpx') or $this->endsWith($lowerFileName, '.kml') or $this->endsWith($lowerFileName, '.kmz')) {
295295
$nbImported = $this->devicesService->importDevices($this->userId, $file);

lib/Controller/FavoritesApiController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ public function addFavorite($apiversion, $name, $lat, $lng, $category, $comment,
133133
public function editFavorite($id, $name, $lat, $lng, $category, $comment, $extensions): DataResponse {
134134
$favorite = $this->favoritesService->getFavoriteFromDB($id, $this->userId);
135135
if ($favorite !== null) {
136-
if (($lat === null || is_numeric($lat)) &&
137-
($lng === null || is_numeric($lng))
136+
if (($lat === null || is_numeric($lat))
137+
&& ($lng === null || is_numeric($lng))
138138
) {
139139
$this->favoritesService->editFavoriteInDB($id, $name, $lat, $lng, $category, $comment, $extensions);
140140
$editedFavorite = $this->favoritesService->getFavoriteFromDB($id);

lib/Controller/FavoritesController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ public function editFavorite(int $id, ?string $name, float $lat, float $lng, ?st
220220
if (is_null($myMapId) || $myMapId === '') {
221221
$favorite = $this->favoritesService->getFavoriteFromDB($id, $this->userId);
222222
if ($favorite !== null) {
223-
if (($lat === null || is_numeric($lat)) &&
224-
($lng === null || is_numeric($lng))
223+
if (($lat === null || is_numeric($lat))
224+
&& ($lng === null || is_numeric($lng))
225225
) {
226226
$this->favoritesService->editFavoriteInDB($id, $name, $lat, $lng, $category, $comment, $extensions);
227227
$editedFavorite = $this->favoritesService->getFavoriteFromDB($id);
@@ -238,8 +238,8 @@ public function editFavorite(int $id, ?string $name, float $lat, float $lng, ?st
238238
$file = $this->getJSONFavoritesFile($folder);
239239
$favorite = $this->favoritesService->getFavoriteFromJSON($file, $id, $this->userId);
240240
if ($favorite !== null) {
241-
if (($lat === null || is_numeric($lat)) &&
242-
($lng === null || is_numeric($lng))
241+
if (($lat === null || is_numeric($lat))
242+
&& ($lng === null || is_numeric($lng))
243243
) {
244244
$this->favoritesService->editFavoriteInJSON($file, $id, $name, $lat, $lng, $category, $comment, $extensions);
245245
$editedFavorite = $this->favoritesService->getFavoriteFromJSON($file, $id);
@@ -512,8 +512,8 @@ public function importFavorites(string $path): DataResponse {
512512

513513
if ($userFolder->nodeExists($cleanpath)) {
514514
$file = $userFolder->get($cleanpath);
515-
if ($file->getType() === \OCP\Files\FileInfo::TYPE_FILE and
516-
$file->isReadable()) {
515+
if ($file->getType() === \OCP\Files\FileInfo::TYPE_FILE
516+
and $file->isReadable()) {
517517
$lowerFileName = strtolower($file->getName());
518518
if ($this->endswith($lowerFileName, '.gpx') or $this->endswith($lowerFileName, '.kml') or $this->endswith($lowerFileName, '.kmz') or $this->endswith($lowerFileName, '.json') or $this->endswith($lowerFileName, '.geojson')) {
519519
$result = $this->favoritesService->importFavorites($this->userId, $file);

lib/Controller/PublicFavoritesController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ public function editFavorite(int $id, ?string $name, float $lat, float $lng, ?st
271271
if ($isUpdateable) {
272272
$favorite = $this->favoritesService->getFavoriteFromJSON($file, $id);
273273
if ($favorite !== null) {
274-
if (($lat === null || is_numeric($lat)) &&
275-
($lng === null || is_numeric($lng))
274+
if (($lat === null || is_numeric($lat))
275+
&& ($lng === null || is_numeric($lng))
276276
) {
277277
$this->favoritesService->editFavoriteInJSON($file, $id, $name, $lat, $lng, $category, $comment, $extensions);
278278
$editedFavorite = $this->favoritesService->getFavoriteFromJSON($file, $id);

lib/Helper/ExifGeoData.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ private function parse(): void {
268268
private function string2time(string $timestamp): ?int {
269269
$result = null;
270270
if (preg_match('#' . self::EXIF_TIME_REGEX . '#ui', $timestamp, $match)) {
271-
$result =
272-
strtotime("{$match['years']}-{$match['months']}-{$match['days']} {$match['hours']}:{$match['minutes']}:{$match['seconds']}")?:null;
271+
$result
272+
= strtotime("{$match['years']}-{$match['months']}-{$match['days']} {$match['hours']}:{$match['minutes']}:{$match['seconds']}")?:null;
273273
}
274274
return $result;
275275
}

lib/Service/AddressService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ private function lookupAddressExternal($adr): array {
203203
$lon = null;
204204
foreach ($result as $addr) {
205205
if (key_exists('lat', $addr) and key_exists('lon', $addr)) {
206-
if (is_null($lat) or
207-
(key_exists('category', $addr) and in_array($addr['category'], ['place', 'building', 'amenity']))) {
206+
if (is_null($lat)
207+
or (key_exists('category', $addr) and in_array($addr['category'], ['place', 'building', 'amenity']))) {
208208
$lat = $addr['lat'];
209209
$lon = $addr['lon'];
210210
}

lib/Service/DevicesService.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,14 @@ public function addPointToDB($deviceId, $lat, $lng, $ts, $altitude, $battery, $a
298298
public function addPointsToDB($deviceId, $points) {
299299
$values = [];
300300
foreach ($points as $p) {
301-
$value = '(' .
302-
$this->db_quote_escape_string($deviceId) . ', ' .
303-
$this->db_quote_escape_string($p['lat']) . ', ' .
304-
$this->db_quote_escape_string($p['lng']) . ', ' .
305-
$this->db_quote_escape_string($p['date']) . ', ' .
306-
((isset($p['altitude']) and is_numeric($p['altitude'])) ? $this->db_quote_escape_string(floatval($p['altitude'])) : 'NULL') . ', ' .
307-
((isset($p['battery']) and is_numeric($p['battery'])) ? $this->db_quote_escape_string(floatval($p['battery'])) : 'NULL') . ', ' .
308-
((isset($p['accuracy']) and is_numeric($p['accuracy'])) ? $this->db_quote_escape_string(floatval($p['accuracy'])) : 'NULL') . ')';
301+
$value = '('
302+
. $this->db_quote_escape_string($deviceId) . ', '
303+
. $this->db_quote_escape_string($p['lat']) . ', '
304+
. $this->db_quote_escape_string($p['lng']) . ', '
305+
. $this->db_quote_escape_string($p['date']) . ', '
306+
. ((isset($p['altitude']) and is_numeric($p['altitude'])) ? $this->db_quote_escape_string(floatval($p['altitude'])) : 'NULL') . ', '
307+
. ((isset($p['battery']) and is_numeric($p['battery'])) ? $this->db_quote_escape_string(floatval($p['battery'])) : 'NULL') . ', '
308+
. ((isset($p['accuracy']) and is_numeric($p['accuracy'])) ? $this->db_quote_escape_string(floatval($p['accuracy'])) : 'NULL') . ')';
309309
array_push($values, $value);
310310
}
311311
$valuesStr = implode(', ', $values);
@@ -431,21 +431,21 @@ private function generateGpxHeader($name, $appVersion, $nbdev = 0) {
431431
$dt = new \DateTime();
432432
$date = $dt->format('Y-m-d\TH:i:s\Z');
433433
$gpxText = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' . "\n";
434-
$gpxText .= '<gpx xmlns="http://www.topografix.com/GPX/1/1"' .
435-
' xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"' .
436-
' xmlns:wptx1="http://www.garmin.com/xmlschemas/WaypointExtension/v1"' .
437-
' xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1"' .
438-
' creator="Nextcloud Maps v' .
439-
$appVersion . '" version="1.1"' .
440-
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' .
441-
' xsi:schemaLocation="http://www.topografix.com/GPX/1/1' .
442-
' http://www.topografix.com/GPX/1/1/gpx.xsd' .
443-
' http://www.garmin.com/xmlschemas/GpxExtensions/v3' .
444-
' http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd' .
445-
' http://www.garmin.com/xmlschemas/WaypointExtension/v1' .
446-
' http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd' .
447-
' http://www.garmin.com/xmlschemas/TrackPointExtension/v1' .
448-
' http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd">' . "\n";
434+
$gpxText .= '<gpx xmlns="http://www.topografix.com/GPX/1/1"'
435+
. ' xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"'
436+
. ' xmlns:wptx1="http://www.garmin.com/xmlschemas/WaypointExtension/v1"'
437+
. ' xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1"'
438+
. ' creator="Nextcloud Maps v'
439+
. $appVersion . '" version="1.1"'
440+
. ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
441+
. ' xsi:schemaLocation="http://www.topografix.com/GPX/1/1'
442+
. ' http://www.topografix.com/GPX/1/1/gpx.xsd'
443+
. ' http://www.garmin.com/xmlschemas/GpxExtensions/v3'
444+
. ' http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd'
445+
. ' http://www.garmin.com/xmlschemas/WaypointExtension/v1'
446+
. ' http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd'
447+
. ' http://www.garmin.com/xmlschemas/TrackPointExtension/v1'
448+
. ' http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd">' . "\n";
449449
$gpxText .= '<metadata>' . "\n" . ' <time>' . $date . '</time>' . "\n";
450450
$gpxText .= ' <name>' . $name . '</name>' . "\n";
451451
if ($nbdev > 0) {
@@ -564,9 +564,9 @@ public function importDevicesFromGpx($userId, $file) {
564564
while ($data = fread($fp, 4096000)) {
565565
if (!xml_parse($xml_parser, $data, feof($fp))) {
566566
$this->logger->error(
567-
'Exception in ' . $file->getName() . ' parsing at line ' .
568-
xml_get_current_line_number($xml_parser) . ' : ' .
569-
xml_error_string(xml_get_error_code($xml_parser)),
567+
'Exception in ' . $file->getName() . ' parsing at line '
568+
. xml_get_current_line_number($xml_parser) . ' : '
569+
. xml_error_string(xml_get_error_code($xml_parser)),
570570
['app' => 'maps']
571571
);
572572
return 0;
@@ -679,9 +679,9 @@ public function importDevicesFromKml($userId, $fp, $name) {
679679
while ($data = fread($fp, 4096000)) {
680680
if (!xml_parse($xml_parser, $data, feof($fp))) {
681681
$this->logger->error(
682-
'Exception in ' . $name . ' parsing at line ' .
683-
xml_get_current_line_number($xml_parser) . ' : ' .
684-
xml_error_string(xml_get_error_code($xml_parser)),
682+
'Exception in ' . $name . ' parsing at line '
683+
. xml_get_current_line_number($xml_parser) . ' : '
684+
. xml_error_string(xml_get_error_code($xml_parser)),
685685
);
686686
return 0;
687687
}

lib/Service/FavoritesService.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -186,24 +186,24 @@ public function addMultipleFavoritesToDB($userId, $favoriteList) {
186186
$values = [];
187187
foreach ($favoriteList as $fav) {
188188
if (
189-
!isset($fav['lat']) or !is_numeric($fav['lat']) or
190-
!isset($fav['lng']) or !is_numeric($fav['lng'])
189+
!isset($fav['lat']) or !is_numeric($fav['lat'])
190+
or !isset($fav['lng']) or !is_numeric($fav['lng'])
191191
) {
192192
continue;
193193
} else {
194194
$lat = floatval($fav['lat']);
195195
$lng = floatval($fav['lng']);
196196
}
197-
$value = '(' .
198-
$this->db_quote_escape_string($userId) . ', ' .
199-
((!isset($fav['name']) or !$fav['name']) ? 'NULL' : $this->db_quote_escape_string($fav['name'])) . ', ' .
200-
((!isset($fav['date_created']) or !is_numeric($fav['date_created'])) ? $this->db_quote_escape_string($nowTimeStamp) : $this->db_quote_escape_string($fav['date_created'])) . ', ' .
201-
$this->db_quote_escape_string($nowTimeStamp) . ', ' .
202-
$this->db_quote_escape_string($lat) . ', ' .
203-
$this->db_quote_escape_string($lng) . ', ' .
204-
((!isset($fav['category']) or !$fav['category']) ? 'NULL' : $this->db_quote_escape_string($fav['category'])) . ', ' .
205-
((!isset($fav['comment']) or !$fav['comment']) ? 'NULL' : $this->db_quote_escape_string($fav['comment'])) . ', ' .
206-
((!isset($fav['extensions']) or !$fav['extensions']) ? 'NULL' : $this->db_quote_escape_string($fav['extensions'])) . ')';
197+
$value = '('
198+
. $this->db_quote_escape_string($userId) . ', '
199+
. ((!isset($fav['name']) or !$fav['name']) ? 'NULL' : $this->db_quote_escape_string($fav['name'])) . ', '
200+
. ((!isset($fav['date_created']) or !is_numeric($fav['date_created'])) ? $this->db_quote_escape_string($nowTimeStamp) : $this->db_quote_escape_string($fav['date_created'])) . ', '
201+
. $this->db_quote_escape_string($nowTimeStamp) . ', '
202+
. $this->db_quote_escape_string($lat) . ', '
203+
. $this->db_quote_escape_string($lng) . ', '
204+
. ((!isset($fav['category']) or !$fav['category']) ? 'NULL' : $this->db_quote_escape_string($fav['category'])) . ', '
205+
. ((!isset($fav['comment']) or !$fav['comment']) ? 'NULL' : $this->db_quote_escape_string($fav['comment'])) . ', '
206+
. ((!isset($fav['extensions']) or !$fav['extensions']) ? 'NULL' : $this->db_quote_escape_string($fav['extensions'])) . ')';
207207
array_push($values, $value);
208208
}
209209
$valuesStr = implode(', ', $values);
@@ -286,8 +286,8 @@ public function deleteFavoritesFromDB($ids, $userId) {
286286
}
287287

288288
public function countFavorites($userId, $categoryList, $begin, $end) {
289-
if ($categoryList === null or
290-
(is_array($categoryList) and count($categoryList) === 0)
289+
if ($categoryList === null
290+
or (is_array($categoryList) and count($categoryList) === 0)
291291
) {
292292
return 0;
293293
}
@@ -308,9 +308,9 @@ public function countFavorites($userId, $categoryList, $begin, $end) {
308308
);
309309
}
310310
// apply category restrictions if it's a non-empty array
311-
if (!is_string($categoryList) and
312-
is_array($categoryList) and
313-
count($categoryList) > 0
311+
if (!is_string($categoryList)
312+
and is_array($categoryList)
313+
and count($categoryList) > 0
314314
) {
315315
$or = $qb->expr()->orx();
316316
foreach ($categoryList as $cat) {
@@ -392,8 +392,8 @@ public function getFavoritesFromJSON($file) {
392392
$currentFavorite['comment'] = '';
393393
}
394394
if (
395-
array_key_exists('Location', $value['properties']) &&
396-
array_key_exists('Address', $value['properties']['Location'])
395+
array_key_exists('Location', $value['properties'])
396+
&& array_key_exists('Address', $value['properties']['Location'])
397397
) {
398398
$currentFavorite['comment'] = $currentFavorite['comment'] . "\n" . $value['properties']['Location']['Address'];
399399
}
@@ -566,9 +566,9 @@ public function exportFavorites($userId, $fileHandler, $categoryList, $begin, $e
566566
);
567567
}
568568
// apply category restrictions if it's a non-empty array
569-
if (!is_string($categoryList) and
570-
is_array($categoryList) and
571-
count($categoryList) > 0
569+
if (!is_string($categoryList)
570+
and is_array($categoryList)
571+
and count($categoryList) > 0
572572
) {
573573
$or = $qb->expr()->orx();
574574
foreach ($categoryList as $cat) {
@@ -676,9 +676,9 @@ public function importFavoritesFromKml($userId, $fp, $name) {
676676
while ($data = fread($fp, 4096000)) {
677677
if (!xml_parse($xml_parser, $data, feof($fp))) {
678678
$this->logger->error(
679-
'Exception in ' . $name . ' parsing at line ' .
680-
xml_get_current_line_number($xml_parser) . ' : ' .
681-
xml_error_string(xml_get_error_code($xml_parser)),
679+
'Exception in ' . $name . ' parsing at line '
680+
. xml_get_current_line_number($xml_parser) . ' : '
681+
. xml_error_string(xml_get_error_code($xml_parser)),
682682
['app' => 'maps']
683683
);
684684
return 0;
@@ -781,9 +781,9 @@ public function importFavoritesFromGpx($userId, $file) {
781781
while ($data = fread($fp, 4096000)) {
782782
if (!xml_parse($xml_parser, $data, feof($fp))) {
783783
$this->logger->error(
784-
'Exception in ' . $file->getName() . ' parsing at line ' .
785-
xml_get_current_line_number($xml_parser) . ' : ' .
786-
xml_error_string(xml_get_error_code($xml_parser)),
784+
'Exception in ' . $file->getName() . ' parsing at line '
785+
. xml_get_current_line_number($xml_parser) . ' : '
786+
. xml_error_string(xml_get_error_code($xml_parser)),
787787
['app' => 'maps']
788788
);
789789
return 0;

lib/Service/GeophotoService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function getAll(string $userId, $folder = null, bool $respectNomediaAndNo
125125
continue;
126126
}
127127
$file = array_shift($files);
128-
128+
129129
if ($file === null) {
130130
continue;
131131
}

0 commit comments

Comments
 (0)