Skip to content

Commit 8bd0185

Browse files
committed
Fixed do not load images from Maps folder test
Signed-off-by: Arne Hamann <git@arne.email>
1 parent e33cab0 commit 8bd0185

File tree

3 files changed

+36
-25
lines changed

3 files changed

+36
-25
lines changed

lib/Controller/PhotosController.php

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,27 @@ public function __construct($AppName,
4949
$this->root = $root;
5050
}
5151

52-
/**
53-
* @NoAdminRequired
54-
* @NoCSRFRequired
52+
/**
53+
* @NoAdminRequired
54+
* @NoCSRFRequired
55+
* @param null $myMapId
56+
* @param null $respectNoMediaAndNoimage
57+
* @param null $hideImagesOnCustomMaps
58+
* @param null $hideImagesInMapsFolder
5559
* @return DataResponse
56-
*/
57-
public function getPhotos($myMapId=null): DataResponse {
60+
* @throws Exception
61+
* @throws NoUserException
62+
* @throws NotFoundException
63+
* @throws NotPermittedException
64+
*/
65+
public function getPhotos($myMapId=null, $respectNoMediaAndNoimage=null, $hideImagesOnCustomMaps=null, $hideImagesInMapsFolder=null): DataResponse {
5866
$userFolder = $this->root->getUserFolder($this->userId);
5967
if (is_null($myMapId) || $myMapId === "") {
60-
$result = $this->geophotoService->getAll($this->userId, $userFolder, true, false, true);
68+
$result = $this->geophotoService->getAll($this->userId, $userFolder, $respectNoMediaAndNoimage??true, $hideImagesOnCustomMaps??false, $hideImagesInMapsFolder??true);
6169
} else {
6270
$folders = $userFolder->getById($myMapId);
6371
$folder = array_shift($folders);
64-
$result = $this->geophotoService->getAll($this->userId, $folder, true, false, false);
72+
$result = $this->geophotoService->getAll($this->userId, $folder, $respectNoMediaAndNoimage??true, $hideImagesOnCustomMaps??false, $hideImagesInMapsFolder??false);
6573
}
6674
return new DataResponse($result);
6775
}
@@ -73,20 +81,23 @@ public function getPhotos($myMapId=null): DataResponse {
7381
* @param string|null $timezone
7482
* @param int $limit
7583
* @param int $offset
84+
* @param null $respectNoMediaAndNoimage
85+
* @param null $hideImagesOnCustomMaps
86+
* @param null $hideImagesInMapsFolder
7687
* @return DataResponse
7788
* @throws Exception
7889
* @throws NoUserException
7990
* @throws NotFoundException
8091
* @throws NotPermittedException
8192
*/
82-
public function getNonLocalizedPhotos(?int $myMapId=null, ?string $timezone=null, int $limit=250, int $offset=0): DataResponse {
93+
public function getNonLocalizedPhotos(?int $myMapId=null, ?string $timezone=null, int $limit=250, int $offset=0, $respectNoMediaAndNoimage=null, $hideImagesOnCustomMaps=null, $hideImagesInMapsFolder=null): DataResponse {
8394
$userFolder = $this->root->getUserFolder($this->userId);
8495
if (is_null($myMapId) || $myMapId === "") {
85-
$result = $this->geophotoService->getNonLocalized($this->userId, $userFolder, true, false, true, $timezone, $limit, $offset);
96+
$result = $this->geophotoService->getNonLocalized($this->userId, $userFolder, $respectNoMediaAndNoimage??true, $hideImagesOnCustomMaps??false, $hideImagesInMapsFolder??true, $timezone, $limit, $offset);
8697
} else {
8798
$folders = $userFolder->getById($myMapId);
8899
$folder = array_shift($folders);
89-
$result = $this->geophotoService->getNonLocalized($this->userId, $folder, true, false, false, $timezone, $limit, $offset);
100+
$result = $this->geophotoService->getNonLocalized($this->userId, $folder, $respectNoMediaAndNoimage??true, $hideImagesOnCustomMaps??false, $hideImagesInMapsFolder??false, $timezone, $limit, $offset);
90101
}
91102
return new DataResponse($result);
92103
}

lib/Service/GeophotoService.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,23 @@ public function clearCache(string $userId=''): bool {
9191
* @param null $folder =null
9292
* @param bool $respectNomediaAndNoimage =true
9393
* @param bool $hideImagesOnCustomMaps =true
94-
* @param bool $hideImageInMapsFolder
94+
* @param bool $hideImagesInMapsFolder
9595
* @return array
9696
* @throws Exception
9797
* @throws NoUserException
9898
* @throws NotFoundException
9999
* @throws NotPermittedException
100100
*/
101-
public function getAll(string $userId, $folder=null, bool $respectNomediaAndNoimage=true, bool $hideImagesOnCustomMaps=false, bool $hideImageInMapsFolder=true): array {
101+
public function getAll(string $userId, $folder=null, bool $respectNomediaAndNoimage=true, bool $hideImagesOnCustomMaps=false, bool $hideImagesInMapsFolder=true): array {
102102
$userFolder = $this->getFolderForUser($userId);
103103
if (is_null($folder)) {
104104
$folder = $userFolder;
105105
}
106-
$key = $userId . ':' . $userFolder->getRelativePath($folder->getPath()) . ':' . (string) $respectNomediaAndNoimage . ':' . (string) $hideImagesOnCustomMaps . ':' . (string) $hideImageInMapsFolder;
106+
$key = $userId . ':' . $userFolder->getRelativePath($folder->getPath()) . ':' . (string) $respectNomediaAndNoimage . ':' . (string) $hideImagesOnCustomMaps . ':' . (string) $hideImagesInMapsFolder;
107107
$filesById = $this->photosCache->get($key);
108108
if ($filesById === null) {
109109
$ignoredPaths = $respectNomediaAndNoimage ? $this->getIgnoredPaths($userId, $folder, $hideImagesOnCustomMaps) : [];
110-
if ($hideImageInMapsFolder) {
110+
if ($hideImagesInMapsFolder) {
111111
$ignoredPaths[] = "/Maps";
112112
}
113113
$photoEntities = $this->photoMapper->findAll($userId);
@@ -175,7 +175,7 @@ public function getAll(string $userId, $folder=null, bool $respectNomediaAndNoim
175175
* @param null $folder =null
176176
* @param bool $respectNomediaAndNoimage
177177
* @param bool $hideImagesOnCustomMaps
178-
* @param bool $hideImageInMapsFolder
178+
* @param bool $hideImagesInMapsFolder
179179
* @param string|null $timezone locale time zone used by images
180180
* @param int $limit
181181
* @param int $offset
@@ -185,7 +185,7 @@ public function getAll(string $userId, $folder=null, bool $respectNomediaAndNoim
185185
* @throws NotFoundException
186186
* @throws NotPermittedException
187187
*/
188-
public function getNonLocalized (string $userId, $folder=null, bool $respectNomediaAndNoimage=true, bool $hideImagesOnCustomMaps=false, bool $hideImageInMapsFolder=true, string $timezone=null, int $limit=250, int $offset=0): array {
188+
public function getNonLocalized (string $userId, $folder=null, bool $respectNomediaAndNoimage=true, bool $hideImagesOnCustomMaps=false, bool $hideImagesInMapsFolder=true, string $timezone=null, int $limit=250, int $offset=0): array {
189189
$userFolder = $this->getFolderForUser($userId);
190190
if (is_null($folder)) {
191191
$folder = $userFolder;
@@ -194,7 +194,7 @@ public function getNonLocalized (string $userId, $folder=null, bool $respectNome
194194
// $filesById = $this->nonLocalizedPhotosCache->get($key);
195195
// if ($filesById === null) {
196196
$ignoredPaths = $respectNomediaAndNoimage ? $this->getIgnoredPaths($userId, $folder, $hideImagesOnCustomMaps) : [];
197-
if ($hideImageInMapsFolder) {
197+
if ($hideImagesInMapsFolder) {
198198
$ignoredPaths[] = "/Maps";
199199
}
200200
$foo = $this->loadTimeorderedPointSets($userId, $folder, $respectNomediaAndNoimage, $hideImagesOnCustomMaps);

tests/Unit/Controller/PhotosControllerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public function testAddGetPhotos() {
213213
$this->assertCount(1, $data);
214214
$this->assertEquals('/nc.jpg', $data[0]->path);
215215

216-
//Test .nomedia repected
216+
//Test .nomedia respected
217217
$this->GeoPhotosService->clearCache();
218218
$file = $userfolder->newFile('.maps.nomedia');
219219
$resp = $this->photosController->getPhotos();
@@ -223,7 +223,7 @@ public function testAddGetPhotos() {
223223
$this->assertCount(0, $data);
224224
$file->delete();
225225

226-
//Test .noimage repected
226+
//Test .noimage respected
227227
$this->GeoPhotosService->clearCache();
228228
$file = $userfolder->newFile('.maps.noimage');
229229
$resp = $this->photosController->getPhotos();
@@ -233,10 +233,10 @@ public function testAddGetPhotos() {
233233
$this->assertCount(0, $data);
234234
$file->delete();
235235

236-
//Test .maps repected
236+
//Test .maps respected
237237
$this->GeoPhotosService->clearCache();
238238
$file = $userfolder->newFile('.index.maps');
239-
$resp = $this->photosController->getPhotos();
239+
$resp = $this->photosController->getPhotos(null, null, true);
240240
$status = $resp->getStatus();
241241
$this->assertEquals(200, $status);
242242
$data = $resp->getData();
@@ -272,7 +272,7 @@ public function testAddGetPhotos() {
272272
$this->assertCount(1, $data);
273273
$this->assertEquals('/nut.jpg', $data[0]->path);
274274

275-
//Test .nomedia repected
275+
//Test .nomedia respected
276276
$this->GeoPhotosService->clearCache();
277277
$file = $userfolder->newFile('.maps.nomedia');
278278
$resp = $this->photosController->getNonLocalizedPhotos();
@@ -282,7 +282,7 @@ public function testAddGetPhotos() {
282282
$this->assertCount(0, $data);
283283
$file->delete();
284284

285-
//Test .noimage repected
285+
//Test .noimage respected
286286
$this->GeoPhotosService->clearCache();
287287
$file = $userfolder->newFile('.maps.noimage');
288288
$resp = $this->photosController->getNonLocalizedPhotos();
@@ -292,10 +292,10 @@ public function testAddGetPhotos() {
292292
$this->assertCount(0, $data);
293293
$file->delete();
294294

295-
//Test .index.maps repected
295+
//Test .index.maps respected
296296
$this->GeoPhotosService->clearCache();
297297
$file = $userfolder->newFile('.index.maps');
298-
$resp = $this->photosController->getNonLocalizedPhotos();
298+
$resp = $this->photosController->getNonLocalizedPhotos(null, null, 250, 0, true, true);
299299
$status = $resp->getStatus();
300300
$this->assertEquals(200, $status);
301301
$data = $resp->getData();

0 commit comments

Comments
 (0)