Permalink
Browse files

Refactor Util Twig extensions

Signed-off-by: Leonardo Strozzi <laps15@inf.ufpr.br>
  • Loading branch information...
laps15 committed Aug 2, 2018
1 parent b65ede4 commit 1037b1d626a338d9de7f34b8503166a664484278
Showing with 254 additions and 247 deletions.
  1. +51 −44 libraries/classes/Twig/UtilExtension.php
  2. +3 −3 templates/columns_definitions/column_definitions_form.twig
  3. +1 −1 templates/columns_definitions/column_type.twig
  4. +1 −1 templates/columns_definitions/move_column.twig
  5. +7 −7 templates/columns_definitions/table_fields_definitions.twig
  6. +5 −5 templates/database/central_columns/main.twig
  7. +2 −2 templates/database/create_table.twig
  8. +1 −1 templates/database/designer/database_tables.twig
  9. +1 −1 templates/database/designer/main.twig
  10. +1 −1 templates/database/designer/page_save_as.twig
  11. +1 −1 templates/database/multi_table_query/form.twig
  12. +1 −1 templates/database/search/main.twig
  13. +4 −4 templates/database/structure/body_for_table_summary.twig
  14. +2 −2 templates/database/structure/print_view_data_dictionary_link.twig
  15. +3 −3 templates/database/structure/structure_table_row.twig
  16. +12 −12 templates/database/structure/table_header.twig
  17. +2 −2 templates/database/structure/tracking_icon.twig
  18. +7 −7 templates/database/tracking/tables.twig
  19. +1 −1 templates/display/export/option_header.twig
  20. +1 −1 templates/display/export/options_output_format.twig
  21. +6 −6 templates/display/import/import.twig
  22. +1 −1 templates/display/import/javascript.twig
  23. +1 −1 templates/display/results/additional_fields.twig
  24. +5 −5 templates/display/results/options_block.twig
  25. +1 −1 templates/list/item.twig
  26. +1 −1 templates/prefs_twofactor.twig
  27. +2 −2 templates/preview_sql.twig
  28. +1 −1 templates/secondary_tabs.twig
  29. +1 −1 templates/server/binlog/log_row.twig
  30. +2 −2 templates/server/binlog/log_selector.twig
  31. +1 −1 templates/server/databases/databases_footer.twig
  32. +8 −8 templates/server/databases/index.twig
  33. +2 −2 templates/server/databases/table_row.twig
  34. +2 −2 templates/server/engines/show_engine.twig
  35. +1 −1 templates/server/privileges/add_user_fieldset.twig
  36. +1 −1 templates/server/privileges/choose_user_group.twig
  37. +1 −1 templates/server/privileges/delete_user_fieldset.twig
  38. +3 −3 templates/server/sub_page_header.twig
  39. +3 −3 templates/server/variables/link_template.twig
  40. +2 −2 templates/server/variables/variable_row.twig
  41. +2 −2 templates/table/chart/tbl_chart.twig
  42. +2 −2 templates/table/gis_visualization/gis_visualization.twig
  43. +4 −4 templates/table/index_form.twig
  44. +2 −2 templates/table/page_with_secondary_tabs.twig
  45. +9 −9 templates/table/relation/common_form.twig
  46. +4 −4 templates/table/relation/foreign_key_row.twig
  47. +2 −2 templates/table/search/geom_func.twig
  48. +3 −3 templates/table/search/input_box.twig
  49. +3 −3 templates/table/search/selection_form.twig
  50. +2 −2 templates/table/structure/action_row_in_structure_table.twig
  51. +7 −7 templates/table/structure/display_partitions.twig
  52. +46 −46 templates/table/structure/display_structure.twig
  53. +8 −8 templates/table/structure/display_table_stats.twig
  54. +4 −4 templates/table/tracking/main.twig
  55. +4 −4 templates/table/tracking/structure_snapshot_columns.twig
@@ -11,6 +11,7 @@
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use Twig\TwigFilter;
/**
* Class UtilExtension
@@ -28,164 +29,170 @@ public function getFunctions()
{
return [
new TwigFunction(
'Util_backquote',
'backquote',
'PhpMyAdmin\Util::backquote'
),
new TwigFunction(
'Util_getBrowseUploadFileBlock',
'get_browse_upload_file_block',
'PhpMyAdmin\Util::getBrowseUploadFileBlock',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_convertBitDefaultValue',
'PhpMyAdmin\Util::convertBitDefaultValue'
),
new TwigFunction(
'Util_escapeMysqlWildcards',
'PhpMyAdmin\Util::escapeMysqlWildcards'
),
new TwigFunction(
'Util_extractColumnSpec',
'extract_column_spec',
'PhpMyAdmin\Util::extractColumnSpec'
),
new TwigFunction(
'Util_formatByteDown',
'format_byte_down',
'PhpMyAdmin\Util::formatByteDown'
),
new TwigFunction(
'Util_formatNumber',
'format_number',
'PhpMyAdmin\Util::formatNumber'
),
new TwigFunction(
'Util_formatSql',
'format_sql',
'PhpMyAdmin\Util::formatSql',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getButtonOrImage',
'get_button_or_image',
'PhpMyAdmin\Util::getButtonOrImage',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getClassForType',
'get_class_for_type',
'PhpMyAdmin\Util::getClassForType',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getDivForSliderEffect',
'get_div_for_slider_effect',
'PhpMyAdmin\Util::getDivForSliderEffect',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getDocuLink',
'get_docu_link',
'PhpMyAdmin\Util::getDocuLink',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getListNavigator',
'get_list_navigator',
'PhpMyAdmin\Util::getListNavigator',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_showDocu',
'show_docu',
'PhpMyAdmin\Util::showDocu',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getDropdown',
'get_dropdown',
'PhpMyAdmin\Util::getDropdown',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getFKCheckbox',
'get_fk_checkbox',
'PhpMyAdmin\Util::getFKCheckbox',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getGISDatatypes',
'get_gis_datatypes',
'PhpMyAdmin\Util::getGISDatatypes'
),
new TwigFunction(
'Util_getGISFunctions',
'get_gis_functions',
'PhpMyAdmin\Util::getGISFunctions'
),
new TwigFunction(
'Util_getHtmlTab',
'get_html_tab',
'PhpMyAdmin\Util::getHtmlTab',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getIcon',
'get_icon',
'PhpMyAdmin\Util::getIcon',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getImage',
'get_image',
'PhpMyAdmin\Util::getImage',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getRadioFields',
'get_radio_fields',
'PhpMyAdmin\Util::getRadioFields',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getSelectUploadFileBlock',
'get_select_upload_file_block',
'PhpMyAdmin\Util::getSelectUploadFileBlock',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getScriptNameForOption',
'get_script_name_for_option',
'PhpMyAdmin\Util::getScriptNameForOption',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getStartAndNumberOfRowsPanel',
'get_start_and_number_of_rows_panel',
'PhpMyAdmin\Util::getStartAndNumberOfRowsPanel',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_getSupportedDatatypes',
'get_supported_datatypes',
'PhpMyAdmin\Util::getSupportedDatatypes',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_isForeignKeySupported',
'is_foreign_key_supported',
'PhpMyAdmin\Util::isForeignKeySupported'
),
new TwigFunction(
'Util_linkOrButton',
'link_or_button',
'PhpMyAdmin\Util::linkOrButton',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_localisedDate',
'localised_date',
'PhpMyAdmin\Util::localisedDate'
),
new TwigFunction(
'Util_showHint',
'show_hint',
'PhpMyAdmin\Util::showHint',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_showDocu',
'PhpMyAdmin\Util::showDocu',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_showIcons',
'show_icons',
'PhpMyAdmin\Util::showIcons'
),
new TwigFunction(
'Util_showMySQLDocu',
'show_mysql_docu',
'PhpMyAdmin\Util::showMySQLDocu',
['is_safe' => ['html']]
),
new TwigFunction(
'Util_sortableTableHeader',
'sortable_table_header',
'PhpMyAdmin\Util::sortableTableHeader',
['is_safe' => ['html']]
),
];
}
/**
* Returns a list of filters to add to the existing list.
*
* @return TwigFilter[]
*/
public function getFilters()
{
return [
new TwigFilter(
'convert_bit_default_value',
'PhpMyAdmin\Util::convertBitDefaultValue'
),
new TwigFilter(
'escape_mysql_wildcards',
'PhpMyAdmin\Util::convertBitDefaultValue'
),
];
}
}
@@ -75,12 +75,12 @@
<td width="25">&nbsp;</td>
<th>
{% trans 'Storage Engine:' %}
{{ Util_showMySQLDocu('Storage_engines') }}
{{ show_mysql_docu('Storage_engines') }}
</th>
<td width="25">&nbsp;</td>
<th>
{% trans 'Connection:' %}
{{ Util_showMySQLDocu('federated-create-connection') }}
{{ show_mysql_docu('federated-create-connection') }}
</th>
</tr>
<tr>
@@ -126,7 +126,7 @@
<tr class="vtop">
<th colspan="5">
{% trans 'PARTITION definition:' %}
{{ Util_showMySQLDocu('Partitioning') }}
{{ show_mysql_docu('Partitioning') }}
</th>
</tr>
<tr>
@@ -4,5 +4,5 @@
{%- if column_meta['column_status'] is defined and not column_meta['column_status']['isEditable'] -%}
disabled="disabled"
{%- endif %}>
{{ Util_getSupportedDatatypes(true, type_upper) }}
{{ get_supported_datatypes(true, type_upper) }}
</select>
@@ -9,7 +9,7 @@
{% for mi in 0..move_columns|length - 1 %}
<option value="{{ move_columns[mi].name }}"
{{- current_index == mi or current_index == mi + 1 ? ' disabled="disabled"' }}>
{{ 'after %s'|trans|format(Util_backquote(move_columns[mi].name|e)) }}
{{ 'after %s'|trans|format(backquote(move_columns[mi].name|e)) }}
</option>
{% endfor %}
</select>
@@ -2,23 +2,23 @@
<table id="table_columns" class="noclick">
<caption class="tblHeaders">
{% trans 'Structure' %}
{{ Util_showMySQLDocu('CREATE_TABLE') }}
{{ show_mysql_docu('CREATE_TABLE') }}
</caption>
<tr>
<th>
{% trans 'Name' %}
</th>
<th>
{% trans 'Type' %}
{{ Util_showMySQLDocu('data-types') }}
{{ show_mysql_docu('data-types') }}
</th>
<th>
{% trans 'Length/Values' %}
{{ Util_showHint('If column type is "enum" or "set", please enter the values using this format: \'a\',\'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) }}
{{ show_hint('If column type is "enum" or "set", please enter the values using this format: \'a\',\'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>
{% trans 'Default' %}
{{ Util_showHint('For default values, please enter just a single value, without backslash escaping or quotes, using this format: a'|trans) }}
{{ show_hint('For default values, please enter just a single value, without backslash escaping or quotes, using this format: a'|trans) }}
</th>
<th>
{% trans 'Collation' %}
@@ -34,7 +34,7 @@
{% if change_column is defined and change_column is not empty %}
<th>
{% trans 'Adjust privileges' %}
{{ Util_showDocu('faq', 'faq6-39') }}
{{ show_docu('faq', 'faq6-39') }}
</th>
{% endif %}
@@ -80,7 +80,7 @@
</th>
<th>
{% trans 'Browser display transformation options' %}
{{ 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) }}
{{ show_hint('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{{ get_common() }}#input_transformation"
@@ -91,7 +91,7 @@
</th>
<th>
{% trans 'Input transformation options' %}
{{ 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) }}
{{ show_hint('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>
{% endif %}
</tr>
@@ -189,7 +189,7 @@
<tr>
<td class="navigation_separator largescreenonly"></td>
<td class="central_columns_navigation">
{{ Util_getIcon('centralColumns_add', 'Add column' | trans)|raw }}
{{ get_icon('centralColumns_add', 'Add column' | trans)|raw }}
<form id="add_column" action="db_central_columns.php" method="post">
{{ get_hidden_inputs(db) | raw }}
<input type="hidden" name="add_column" value="add">
@@ -276,10 +276,10 @@
value="{{ row['col_name'] | raw }}" id="{{ 'checkbox_row_' ~ row_num }}"/>
</td>
<td id="{{ 'edit_' ~ row_num }}" class="edit center">
<a href="#"> {{ Util_getIcon('b_edit', 'Edit' | trans) | raw }}</a>
<a href="#"> {{ get_icon('b_edit', 'Edit' | trans) | raw }}</a>
</td>
<td class="del_row" data-rownum = "{{ row_num }}">
<a hrf="#">{{ Util_getIcon('b_drop', 'Delete' | trans) }}</a>
<a hrf="#">{{ get_icon('b_drop', 'Delete' | trans) }}</a>
<input type="submit" data-rownum = "{{ row_num }}" class="edit_cancel_form" value="Cancel">
</td>
<td id="{{ 'save_' ~ row_num }}" class="hide">
@@ -391,14 +391,14 @@
'text_dir' : text_dir,
'form_name' : 'tableslistcontainer',
} only %}
{{ Util_getButtonOrImage(
{{ get_button_or_image(
'edit_central_columns',
'mult_submit change_central_columns',
'Edit' | trans,
'b_edit',
'edit central columns'
) | raw }}
{{ Util_getButtonOrImage(
{{ get_button_or_image(
'delete_central_columns',
'mult_submit',
'Delete' | trans,
@@ -1,8 +1,8 @@
<form id="create_table_form_minimal" method="post" action="tbl_create.php" class="lock-page">
<fieldset>
<legend>
{% if Util_showIcons('ActionLinksMode') -%}
{{ Util_getImage('b_table_add') }}
{% if show_icons('ActionLinksMode') -%}
{{ get_image('b_table_add') }}
{%- endif %}
{% trans "Create table" %}
</legend>
@@ -64,7 +64,7 @@
table_names_small_url[i],
tab_column[t_n]['COLUMN_NAME'][j]|url_encode
] %}
{% if not Util_isForeignKeySupported(table_types[i]) %}
{% if not is_foreign_key_supported(table_types[i]) %}
{% set click_field_param = click_field_param|merge([tables_pk_or_unique_keys[tmp_column] is defined ? 1 : 0]) %}
{% else %}
{# if foreign keys are supported, it's not necessary that the
@@ -110,7 +110,7 @@ var designer_config = {{ designer_config | raw }};
{% trans 'Reload' %}
</span>
</a>
<a href="{{ Util_getDocuLink('faq', 'faq6-31') }}"
<a href="{{ get_docu_link('faq', 'faq6-31') }}"
target="documentation"
class="M_butt">
<img title="{% trans 'Help' %}"
@@ -14,7 +14,7 @@
</tr>
<tr>
<td>
{{ Util_getRadioFields(
{{ get_radio_fields(
'save_page',
{
'same': 'Save to selected page'|trans,
Oops, something went wrong.

0 comments on commit 1037b1d

Please sign in to comment.