Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-10-23 15:32:48 +02:00
commit 228f8472d2
8 changed files with 328 additions and 253 deletions

View File

@ -15,6 +15,7 @@ use PhpMyAdmin\CreateAddField;
use PhpMyAdmin\Index;
use PhpMyAdmin\Message;
use PhpMyAdmin\ParseAnalyze;
use PhpMyAdmin\Partition;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Sql;
use PhpMyAdmin\SqlParser\Context;
@ -23,6 +24,7 @@ use PhpMyAdmin\SqlParser\Statements\CreateStatement;
use PhpMyAdmin\SqlParser\Utils\Table as SqlTable;
use PhpMyAdmin\Table;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tracker;
use PhpMyAdmin\Transformations;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@ -1259,7 +1261,7 @@ class TableStructureController extends TableController
return Template::get('table/structure/display_structure')->render(
array(
'HideStructureActions' => $HideStructureActions,
'hide_structure_actions' => $HideStructureActions,
'db' => $this->db,
'table' => $this->table,
'db_is_system_schema' => $this->_db_is_system_schema,
@ -1272,11 +1274,23 @@ class TableStructureController extends TableController
'columns_with_unique_index' => $columns_with_unique_index,
'edit_view_url' => isset($edit_view_url) ? $edit_view_url : null,
'columns_list' => $columns_list,
'tablestats' => isset($tablestats) ? $tablestats : null,
'table_stats' => isset($tablestats) ? $tablestats : null,
'fields' => $fields,
'columns_with_index' => $columns_with_index,
'central_list' => $central_list,
'comments_map' => $comments_map
'comments_map' => $comments_map,
'browse_mime' => $GLOBALS['cfg']['BrowseMIME'],
'show_column_comments' => $GLOBALS['cfg']['ShowColumnComments'],
'show_stats' => $GLOBALS['cfg']['ShowStats'],
'relation_commwork' => $GLOBALS['cfgRelation']['commwork'],
'relation_mimework' => $GLOBALS['cfgRelation']['mimework'],
'central_columns_work' => $GLOBALS['cfgRelation']['centralcolumnswork'],
'mysql_int_version' => $GLOBALS['dbi']->getVersion(),
'pma_theme_image' => $GLOBALS['pmaThemeImage'],
'text_dir' => $GLOBALS['text_dir'],
'is_active' => Tracker::isActive(),
'have_partitioning' => Partition::havePartitioning(),
'partition_names' => Partition::getPartitionNames($this->db, $this->table),
)
);
}

View File

@ -10,7 +10,9 @@ namespace PhpMyAdmin;
use PhpMyAdmin\Twig\CharsetsExtension;
use PhpMyAdmin\Twig\CoreExtension;
use PhpMyAdmin\Twig\I18nExtension;
use PhpMyAdmin\Twig\IndexExtension;
use PhpMyAdmin\Twig\MessageExtension;
use PhpMyAdmin\Twig\PartitionExtension;
use PhpMyAdmin\Twig\PhpFunctionsExtension;
use PhpMyAdmin\Twig\PluginsExtension;
use PhpMyAdmin\Twig\RelationExtension;
@ -69,7 +71,9 @@ class Template
$twig->addExtension(new CharsetsExtension());
$twig->addExtension(new CoreExtension());
$twig->addExtension(new I18nExtension());
$twig->addExtension(new IndexExtension());
$twig->addExtension(new MessageExtension());
$twig->addExtension(new PartitionExtension());
$twig->addExtension(new PhpFunctionsExtension());
$twig->addExtension(new PluginsExtension());
$twig->addExtension(new RelationExtension());

View File

@ -0,0 +1,35 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* hold PhpMyAdmin\Twig\IndexExtension class
*
* @package PhpMyAdmin\Twig
*/
namespace PhpMyAdmin\Twig;
use Twig_Extension;
use Twig_SimpleFunction;
/**
* Class IndexExtension
*
* @package PhpMyAdmin\Twig
*/
class IndexExtension extends Twig_Extension
{
/**
* Returns a list of functions to add to the existing list.
*
* @return Twig_SimpleFunction[]
*/
public function getFunctions()
{
return array(
new Twig_SimpleFunction(
'Index_getHtmlForDisplayIndexes',
'PhpMyAdmin\Index::getHtmlForDisplayIndexes',
array('is_safe' => array('html'))
),
);
}
}

View File

@ -0,0 +1,35 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* hold PhpMyAdmin\Twig\PartitionExtension class
*
* @package PhpMyAdmin\Twig
*/
namespace PhpMyAdmin\Twig;
use Twig_Extension;
use Twig_SimpleFunction;
/**
* Class PartitionExtension
*
* @package PhpMyAdmin\Twig
*/
class PartitionExtension extends Twig_Extension
{
/**
* Returns a list of functions to add to the existing list.
*
* @return Twig_SimpleFunction[]
*/
public function getFunctions()
{
return array(
new Twig_SimpleFunction(
'Partition_getPartitions',
'PhpMyAdmin\Partition::getPartitions',
array('is_safe' => array('html'))
),
);
}
}

View File

@ -37,6 +37,10 @@ class UtilExtension extends Twig_Extension
'Util_escapeMysqlWildcards',
'PhpMyAdmin\Util::escapeMysqlWildcards'
),
new Twig_SimpleFunction(
'Util_extractColumnSpec',
'PhpMyAdmin\Util::extractColumnSpec'
),
new Twig_SimpleFunction(
'Util_formatByteDown',
'PhpMyAdmin\Util::formatByteDown'
@ -55,6 +59,11 @@ class UtilExtension extends Twig_Extension
'PhpMyAdmin\Util::getButtonOrImage',
array('is_safe' => array('html'))
),
new Twig_SimpleFunction(
'Util_getClassForType',
'PhpMyAdmin\Util::getClassForType',
array('is_safe' => array('html'))
),
new Twig_SimpleFunction(
'Util_getDivForSliderEffect',
'PhpMyAdmin\Util::getDivForSliderEffect',

View File

@ -7,7 +7,9 @@ require_once AUTOLOAD_FILE;
use PhpMyAdmin\Twig\CharsetsExtension;
use PhpMyAdmin\Twig\CoreExtension;
use PhpMyAdmin\Twig\I18nExtension;
use PhpMyAdmin\Twig\IndexExtension;
use PhpMyAdmin\Twig\MessageExtension;
use PhpMyAdmin\Twig\PartitionExtension;
use PhpMyAdmin\Twig\PhpFunctionsExtension;
use PhpMyAdmin\Twig\PluginsExtension;
use PhpMyAdmin\Twig\RelationExtension;
@ -29,7 +31,9 @@ $twig = new Twig_Environment($loader, array(
$twig->addExtension(new CharsetsExtension());
$twig->addExtension(new CoreExtension());
$twig->addExtension(new I18nExtension());
$twig->addExtension(new IndexExtension());
$twig->addExtension(new MessageExtension());
$twig->addExtension(new PartitionExtension());
$twig->addExtension(new PhpFunctionsExtension());
$twig->addExtension(new PluginsExtension());
$twig->addExtension(new RelationExtension());

View File

@ -1,250 +0,0 @@
<?php
use PhpMyAdmin\Index;
use PhpMyAdmin\Partition;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tracker;
use PhpMyAdmin\Util;
use PhpMyAdmin\Url;
$rownum = 0; ?>
<form method="post" action="tbl_structure.php" name="fieldsForm" id="fieldsForm" class="ajax<?= $HideStructureActions; ?>">
<?= Url::getHiddenInputs($db, $table); ?>
<input type="hidden" name="table_type" value=
<?php if ($db_is_system_schema): ?>
"information_schema" />
<?php elseif ($tbl_is_view): ?>
"view" />
<?php else: ?>
"table" />
<?php endif; ?>
<div class="responsivetable">
<table id="tablestructure" class="data topmargin">
<!-- table header -->
<?= PhpMyAdmin\Template::get('table/structure/table_structure_header')->render(
array(
'db_is_system_schema' => $db_is_system_schema,
'tbl_is_view' => $tbl_is_view,
'show_column_comments' => $GLOBALS['cfg']['ShowColumnComments']
)
); ?>
<tbody>
<!-- table body -->
<?php foreach($fields as $row): ?>
<?php
$rownum++;
$columns_list[] = $row['Field'];
$field_charset = $row['Collation'];
$extracted_columnspec = Util::extractColumnSpec($row['Type']);
$attribute = $extracted_columnspec['attribute'];
if (strpos($row['Extra'], 'on update CURRENT_TIMESTAMP') !== false) {
$attribute = 'on update CURRENT_TIMESTAMP';
}
if (! isset($row['Default'])) {
if ($row['Null'] == 'YES') {
$row['Default'] = '<i>NULL</i>';
}
} else {
$row['Default'] = htmlspecialchars($row['Default']);
}
$field_name = htmlspecialchars($row['Field']);
$displayed_field_name = $field_name;
$comments = ''; //For column comments
// underline commented fields and display a hover-title (CSS only)
if (isset($comments_map[$row['Field']])) {
$displayed_field_name = '<span class="commented_column" title="'
. htmlspecialchars($comments_map[$row['Field']]) . '">'
. $field_name . '</span>';
$comments = htmlspecialchars($comments_map[$row['Field']]);
}
if ($primary && $primary->hasColumn($field_name)) {
$displayed_field_name .= Util::getImage(
'b_primary.png', __('Primary')
);
}
if (in_array($field_name, $columns_with_index)) {
$displayed_field_name .= Util::getImage(
'b_key.png', __('Index')
);
}
?>
<tr>
<?= PhpMyAdmin\Template::get('table/structure/table_structure_row')->render(
array(
'row' => $row,
'rownum' => $rownum,
'displayed_field_name' => preg_replace(
'/[\x00-\x1F]/',
'&#x2051;',
$displayed_field_name
),
'type_nowrap' => Util::getClassForType($extracted_columnspec['type']),
'extracted_columnspec' => $extracted_columnspec,
'attribute' => $attribute,
'tbl_is_view' => $tbl_is_view,
'db_is_system_schema' => $db_is_system_schema,
'url_query' => $url_query,
'titles' => $titles,
'table' => $table,
'tbl_storage_engine' => $tbl_storage_engine,
'field_charset' => $field_charset,
'comments' => $comments,
'show_column_comments' => $GLOBALS['cfg']['ShowColumnComments'],
'relation_commwork' => $GLOBALS['cfgRelation']['commwork'],
'relation_mimework' => $GLOBALS['cfgRelation']['mimework'],
'browse_mime' => $GLOBALS['cfg']['BrowseMIME']
)
); ?>
<?php if (! $tbl_is_view && ! $db_is_system_schema): ?>
<?= Template::get('table/structure/actions_in_table_structure')->render(
array(
'extracted_columnspec' => $extracted_columnspec,
'type' => (!empty($extracted_columnspec['print_type'])) ? $extracted_columnspec['print_type'] : ' ',
'tbl_storage_engine' => $tbl_storage_engine,
'primary' => $primary,
'field_name' => $field_name,
'url_query' => $url_query,
'titles' => $titles,
'row' => $row,
'rownum' => $rownum,
'columns_with_unique_index' => $columns_with_unique_index,
'is_in_central_columns' => in_array($row['Field'], $central_list) ? true : false,
'central_columns_work' => $GLOBALS['cfgRelation']['centralcolumnswork'],
'table' => $GLOBALS['table'],
'mysql_int_version' => $GLOBALS['dbi']->getVersion()
)
); ?>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?= Template::get('table/structure/check_all_table_column')->render(
array(
'pma_theme_image' => $GLOBALS['pmaThemeImage'],
'text_dir' => $GLOBALS['text_dir'],
'tbl_is_view' => $tbl_is_view,
'db_is_system_schema' => $db_is_system_schema,
'tbl_storage_engine' => $tbl_storage_engine,
'central_columns_work' => $GLOBALS['cfgRelation']['centralcolumnswork']
)
); ?>
</form>
<hr class="print_ignore"/>
<?= Template::get('table/structure/move_columns_dialog')->render(array(
'db' => $GLOBALS['db'],
'table' => $GLOBALS['table'],
)); ?>
<!--Work on the table-->
<div id="structure-action-links">
<?php if ($tbl_is_view && ! $db_is_system_schema): ?>
<?= Util::linkOrButton(
$edit_view_url,
Util::getIcon('b_edit.png', __('Edit view'), true)
); ?>
<?php endif; ?>
<?= Template::get('table/structure/optional_action_links')->render(
array(
'url_query' => $url_query,
'tbl_is_view' => $tbl_is_view,
'db_is_system_schema' => $db_is_system_schema,
'table' => $GLOBALS['table'],
'is_active' => Tracker::isActive()
)
); ?>
</div>
<?php if (! $tbl_is_view && ! $db_is_system_schema): ?>
<br />
<?= Template::get('table/structure/add_column')->render(array(
'columns_list' => $columns_list,
'db' => $GLOBALS['db'],
'table' => $GLOBALS['table']
)); ?>
<?php endif; ?>
<!--Displays indexes-->
<?php if (! $tbl_is_view
&& ! $db_is_system_schema && 'ARCHIVE' != $tbl_storage_engine): ?>
<?= Index::getHtmlForDisplayIndexes(); ?>
<?php endif; ?>
<!--Display partition details-->
<?php if (Partition::havePartitioning()):
$partition_names = Partition::getPartitionNames($db, $table);
// detect partitioning
if (! empty($partition_names) && ! is_null($partition_names[0])):
$partitions = Partition::getPartitions($db, $table);
$firstPartition = $partitions[0];
$rangeOrList = $firstPartition->getMethod() == 'RANGE'
|| $firstPartition->getMethod() == 'RANGE COLUMNS'
|| $firstPartition->getMethod() == 'LIST'
|| $firstPartition->getMethod() == 'LIST COLUMNS';
$subParitions = $firstPartition->getSubPartitions();
$hasSubPartitions = $firstPartition->hasSubPartitions();
if ($hasSubPartitions) {
$firstSubPartition = $subParitions[0];
}
$actionIcons = array(
'ANALYZE' => Util::getIcon('b_search.png', __('Analyze')),
'CHECK' => Util::getIcon('eye.png', __('Check')),
'OPTIMIZE' => Util::getIcon('normalize.png', __('Optimize')),
'REBUILD' => Util::getIcon('s_tbl.png', __('Rebuild')),
'REPAIR' => Util::getIcon('b_tblops.png', __('Repair')),
'TRUNCATE' => Util::getIcon('b_empty.png', __('Truncate')),
);
if ($rangeOrList) {
$actionIcons['DROP'] = Util::getIcon('b_drop.png', __('Drop'));
}
echo Util::getDivForSliderEffect(
'partitions', __('Partitions')
);
$tmp_partition_description = $firstPartition->getDescription();
$removeSQL = "ALTER TABLE " . Util::backquote($table) . " REMOVE PARTITIONING";
$removeUrl = 'sql.php' . $url_query . '&sql_query=' . urlencode($removeSQL);
echo Template::get('table/structure/display_partitions')->render(
array(
'db' => $db,
'table' => $table,
'url_query' => $url_query,
'partitions' => $partitions,
'partition_method' => $firstPartition->getMethod(),
'partition_expression' => $firstPartition->getExpression(),
'has_description' => ! empty($tmp_partition_description),
'has_sub_partitions' => $hasSubPartitions,
'sub_partition_method' => $hasSubPartitions ? $firstSubPartition->getMethod() : null,
'sub_partition_expression' => $hasSubPartitions ? $firstSubPartition->getExpression() : null,
'action_icons' => $actionIcons,
'range_or_list' => $rangeOrList,
'remove_url' => $removeUrl,
)
);
else:
echo Template::get('table/structure/display_partitions')->render(
array(
'db' => $db,
'table' => $table,
)
);
endif;
?>
<!-- For closing Slider effect div-->
</div>
<?php endif; ?>
<!--Displays Space usage and row statistics-->
<?php if ($GLOBALS['cfg']['ShowStats']): ?>
<?= $tablestats; ?>
<?php endif; ?>
<div class="clearfloat"></div>

View File

@ -0,0 +1,224 @@
<form method="post" action="tbl_structure.php" name="fieldsForm" id="fieldsForm"
class="ajax{{ hide_structure_actions }}">
{{ Url_getHiddenInputs(db, table) }}
<input type="hidden" name="table_type" value=
{%- if db_is_system_schema -%}
"information_schema"
{%- elseif tbl_is_view -%}
"view"
{%- else -%}
"table"
{%- endif %} />
<div class="responsivetable">
<table id="tablestructure" class="data topmargin">
{# Table header #}
{% include 'table/structure/table_structure_header.twig' with {
'db_is_system_schema': db_is_system_schema,
'tbl_is_view': tbl_is_view,
'show_column_comments': show_column_comments
} only %}
<tbody>
{# Table body #}
{% set rownum = 0 %}
{% set columns_list = [] %}
{% for row in fields %}
{% set rownum = rownum + 1 %}
{% set columns_list = columns_list|merge([row['Field']]) %}
{% set field_charset = row['Collation'] %}
{% set extracted_columnspec = Util_extractColumnSpec(row['Type']) %}
{% set attribute = extracted_columnspec['attribute'] %}
{% if strpos(row['Extra'], 'on update CURRENT_TIMESTAMP')
is not same as(false) %}
{% set attribute = 'on update CURRENT_TIMESTAMP' %}
{% endif %}
{% if row['Default'] is not defined %}
{% if row['Null'] == 'YES' %}
{% set row = row|merge({'Default': '<em>NULL</em>'}) %}
{% endif %}
{% else %}
{% set row = row|merge({'Default': row['Default']|e}) %}
{% endif %}
{% set field_name = row['Field']|e %}
{% set displayed_field_name = field_name %}
{# For column comments #}
{% set comments = '' %}
{# Underline commented fields and display a hover-title (CSS only) #}
{% if comments_map[row['Field']] is defined %}
{% set displayed_field_name -%}
<span class="commented_column" title="
{{- comments_map[row['Field']] }}">
{{- field_name|raw -}}
</span>
{%- endset %}
{% set comments = comments_map[row['Field']]|e %}
{% endif %}
{% if primary and primary.hasColumn(field_name) %}
{% set displayed_field_name = displayed_field_name ~ Util_getImage(
'b_primary.png', 'Primary'|trans
) %}
{% endif %}
{% if field_name in columns_with_index %}
{% set displayed_field_name = displayed_field_name ~ Util_getImage(
'b_key.png', 'Index'|trans
) %}
{% endif %}
<tr>
{% include 'table/structure/table_structure_row.twig' with {
'row': row,
'rownum': rownum,
'displayed_field_name': preg_replace(
'/[\x00-\x1F]/',
'&#x2051;',
displayed_field_name
),
'type_nowrap': Util_getClassForType(extracted_columnspec['type']),
'extracted_columnspec': extracted_columnspec,
'attribute': attribute,
'tbl_is_view': tbl_is_view,
'db_is_system_schema': db_is_system_schema,
'url_query': url_query,
'titles': titles,
'table': table,
'tbl_storage_engine': tbl_storage_engine,
'field_charset': field_charset,
'comments': comments,
'show_column_comments': show_column_comments,
'relation_commwork': relation_commwork,
'relation_mimework': relation_mimework,
'browse_mime': browse_mime
} only %}
{% if not tbl_is_view and not db_is_system_schema %}
{% include 'table/structure/actions_in_table_structure.twig' with {
'row': row,
'rownum': rownum,
'extracted_columnspec': extracted_columnspec,
'type': extracted_columnspec['print_type'] is not empty ? extracted_columnspec['print_type'],
'tbl_storage_engine': tbl_storage_engine,
'primary': primary,
'field_name': field_name,
'url_query': url_query,
'titles': titles,
'columns_with_unique_index': columns_with_unique_index,
'is_in_central_columns': row['Field'] in central_list ? true : false,
'central_columns_work': central_columns_work,
'table': table,
'mysql_int_version': mysql_int_version
} only %}
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% include 'table/structure/check_all_table_column.twig' with {
'pma_theme_image': pma_theme_image,
'text_dir': text_dir,
'tbl_is_view': tbl_is_view,
'db_is_system_schema': db_is_system_schema,
'tbl_storage_engine': tbl_storage_engine,
'central_columns_work': central_columns_work
} only %}
</form>
<hr class="print_ignore"/>
{% include 'table/structure/move_columns_dialog.twig' with {
'db': db,
'table': table
} only %}
{# Work on the table #}
<div id="structure-action-links">
{% if tbl_is_view and not db_is_system_schema %}
{{ Util_linkOrButton(
edit_view_url,
Util_getIcon('b_edit.png', 'Edit view'|trans, true)
) }}
{% endif %}
{% include 'table/structure/optional_action_links.twig' with {
'url_query': url_query,
'tbl_is_view': tbl_is_view,
'db_is_system_schema': db_is_system_schema,
'table': table,
'is_active': is_active
} only %}
</div>
{% if not tbl_is_view and not db_is_system_schema %}
{% include 'table/structure/add_column.twig' with {
'columns_list': columns_list,
'db': db,
'table': table
} only %}
{% endif %}
{# Displays indexes #}
{% if not tbl_is_view and not db_is_system_schema
and 'ARCHIVE' != tbl_storage_engine %}
{{ Index_getHtmlForDisplayIndexes() }}
{% endif %}
{# Display partition details #}
{% if have_partitioning %}
{# Detect partitioning #}
{% if partition_names is not empty and partition_names[0] is not null %}
{% set partitions = Partition_getPartitions(db, table) %}
{% set first_partition = partitions[0] %}
{% set range_or_list = first_partition.getMethod() == 'RANGE'
or first_partition.getMethod() == 'RANGE COLUMNS'
or first_partition.getMethod() == 'LIST'
or first_partition.getMethod() == 'LIST COLUMNS' %}
{% set sub_partitions = first_partition.getSubPartitions() %}
{% set has_sub_partitions = first_partition.hasSubPartitions() %}
{% if has_sub_partitions %}
{% set first_sub_partition = sub_partitions[0] %}
{% endif %}
{% set action_icons = {
'ANALYZE': Util_getIcon('b_search.png', 'Analyze'|trans),
'CHECK': Util_getIcon('eye.png', 'Check'|trans),
'OPTIMIZE': Util_getIcon('normalize.png', 'Optimize'|trans),
'REBUILD': Util_getIcon('s_tbl.png', 'Rebuild'|trans),
'REPAIR': Util_getIcon('b_tblops.png', 'Repair'|trans),
'TRUNCATE': Util_getIcon('b_empty.png', 'Truncate'|trans),
} %}
{% if range_or_list %}
{% set action_icons = action_icons|merge({'DROP': Util_getIcon('b_drop.png', 'Drop'|trans)}) %}
{% endif %}
{{ Util_getDivForSliderEffect('partitions', 'Partitions'|trans) }}
{% set remove_sql = 'ALTER TABLE ' ~ Util_backquote(table) ~ ' REMOVE PARTITIONING' %}
{% set remove_url = 'sql.php' ~ url_query ~ '&sql_query=' ~ remove_sql|url_encode %}
{% include 'table/structure/display_partitions.twig' with {
'db': db,
'table': table,
'url_query': url_query,
'partitions': partitions,
'partition_method': first_partition.getMethod(),
'partition_expression': first_partition.getExpression(),
'has_description': first_partition.getDescription() is not empty,
'has_sub_partitions': has_sub_partitions,
'sub_partition_method': has_sub_partitions ? first_sub_partition.getMethod(),
'sub_partition_expression': has_sub_partitions ? first_sub_partition.getExpression(),
'action_icons': action_icons,
'range_or_list': range_or_list,
'remove_url': remove_url
} only %}
{% else %}
{% include 'table/structure/display_partitions.twig' with {
'db': db,
'table': table
} only %}
{% endif %}
{# For closing Slider effect div #}
</div>
{% endif %}
{# Displays Space usage and row statistics #}
{% if show_stats %}
{{ table_stats|raw }}
{% endif %}
<div class="clearfloat"></div>