Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension removal #14317

Merged
merged 1 commit into from May 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions browse_foreigners.php
Expand Up @@ -68,8 +68,8 @@
$table,
$_REQUEST['field'],
$foreignData,
isset($fieldkey) ? $fieldkey : null,
isset($data) ? $data : null
isset($fieldkey) ? $fieldkey : '',
isset($data) ? $data : ''
);

$response->addHtml($html);
Expand Up @@ -681,12 +681,12 @@ protected function displayTableList()
'formatted_size' => $formatted_size,
'unit' => $unit,
'overhead' => $overhead,
'create_time' => isset($create_time)
? $create_time : '',
'update_time' => isset($update_time)
? $update_time : '',
'check_time' => isset($check_time)
? $check_time : '',
'create_time' => (isset($create_time) && $create_time
? Util::localisedDate(strtotime($create_time)) : '-'),
'update_time' => (isset($update_time) && $update_time
? Util::localisedDate(strtotime($update_time)) : '-'),
'check_time' => (isset($check_time) && $check_time
? Util::localisedDate(strtotime($check_time)) : '-'),
'charset' => isset($charset)
? $charset : '',
'is_show_stats' => $this->_is_show_stats,
Expand Down Expand Up @@ -730,9 +730,9 @@ protected function displayTableList()
'db_charset' => $db_charset,
'sum_size' => $sum_size,
'overhead_size' => $overhead_size,
'create_time_all' => $create_time_all,
'update_time_all' => $update_time_all,
'check_time_all' => $check_time_all,
'create_time_all' => ($create_time_all ? Util::localisedDate(strtotime($create_time_all)) : '-'),
'update_time_all' => ($update_time_all ? Util::localisedDate(strtotime($update_time_all)) : '-'),
'check_time_all' => ($check_time_all ? Util::localisedDate(strtotime($check_time_all)) : '-'),
'approx_rows' => $overall_approx_rows,
'num_favorite_tables' => $GLOBALS['cfg']['NumFavoriteTables'],
'db' => $GLOBALS['db'],
Expand Down
38 changes: 38 additions & 0 deletions libraries/classes/Controllers/Server/ServerDatabasesController.php
@@ -1,5 +1,6 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */

/**
* Holds the PhpMyAdmin\Controllers\Server\ServerDatabasesController
*
Expand All @@ -14,6 +15,7 @@
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\Server\Common;
use PhpMyAdmin\Template;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
Expand Down Expand Up @@ -273,6 +275,22 @@ private function _getHtmlForDatabases(array $replication_types)
}
}

$values = array();
$units = array();
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name,$first_database)) {
if ($stat['format'] == 'byte') {
$byte_format = Util_formatByteDown($stat['footer'], 3, 1);
$values[$stat_name] = $byte_format[0];
$units[$stat_name] = $byte_format[1];
} elseif ($stat['format'] == 'number') {
$values[$stat_name] = Util::formatNumber($stat['footer'], 0);
} else{
$values[$stat_name] = htmlentities($stat['footer'], 0);
}
}
}

$_url_params = array(
'pos' => $this->_pos,
'dbstats' => $this->_dbstats,
Expand Down Expand Up @@ -308,6 +326,8 @@ private function _getHtmlForDatabases(array $replication_types)
'pma_theme_image' => $GLOBALS['pmaThemeImage'],
'text_dir' => $GLOBALS['text_dir'],
'dbstats' => $this->_dbstats,
'values' => $values,
'units' => $units,
]);

return $html;
Expand Down Expand Up @@ -446,6 +466,22 @@ function _buildHtmlForDb(
}
}

$values = array();
$units = array();
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name,$current)) {
if ($stat['format'] == 'byte') {
$byte_format = Util::formatByteDown($stat['footer'], 3, 1);
$values[$stat_name] = $byte_format[0];
$units[$stat_name] = $byte_format[1];
} elseif ($stat['format'] == 'number') {
$values[$stat_name] = Util_formatNumber($stat['footer'], 0);
} else{
$values[$stat_name] = htmlentities($stat['footer'], 0);
}
}
}

return Template::get('server/databases/table_row')->render([
'current' => $current,
'tr_class' => $tr_class,
Expand All @@ -458,6 +494,8 @@ function _buildHtmlForDb(
'allow_user_drop_database' => $GLOBALS['cfg']['AllowUserDropDatabase'],
'is_system_schema' => $this->dbi->isSystemSchema($current['SCHEMA_NAME'], true),
'default_tab_database' => $GLOBALS['cfg']['DefaultTabDatabase'],
'values' => $values,
'units' => $units,
]);
}
}
13 changes: 12 additions & 1 deletion libraries/classes/Controllers/Server/ServerPluginsController.php
Expand Up @@ -96,15 +96,26 @@ private function _setServerPlugins()
*/
private function _getPluginsHtml()
{
$plugins_type_clean = array();
$keys = array_keys($this->plugins);
foreach ($keys as $plugin_type) {
$plugins_type_clean[$plugin_type] = preg_replace(
'/[^a-z]/', '', mb_strtolower($plugin_type)
);
}
$html = '<div id="plugins_plugins">';
$html .= Template::get('server/plugins/section_links')
->render(array('plugins' => $this->plugins));
->render(array(
'plugins' => $this->plugins,
'plugins_type_clean' => $plugins_type_clean,
));

foreach ($this->plugins as $plugin_type => $plugin_list) {
$html .= Template::get('server/plugins/section')
->render(
array(
'plugin_type' => $plugin_type,
'plugin_type_clean' => $plugins_type_clean[$plugin_type],
'plugin_list' => $plugin_list,
)
);
Expand Down
29 changes: 26 additions & 3 deletions libraries/classes/Controllers/Table/TableSearchController.php
Expand Up @@ -525,6 +525,27 @@ public function displaySelectionFormAction($dataLabel = null)
)
)
);

$column_names = $this->_columnNames;
$column_types = $this->_columnTypes;
$types = array();
if ($this->_searchType == 'replace') {
$num_cols = count($column_names);
for ($i= 0; $i < $num_cols; $i++) {
$types[$column_names[$i]] = preg_replace('@\\(.*@s', '', $column_types[$i]);
}
}

$criteria_column_names = isset($_POST['criteriaColumnNames']) ? $_POST['criteriaColumnNames'] : null;
$keys = array();
for ($i= 0; $i < 4; $i++) {
if (isset($criteria_column_names[$i])) {
if ($criteria_column_names[$i] != 'pma_null') {
$keys[$criteria_column_names[$i]] = array_search($criteria_column_names[$i], $column_names);
}
}
}

$this->response->addHTML(
Template::get('table/search/selection_form')->render(array(
'search_type' => $this->_searchType,
Expand All @@ -533,11 +554,13 @@ public function displaySelectionFormAction($dataLabel = null)
'goto' => $goto,
'self' => $this,
'geom_column_flag' => $this->_geomColumnFlag,
'column_names' => $this->_columnNames,
'column_types' => $this->_columnTypes,
'column_names' => $column_names,
'column_types' => $column_types,
'types' => $types,
'column_collations' => $this->_columnCollations,
'data_label' => $dataLabel,
'criteria_column_names' => isset($_POST['criteriaColumnNames']) ? $_POST['criteriaColumnNames'] : null,
'keys' => $keys,
'criteria_column_names' => $criteria_column_names,
'criteria_column_types' => isset($_POST['criteriaColumnTypes']) ? $_POST['criteriaColumnTypes'] : null,
'sql_types' => $this->dbi->types,
'max_rows' => intval($GLOBALS['cfg']['MaxRows']),
Expand Down
58 changes: 58 additions & 0 deletions libraries/classes/Controllers/Table/TableStructureController.php
Expand Up @@ -1308,6 +1308,58 @@ function ($key, $val) {
$hideStructureActions = true;
}

// logic removed from Template
$rownum = 0;
$columns_list = array();
$attributes = array();
$displayed_field_names = array();
$displayed_field_names_replaced = array();
$row_comments = array();
$extracted_columnspecs = array();
foreach ($fields as $field) {
$rownum += 1;
$columns_list[] = $field['Field'];

$extracted_columnspecs[$rownum] = Util::extractColumnSpec($field['Type']);
$attributes[$rownum] = $extracted_columnspecs[$rownum]['attribute'];
if (strpos($field['Extra'], 'on update CURRENT_TIMESTAMP') !== false) {
$attributes[$rownum] = 'on update CURRENT_TIMESTAMP';
}

if (isset($field['Default'])) {
if ($field['Null'] == 'Yes') {
$field = array_merge($field, array('Default' => '<em>NULL</em>'));
}
} else {
$field = array_merge($field, array('Default' => $field['Default']));
}

$displayed_field_names[$rownum] = $field['Field'];
$row_comments[$rownum] = '';

if (isset($comments_map[$field['Field']])) {
$displayed_field_names[$rownum] = '<span ' .
'class="commented_column" title="' . $comments_map[$field['Field']] .
'">' . htmlspecialchars($field['Field']) . "</span>";
$row_comments[$rownum] = $comments_map[$field['Field']];
}

if ($primary_index && $primary_index->hasColumn($field['Field'])) {
$displayed_field_names[$rownum] = $displayed_field_names[$rownum] .
Util::getImage('b_primary', __('Primary'));
}

if (in_array($field['Field'], $columns_with_index)) {
$displayed_field_names[$rownum] = $displayed_field_names[$rownum] .
Util::getImage('b_key', __('Index'));
}
$displayed_field_names_replaced[$rownum] = preg_replace(
'/[\\x00-\\x1F]/',
'&#x2051;',
$displayed_field_names[$rownum]
);
}

return Template::get('table/structure/display_structure')->render(
array(
'hide_structure_actions' => $hideStructureActions,
Expand All @@ -1325,6 +1377,7 @@ function ($key, $val) {
'columns_list' => $columns_list,
'table_stats' => isset($tablestats) ? $tablestats : null,
'fields' => $fields,
'extracted_columnspecs' => $extracted_columnspecs,
'columns_with_index' => $columns_with_index,
'central_list' => $central_list,
'comments_map' => $comments_map,
Expand All @@ -1340,6 +1393,11 @@ function ($key, $val) {
'is_active' => Tracker::isActive(),
'have_partitioning' => Partition::havePartitioning(),
'partition_names' => Partition::getPartitionNames($this->db, $this->table),
'columns_list' => $columns_list,
'attributes' => $attributes,
'displayed_field_names' => $displayed_field_names,
'displayed_field_names_replaced' => $displayed_field_names_replaced,
'row_comments' => $row_comments,
)
);
}
Expand Down
31 changes: 29 additions & 2 deletions libraries/classes/Database/Designer.php
Expand Up @@ -212,7 +212,7 @@ private function getSideMenuParamsArray()

$result = $this->dbi->fetchSingleRow($query);

$params = json_decode($result['settings_data'], true);
$params = json_decode((string)$result['settings_data'], true);
}

return $params;
Expand Down Expand Up @@ -328,6 +328,32 @@ public function getDatabaseTables(
array $tables_all_keys,
array $tables_pk_or_unique_keys
) {
$table_names = $GLOBALS['designer']['TABLE_NAME'];
$columns_type = array();
foreach ($table_names as $table_name) {
$limit = count($tab_column[$table_name]['COLUMN_ID']);
for ($j = 0; $j < $limit; $j++) {
$table_column_name = $table_name . '.' . $tab_column[$table_name]['COLUMN_NAME'][$j];
if (isset($tables_pk_or_unique_keys[$table_column_name])) {
$columns_type[$table_column_name] = 'designer/FieldKey_small';
} else {
$columns_type[$table_column_name] = 'designer/Field_small';
if (strstr($tab_column[$table_name]['TYPE'][$j], 'char')
|| strstr($tab_column[$table_name]['TYPE'][$j], 'text')) {
$columns_type[$table_column_name] .= '_char';
} elseif (strstr($tab_column[$table_name]['TYPE'][$j], 'int')
|| strstr($tab_column[$table_name]['TYPE'][$j], 'float')
|| strstr($tab_column[$table_name]['TYPE'][$j], 'double')
|| strstr($tab_column[$table_name]['TYPE'][$j], 'decimal')) {
$columns_type[$table_column_name] .= '_int';
} elseif (strstr($tab_column[$table_name]['TYPE'][$j], 'date')
|| strstr($tab_column[$table_name]['TYPE'][$j], 'time')
|| strstr($tab_column[$table_name]['TYPE'][$j], 'year')) {
$columns_type[$table_column_name] .= '_date';
}
}
}
}
return Template::get('database/designer/database_tables')->render([
'db' => $GLOBALS['db'],
'get_db' => $_GET['db'],
Expand All @@ -337,13 +363,14 @@ public function getDatabaseTables(
'tab_column' => $tab_column,
'tables_all_keys' => $tables_all_keys,
'tables_pk_or_unique_keys' => $tables_pk_or_unique_keys,
'table_names' => $GLOBALS['designer']['TABLE_NAME'],
'table_names' => $table_names,
'table_names_url' => $GLOBALS['designer_url']['TABLE_NAME'],
'table_names_small' => $GLOBALS['designer']['TABLE_NAME_SMALL'],
'table_names_small_url' => $GLOBALS['designer_url']['TABLE_NAME_SMALL'],
'table_names_small_out' => $GLOBALS['designer_out']['TABLE_NAME_SMALL'],
'table_types' => $GLOBALS['designer']['TABLE_TYPE'],
'owner_out' => $GLOBALS['designer_out']['OWNER'],
'columns_type' => $columns_type,
'theme' => $GLOBALS['PMA_Theme'],
]);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Display/Results.php
Expand Up @@ -4448,7 +4448,7 @@ private function _getSortedColumnMessage(

$column_for_first_row = mb_strtoupper(
mb_substr(
$column_for_first_row, 0, $GLOBALS['cfg']['LimitChars']
(string) $column_for_first_row, 0, $GLOBALS['cfg']['LimitChars']
) . '...'
);

Expand Down
2 changes: 0 additions & 2 deletions libraries/classes/Template.php
Expand Up @@ -15,7 +15,6 @@
use PhpMyAdmin\Twig\IndexExtension;
use PhpMyAdmin\Twig\MessageExtension;
use PhpMyAdmin\Twig\PartitionExtension;
use PhpMyAdmin\Twig\PhpFunctionsExtension;
use PhpMyAdmin\Twig\PluginsExtension;
use PhpMyAdmin\Twig\RelationExtension;
use PhpMyAdmin\Twig\SanitizeExtension;
Expand Down Expand Up @@ -77,7 +76,6 @@ protected function __construct($name)
$twig->addExtension(new IndexExtension());
$twig->addExtension(new MessageExtension());
$twig->addExtension(new PartitionExtension());
$twig->addExtension(new PhpFunctionsExtension());
$twig->addExtension(new PluginsExtension());
$twig->addExtension(new RelationExtension());
$twig->addExtension(new SanitizeExtension());
Expand Down
40 changes: 0 additions & 40 deletions libraries/classes/Twig/PhpFunctionsExtension.php

This file was deleted.