Port table/search/search_and_replace to Twig

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
Maurício Meneghini Fauth 2017-10-06 20:49:22 -03:00
parent 9b38ea8ca3
commit fe4f6148c2
4 changed files with 29 additions and 31 deletions

View File

@ -27,6 +27,7 @@ class PhpFunctionsExtension extends Twig_Extension
return array(
new Twig_SimpleFunction('array_search', 'array_search'),
new Twig_SimpleFunction('md5', 'md5'),
new Twig_SimpleFunction('preg_replace', 'preg_replace'),
);
}
}

View File

@ -1,29 +0,0 @@
<?= __('Find:'); ?>
<input type="text" value="" name="find" required />
<?= __('Replace with:'); ?>
<input type="text" value="" name="replaceWith" />
<?= __('Column:'); ?>
<select name="columnIndex">
<?php for ($i = 0, $nb = count($columnNames); $i < $nb; $i++): ?>
<?php $type = preg_replace('@\(.*@s', '', $columnTypes[$i]); ?>
<?php if ($GLOBALS['PMA_Types']->getTypeClass($type) == 'CHAR'): ?>
<?php $column = $columnNames[$i]; ?>
<option value="<?= $i; ?>">
<?= htmlspecialchars($column); ?>
</option>
<?php endif; ?>
<?php endfor; ?>
</select>
<br>
<?= PhpMyAdmin\Template::get('checkbox')
->render(
array(
'html_field_name' => 'useRegex',
'label' => __('Use regular expression'),
'checked' => false,
'onclick' => false,
'html_field_id' => 'useRegex',
)
); ?>

View File

@ -0,0 +1,25 @@
{% trans 'Find:' %}
<input type="text" value="" name="find" required />
{% trans 'Replace with:' %}
<input type="text" value="" name="replaceWith" />
{% trans 'Column:' %}
<select name="columnIndex">
{% for i in 0..column_names|length - 1 %}
{% set type = preg_replace('@\(.*@s', '', column_types[i]) %}
{% if sql_types.getTypeClass(type) == 'CHAR' %}
{% set column = column_names[i] %}
<option value="{{ i }}">
{{ column }}
</option>
{% endif %}
{% endfor %}
</select>
{% include 'checkbox.twig' with {
'html_field_id': 'useRegex',
'html_field_name': 'useRegex',
'label': 'Use regular expression'|trans,
'checked': false,
'onclick': false
} only %}

View File

@ -90,8 +90,9 @@ switch ($searchType) {
</legend>
<?= PhpMyAdmin\Template::get('table/search/search_and_replace')
->render(array(
'columnNames' => $columnNames,
'columnTypes' => $columnTypes
'column_names' => $columnNames,
'column_types' => $columnTypes,
'sql_types' => $GLOBALS['PMA_Types'],
)); ?>
</fieldset>
</fieldset>