From 04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 9 Jan 2020 10:55:03 +0100 Subject: phpmyadmin working --- .../database/structure/body_for_table_summary.twig | 95 +++++++++ .../database/structure/check_all_tables.twig | 40 ++++ .../database/structure/favorite_anchor.twig | 7 + .../templates/database/structure/index.twig | 24 +++ .../templates/database/structure/show_create.twig | 31 +++ .../database/structure/show_create_row.twig | 19 ++ .../database/structure/structure_table_row.twig | 223 +++++++++++++++++++++ .../templates/database/structure/table_header.twig | 78 +++++++ .../database/structure/tracking_icon.twig | 7 + 9 files changed, 524 insertions(+) create mode 100644 srcs/phpmyadmin/templates/database/structure/body_for_table_summary.twig create mode 100644 srcs/phpmyadmin/templates/database/structure/check_all_tables.twig create mode 100644 srcs/phpmyadmin/templates/database/structure/favorite_anchor.twig create mode 100644 srcs/phpmyadmin/templates/database/structure/index.twig create mode 100644 srcs/phpmyadmin/templates/database/structure/show_create.twig create mode 100644 srcs/phpmyadmin/templates/database/structure/show_create_row.twig create mode 100644 srcs/phpmyadmin/templates/database/structure/structure_table_row.twig create mode 100644 srcs/phpmyadmin/templates/database/structure/table_header.twig create mode 100644 srcs/phpmyadmin/templates/database/structure/tracking_icon.twig (limited to 'srcs/phpmyadmin/templates/database/structure') diff --git a/srcs/phpmyadmin/templates/database/structure/body_for_table_summary.twig b/srcs/phpmyadmin/templates/database/structure/body_for_table_summary.twig new file mode 100644 index 0000000..8dcebdf --- /dev/null +++ b/srcs/phpmyadmin/templates/database/structure/body_for_table_summary.twig @@ -0,0 +1,95 @@ + + + + + {% set num_tables_trans -%} + {% trans %}%s table{% plural num_tables %}%s tables{% endtrans %} + {%- endset %} + {{ num_tables_trans|format(format_number(num_tables, 0)) }} + + {% if server_slave_status %} + {% trans 'Replication' %} + {% endif %} + {% set sum_colspan = db_is_system_schema ? 4 : 7 %} + {% if num_favorite_tables == 0 %} + {% set sum_colspan = sum_colspan - 1 %} + {% endif %} + {% trans 'Sum' %} + {% set row_count_sum = format_number(sum_entries, 0) %} + {# If a table shows approximate rows count, display update-all-real-count anchor. #} + {% set row_sum_url = [] %} + {% if approx_rows is defined %} + {% set row_sum_url = { + 'ajax_request': true, + 'db': db, + 'real_row_count': 'true', + 'real_row_count_all': 'true' + } %} + {% endif %} + {% if approx_rows %} + {% set cell_text -%} + ~ + {{- row_count_sum -}} + + {%- endset %} + {% else %} + {% set cell_text = row_count_sum %} + {% endif %} + {{ cell_text }} + {% if not (properties_num_columns > 1) %} + {# MySQL <= 5.5.2 #} + {% set default_engine = dbi.fetchValue('SELECT @@storage_engine;') %} + {% if default_engine is empty %} + {# MySQL >= 5.5.3 #} + {% set default_engine = dbi.fetchValue('SELECT @@default_storage_engine;') %} + {% endif %} + + + {{ default_engine }} + + + + {% if database_collation is not empty %} + + {{ database_collation.name }} + + {% endif %} + + {% endif %} + + {% if is_show_stats %} + {% set sum = format_byte_down(sum_size, 3, 1) %} + {% set sum_formatted = sum[0] %} + {% set sum_unit = sum[1] %} + {{ sum_formatted }} {{ sum_unit }} + + {% set overhead = format_byte_down(overhead_size, 3, 1) %} + {% set overhead_formatted = overhead[0] %} + {% set overhead_unit = overhead[1] %} + {{ overhead_formatted }} {{ overhead_unit }} + {% endif %} + + {% if show_charset %} + {{ database_charset }} + {% endif %} + {% if show_comment %} + + {% endif %} + {% if show_creation %} + + {{ create_time_all }} + + {% endif %} + {% if show_last_update %} + + {{ update_time_all }} + + {% endif %} + {% if show_last_check %} + + {{ check_time_all }} + + {% endif %} + + diff --git a/srcs/phpmyadmin/templates/database/structure/check_all_tables.twig b/srcs/phpmyadmin/templates/database/structure/check_all_tables.twig new file mode 100644 index 0000000..7a4e7e9 --- /dev/null +++ b/srcs/phpmyadmin/templates/database/structure/check_all_tables.twig @@ -0,0 +1,40 @@ + diff --git a/srcs/phpmyadmin/templates/database/structure/favorite_anchor.twig b/srcs/phpmyadmin/templates/database/structure/favorite_anchor.twig new file mode 100644 index 0000000..91e002e --- /dev/null +++ b/srcs/phpmyadmin/templates/database/structure/favorite_anchor.twig @@ -0,0 +1,7 @@ + + {{ already_favorite ? titles['Favorite']|raw : titles['NoFavorite']|raw }} + diff --git a/srcs/phpmyadmin/templates/database/structure/index.twig b/srcs/phpmyadmin/templates/database/structure/index.twig new file mode 100644 index 0000000..1632839 --- /dev/null +++ b/srcs/phpmyadmin/templates/database/structure/index.twig @@ -0,0 +1,24 @@ +{% if has_tables %} +
+ {{ list_navigator_html|raw }} + + {{ table_list_html|raw }} + + {{ list_navigator_html|raw }} +
+
+ +{% else %} + {{ 'No tables found in database.'|trans|notice }} +{% endif %} + +{% if not is_system_schema %} + {{ create_table_html|raw }} +{% endif %} diff --git a/srcs/phpmyadmin/templates/database/structure/show_create.twig b/srcs/phpmyadmin/templates/database/structure/show_create.twig new file mode 100644 index 0000000..520e974 --- /dev/null +++ b/srcs/phpmyadmin/templates/database/structure/show_create.twig @@ -0,0 +1,31 @@ +
+

{% trans 'Showing create queries' %}

+ {% set views = [] %} + {% set tables = [] %} + {% for object in db_objects %} + {% if dbi.getTable(db, object).isView() %} + {% set views = views|merge([object]) %} + {% else %} + {% set tables = tables|merge([object]) %} + {% endif %} + {% endfor %} + {% if tables is not empty %} + {% include 'database/structure/show_create_row.twig' with { + 'db': db, + 'title': 'Tables'|trans, + 'raw_title': 'Table', + 'db_objects': tables, + 'dbi': dbi + } only %} + {% endif %} + + {% if views is not empty %} + {% include 'database/structure/show_create_row.twig' with { + 'db': db, + 'title': 'Views'|trans, + 'raw_title': 'View', + 'db_objects': views, + 'dbi': dbi + } only %} + {% endif %} +
diff --git a/srcs/phpmyadmin/templates/database/structure/show_create_row.twig b/srcs/phpmyadmin/templates/database/structure/show_create_row.twig new file mode 100644 index 0000000..db18cdd --- /dev/null +++ b/srcs/phpmyadmin/templates/database/structure/show_create_row.twig @@ -0,0 +1,19 @@ +
+ {{ title }} + + + + + + + + + {% for object in db_objects %} + + + + + {% endfor %} + +
{{ raw_title }}{{ 'Create %s'|trans|format(raw_title) }}
{{ object|mime_default_function }}{{ dbi.getTable(db, object).showCreate()|mime_default_function }}
+
diff --git a/srcs/phpmyadmin/templates/database/structure/structure_table_row.twig b/srcs/phpmyadmin/templates/database/structure/structure_table_row.twig new file mode 100644 index 0000000..b87ea48 --- /dev/null +++ b/srcs/phpmyadmin/templates/database/structure/structure_table_row.twig @@ -0,0 +1,223 @@ + + + + + + + {{ browse_table_label_truename }} + + {{ tracking_icon|raw }} + + {% if server_slave_status %} + + {{ ignored ? get_image('s_cancel', 'Not replicated'|trans) }} + {{ do ? get_image('s_success', 'Replicated'|trans) }} + + {% endif %} + + {# Favorite table anchor #} + {% if num_favorite_tables > 0 %} + + {# Check if current table is already in favorite list #} + {% set fav_params = { + 'db': db, + 'ajax_request': true, + 'favorite_table': current_table['TABLE_NAME'], + ((already_favorite ? 'remove' : 'add') ~ '_favorite'): true + } %} + {% include 'database/structure/favorite_anchor.twig' with { + 'table_name_hash': table_name_hash, + 'db_table_name_hash': db_table_name_hash, + 'fav_params': fav_params, + 'already_favorite': already_favorite, + 'titles': titles + } only %} + + {% endif %} + + + + {{ browse_table_title|raw }} + + + + + + {{ titles['Structure']|raw }} + + + + + {{ search_table_title|raw }} + + + + {% if not db_is_system_schema %} + + {{ titles['Insert']|raw }} + + {% if table_is_view %} + + {{ titles['Edit']|raw }} + + {% else %} + + + {{ empty_table_title|raw }} + + + {% endif %} + + + {{ titles['Drop']|raw }} + + + {% endif %} + + {% if current_table['TABLE_ROWS'] is defined + and (current_table['ENGINE'] != null or table_is_view) %} + {# Get the row count #} + {% set row_count = format_number(current_table['TABLE_ROWS'], 0) %} + + {# Content to be appended into 'tbl_rows' cell. + If row count is approximate, display it as an anchor to get real count. #} + + {% if approx_rows %} + + + ~{{ row_count }} + + + {% else %} + {{ row_count }} + {% endif %} + {{ show_superscript|raw }} + + + {% if not (properties_num_columns > 1) %} + + {% if current_table['ENGINE'] is not empty %} + {{ current_table['ENGINE'] }} + {% elseif table_is_view %} + {% trans 'View' %} + {% endif %} + + {% if collation|length > 0 %} + + {{ collation|raw }} + + {% endif %} + {% endif %} + + {% if is_show_stats %} + + + {{ formatted_size }} {{ unit }} + + + + {{ overhead|raw }} + + {% endif %} + + {% if not (show_charset > 1) %} + {% if charset|length > 0 %} + + {{ charset|raw }} + + {% endif %} + {% endif %} + + {% if show_comment %} + {% set comment = current_table['Comment'] %} + + {% if comment|length > limit_chars %} + + {{ comment|slice(0, limit_chars) }} + ... + + {% else %} + {{ comment }} + {% endif %} + + {% endif %} + + {% if show_creation %} + + {{ create_time }} + + {% endif %} + + {% if show_last_update %} + + {{ update_time }} + + {% endif %} + + {% if show_last_check %} + + {{ check_time }} + + {% endif %} + + {% elseif table_is_view %} + - + + {% trans 'View' %} + + --- + {% if is_show_stats %} + - + - + {% endif %} + {% if show_charset %} + + {% endif %} + {% if show_comment %} + + {% endif %} + {% if show_creation %} + - + {% endif %} + {% if show_last_update %} + - + {% endif %} + {% if show_last_check %} + - + {% endif %} + + {% else %} + + {% if db_is_system_schema %} + {% set action_colspan = 3 %} + {% else %} + {% set action_colspan = 6 %} + {% endif %} + {% if num_favorite_tables > 0 %} + {% set action_colspan = action_colspan + 1 %} + {% endif %} + + {% set colspan_for_structure = action_colspan + 3 %} + + {% trans 'in use' %} + + {% endif %} + diff --git a/srcs/phpmyadmin/templates/database/structure/table_header.twig b/srcs/phpmyadmin/templates/database/structure/table_header.twig new file mode 100644 index 0000000..e479f5e --- /dev/null +++ b/srcs/phpmyadmin/templates/database/structure/table_header.twig @@ -0,0 +1,78 @@ +
+{{ get_hidden_inputs(db) }} +
+ + + + + + {% if replication %} + + {% endif %} + + {% if db_is_system_schema %} + {% set action_colspan = 3 %} + {% else %} + {% set action_colspan = 6 %} + {% endif %} + {% if num_favorite_tables > 0 %} + {% set action_colspan = action_colspan + 1 %} + {% endif %} + + {# larger values are more interesting so default sort order is DESC #} + + {% if not (properties_num_columns > 1) %} + + + {% endif %} + + {% if is_show_stats %} + {# larger values are more interesting so default sort order is DESC #} + + {# larger values are more interesting so default sort order is DESC #} + + {% endif %} + + {% if show_charset %} + + {% endif %} + + {% if show_comment %} + + {% endif %} + + {% if show_creation %} + {# newer values are more interesting so default sort order is DESC #} + + {% endif %} + + {% if show_last_update %} + {# newer values are more interesting so default sort order is DESC #} + + {% endif %} + + {% if show_last_check %} + {# newer values are more interesting so default sort order is DESC #} + + {% endif %} + + + + {% for structure_table_row in structure_table_rows %} + {% include 'database/structure/structure_table_row.twig' with structure_table_row only %} + {% endfor %} + + {% if body_for_table_summary %} + {% include 'database/structure/body_for_table_summary.twig' with body_for_table_summary only %} + {% endif %} +
{{ sortable_table_header('Table'|trans, 'table') }}{% trans 'Replication' %} + {% trans 'Action' %} + + {{ sortable_table_header('Rows'|trans, 'records', 'DESC') }} + {{ show_hint('May be approximate. Click on the number to get the exact count. See [doc@faq3-11]FAQ 3.11[/doc].'|trans|sanitize) }} + {{ sortable_table_header('Type'|trans, 'type') }}{{ sortable_table_header('Collation'|trans, 'collation') }}{{ sortable_table_header('Size'|trans, 'size', 'DESC') }}{{ sortable_table_header('Overhead'|trans, 'overhead', 'DESC') }}{{ sortable_table_header('Charset'|trans, 'charset') }}{{ sortable_table_header('Comment'|trans, 'comment') }}{{ sortable_table_header('Creation'|trans, 'creation', 'DESC') }}{{ sortable_table_header('Last update'|trans, 'last_update', 'DESC') }}{{ sortable_table_header('Last check'|trans, 'last_check', 'DESC') }}
+
+{% if check_all_tables %} + {% include 'database/structure/check_all_tables.twig' with check_all_tables only %} +{% endif %} +
diff --git a/srcs/phpmyadmin/templates/database/structure/tracking_icon.twig b/srcs/phpmyadmin/templates/database/structure/tracking_icon.twig new file mode 100644 index 0000000..b09c9bb --- /dev/null +++ b/srcs/phpmyadmin/templates/database/structure/tracking_icon.twig @@ -0,0 +1,7 @@ + + {% if is_tracked -%} + {{ get_image('eye', 'Tracking is active.'|trans) }} + {%- else -%} + {{ get_image('eye_grey', 'Tracking is not active.'|trans) }} + {%- endif %} + -- cgit