Skip to content

Commit

Permalink
Remove controller object from table/search/index template
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Mar 9, 2024
1 parent 66916f3 commit f6a8b78
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
3 changes: 0 additions & 3 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3633,9 +3633,6 @@
<PossiblyInvalidCast>
<code><![CDATA[$_POST['column']]]></code>
</PossiblyInvalidCast>
<PossiblyUnusedMethod>
<code><![CDATA[getColumnProperties]]></code>
</PossiblyUnusedMethod>
<RedundantCastGivenDocblockType>
<code><![CDATA[(int) $config->settings['MaxRows']]]></code>
</RedundantCastGivenDocblockType>
Expand Down
13 changes: 6 additions & 7 deletions resources/templates/table/search/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</tr>
</thead>
<tbody>
{% for column_index in 0..column_names|length - 1 %}
{% for column_index in column_names|keys %}
<tr class="noclick">
{# If 'Function' column is present trying to change comment #}
{% if geom_column_flag %}
Expand All @@ -69,19 +69,18 @@
{#- Keep this without extra spaces because it is used for a request to build the BETWEEN modal -#}
{{- column_names[column_index] -}}
</th>
{% set properties = self.getColumnProperties(column_index, column_index) %}
<td dir="ltr">
{{ properties['type'] }}
{{ properties[column_index]['type'] }}
</td>
<td>
{{ properties['collation'] }}
{{ properties[column_index]['collation'] }}
</td>
<td>
{{ properties['func']|raw }}
{{ properties[column_index]['func']|raw }}
</td>
{# here, the data-type attribute is needed for a date/time picker #}
<td data-type="{{ properties['type'] }}">
{{ properties['value']|raw }}
<td data-type="{{ properties[column_index]['type'] }}">
{{ properties[column_index]['value']|raw }}
{# Displays hidden fields #}
<input type="hidden" name="criteriaColumnNames[{{ column_index }}]" value="{{ column_names[column_index] }}">
<input type="hidden" name="criteriaColumnTypes[{{ column_index }}]" value="{{ column_types[column_index] }}">
Expand Down
10 changes: 8 additions & 2 deletions src/Controllers/Table/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use PhpMyAdmin\Utils\Gis;

use function __;
use function array_keys;
use function in_array;
use function is_array;
use function mb_strtolower;
Expand Down Expand Up @@ -272,11 +273,16 @@ public function displaySelectionFormAction(): void
$GLOBALS['goto'] = Util::getScriptNameForOption($config->settings['DefaultTabTable'], 'table');
}

$properties = [];
foreach (array_keys($this->columnNames) as $columnIndex) {
$properties[$columnIndex] = $this->getColumnProperties($columnIndex, $columnIndex);
}

$this->render('table/search/index', [
'db' => Current::$database,
'table' => Current::$table,
'goto' => $GLOBALS['goto'],
'self' => $this,
'properties' => $properties,
'geom_column_flag' => $this->geomColumnFlag,
'column_names' => $this->columnNames,
'column_types' => $this->columnTypes,
Expand Down Expand Up @@ -319,7 +325,7 @@ public function getColumnMinMax(string $column): array|null
*
* @return mixed[] Array containing column's properties
*/
public function getColumnProperties(int $searchIndex, int $columnIndex): array
private function getColumnProperties(int $searchIndex, int $columnIndex): array
{
$selectedOperator = $_POST['criteriaColumnOperators'][$searchIndex] ?? '';
$enteredValue = $_POST['criteriaValues'] ?? '';
Expand Down

0 comments on commit f6a8b78

Please sign in to comment.