Skip to content

Commit 035e29a

Browse files
committed
Extract GIS related methods from Util class
Creates the PhpMyAdmin\Utils\Gis class. Signed-off-by: Maurício Meneghini Fauth <[email protected]>
1 parent f6a9cf1 commit 035e29a

File tree

10 files changed

+489
-514
lines changed

10 files changed

+489
-514
lines changed

libraries/classes/Controllers/Table/SearchController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use PhpMyAdmin\Transformations;
1818
use PhpMyAdmin\Url;
1919
use PhpMyAdmin\Util;
20+
use PhpMyAdmin\Utils\Gis;
2021

2122
use function in_array;
2223
use function intval;
@@ -140,7 +141,7 @@ private function loadTableInfo(): void
140141
true
141142
);
142143
// Get details about the geometry functions
143-
$geom_types = Util::getGISDatatypes();
144+
$geom_types = Gis::getDataTypes();
144145

145146
foreach ($columns as $row) {
146147
// set column name

libraries/classes/Controllers/Table/ZoomSearchController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use PhpMyAdmin\Template;
1414
use PhpMyAdmin\Url;
1515
use PhpMyAdmin\Util;
16+
use PhpMyAdmin\Utils\Gis;
1617

1718
use function array_search;
1819
use function count;
@@ -187,7 +188,7 @@ private function loadTableInfo(): void
187188
true
188189
);
189190
// Get details about the geometry functions
190-
$geom_types = Util::getGISDatatypes();
191+
$geom_types = Gis::getDataTypes();
191192

192193
foreach ($columns as $row) {
193194
// set column name

libraries/classes/Display/Results.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use PhpMyAdmin\Transformations;
3030
use PhpMyAdmin\Url;
3131
use PhpMyAdmin\Util;
32+
use PhpMyAdmin\Utils\Gis;
3233

3334
use function array_filter;
3435
use function array_keys;
@@ -3656,7 +3657,7 @@ private function getDataCellForGeometryColumns(
36563657
$whereComparison = ' = ' . $column;
36573658

36583659
// Convert to WKT format
3659-
$wktval = Util::asWKT($column);
3660+
$wktval = Gis::convertToWellKnownText($column);
36603661
[
36613662
$isFieldTruncated,
36623663
$displayedColumn,

libraries/classes/InsertEdit.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PhpMyAdmin\Controllers\Table\ChangeController;
1111
use PhpMyAdmin\Html\Generator;
1212
use PhpMyAdmin\Plugins\TransformationsPlugin;
13+
use PhpMyAdmin\Utils\Gis;
1314

1415
use function array_fill;
1516
use function array_flip;
@@ -2115,7 +2116,7 @@ private function getSpecialCharsAndBackupFieldForExistingRow(
21152116
// Convert gis data to Well Know Text format
21162117
$current_row[$column['Field']] = $as_is
21172118
? $current_row[$column['Field']]
2118-
: Util::asWKT(
2119+
: Gis::convertToWellKnownText(
21192120
$current_row[$column['Field']],
21202121
true
21212122
);
@@ -3393,7 +3394,7 @@ private function getHtmlForInsertEditFormColumn(
33933394
}
33943395

33953396
// Get a list of GIS data types.
3396-
$gis_data_types = Util::getGISDatatypes();
3397+
$gis_data_types = Gis::getDataTypes();
33973398

33983399
// Prepares the field value
33993400
$real_null_value = false;

libraries/classes/Table/Search.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PhpMyAdmin\DatabaseInterface;
88
use PhpMyAdmin\Util;
9+
use PhpMyAdmin\Utils\Gis;
910

1011
use function count;
1112
use function explode;
@@ -280,7 +281,7 @@ private function getGeomWhereClause(
280281
$where = '';
281282

282283
// Get details about the geometry functions
283-
$geom_funcs = Util::getGISFunctions($types, true, false);
284+
$geom_funcs = Gis::getFunctions($types, true, false);
284285

285286
// If the function takes multiple parameters
286287
if (strpos($func_type, 'IS NULL') !== false || strpos($func_type, 'IS NOT NULL') !== false) {
@@ -289,7 +290,7 @@ private function getGeomWhereClause(
289290

290291
if ($geom_funcs[$geom_func]['params'] > 1) {
291292
// create gis data from the criteria input
292-
$gis_data = Util::createGISData($criteriaValues, $this->dbi->getVersion());
293+
$gis_data = Gis::createData($criteriaValues, $this->dbi->getVersion());
293294

294295
return $geom_func . '(' . Util::backquote($names)
295296
. ', ' . $gis_data . ')';
@@ -307,11 +308,11 @@ private function getGeomWhereClause(
307308
) {
308309
$where = $geom_function_applied;
309310
} elseif (
310-
in_array($type, Util::getGISDatatypes())
311+
in_array($type, Gis::getDataTypes())
311312
&& ! empty($criteriaValues)
312313
) {
313314
// create gis data from the criteria input
314-
$gis_data = Util::createGISData($criteriaValues, $this->dbi->getVersion());
315+
$gis_data = Gis::createData($criteriaValues, $this->dbi->getVersion());
315316
$where = $geom_function_applied . ' ' . $func_type . ' ' . $gis_data;
316317
} elseif (strlen($criteriaValues) > 0) {
317318
$where = $geom_function_applied . ' '

libraries/classes/Twig/UtilExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ public function getFunctions()
6060
),
6161
new TwigFunction(
6262
'get_gis_datatypes',
63-
'PhpMyAdmin\Util::getGISDatatypes'
63+
'PhpMyAdmin\Utils\Gis::getDataTypes'
6464
),
6565
new TwigFunction(
6666
'get_gis_functions',
67-
'PhpMyAdmin\Util::getGISFunctions'
67+
'PhpMyAdmin\Utils\Gis::getFunctions'
6868
),
6969
new TwigFunction(
7070
'get_icon',

0 commit comments

Comments
 (0)