diff options
Diffstat (limited to 'srcs/phpmyadmin/templates/columns_definitions')
20 files changed, 987 insertions, 0 deletions
diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_adjust_privileges.twig b/srcs/phpmyadmin/templates/columns_definitions/column_adjust_privileges.twig new file mode 100644 index 0000000..d0d1e91 --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_adjust_privileges.twig @@ -0,0 +1,16 @@ +{% if privs_available %} + <input name="field_adjust_privileges[{{ column_number }}]" + id="field_{{ column_number }}_{{ ci - ci_offset }}" + checked="checked" + type="checkbox" + value="NULL" + class="allow_null"> +{% else %} + <input name="field_adjust_privileges[{{ column_number }}]" + id="field_{{ column_number }}_{{ ci - ci_offset }}" + disabled + type="checkbox" + value="NULL" + class="allow_null" + title="{% trans "You don't have sufficient privileges to perform this operation; Please refer to the documentation for more details" %}"> +{% endif %} diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_attribute.twig b/srcs/phpmyadmin/templates/columns_definitions/column_attribute.twig new file mode 100644 index 0000000..905d093 --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_attribute.twig @@ -0,0 +1,21 @@ +{% if submit_attribute is defined and submit_attribute != false %} + {% set attribute = submit_attribute %} +{% elseif column_meta['Extra'] is defined + and column_meta['Extra'] == 'on update CURRENT_TIMESTAMP' %} + {% set attribute = 'on update CURRENT_TIMESTAMP' %} +{% elseif extracted_columnspec['attribute'] is defined %} + {% set attribute = extracted_columnspec['attribute'] %} +{% else %} + {% set attribute = '' %} +{% endif %} +{% set attribute = attribute|upper %} +<select name="field_attribute[{{ column_number }}]" + id="field_{{ column_number }}_{{ ci - ci_offset }}"> + {% set cnt_attribute_types = attribute_types|length - 1 %} + {% for i in 0..cnt_attribute_types %} + <option value="{{ attribute_types[i] }}" + {{- attribute == attribute_types[i]|upper ? ' selected="selected"' }}> + {{ attribute_types[i] }} + </option> + {% endfor %} +</select> diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_attributes.twig b/srcs/phpmyadmin/templates/columns_definitions/column_attributes.twig new file mode 100644 index 0000000..89eef86 --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_attributes.twig @@ -0,0 +1,246 @@ +{# Cell index: If certain fields get left out, the counter shouldn't change. #} +{% set ci = 0 %} + +{# Every time a cell shall be left out the STRG-jumping feature, $ci_offset has + to be incremented ($ci_offset++) #} +{% set ci_offset = -1 %} + +<td class="center"> + {# column name #} + {% include 'columns_definitions/column_name.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta, + 'cfg_relation': cfg_relation, + 'max_rows': max_rows + } only %} + {% set ci = ci + 1 %} +</td> +<td class="center"> + {# column type #} + {% include 'columns_definitions/column_type.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta, + 'type_upper': type_upper + } only %} + {% set ci = ci + 1 %} +</td> +<td class="center"> + {# column length #} + {% include 'columns_definitions/column_length.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'length_values_input_size': length_values_input_size, + 'length_to_display': length + } only %} + {% set ci = ci + 1 %} +</td> +<td class="center"> + {# column default #} + {% include 'columns_definitions/column_default.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta, + 'type_upper': type_upper, + 'default_value': default_value, + 'char_editing': char_editing + } only %} + {% set ci = ci + 1 %} +</td> +<td class="center"> + {# column collation #} + <select lang="en" dir="ltr" name="field_collation[{{ column_number }}]" id="field_{{ column_number }}_{{ ci - ci_offset }}"> + <option value=""></option> + {% for charset in charsets %} + <optgroup label="{{ charset.name }}" title="{{ charset.description }}"> + {% for collation in charset.collations %} + <option value="{{ collation.name }}" title="{{ collation.description }}" + {{- collation.name == column_meta['Collation'] ? ' selected' }}> + {{- collation.name -}} + </option> + {% endfor %} + </optgroup> + {% endfor %} + </select> + {% set ci = ci + 1 %} +</td> +<td class="center"> + {# column attribute #} + {% include 'columns_definitions/column_attribute.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta, + 'extracted_columnspec': extracted_columnspec, + 'submit_attribute': submit_attribute, + 'attribute_types': attribute_types + } only %} + {% set ci = ci + 1 %} +</td> +<td class="center"> + {# column NULL #} + {% include 'columns_definitions/column_null.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta + } only %} + {% set ci = ci + 1 %} +</td> +{% if change_column is defined and change_column is not empty %} + {# column Adjust privileges, Only for 'Edit' Column(s) #} + <td class="center"> + {% include 'columns_definitions/column_adjust_privileges.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'privs_available': privs_available + } only %} + {% set ci = ci + 1 %} + </td> +{% endif %} +{% if not is_backup %} + {# column indexes, See my other comment about this 'if'. #} + <td class="center"> + {% include 'columns_definitions/column_indexes.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta + } only %} + {% set ci = ci + 1 %} + </td> +{% endif %} +<td class="center"> + {# column auto_increment #} + {% include 'columns_definitions/column_auto_increment.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta + } only %} + {% set ci = ci + 1 %} +</td> +<td class="center"> + {# column comments #} + {% include 'columns_definitions/column_comment.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'max_length': max_length, + 'value': column_meta['Field'] is defined + and comments_map is iterable + and comments_map[column_meta['Field']] is defined + ? comments_map[column_meta['Field']]|e + } only %} + {% set ci = ci + 1 %} +</td> + {# column virtuality #} +{% if is_virtual_columns_supported %} + <td class="center"> + {% include 'columns_definitions/column_virtuality.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta, + 'char_editing': char_editing, + 'expression': column_meta['Expression'] is defined ? column_meta['Expression'], + 'options': options + } only %} + {% set ci = ci + 1 %} + </td> +{% endif %} +{# move column #} +{% if fields_meta is defined %} + {% set current_index = 0 %} + {% set cols = move_columns|length - 1 %} + {% set break = false %} + {% for mi in 0..cols %} + {% if move_columns[mi].name == column_meta['Field'] and not break %} + {% set current_index = mi %} + {% set break = true %} + {% endif %} + {% endfor %} + + <td class="center"> + {% include 'columns_definitions/move_column.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta, + 'move_columns': move_columns, + 'current_index': current_index + } only %} + {% set ci = ci + 1 %} + </td> +{% endif %} + +{% if cfg_relation['mimework'] and browse_mime and cfg_relation['commwork'] %} + <td class="center"> + {# Column Mime-type #} + {% include 'columns_definitions/mime_type.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta, + 'available_mime': available_mime, + 'mime_map': mime_map + } only %} + {% set ci = ci + 1 %} + </td> + <td class="center"> + {# Column Browser transformation #} + {% include 'columns_definitions/transformation.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta, + 'available_mime': available_mime, + 'mime_map': mime_map, + 'type': 'transformation' + } only %} + {% set ci = ci + 1 %} + </td> + <td class="center"> + {# column Transformation options #} + {% include 'columns_definitions/transformation_option.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta, + 'mime_map': mime_map, + 'type_prefix': '' + } only %} + {% set ci = ci + 1 %} + </td> + <td class="center"> + {# Column Input transformation #} + {% include 'columns_definitions/transformation.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta, + 'available_mime': available_mime, + 'mime_map': mime_map, + 'type': 'input_transformation' + } only %} + {% set ci = ci + 1 %} + </td> + <td class="center"> + {# column Input transformation options #} + {% include 'columns_definitions/transformation_option.twig' with { + 'column_number': column_number, + 'ci': ci, + 'ci_offset': ci_offset, + 'column_meta': column_meta, + 'mime_map': mime_map, + 'type_prefix': 'input_' + } only %} + {% set ci = ci + 1 %} + </td> +{% endif %} diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_auto_increment.twig b/srcs/phpmyadmin/templates/columns_definitions/column_auto_increment.twig new file mode 100644 index 0000000..46bfb42 --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_auto_increment.twig @@ -0,0 +1,7 @@ +<input name="field_extra[{{ column_number }}]" + id="field_{{ column_number }}_{{ ci - ci_offset }}" + {% if column_meta['Extra'] is defined and column_meta['Extra']|lower == 'auto_increment' -%} + checked="checked" + {%- endif %} + type="checkbox" + value="AUTO_INCREMENT"> diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_comment.twig b/srcs/phpmyadmin/templates/columns_definitions/column_comment.twig new file mode 100644 index 0000000..653441b --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_comment.twig @@ -0,0 +1,6 @@ +<textarea id="field_{{ column_number }}_{{ ci - ci_offset }}" + rows="1" + name="field_comments[{{ column_number }}]" + maxlength="{{ max_length }}"> + {{- value|raw -}} +</textarea> diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_default.twig b/srcs/phpmyadmin/templates/columns_definitions/column_default.twig new file mode 100644 index 0000000..dcb6644 --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_default.twig @@ -0,0 +1,35 @@ +{# here we put 'NONE' as the default value of drop-down; otherwise users would +have problems if they forget to enter the default value (example, for an INT) #} +{% set translation %}{% trans %}None{% context %}for default{% endtrans %}{% endset %} +{% set default_options = { + 'NONE': translation, + 'USER_DEFINED': 'As defined:'|trans, + 'NULL': 'NULL', + 'CURRENT_TIMESTAMP': 'CURRENT_TIMESTAMP' +} %} + +<select name="field_default_type[{{ column_number }}]" + id="field_{{ column_number }}_{{ ci - ci_offset }}" + class="default_type"> + {% for key, value in default_options %} + <option value="{{ key }}" + {%- if column_meta['DefaultType'] is defined + and column_meta['DefaultType'] == key %} + selected="selected" + {%- endif %}> + {{ value }} + </option> + {% endfor %} +</select> +{% if char_editing == 'textarea' %} + <textarea name="field_default_value[{{ column_number }}]" + cols="15" + class="textfield + default_value">{{ default_value }}</textarea> +{% else %} + <input type="text" + name="field_default_value[{{ column_number }}]" + size="12" + value="{{ default_value }}" + class="textfield default_value"> +{% endif %} diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_definitions_form.twig b/srcs/phpmyadmin/templates/columns_definitions/column_definitions_form.twig new file mode 100644 index 0000000..1fd4b64 --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_definitions_form.twig @@ -0,0 +1,155 @@ +<form method="post" action="{{ action }}" class=" + {{- action == 'tbl_create.php' ? 'create_table' : 'append_fields' -}} + _form ajax lock-page"> + {{ 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 #} + <input type="hidden" name="primary_indexes" value=" + {{- primary_indexes is not empty ? primary_indexes : '[]' }}"> + <input type="hidden" name="unique_indexes" value=" + {{- unique_indexes is not empty ? unique_indexes : '[]' }}"> + <input type="hidden" name="indexes" value=" + {{- indexes is not empty ? indexes : '[]' }}"> + <input type="hidden" name="fulltext_indexes" value=" + {{- fulltext_indexes is not empty ? fulltext_indexes : '[]' }}"> + <input type="hidden" name="spatial_indexes" value=" + {{- spatial_indexes is not empty ? spatial_indexes : '[]' }}"> + + {% if action == 'tbl_create.php' %} + <div id="table_name_col_no_outer"> + <table id="table_name_col_no" class="tdblock"> + <tr class="vmiddle floatleft"> + <td>{% trans 'Table name' %}: + <input type="text" + name="table" + size="40" + maxlength="64" + value="{{ table is defined ? table }}" + class="textfield" autofocus required> + </td> + <td> + {% trans 'Add' %} + <input type="number" + id="added_fields" + name="added_fields" + size="2" + value="1" + min="1" + onfocus="this.select()"> + {% trans 'column(s)' %} + <input class="btn btn-secondary" type="button" + name="submit_num_fields" + value="{% trans 'Go' %}"> + </td> + </tr> + </table> + </div> + {% endif %} + {% if content_cells is iterable %} + {% include 'columns_definitions/table_fields_definitions.twig' with { + 'is_backup': is_backup, + 'fields_meta': fields_meta, + 'mimework': mimework, + 'content_cells': content_cells, + 'change_column': change_column, + 'is_virtual_columns_supported': is_virtual_columns_supported, + 'browse_mime': browse_mime, + 'server_type': server_type, + 'max_rows': max_rows, + 'char_editing': char_editing, + 'attribute_types': attribute_types, + 'privs_available': privs_available, + 'max_length': max_length, + 'charsets': charsets + } only %} + {% endif %} + {% if action == 'tbl_create.php' %} + <div class="responsivetable"> + <table> + <tr class="vtop"> + <th>{% trans 'Table comments:' %}</th> + <td width="25"> </td> + <th>{% trans 'Collation:' %}</th> + <td width="25"> </td> + <th> + {% trans 'Storage Engine:' %} + {{ show_mysql_docu('Storage_engines') }} + </th> + <td width="25"> </td> + <th> + {% trans 'Connection:' %} + {{ show_mysql_docu('federated-create-connection') }} + </th> + </tr> + <tr> + <td> + <input type="text" + name="comment" + size="40" + maxlength="60" + value="{{ comment is defined ? comment }}" + class="textfield"> + </td> + <td width="25"> </td> + <td> + <select lang="en" dir="ltr" name="tbl_collation"> + <option value=""></option> + {% for charset in charsets %} + <optgroup label="{{ charset.name }}" title="{{ charset.description }}"> + {% for collation in charset.collations %} + <option value="{{ collation.name }}" title="{{ collation.description }}" + {{- collation.name == tbl_collation ? ' selected' }}> + {{- collation.name -}} + </option> + {% endfor %} + </optgroup> + {% endfor %} + </select> + </td> + <td width="25"> </td> + <td> + {{ get_html_select( + 'tbl_storage_engine', + null, + tbl_storage_engine + ) }} + </td> + <td width="25"> </td> + <td> + <input type="text" + name="connection" + size="40" + value="{{ connection is defined ? connection }}" + placeholder="scheme://user_name[:password]@host_name[:port_num]/db_name/tbl_name" + class="textfield" + required="required"> + </td> + </tr> + {% if have_partitioning %} + <tr class="vtop"> + <th colspan="5"> + {% trans 'PARTITION definition:' %} + {{ show_mysql_docu('Partitioning') }} + </th> + </tr> + <tr> + <td colspan="5"> + {% include 'columns_definitions/partitions.twig' with { + 'partition_details': partition_details + } only %} + </td> + </tr> + {% endif %} + </table> + </div> + {% endif %} + <fieldset class="tblFooters"> + <input class="btn btn-secondary preview_sql" type="button" + value="{% trans 'Preview SQL' %}"> + <input class="btn btn-primary" type="submit" + name="do_save_data" + value="{% trans 'Save' %}"> + </fieldset> + <div id="properties_message"></div> +</form> diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_extra.twig b/srcs/phpmyadmin/templates/columns_definitions/column_extra.twig new file mode 100644 index 0000000..7f61f5c --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_extra.twig @@ -0,0 +1,7 @@ +<input name="col_extra[{{ column_number }}]" + id="field_{{ column_number }}_{{ ci - ci_offset }}" + {% if column_meta['Extra'] is not empty and column_meta['Extra'] == 'auto_increment' -%} + checked="checked" + {%- endif %} + type="checkbox" + value="auto_increment"> diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_indexes.twig b/srcs/phpmyadmin/templates/columns_definitions/column_indexes.twig new file mode 100644 index 0000000..3980229 --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_indexes.twig @@ -0,0 +1,24 @@ +<select name="field_key[{{ column_number }}]" + id="field_{{ column_number }}_{{ ci - ci_offset }}" data-index=""> + <option value="none_{{ column_number }}">---</option> + <option value="primary_{{ column_number }}" title="{% trans "Primary" %}" + {{- column_meta['Key'] is defined and column_meta['Key'] == 'PRI' ? ' selected="selected"' }}> + PRIMARY + </option> + <option value="unique_{{ column_number }}" title="{% trans "Unique" %}" + {{- column_meta['Key'] is defined and column_meta['Key'] == 'UNI' ? ' selected="selected"' }}> + UNIQUE + </option> + <option value="index_{{ column_number }}" title="{% trans "Index" %}" + {{- column_meta['Key'] is defined and column_meta['Key'] == 'MUL' ? ' selected="selected"' }}> + INDEX + </option> + <option value="fulltext_{{ column_number }}" title="{% trans "Fulltext" %}" + {{- column_meta['Key'] is defined and column_meta['Key'] == 'FULLTEXT' ? ' selected="selected"' }}> + FULLTEXT + </option> + <option value="spatial_{{ column_number }}" title="{% trans "Spatial" %}" + {{- column_meta['Key'] is defined and column_meta['Key'] == 'SPATIAL' ? ' selected="selected"' }}> + SPATIAL + </option> +</select> diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_length.twig b/srcs/phpmyadmin/templates/columns_definitions/column_length.twig new file mode 100644 index 0000000..ef7e5f0 --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_length.twig @@ -0,0 +1,11 @@ +<input id="field_{{ column_number }}_{{ ci - ci_offset }}" + type="text" + name="field_length[{{ column_number }}]" + size="{{ length_values_input_size }}" + value="{{ length_to_display }}" + class="textfield"> +<p class="enum_notice" id="enum_notice_{{ column_number }}_{{ ci - ci_offset }}"> + <a href="#" class="open_enum_editor"> + {% trans 'Edit ENUM/SET values' %} + </a> +</p> diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_name.twig b/srcs/phpmyadmin/templates/columns_definitions/column_name.twig new file mode 100644 index 0000000..a0a31ad --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_name.twig @@ -0,0 +1,42 @@ +{% set title = '' %} +{% if column_meta['column_status'] is defined %} + {% if column_meta['column_status']['isReferenced'] %} + {% set title = title ~ 'Referenced by %s.'|trans|format( + column_meta['column_status']['references']|join(',') + ) %} + {% endif %} + {% if column_meta['column_status']['isForeignKey'] %} + {% if title is not empty %} + {% set title = title ~ '\n'|raw %} + {% endif %} + {% set title = title ~ 'Is a foreign key.'|trans %} + {% endif %} +{% endif %} +{% if title is empty %} + {% set title = 'Column'|trans %} +{% endif %} + +<input id="field_{{ column_number }}_{{ ci - ci_offset }}" + {% if column_meta['column_status'] is defined + and not column_meta['column_status']['isEditable'] %} + disabled="disabled" + {% endif %} + type="text" + name="field_name[{{ column_number }}]" + maxlength="64" + class="textfield" + title="{{ title }}" + size="10" + value="{{ column_meta['Field'] is defined ? column_meta['Field'] }}"> + +{% if cfg_relation['centralcolumnswork'] + and not (column_meta['column_status'] is defined + and not column_meta['column_status']['isEditable']) %} + <p class="column_name" id="central_columns_{{ column_number }}_{{ ci - ci_offset }}"> + <a data-maxrows="{{ max_rows }}" + href="#" + class="central_columns_dialog"> + {% trans 'Pick from Central Columns' %} + </a> + </p> +{% endif %} diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_null.twig b/srcs/phpmyadmin/templates/columns_definitions/column_null.twig new file mode 100644 index 0000000..5afd649 --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_null.twig @@ -0,0 +1,8 @@ +<input name="field_null[{{ column_number }}]" + id="field_{{ column_number }}_{{ ci - ci_offset }}" + {% if column_meta['Null'] is not empty and column_meta['Null'] != 'NO' and column_meta['Null'] != 'NOT NULL' -%} + checked="checked" + {%- endif %} + type="checkbox" + value="YES" + class="allow_null"> diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_type.twig b/srcs/phpmyadmin/templates/columns_definitions/column_type.twig new file mode 100644 index 0000000..e74eb0e --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_type.twig @@ -0,0 +1,8 @@ +<select class="column_type" + name="field_type[{{ column_number }}]" + id="field_{{ column_number }}_{{ ci - ci_offset }}" + {%- if column_meta['column_status'] is defined and not column_meta['column_status']['isEditable'] -%} + disabled="disabled" + {%- endif %}> + {{ get_supported_datatypes(true, type_upper) }} +</select> diff --git a/srcs/phpmyadmin/templates/columns_definitions/column_virtuality.twig b/srcs/phpmyadmin/templates/columns_definitions/column_virtuality.twig new file mode 100644 index 0000000..96f020e --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/column_virtuality.twig @@ -0,0 +1,32 @@ +<select name="field_virtuality[{{ column_number }}]" + id="field_{{ column_number }}_{{ ci - ci_offset }}" + class="virtuality"> + {% for key, value in options %} + <option value="{{ key }}" + {% set key_length = key|length %} + {%- if column_meta['Extra'] is defined + and key != '' + and column_meta['Extra']|slice(0,key_length) is same as (key) %} + selected="selected" + {%- endif %}> + {{ value }} + </option> + {% endfor %} +</select> + +{% if char_editing == 'textarea' %} + {% apply spaceless %} + <textarea name="field_expression[{{ column_number }}]" + cols="15" + class="textfield expression"> + {{ expression }} + </textarea> + {% endapply %} +{% else %} + <input type="text" + name="field_expression[{{ column_number }}]" + size="12" + value="{{ expression }}" + placeholder="{% trans 'Expression' %}" + class="textfield expression"> +{% endif %} diff --git a/srcs/phpmyadmin/templates/columns_definitions/mime_type.twig b/srcs/phpmyadmin/templates/columns_definitions/mime_type.twig new file mode 100644 index 0000000..ef395b6 --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/mime_type.twig @@ -0,0 +1,17 @@ +<select id="field_{{ column_number }}_{{ ci - ci_offset }}" + size="1" + name="field_mimetype[{{ column_number }}]"> + <option value=""> </option> + {% if available_mime['mimetype'] is defined + and available_mime['mimetype'] is iterable %} + {% for mimetype in available_mime['mimetype'] %} + {% set checked = column_meta['Field'] is defined + and mime_map[column_meta['Field']]['mimetype'] is defined + and mime_map[column_meta['Field']]['mimetype'] == mimetype|replace({'/': '_'}) + ? ' selected' %} + <option value="{{ mimetype|replace({'/': '_'}) }}"{{ checked }}> + {{ mimetype|lower }} + </option> + {% endfor %} + {% endif %} +</select> diff --git a/srcs/phpmyadmin/templates/columns_definitions/move_column.twig b/srcs/phpmyadmin/templates/columns_definitions/move_column.twig new file mode 100644 index 0000000..7c0b3f4 --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/move_column.twig @@ -0,0 +1,15 @@ +<select id="field_{{ column_number }}_{{ ci - ci_offset }}" + name="field_move_to[{{ column_number }}]" + size="1" + width="5em"> + <option value="" selected="selected"> </option> + <option value="-first"{{ current_index == 0 ? ' disabled="disabled"' }}> + {% trans 'first' %} + </option> + {% 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(backquote(move_columns[mi].name|e)) }} + </option> + {% endfor %} +</select> diff --git a/srcs/phpmyadmin/templates/columns_definitions/partitions.twig b/srcs/phpmyadmin/templates/columns_definitions/partitions.twig new file mode 100644 index 0000000..b8c88af --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/partitions.twig @@ -0,0 +1,180 @@ +{% set partition_options = [ + '', + 'HASH', + 'LINEAR HASH', + 'KEY', + 'LINEAR KEY', + 'RANGE', + 'RANGE COLUMNS', + 'LIST', + 'LIST COLUMNS' +] %} +{% set sub_partition_options = ['', 'HASH', 'LINEAR HASH', 'KEY', 'LINEAR KEY'] %} +{% set value_type_options = ['', 'LESS THAN', 'LESS THAN MAXVALUE', 'IN'] %} + +<table id="partition_table"> + <tr class="vmiddle"> + <td><label for="partition_by">{% trans 'Partition by:' %}</label></td> + <td> + <select name="partition_by" id="partition_by"> + {% for option in partition_options %} + <option value="{{ option }}" + {%- if partition_details['partition_by'] == option %} + selected="selected" + {%- endif %}> + {{ option }} + </option> + {% endfor %} + </select> + </td> + <td> + (<input name="partition_expr" type="text" + placeholder="{% trans 'Expression or column list' %}" + value="{{ partition_details['partition_expr'] }}">) + </td> + </tr> + <tr class="vmiddle"> + <td><label for="partition_count">{% trans 'Partitions:' %}</label></td> + <td colspan="2"> + <input name="partition_count" type="number" min="2" + value="{{ partition_details['partition_count'] }}"> + </td> + </tr> + {% if partition_details['can_have_subpartitions'] %} + <tr class="vmiddle"> + <td><label for="subpartition_by">{% trans 'Subpartition by:' %}</label></td> + <td> + <select name="subpartition_by" id="subpartition_by"> + {% for option in sub_partition_options %} + <option value="{{ option }}" + {%- if partition_details['subpartition_by'] == option %} + selected="selected" + {%- endif %}> + {{ option }} + </option> + {% endfor %} + </select> + </td> + <td> + (<input name="subpartition_expr" type="text" + placeholder="{% trans 'Expression or column list' %}" + value="{{ partition_details['subpartition_expr'] }}">) + </td> + </tr> + <tr class="vmiddle"> + <td><label for="subpartition_count">{% trans 'Subpartitions:' %}</label></td> + <td colspan="2"> + <input name="subpartition_count" type="number" min="2" + value="{{ partition_details['subpartition_count'] }}"> + </td> + </tr> + {% endif %} +</table> +{% if partition_details['partition_count'] > 1 %} + <table id="partition_definition_table"> + <thead><tr> + <th>{% trans 'Partition' %}</th> + {% if partition_details['value_enabled'] %} + <th>{% trans 'Values' %}</th> + {% endif %} + {% if partition_details['can_have_subpartitions'] + and partition_details['subpartition_count'] > 1 %} + <th>{% trans 'Subpartition' %}</th> + {% endif %} + <th>{% trans 'Engine' %}</th> + <th>{% trans 'Comment' %}</th> + <th>{% trans 'Data directory' %}</th> + <th>{% trans 'Index directory' %}</th> + <th>{% trans 'Max rows' %}</th> + <th>{% trans 'Min rows' %}</th> + <th>{% trans 'Table space' %}</th> + <th>{% trans 'Node group' %}</th> + </tr></thead> + {% for partition in partition_details['partitions'] %} + {% set rowspan = partition['subpartition_count'] is not empty + ? partition['subpartition_count'] + 1 : 2 %} + <tr> + <td rowspan="{{ rowspan }}"> + <input type="text" name="{{ partition['prefix'] }}[name]" + value="{{ partition['name'] }}"> + </td> + {% if partition_details['value_enabled'] %} + <td rowspan="{{ rowspan }}" class="vmiddle"> + <select class="partition_value" + name="{{ partition['prefix'] }}[value_type]"> + {% for option in value_type_options %} + <option value="{{ option }}" + {%- if partition['value_type'] == option %} + selected="selected" + {%- endif %}> + {{ option }} + </option> + {% endfor %} + </select> + <input type="text" class="partition_value" + name="{{ partition['prefix'] }}[value]" + value="{{ partition['value'] }}"> + </td> + {% endif %} + </tr> + + {% if partition['subpartitions'] is defined %} + {% set subpartitions = partition['subpartitions'] %} + {% else %} + {% set subpartitions = [partition] %} + {% endif %} + + {% for subpartition in subpartitions %} + <tr> + {% if partition_details['can_have_subpartitions'] + and partition_details['subpartition_count'] > 1 %} + <td> + <input type="text" name="{{ subpartition['prefix'] }}[name]" + value="{{ subpartition['name'] }}"> + </td> + {% endif %} + <td> + {{ get_html_select( + subpartition['prefix'] ~ '[engine]', + null, + subpartition['engine'], + false, + true + ) }} + </td> + <td> + {% apply spaceless %} + <textarea name="{{ subpartition['prefix'] }}[comment]"> + {{ subpartition['comment'] }} + </textarea> + {% endapply %} + </td> + <td> + <input type="text" name="{{ subpartition['prefix'] }}[data_directory]" + value="{{ subpartition['data_directory'] }}"> + </td> + <td> + <input type="text" name="{{ subpartition['prefix'] }}[index_directory]" + value="{{ subpartition['index_directory'] }}"> + </td> + <td> + <input type="number" name="{{ subpartition['prefix'] }}[max_rows]" + value="{{ subpartition['max_rows'] }}"> + </td> + <td> + <input type="number" min="0" name="{{ subpartition['prefix'] }}[min_rows]" + value="{{ subpartition['min_rows'] }}"> + </td> + <td> + <input type="text" min="0" name="{{ subpartition['prefix'] }}[tablespace]" + value="{{ subpartition['tablespace'] }}"> + </td> + <td> + <input type="text" name="{{ subpartition['prefix'] }}[node_group]" + value="{{ subpartition['node_group'] }}"> + </td> + </tr> + {% endfor %} + {% endfor %} + </table> +{% endif %} diff --git a/srcs/phpmyadmin/templates/columns_definitions/table_fields_definitions.twig b/srcs/phpmyadmin/templates/columns_definitions/table_fields_definitions.twig new file mode 100644 index 0000000..f23b2fe --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/table_fields_definitions.twig @@ -0,0 +1,122 @@ +<div class="responsivetable"> +<table id="table_columns" class="noclick"> + <caption class="tblHeaders"> + {% trans 'Structure' %} + {{ show_mysql_docu('CREATE_TABLE') }} + </caption> + <tr> + <th> + {% trans 'Name' %} + </th> + <th> + {% trans 'Type' %} + {{ show_mysql_docu('data-types') }} + </th> + <th> + {% trans 'Length/Values' %} + {{ 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' %} + {{ 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' %} + </th> + <th> + {% trans 'Attributes' %} + </th> + <th> + {% trans 'Null' %} + </th> + + {# Only for 'Edit' Column(s) #} + {% if change_column is defined and change_column is not empty %} + <th> + {% trans 'Adjust privileges' %} + {{ show_docu('faq', 'faq6-39') }} + </th> + {% endif %} + + {# We could remove this 'if' and let the key information be shown and + editable. However, for this to work, structure.lib.php must be + modified to use the key fields, as tbl_addfield does. #} + {% if not is_backup %} + <th> + {% trans 'Index' %} + </th> + {% endif %} + + <th> + <abbr title="AUTO_INCREMENT">A_I</abbr> + </th> + <th> + {% trans 'Comments' %} + </th> + + {% if is_virtual_columns_supported %} + <th> + {% trans 'Virtuality' %} + </th> + {% endif %} + + {% if fields_meta is defined %} + <th> + {% trans 'Move column' %} + </th> + {% endif %} + + {% if mimework and browse_mime %} + <th> + {% trans 'Media (MIME) type' %} + </th> + <th> + <a href="transformation_overview.php + {{- get_common() }}#transformation" title=" + {%- trans 'List of available transformations and their options' -%} + " target="_blank"> + {% trans 'Browser display transformation' %} + </a> + </th> + <th> + {% trans 'Browser display transformation options' %} + {{ 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" + title="{% trans 'List of available transformations and their options' %}" + target="_blank"> + {% trans 'Input transformation' %} + </a> + </th> + <th> + {% trans 'Input transformation options' %} + {{ 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> + {% set options = {'': '', 'VIRTUAL': 'VIRTUAL'} %} + {% if server_type == 'MariaDB' %} + {% set options = options|merge({'PERSISTENT': 'PERSISTENT'}) %} + {% set options = options|merge({'STORED': 'STORED'}) %} + {% else %} + {% set options = options|merge({'STORED': 'STORED'}) %} + {% endif %} + {% for content_row in content_cells %} + <tr> + {% include 'columns_definitions/column_attributes.twig' with content_row|merge({ + 'options': options, + 'change_column': change_column, + 'is_virtual_columns_supported': is_virtual_columns_supported, + 'browse_mime': browse_mime, + 'max_rows': max_rows, + 'char_editing': char_editing, + 'attribute_types': attribute_types, + 'privs_available': privs_available, + 'max_length': max_length, + 'charsets': charsets + }) only %} + </tr> + {% endfor %} +</table> +</div> diff --git a/srcs/phpmyadmin/templates/columns_definitions/transformation.twig b/srcs/phpmyadmin/templates/columns_definitions/transformation.twig new file mode 100644 index 0000000..9aec94a --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/transformation.twig @@ -0,0 +1,26 @@ +<select id="field_{{ column_number }}_{{ ci - ci_offset }}" + size="1" + name="field_{{ type }}[{{ column_number }}]"> + <option value="" title="{% trans 'None' %}"></option> + {% if available_mime[type] is defined and available_mime[type] is iterable %} + {% for mimekey, transform in available_mime[type] %} + {% set checked = column_meta['Field'] is defined + and mime_map[column_meta['Field']][type] is defined + and mime_map[column_meta['Field']][type] matches + '@' ~ available_mime[type ~ '_file_quoted'][mimekey] ~ '3?@i' + ? 'selected ' %} + {% set tooltip = get_description( + available_mime[type ~ '_file'][mimekey] + ) %} + {% set parts = transform|split(':') %} + {% set name = get_name( + available_mime[type ~ '_file'][mimekey] + ) ~ ' (' ~ parts[0]|lower ~ ':' ~ parts[1] ~ ')' %} + <option value="{{ available_mime[type ~ '_file'][mimekey] }}" + {{ checked }} + title="{{ tooltip }}"> + {{ name }} + </option> + {% endfor %} + {% endif %} +</select> diff --git a/srcs/phpmyadmin/templates/columns_definitions/transformation_option.twig b/srcs/phpmyadmin/templates/columns_definitions/transformation_option.twig new file mode 100644 index 0000000..f87ba7c --- /dev/null +++ b/srcs/phpmyadmin/templates/columns_definitions/transformation_option.twig @@ -0,0 +1,9 @@ +{% set options_key = type_prefix ~ 'transformation_options' %} +<input id="field_{{ column_number }}_{{ ci - ci_offset }}" + type="text" + name="field_{{ options_key }}[{{ column_number }}]" + size="16" + class="textfield" + value="{% if column_meta['Field'] is defined and mime_map[column_meta['Field']][options_key] is defined -%} + {{- mime_map[column_meta['Field']][options_key] -}} + {%- endif %}"> |
