Permalink
Browse files

Refactor Url Twig extensions

Signed-off-by: Leonardo Strozzi <laps15@inf.ufpr.br>
  • Loading branch information...
laps15 committed Aug 1, 2018
1 parent ed8aadd commit b65ede42ee36fcdf17e8a6ff3d4cf3edafcb90b0
Showing with 104 additions and 92 deletions.
  1. +18 −6 libraries/classes/Twig/UrlExtension.php
  2. +1 −1 templates/columns_definitions/column_definitions_form.twig
  3. +2 −2 templates/columns_definitions/table_fields_definitions.twig
  4. +1 −1 templates/create_tracking_version.twig
  5. +7 −7 templates/database/central_columns/main.twig
  6. +1 −1 templates/database/create_table.twig
  7. +1 −1 templates/database/designer/edit_delete_pages.twig
  8. +1 −1 templates/database/designer/main.twig
  9. +1 −1 templates/database/designer/page_save_as.twig
  10. +1 −1 templates/database/designer/schema_export.twig
  11. +1 −1 templates/database/search/main.twig
  12. +2 −2 templates/database/search/results.twig
  13. +1 −1 templates/database/structure/body_for_table_summary.twig
  14. +1 −1 templates/database/structure/favorite_anchor.twig
  15. +1 −1 templates/database/structure/structure_table_row.twig
  16. +1 −1 templates/database/structure/table_header.twig
  17. +1 −1 templates/database/structure/tracking_icon.twig
  18. +2 −2 templates/database/tracking/tables.twig
  19. +3 −3 templates/display/export/hidden_inputs.twig
  20. +3 −3 templates/display/import/import.twig
  21. +2 −2 templates/display/import/javascript.twig
  22. +1 −1 templates/display/results/multi_row_operations_form.twig
  23. +1 −1 templates/display/results/options_block.twig
  24. +1 −1 templates/display/results/show_all_checkbox.twig
  25. +1 −1 templates/display/results/table_navigation_button.twig
  26. +1 −1 templates/login/header.twig
  27. +1 −1 templates/login/twofactor.twig
  28. +1 −1 templates/login/twofactor/application_configure.twig
  29. +2 −2 templates/prefs_twofactor.twig
  30. +1 −1 templates/prefs_twofactor_configure.twig
  31. +1 −1 templates/prefs_twofactor_confirm.twig
  32. +1 −1 templates/select_lang.twig
  33. +1 −1 templates/server/binlog/log_selector.twig
  34. +1 −1 templates/server/databases/databases_footer.twig
  35. +4 −4 templates/server/databases/index.twig
  36. +2 −2 templates/server/databases/table_row.twig
  37. +1 −1 templates/server/engines/list_engines.twig
  38. +2 −2 templates/server/engines/show_engine.twig
  39. +2 −2 templates/server/privileges/add_user_fieldset.twig
  40. +1 −1 templates/server/privileges/choose_user_group.twig
  41. +1 −1 templates/server/privileges/edit_routine_privileges.twig
  42. +2 −2 templates/server/privileges/initials_row.twig
  43. +1 −1 templates/table/chart/tbl_chart.twig
  44. +1 −1 templates/table/gis_visualization/gis_visualization.twig
  45. +1 −1 templates/table/index_form.twig
  46. +1 −1 templates/table/insert/continue_insertion_form.twig
  47. +1 −1 templates/table/relation/common_form.twig
  48. +1 −1 templates/table/relation/foreign_key_row.twig
  49. +1 −1 templates/table/search/form_tag.twig
  50. +2 −2 templates/table/search/input_box.twig
  51. +1 −1 templates/table/search/replace_preview.twig
  52. +1 −1 templates/table/search/zoom_result_form.twig
  53. +1 −1 templates/table/structure/display_partitions.twig
  54. +3 −3 templates/table/structure/display_structure.twig
  55. +1 −1 templates/table/structure/partition_definition_form.twig
  56. +5 −5 templates/table/tracking/main.twig
  57. +1 −1 templates/theme_preview.twig
  58. +1 −1 templates/view_create.twig
@@ -11,6 +11,7 @@
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use Twig\TwigFilter;
/**
* Class UrlExtension
@@ -28,27 +29,38 @@ public function getFunctions()
{
return [
new TwigFunction(
'Url_getHiddenInputs',
'get_hidden_inputs',
'PhpMyAdmin\Url::getHiddenInputs',
['is_safe' => ['html']]
),
new TwigFunction(
'Url_getHiddenFields',
'get_hidden_fields',
'PhpMyAdmin\Url::getHiddenFields',
['is_safe' => ['html']]
),
new TwigFunction(
'Url_getCommon',
'get_common',
'PhpMyAdmin\Url::getCommon',
['is_safe' => ['html']]
),
new TwigFunction(
'Url_getCommonRaw',
'get_common_raw',
'PhpMyAdmin\Url::getCommonRaw',
['is_safe' => ['html']]
),
new TwigFunction(
'Url_link',
];
}
/**
* Returns a list of filters to add to the existing list.
*
* @return TwigFilter[]
*/
public function getFilters()
{
return [
new TwigFilter(
'link',
'PhpMyAdmin\Core::linkURL'
),
];
@@ -1,7 +1,7 @@
<form method="post" action="{{ action }}" class="
{{- action == 'tbl_create.php' ? 'create_table' : 'append_fields' -}}
_form ajax lock-page">
{{ Url_getHiddenInputs(form_params) }}
{{ get_hidden_inputs(form_params) }}
{# happens when an index has been set on a column #}
{# and a column is added to the table creation dialog #}
{# This contains a JSON-encoded string #}
@@ -72,7 +72,7 @@
</th>
<th>
<a href="transformation_overview.php
{{- Url_getCommon() }}#transformation" title="
{{- get_common() }}#transformation" title="
{%- trans 'List of available transformations and their options' -%}
" target="_blank">
{% trans 'Browser display transformation' %}
@@ -83,7 +83,7 @@
{{ Util_showHint('Please enter the values for transformation options using this format: \'a\', 100, b,\'c\'…<br />If you ever need to put a backslash ("\\") or a single quote ("\'") amongst those values, precede it with a backslash (for example \'\\\\xyz\' or \'a\\\'b\').'|trans) }}
</th>
<th>
<a href="transformation_overview.php{{ Url_getCommon() }}#input_transformation"
<a href="transformation_overview.php{{ get_common() }}#input_transformation"
title="{% trans 'List of available transformations and their options' %}"
target="_blank">
{% trans 'Input transformation' %}
@@ -1,6 +1,6 @@
<div id="div_create_version">
<form method="post" action="{{ url_query|raw }}">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
{% for selected_table in selected %}
<input type="hidden" name="selected[]" value="{{ selected_table }}">
{% endfor %}
@@ -5,7 +5,7 @@
</a>
<form id="add_new" class="new_central_col{{ (total_rows != 0) ? ' hide' : ''}}"
method="post" action="db_central_columns.php">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<input type="hidden" name="add_new_column" value="add_new_column">
<div class="responsivetable">
<table>
@@ -147,7 +147,7 @@
{% if pos - max_rows >= 0 %}
<td>
<form action="db_central_columns.php" method="post">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<input type="hidden" name="pos" value="{{ pos - max_rows }}" />
<input type="hidden" name="total_rows" value="{{ total_rows }}"/>
<input type="submit" name="navig" class="ajax" value="&lt" />
@@ -157,7 +157,7 @@
{% if tn_nbTotalPage > 1 %}
<td>
<form action="db_central_columns.php" method="post">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<input type="hidden" name="total_rows" value="{{ total_rows }}"/>
{{ tn_page_selector | raw }}
</form>
@@ -166,7 +166,7 @@
{% if pos + max_rows < total_rows %}
<td>
<form action="db_central_columns.php" method="post">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<input type="hidden" name="pos" value="{{ pos + max_rows }}"/>
<input type="hidden" name="total_rows" value="{{ total_rows }}"/>
<input type="submit" name="navig" class="ajax" value="&gt" />
@@ -191,7 +191,7 @@
<td class="central_columns_navigation">
{{ Util_getIcon('centralColumns_add', 'Add column' | trans)|raw }}
<form id="add_column" action="db_central_columns.php" method="post">
{{ Url_getHiddenInputs(db) | raw }}
{{ get_hidden_inputs(db) | raw }}
<input type="hidden" name="add_column" value="add">
<input type="hidden" name="pos" value="{{ pos }}" />
<input type="hidden" name="total_rows" value="{{ total_rows }}"/>
@@ -215,7 +215,7 @@
</table>
{% if total_rows > 0 %}
<form method="post" id="del_form" action="db_central_columns.php">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<input id="del_col_name" type="hidden" name="col_name" value="">
<input type="hidden" name="pos" value="{{ pos }}">
<input type="hidden" name="delete_save" value="delete">
@@ -269,7 +269,7 @@
{% for row in rows_list %}
{# getHtmlForTableRow #}
<tr data-rownum="{{ row_num }}" id="{{ 'f_' ~ row_num }}">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<input type="hidden" name="edit_save" value="save">
<td class="nowrap">
<input type="checkbox" class="checkall" name="selected_fld[]"
@@ -6,7 +6,7 @@
{%- endif %}
{% trans "Create table" %}
</legend>
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<div class="formelement">
{% trans "Name" %}:
<input type="text" name="table" maxlength="64" size="30" required="required" />
@@ -1,5 +1,5 @@
<form action="db_designer.php" method="post" name="edit_delete_pages" id="edit_delete_pages" class="ajax">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<fieldset id="page_edit_delete_options">
<input type="hidden" name="operation" value="{{ operation }}" />
<label for="selected_page">
@@ -1130,7 +1130,7 @@ var designer_config = {{ designer_config | raw }};
<form method="post" action="db_qbe.php" id="vqb_form">
<textarea cols="80" name="sql_query" id="textSqlquery" rows="15"></textarea>
<input type="hidden" name="submit_sql" value="true">
{{ Url_getHiddenInputs(get_db) }}
{{ get_hidden_inputs(get_db) }}
</form>
</div>
{% endif %}
@@ -1,5 +1,5 @@
<form action="db_designer.php" method="post" name="save_as_pages" id="save_as_pages" class="ajax">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<fieldset id="page_save_as_options">
<table>
<tbody>
@@ -1,6 +1,6 @@
<form method="post" action="schema_export.php" class="disableAjax" id="id_export_pages">
<fieldset>
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<label>{% trans 'Select Export Relational Type' %}</label>
{{ get_choice('Schema', 'export_type', export_list, 'format') }}
<input type="hidden" name="page_number" value="{{ page }}" />
@@ -1,6 +1,6 @@
<a id="db_search"></a>
<form id="db_search_form" method="post" action="db_search.php" name="db_search" class="ajax lock-page">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<fieldset>
<legend>{% trans 'Search in database' %}</legend>
<p>
@@ -28,7 +28,7 @@
<td>
<a name="browse_search"
class="ajax browse_results"
href="sql.php{{ Url_getCommon(url_params) }}"
href="sql.php{{ get_common(url_params) }}"
data-browse-sql="{{ row.new_search_sqls.select_columns }}"
data-table-name="{{ row.table }}">
{% trans 'Browse' %}
@@ -37,7 +37,7 @@
<td>
<a name="delete_search"
class="ajax delete_results"
href="sql.php{{ Url_getCommon(url_params) }}"
href="sql.php{{ get_common(url_params) }}"
data-delete-sql="{{ row.new_search_sqls.delete }}"
data-table-name="{{ row.table }}">
{% trans 'Delete' %}
@@ -29,7 +29,7 @@
{% if approx_rows %}
{% set cell_text -%}
<a href="db_structure.php
{{- Url_getCommon(row_sum_url) }}" class="ajax row_count_sum">~
{{- get_common(row_sum_url) }}" class="ajax row_count_sum">~
{{- row_count_sum -}}
</a>
{%- endset %}
@@ -1,6 +1,6 @@
<a id="{{ table_name_hash }}_favorite_anchor"
class="ajax favorite_table_anchor"
href="db_structure.php{{ Url_getCommon(fav_params) }}"
href="db_structure.php{{ get_common(fav_params) }}"
title="{{ already_favorite ? 'Remove from Favorites'|trans : 'Add to Favorites'|trans }}"
data-favtargets="{{ db_table_name_hash }}" >
{{ already_favorite ? titles['Favorite']|raw : titles['NoFavorite']|raw }}
@@ -88,7 +88,7 @@
<td class="value tbl_rows"
data-table="{{ current_table['TABLE_NAME'] }}">
{% if approx_rows %}
<a href="db_structure.php{{ Url_getCommon({
<a href="db_structure.php{{ get_common({
'ajax_request': true,
'db': db,
'table': current_table['TABLE_NAME'],
@@ -1,5 +1,5 @@
<form method="post" action="db_structure.php" name="tablesForm" id="tablesForm">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<div class="responsivetable">
<table id="structureTable" class="data">
<thead>
@@ -1,4 +1,4 @@
<a href="tbl_tracking.php{{ Url_getCommon({'table': table, 'db': db}) }}">
<a href="tbl_tracking.php{{ get_common({'table': table, 'db': db}) }}">
{% if is_tracked -%}
{{ Util_getImage('eye', 'Tracking is active.'|trans) }}
{%- else -%}
@@ -5,7 +5,7 @@
<form method="post" action="db_tracking.php" name="trackedForm"
id="trackedForm" class="ajax">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<table id="versions" class="data">
<thead>
<tr>
@@ -90,7 +90,7 @@
<h3>{% trans 'Untracked tables' %}</h3>
<form method="post" action="db_tracking.php" name="untrackedForm"
id="untrackedForm" class="ajax">
{{ Url_getHiddenInputs(db) }}
{{ get_hidden_inputs(db) }}
<table id="noversions" class="data">
<thead>
<tr>
@@ -1,9 +1,9 @@
{% if export_type == 'server' %}
{{ Url_getHiddenInputs('', '', 1) }}
{{ get_hidden_inputs('', '', 1) }}
{% elseif export_type == 'database' %}
{{ Url_getHiddenInputs(db, '', 1) }}
{{ get_hidden_inputs(db, '', 1) }}
{% else %}
{{ Url_getHiddenInputs(db, table, 1) }}
{{ get_hidden_inputs(db, table, 1) }}
{% endif %}
{# Just to keep this value for possible next display of this form after saving on server #}
@@ -25,11 +25,11 @@
<input type="hidden" name="{{ id_key }}" value="{{ upload_id }}" />
{% if import_type == 'server' %}
{{ Url_getHiddenInputs('', '', 1) }}
{{ get_hidden_inputs('', '', 1) }}
{% elseif import_type == 'database' %}
{{ Url_getHiddenInputs(db, '', 1) }}
{{ get_hidden_inputs(db, '', 1) }}
{% else %}
{{ Url_getHiddenInputs(db, table, 1) }}
{{ get_hidden_inputs(db, table, 1) }}
{% endif %}
<input type="hidden" name="import_type" value="{{ import_type }}" />
@@ -6,7 +6,7 @@ $( function() {
{% if handler != 'PhpMyAdmin\\Plugins\\Import\\Upload\\UploadNoplugin' %}
{# Some variable for javascript #}
{% set ajax_url = 'import_status.php?id=' ~ upload_id ~ '&' ~ Url_getCommonRaw({
{% set ajax_url = 'import_status.php?id=' ~ upload_id ~ '&' ~ get_common_raw({
'import_status': 1
}) %}
{% set promot_str = Sanitize_jsFormat(
@@ -21,7 +21,7 @@ $( function() {
'The file is being processed, please be patient.'|trans,
false
) %}
{% set import_url = Url_getCommonRaw({'import_status': 1}) %}
{% set import_url = get_common_raw({'import_status': 1}) %}
{% set upload_html %}
{% spaceless %}
@@ -4,7 +4,7 @@
name="resultsForm"
id="resultsForm_{{ unique_id }}"
class="ajax">
{{ Url_getHiddenInputs(db, table, 1) }}
{{ get_hidden_inputs(db, table, 1) }}
<input type="hidden" name="goto" value="sql.php" />
{% endif %}
@@ -1,5 +1,5 @@
<form method="post" action="sql.php" name="displayOptionsForm" class="ajax print_ignore">
{{ Url_getHiddenInputs({
{{ get_hidden_inputs({
'db': db,
'table': table,
'sql_query': sql_query,
@@ -1,6 +1,6 @@
<td>
<form action="sql.php" method="post">
{{ Url_getHiddenInputs(db, table) }}
{{ get_hidden_inputs(db, table) }}
<input type="hidden" name="sql_query" value="{{ html_sql_query|raw }}" />
<input type="hidden" name="pos" value="0" />
<input type="hidden" name="is_browse_distinct" value="{{ is_browse_distinct }}" />
@@ -1,6 +1,6 @@
<td>
<form action="sql.php" method="post"{{ onsubmit|raw }}>
{{ Url_getHiddenInputs(db, table) }}
{{ get_hidden_inputs(db, table) }}
<input type="hidden" name="sql_query" value="{{ sql_query|raw }}" />
<input type="hidden" name="pos" value="{{ pos }}" />
<input type="hidden" name="is_browse_distinct" value="{{ is_browse_distinct }}" />
@@ -1,5 +1,5 @@
<div class="container">
<a href="{{ Url_link('https://www.phpmyadmin.net/') }}" target="_blank" rel="noopener noreferrer" class="logo">
<a href="{{ 'https://www.phpmyadmin.net/'|link }}" target="_blank" rel="noopener noreferrer" class="logo">
<img src="{{ theme.getImgPath('logo_right.png', 'pma_logo.png') }}" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />
</a>
<h1>{{ 'Welcome to %s'|trans|format('<bdo dir="ltr" lang="en">phpMyAdmin</bdo>')|raw }}</h1>
@@ -1,5 +1,5 @@
<form method="POST" class="disableAjax">
{{ Url_getHiddenInputs() }}
{{ get_hidden_inputs() }}
{{ form|raw }}
{% if show_submit %}
<input type="submit" value="{% trans "Verify" %}" />
@@ -1,4 +1,4 @@
{{ Url_getHiddenInputs() }}
{{ get_hidden_inputs() }}
{% if image is defined %}
<p>
{% trans "Please scan following QR code into the two-factor authentication app on your device and enter authentication code it generates." %}
@@ -33,7 +33,7 @@
<p>{% trans "You have enabled two factor authentication." %}</p>
<p>{{ backend_description }}</p>
<form method="POST" action="prefs_twofactor.php">
{{ Url_getHiddenInputs() }}
{{ get_hidden_inputs() }}
<input type="submit" name="2fa_remove" value="{% trans "Disable two-factor authentication" %}" />
</form>
</div>
@@ -43,7 +43,7 @@
<h2>{% trans "Configure two-factor authentication" %}</h2>
<div class="group-cnt">
<form method="POST" action="prefs_twofactor.php">
{{ Url_getHiddenInputs() }}
{{ get_hidden_inputs() }}
{% for backend in backends %}
<label>
<input type="radio" name="2fa_configure" {% if backend["id"] == "" %}checked="checked"{% endif %} value="{{ backend["id"] }}"/>
@@ -2,7 +2,7 @@
<h2>{% trans "Configure two-factor authentication" %}</h2>
<div class="group-cnt">
<form method="POST" action="prefs_twofactor.php">
{{ Url_getHiddenInputs() }}
{{ get_hidden_inputs() }}
<input type="hidden" name="2fa_configure" value="{{ configure }}" />
{{ form|raw }}
<input type="submit" value="{% trans "Enable two-factor authentication" %}" />
Oops, something went wrong.

0 comments on commit b65ede4

Please sign in to comment.