2424use function str_contains ;
2525use function strlen ;
2626use function strpos ;
27+ use function trim ;
2728
2829/**
2930 * Displays form for editing and inserting new table rows.
@@ -61,7 +62,6 @@ public function __invoke(ServerRequest $request): void
6162 $ GLOBALS ['tabindex ' ] ??= null ;
6263 $ GLOBALS ['tabindex_for_value ' ] ??= null ;
6364 $ GLOBALS ['o_rows ' ] ??= null ;
64- $ GLOBALS ['biggest_max_file_size ' ] ??= null ;
6565 $ GLOBALS ['has_blob_field ' ] ??= null ;
6666 $ GLOBALS ['jsvkey ' ] ??= null ;
6767 $ GLOBALS ['vkey ' ] ??= null ;
@@ -182,14 +182,10 @@ public function __invoke(ServerRequest $request): void
182182 $ GLOBALS ['tabindex ' ] = 0 ;
183183 $ GLOBALS ['tabindex_for_value ' ] = 0 ;
184184 $ GLOBALS ['o_rows ' ] = 0 ;
185- $ GLOBALS ['biggest_max_file_size ' ] = 0 ;
186185
187186 $ GLOBALS ['urlParams ' ]['db ' ] = $ GLOBALS ['db ' ];
188187 $ GLOBALS ['urlParams ' ]['table ' ] = $ GLOBALS ['table ' ];
189- $ GLOBALS ['urlParams ' ] = $ this ->insertEdit ->urlParamsInEditMode (
190- $ GLOBALS ['urlParams ' ],
191- $ GLOBALS ['where_clause_array ' ],
192- );
188+ $ GLOBALS ['urlParams ' ] = $ this ->urlParamsInEditMode ($ GLOBALS ['urlParams ' ], $ GLOBALS ['where_clause_array ' ]);
193189
194190 $ GLOBALS ['has_blob_field ' ] = false ;
195191 foreach ($ GLOBALS ['table_columns ' ] as $ column ) {
@@ -263,7 +259,6 @@ public function __invoke(ServerRequest $request): void
263259 $ GLOBALS ['table ' ],
264260 $ GLOBALS ['db ' ],
265261 $ rowId ,
266- $ GLOBALS ['biggest_max_file_size ' ],
267262 $ GLOBALS ['text_dir ' ],
268263 $ GLOBALS ['repopulate ' ],
269264 $ GLOBALS ['where_clause_array ' ],
@@ -286,11 +281,6 @@ public function __invoke(ServerRequest $request): void
286281 'is_numeric ' => $ isNumeric ,
287282 ]);
288283
289- if ($ GLOBALS ['biggest_max_file_size ' ] > 0 ) {
290- $ htmlOutput .= '<input type="hidden" name="MAX_FILE_SIZE" value=" '
291- . $ GLOBALS ['biggest_max_file_size ' ] . '"> ' . "\n" ;
292- }
293-
294284 $ htmlOutput .= '</form> ' ;
295285
296286 $ htmlOutput .= $ this ->insertEdit ->getHtmlForGisEditor ();
@@ -308,4 +298,27 @@ public function __invoke(ServerRequest $request): void
308298
309299 $ this ->response ->addHTML ($ htmlOutput );
310300 }
301+
302+ /**
303+ * Add some url parameters
304+ *
305+ * @param mixed[] $urlParams containing $db and $table as url parameters
306+ * @param mixed[] $whereClauseArray where clauses array
307+ *
308+ * @return mixed[] Add some url parameters to $url_params array and return it
309+ */
310+ public function urlParamsInEditMode (
311+ array $ urlParams ,
312+ array $ whereClauseArray ,
313+ ): array {
314+ foreach ($ whereClauseArray as $ whereClause ) {
315+ $ urlParams ['where_clause ' ] = trim ($ whereClause );
316+ }
317+
318+ if (! empty ($ _POST ['sql_query ' ])) {
319+ $ urlParams ['sql_query ' ] = $ _POST ['sql_query ' ];
320+ }
321+
322+ return $ urlParams ;
323+ }
311324}
0 commit comments