Skip to content

Commit 70ff955

Browse files
J9remmrflos
authored andcommitted
fix(BazarCarto): prevent querying entries without bf_latitude or bf_longitude
1 parent f13b2c2 commit 70ff955

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tools/bazar/actions/BazarCartoAction.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use YesWiki\Bazar\Controller\EntryController;
34
use YesWiki\Core\YesWikiAction;
45

56
class BazarCartoAction extends YesWikiAction
@@ -39,14 +40,25 @@ public function formatArguments($arg)
3940
$template = (!$dynamic) ?
4041
($arg['template'] ?? 'map.tpl.html') :
4142
($arg['template'] ?? 'map');
42-
if (strpos($template, 'gogomap') !== false) $template = 'gogocarto';
43+
if (strpos($template, 'gogomap') !== false) {
44+
$template = 'gogocarto';
45+
}
4346
$spider = (!$dynamic) ?
4447
($arg['spider'] ?? 'false') :
4548
$this->formatBoolean($arg, false, 'spider');
4649
$cluster = (!$dynamic) ?
4750
($arg['cluster'] ?? 'false') :
4851
$this->formatBoolean($arg, false, 'cluster');
4952

53+
// Filters entries via query to remove whose withou bf_latitude nor bf_longitude
54+
$query = $this->getService(EntryController::class)->formatQuery($arg, $_GET);
55+
if (!isset($query['bf_latitude!'])) {
56+
$query['bf_latitude!'] = "";
57+
}
58+
if (!isset($query['bf_longitude!'])) {
59+
$query['bf_longitude!'] = "";
60+
}
61+
5062
return([
5163
/*
5264
* Le fond de carte utilisé pour la carte
@@ -109,7 +121,8 @@ public function formatArguments($arg)
109121
'template' => $template,
110122

111123
'entrydisplay' => $arg['entrydisplay'] ?? 'sidebar',
112-
'pagination' => -1 // disable pagination
124+
'pagination' => -1, // disable pagination
125+
'query' => $query,
113126
]);
114127
}
115128

0 commit comments

Comments
 (0)