Port columns_definitions/column_definitions_form to Twig
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
b670552cbf
commit
c7ca02fbaa
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
use PhpMyAdmin\Di\Container;
|
||||
use PhpMyAdmin\Partition;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Table;
|
||||
@ -392,18 +393,35 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
|
||||
} // end for
|
||||
|
||||
include 'libraries/tbl_partition_definition.inc.php';
|
||||
$html = Template::get('columns_definitions/column_definitions_form')
|
||||
->render(
|
||||
array(
|
||||
'is_backup' => $is_backup,
|
||||
'fields_meta' => isset($fields_meta) ? $fields_meta : null,
|
||||
'mimework' => $cfgRelation['mimework'],
|
||||
'action' => $action,
|
||||
'form_params' => $form_params,
|
||||
'content_cells' => $content_cells,
|
||||
'partitionDetails' => $partitionDetails
|
||||
)
|
||||
);
|
||||
$html = Template::get('columns_definitions/column_definitions_form')->render([
|
||||
'is_backup' => $is_backup,
|
||||
'fields_meta' => isset($fields_meta) ? $fields_meta : null,
|
||||
'mimework' => $cfgRelation['mimework'],
|
||||
'action' => $action,
|
||||
'form_params' => $form_params,
|
||||
'content_cells' => $content_cells,
|
||||
'partition_details' => $partitionDetails,
|
||||
'primary_indexes' => $_REQUEST['primary_indexes'],
|
||||
'unique_indexes' => $_REQUEST['unique_indexes'],
|
||||
'indexes' => $_REQUEST['indexes'],
|
||||
'fulltext_indexes' => $_REQUEST['fulltext_indexes'],
|
||||
'spatial_indexes' => $_REQUEST['spatial_indexes'],
|
||||
'table' => $_REQUEST['table'],
|
||||
'comment' => $_REQUEST['comment'],
|
||||
'tbl_collation' => $_REQUEST['tbl_collation'],
|
||||
'tbl_storage_engine' => $_REQUEST['tbl_storage_engine'],
|
||||
'connection' => $_REQUEST['connection'],
|
||||
'change_column' => $_REQUEST['change_column'],
|
||||
'is_virtual_columns_supported' => Util::isVirtualColumnsSupported(),
|
||||
'browse_mime' => $GLOBALS['cfg']['BrowseMIME'],
|
||||
'server_type' => Util::getServerType(),
|
||||
'max_rows' => intval($GLOBALS['cfg']['MaxRows']),
|
||||
'char_editing' => $GLOBALS['cfg']['CharEditing'],
|
||||
'attribute_types' => $GLOBALS['dbi']->types->getAttributes(),
|
||||
'privs_available' => $GLOBALS['col_priv'] && $GLOBALS['is_reload_priv'],
|
||||
'max_length' => $GLOBALS['dbi']->getVersion() >= 50503 ? 1024 : 255,
|
||||
'have_partitioning' => Partition::havePartitioning(),
|
||||
]);
|
||||
|
||||
unset($form_params);
|
||||
|
||||
|
||||
@ -1,182 +0,0 @@
|
||||
<?php
|
||||
use PhpMyAdmin\Partition;
|
||||
use PhpMyAdmin\StorageEngine;
|
||||
use PhpMyAdmin\Url;
|
||||
|
||||
?>
|
||||
<form method="post"
|
||||
action="<?= $action; ?>"
|
||||
class="<?= ($action == 'tbl_create.php' ? 'create_table' : 'append_fields'); ?>_form ajax lock-page">
|
||||
<?= Url::getHiddenInputs($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="<?= (! empty($_REQUEST['primary_indexes'])) ?
|
||||
htmlspecialchars($_REQUEST['primary_indexes'])
|
||||
: '[]'
|
||||
?>">
|
||||
<input type="hidden"
|
||||
name="unique_indexes"
|
||||
value="<?= (! empty($_REQUEST['unique_indexes'])) ?
|
||||
htmlspecialchars($_REQUEST['unique_indexes'])
|
||||
: '[]'
|
||||
?>">
|
||||
<input type="hidden"
|
||||
name="indexes"
|
||||
value="<?= (! empty($_REQUEST['indexes'])) ?
|
||||
htmlspecialchars($_REQUEST['indexes'])
|
||||
: '[]'
|
||||
?>">
|
||||
<input type="hidden"
|
||||
name="fulltext_indexes"
|
||||
value="<?= (! empty($_REQUEST['fulltext_indexes'])) ?
|
||||
htmlspecialchars($_REQUEST['fulltext_indexes'])
|
||||
: '[]'
|
||||
?>">
|
||||
<input type="hidden"
|
||||
name="spatial_indexes"
|
||||
value="<?= (! empty($_REQUEST['spatial_indexes'])) ?
|
||||
htmlspecialchars($_REQUEST['spatial_indexes'])
|
||||
: '[]'
|
||||
?>">
|
||||
|
||||
<?php 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><?= __('Table name'); ?>:
|
||||
<input type="text"
|
||||
name="table"
|
||||
size="40"
|
||||
maxlength="64"
|
||||
value="<?= (isset($_REQUEST['table']) ? htmlspecialchars($_REQUEST['table']) : '') ?>"
|
||||
class="textfield" autofocus required />
|
||||
</td>
|
||||
<td>
|
||||
<?= __('Add'); ?>
|
||||
<input type="number"
|
||||
id="added_fields"
|
||||
name="added_fields"
|
||||
size="2"
|
||||
value="1"
|
||||
min="1"
|
||||
onfocus="this.select()" />
|
||||
<?= __('column(s)'); ?>
|
||||
<input type="button"
|
||||
name="submit_num_fields"
|
||||
value="<?= __('Go'); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (is_array($content_cells)): ?>
|
||||
<?= PhpMyAdmin\Template::get(
|
||||
'columns_definitions/table_fields_definitions'
|
||||
)->render(array(
|
||||
'is_backup' => $is_backup,
|
||||
'fields_meta' => $fields_meta,
|
||||
'mimework' => $mimework,
|
||||
'content_cells' => $content_cells,
|
||||
'change_column' => $_REQUEST['change_column'],
|
||||
'is_virtual_columns_supported' => PhpMyAdmin\Util::isVirtualColumnsSupported(),
|
||||
'browse_mime' => $GLOBALS['cfg']['BrowseMIME'],
|
||||
'server_type' => PhpMyAdmin\Util::getServerType(),
|
||||
'max_rows' => intval($GLOBALS['cfg']['MaxRows']),
|
||||
'char_editing' => $GLOBALS['cfg']['CharEditing'],
|
||||
'attribute_types' => $GLOBALS['dbi']->types->getAttributes(),
|
||||
'privs_available' => $GLOBALS['col_priv'] && $GLOBALS['is_reload_priv'],
|
||||
'max_length' => $GLOBALS['dbi']->getVersion() >= 50503 ? 1024 : 255,
|
||||
)); ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($action == 'tbl_create.php'): ?>
|
||||
<div class="responsivetable">
|
||||
<table>
|
||||
<tr class="vtop">
|
||||
<th>
|
||||
<?= __('Table comments:'); ?>
|
||||
</th>
|
||||
<td width="25"> </td>
|
||||
<th>
|
||||
<?= __('Collation:'); ?>
|
||||
</th>
|
||||
<td width="25"> </td>
|
||||
<th>
|
||||
<?= __('Storage Engine:'); ?>
|
||||
<?= PhpMyAdmin\Util::showMySQLDocu('Storage_engines'); ?>
|
||||
</th>
|
||||
<td width="25"> </td>
|
||||
<th>
|
||||
<?= __('Connection:'); ?>
|
||||
<?= PhpMyAdmin\Util::showMySQLDocu('federated-create-connection'); ?>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text"
|
||||
name="comment"
|
||||
size="40"
|
||||
maxlength="60"
|
||||
value="<?= (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']): ''); ?>"
|
||||
class="textfield" />
|
||||
</td>
|
||||
<td width="25"> </td>
|
||||
<td>
|
||||
<?= PhpMyAdmin\Charsets::getCollationDropdownBox(
|
||||
'tbl_collation',
|
||||
null,
|
||||
isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null,
|
||||
false
|
||||
); ?>
|
||||
</td>
|
||||
<td width="25"> </td>
|
||||
<td>
|
||||
<?= StorageEngine::getHtmlSelect(
|
||||
'tbl_storage_engine',
|
||||
null,
|
||||
(isset($_REQUEST['tbl_storage_engine']) ? $_REQUEST['tbl_storage_engine'] : null)
|
||||
); ?>
|
||||
</td>
|
||||
<td width="25"> </td>
|
||||
<td>
|
||||
<input type="text"
|
||||
name="connection"
|
||||
size="40"
|
||||
value="<?= (isset($_REQUEST['connection']) ? htmlspecialchars($_REQUEST['connection']) : ''); ?>"
|
||||
placeholder="scheme://user_name[:password]@host_name[:port_num]/db_name/tbl_name"
|
||||
class="textfield"
|
||||
required="required" />
|
||||
</td>
|
||||
</tr>
|
||||
<?php if (Partition::havePartitioning()): ?>
|
||||
<tr class="vtop">
|
||||
<th colspan="5">
|
||||
<?= __('PARTITION definition:'); ?>
|
||||
|
||||
<?= PhpMyAdmin\Util::showMySQLDocu('Partitioning'); ?>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<?= PhpMyAdmin\Template::get('columns_definitions/partitions')
|
||||
->render(array('partition_details' => $partitionDetails)); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
<br />
|
||||
<?php endif; ?>
|
||||
<fieldset class="tblFooters">
|
||||
<input type="button"
|
||||
class="preview_sql"
|
||||
value="<?= __('Preview SQL') ?>" />
|
||||
<input type="submit"
|
||||
name="do_save_data"
|
||||
value="<?= __('Save'); ?>" />
|
||||
</fieldset>
|
||||
<div id="properties_message">
|
||||
</div>
|
||||
</form>
|
||||
148
templates/columns_definitions/column_definitions_form.twig
Normal file
148
templates/columns_definitions/column_definitions_form.twig
Normal file
@ -0,0 +1,148 @@
|
||||
<form method="post" action="{{ action }}" class="
|
||||
{{- action == 'tbl_create.php' ? 'create_table' : 'append_fields' -}}
|
||||
_form ajax lock-page">
|
||||
{{ Url_getHiddenInputs(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 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
|
||||
} 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:' %}
|
||||
{{ Util_showMySQLDocu('Storage_engines') }}
|
||||
</th>
|
||||
<td width="25"> </td>
|
||||
<th>
|
||||
{% trans 'Connection:' %}
|
||||
{{ Util_showMySQLDocu('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>
|
||||
{{ Charsets_getCollationDropdownBox(
|
||||
'tbl_collation',
|
||||
null,
|
||||
tbl_collation,
|
||||
false
|
||||
) }}
|
||||
</td>
|
||||
<td width="25"> </td>
|
||||
<td>
|
||||
{{ StorageEngine_getHtmlSelect(
|
||||
'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:' %}
|
||||
{{ Util_showMySQLDocu('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 type="button"
|
||||
class="preview_sql"
|
||||
value="{% trans 'Preview SQL' %}" />
|
||||
<input type="submit"
|
||||
name="do_save_data"
|
||||
value="{% trans 'Save' %}" />
|
||||
</fieldset>
|
||||
<div id="properties_message"></div>
|
||||
</form>
|
||||
Loading…
Reference in New Issue
Block a user