diff --git a/libraries/classes/Controllers/Server/ServerDatabasesController.php b/libraries/classes/Controllers/Server/ServerDatabasesController.php index a1c372605d..5877180ada 100644 --- a/libraries/classes/Controllers/Server/ServerDatabasesController.php +++ b/libraries/classes/Controllers/Server/ServerDatabasesController.php @@ -1,6 +1,5 @@ dbi); - $checkUserPrivileges->getPrivileges(); - - $response = Response::getInstance(); - - if (isset($_POST['drop_selected_dbs']) - && $response->isAjax() - && ($this->dbi->isSuperuser() || $GLOBALS['cfg']['AllowUserDropDatabase']) - ) { - $this->dropDatabasesAction(); - return; - } + global $cfg, $server, $dblist, $is_create_db_priv; + global $replication_info, $db_to_create, $pmaThemeImage, $text_dir; include_once ROOT_PATH . 'libraries/replication.inc.php'; - - if (isset($_POST['new_db']) - && $response->isAjax() - ) { - $this->createDatabaseAction(); - return; - } - include_once ROOT_PATH . 'libraries/server_common.inc.php'; - $header = $this->response->getHeader(); - $scripts = $header->getScripts(); - $scripts->addFile('server_databases.js'); - - $this->_setSortDetails(); - $this->_dbstats = empty($_REQUEST['dbstats']) ? false : true; - $this->_pos = empty($_REQUEST['pos']) ? 0 : (int) $_REQUEST['pos']; + $this->setSortDetails($params['sort_by'], $params['sort_order']); + $this->hasStatistics = ! empty($params['statistics']); + $this->position = ! empty($params['pos']) ? (int) $params['pos'] : 0; /** * Gets the databases list */ - if ($GLOBALS['server'] > 0) { - $this->_databases = $this->dbi->getDatabasesFull( + if ($server > 0) { + $this->databases = $this->dbi->getDatabasesFull( null, - $this->_dbstats, + $this->hasStatistics, DatabaseInterface::CONNECT_USER, - $this->_sort_by, - $this->_sort_order, - $this->_pos, + $this->sortBy, + $this->sortOrder, + $this->position, true ); - $this->_database_count = count($GLOBALS['dblist']->databases); - } else { - $this->_database_count = 0; + $this->databaseCount = count($dblist->databases); } - $_url_params = [ - 'pos' => $this->_pos, - 'dbstats' => $this->_dbstats, - 'sort_by' => $this->_sort_by, - 'sort_order' => $this->_sort_order, + $urlParams = [ + 'statistics' => $this->hasStatistics, + 'pos' => $this->position, + 'sort_by' => $this->sortBy, + 'sort_order' => $this->sortOrder, ]; - $column_order = null; - $first_database = null; + $databases = $this->getDatabases($replication_types ?? []); - if ($this->_database_count > 0 && ! empty($this->_databases)) { - $first_database = reset($this->_databases); - // table col order - $column_order = $this->_getColumnOrder(); - $databases = $this->_getHtmlForDatabases($replication_types); + $collationDropdownBox = ''; + if ($cfg['ShowCreateDb'] && $is_create_db_priv) { + $collationDropdownBox = Charsets::getCollationDropdownBox( + $this->dbi, + $cfg['Server']['DisableIS'], + 'db_collation', + null, + $this->dbi->getServerCollation(), + true + ); } - $this->response->addHTML($this->template->render('server/databases/index', [ - 'show_create_db' => $GLOBALS['cfg']['ShowCreateDb'], - 'is_create_db_priv' => $GLOBALS['is_create_db_priv'], - 'dbstats' => $this->_dbstats, - 'db_to_create' => $GLOBALS['db_to_create'], - 'databases' => isset($databases) ? $databases : null, - 'dbi' => $this->dbi, - 'disable_is' => $GLOBALS['cfg']['Server']['DisableIS'], - 'database_count' => $this->_database_count, - 'pos' => $this->_pos, - 'url_params' => $_url_params, - 'max_db_list' => $GLOBALS['cfg']['MaxDbList'], - 'sort_by' => $this->_sort_by, - 'sort_order' => $this->_sort_order, - 'column_order' => $column_order, - 'first_database' => $first_database, - 'master_replication' => $GLOBALS['replication_info']['master']['status'], - 'slave_replication' => $GLOBALS['replication_info']['slave']['status'], - 'is_superuser' => $this->dbi->isSuperuser(), - 'allow_user_drop_database' => $GLOBALS['cfg']['AllowUserDropDatabase'], - ])); + $headerStatistics = $this->getStatisticsColumns(); + + return $this->template->render('server/databases/index', [ + 'is_create_database_shown' => $cfg['ShowCreateDb'], + 'has_create_database_privileges' => $is_create_db_priv, + 'has_statistics' => $this->hasStatistics, + 'database_to_create' => $db_to_create, + 'databases' => $databases['databases'], + 'total_statistics' => $databases['total_statistics'], + 'header_statistics' => $headerStatistics, + 'collation_dropdown_box' => $collationDropdownBox, + 'database_count' => $this->databaseCount, + 'pos' => $this->position, + 'url_params' => $urlParams, + 'max_db_list' => $cfg['MaxDbList'], + 'has_master_replication' => $replication_info['master']['status'], + 'has_slave_replication' => $replication_info['slave']['status'], + 'is_drop_allowed' => $this->dbi->isSuperuser() || $cfg['AllowUserDropDatabase'], + 'default_tab_database' => $cfg['DefaultTabDatabase'], + 'pma_theme_image' => $pmaThemeImage, + 'text_dir' => $text_dir, + ]); } /** * Handles creating a new database * - * @return void + * @param array $params Request parameters + * + * @return array JSON */ - public function createDatabaseAction() + public function createDatabaseAction(array $params): array { + global $cfg, $db; + /** * Builds and executes the db creation sql query */ - $sql_query = 'CREATE DATABASE ' . Util::backquote($_POST['new_db']); - if (! empty($_POST['db_collation'])) { - list($db_charset) = explode('_', $_POST['db_collation']); + $sqlQuery = 'CREATE DATABASE ' . Util::backquote($params['new_db']); + if (! empty($params['db_collation'])) { + list($databaseCharset) = explode('_', $params['db_collation']); $charsets = Charsets::getMySQLCharsets( $this->dbi, - $GLOBALS['cfg']['Server']['DisableIS'] + $cfg['Server']['DisableIS'] ); $collations = Charsets::getMySQLCollations( $this->dbi, - $GLOBALS['cfg']['Server']['DisableIS'] + $cfg['Server']['DisableIS'] ); - if (in_array($db_charset, $charsets) - && in_array($_POST['db_collation'], $collations[$db_charset]) + if (in_array($databaseCharset, $charsets) + && in_array($params['db_collation'], $collations[$databaseCharset]) ) { - $sql_query .= ' DEFAULT' - . Util::getCharsetQueryPart($_POST['db_collation']); + $sqlQuery .= ' DEFAULT' + . Util::getCharsetQueryPart($params['db_collation']); } } - $sql_query .= ';'; + $sqlQuery .= ';'; - $result = $this->dbi->tryQuery($sql_query); + $result = $this->dbi->tryQuery($sqlQuery); if (! $result) { // avoid displaying the not-created db name in header or navi panel - $GLOBALS['db'] = ''; + $db = ''; $message = Message::rawError($this->dbi->getError()); + $json = ['message' => $message]; + $this->response->setRequestStatus(false); - $this->response->addJSON('message', $message); } else { - $GLOBALS['db'] = $_POST['new_db']; + $db = $params['new_db']; $message = Message::success(__('Database %1$s has been created.')); - $message->addParam($_POST['new_db']); - $this->response->addJSON('message', $message); - $this->response->addJSON( - 'sql_query', - Util::getMessage(null, $sql_query, 'success') - ); + $message->addParam($params['new_db']); - $this->response->addJSON( - 'url_query', - Util::getScriptNameForOption( - $GLOBALS['cfg']['DefaultTabDatabase'], + $json = [ + 'message' => $message, + 'sql_query' => Util::getMessage(null, $sqlQuery, 'success'), + 'url_query' => Util::getScriptNameForOption( + $cfg['DefaultTabDatabase'], 'database' - ) - . Url::getCommon(['db' => $_POST['new_db']]) - ); + ) . Url::getCommon(['db' => $params['new_db']]), + ]; } + + return $json; } /** * Handles dropping multiple databases * - * @return void + * @param array $params Request parameters + * + * @return array JSON */ - public function dropDatabasesAction() + public function dropDatabasesAction(array $params): array { - if (! isset($_POST['selected_dbs'])) { + global $submit_mult, $mult_btn, $selected; + + if (! isset($params['selected_dbs'])) { $message = Message::error(__('No databases selected.')); } else { $action = 'server_databases.php'; $err_url = $action . Url::getCommon(); - $GLOBALS['submit_mult'] = 'drop_db'; - $GLOBALS['mult_btn'] = __('Yes'); + $submit_mult = 'drop_db'; + $mult_btn = __('Yes'); include ROOT_PATH . 'libraries/mult_submits.inc.php'; if (empty($message)) { // no error message - $number_of_databases = count($selected); + $numberOfDatabases = count($selected); $message = Message::success( _ngettext( '%1$d database has been dropped successfully.', '%1$d databases have been dropped successfully.', - $number_of_databases + $numberOfDatabases ) ); - $message->addParam($number_of_databases); + $message->addParam($numberOfDatabases); } } + $json = []; if ($message instanceof Message) { + $json = ['message' => $message]; $this->response->setRequestStatus($message->isSuccess()); - $this->response->addJSON('message', $message); } + + return $json; } /** - * Extracts parameters $sort_order and $sort_by + * Extracts parameters sort order and sort by + * + * @param string|null $sortBy sort by + * @param string|null $sortOrder sort order * * @return void */ - private function _setSortDetails() + private function setSortDetails(?string $sortBy, ?string $sortOrder): void { - if (empty($_REQUEST['sort_by'])) { - $this->_sort_by = 'SCHEMA_NAME'; + if (empty($sortBy)) { + $this->sortBy = 'SCHEMA_NAME'; } else { - $sort_by_whitelist = [ + $sortByWhitelist = [ 'SCHEMA_NAME', 'DEFAULT_COLLATION_NAME', 'SCHEMA_TABLES', @@ -266,262 +263,135 @@ class ServerDatabasesController extends Controller 'SCHEMA_LENGTH', 'SCHEMA_DATA_FREE', ]; - if (in_array($_REQUEST['sort_by'], $sort_by_whitelist)) { - $this->_sort_by = $_REQUEST['sort_by']; - } else { - $this->_sort_by = 'SCHEMA_NAME'; + $this->sortBy = 'SCHEMA_NAME'; + if (in_array($sortBy, $sortByWhitelist)) { + $this->sortBy = $sortBy; } } - if (isset($_REQUEST['sort_order']) - && mb_strtolower($_REQUEST['sort_order']) == 'desc' + $this->sortOrder = 'asc'; + if (isset($sortOrder) + && mb_strtolower($sortOrder) === 'desc' ) { - $this->_sort_order = 'desc'; - } else { - $this->_sort_order = 'asc'; + $this->sortOrder = 'desc'; } } /** - * Returns the html for Database List + * Returns database list * - * @param array $replication_types replication types - * - * @return string - */ - private function _getHtmlForDatabases(array $replication_types) - { - $first_database = reset($this->_databases); - // table col order - $column_order = $this->_getColumnOrder(); - $dbColumnOrders = []; - - // calculate aggregate stats to display in footer - foreach ($this->_databases as $current) { - $dbColumnOrders[$current['SCHEMA_NAME']] = $this->_getColumnOrder(); - foreach ($column_order as $stat_name => $stat) { - if (array_key_exists($stat_name, $current) - && is_numeric($stat['footer']) - ) { - $column_order[$stat_name]['footer'] += $current[$stat_name]; - $dbColumnOrders[$current['SCHEMA_NAME']][$stat_name]['footer'] = $current[$stat_name]; - } - } - } - - $values = []; - $units = []; - 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 = [ - 'pos' => $this->_pos, - 'dbstats' => $this->_dbstats, - 'sort_by' => $this->_sort_by, - 'sort_order' => $this->_sort_order, - ]; - - $html = $this->_getHtmlForTableBody($dbColumnOrders, $replication_types); - - $html .= $this->template->render('server/databases/databases_footer', [ - 'column_order' => $column_order, - 'first_database' => $first_database, - 'master_replication' => $GLOBALS['replication_info']['master']['status'], - 'slave_replication' => $GLOBALS['replication_info']['slave']['status'], - 'database_count' => $this->_database_count, - 'is_superuser' => $this->dbi->isSuperuser(), - 'allow_user_drop_database' => $GLOBALS['cfg']['AllowUserDropDatabase'], - 'pma_theme_image' => $GLOBALS['pmaThemeImage'], - 'text_dir' => $GLOBALS['text_dir'], - 'dbstats' => $this->_dbstats, - 'values' => $values, - 'units' => $units, - ]); - - return $html; - } - - /** - * Prepares the $column_order array + * @param array $replicationTypes replication types * * @return array */ - private function _getColumnOrder() + private function getDatabases(array $replicationTypes): array { - $column_order = []; - $column_order['DEFAULT_COLLATION_NAME'] = [ - 'disp_name' => __('Collation'), - 'description_function' => [ - Charsets::class, - 'getCollationDescr', - ], - 'format' => 'string', - 'footer' => '', - ]; - $column_order['SCHEMA_TABLES'] = [ - 'disp_name' => __('Tables'), - 'format' => 'number', - 'footer' => 0, - ]; - $column_order['SCHEMA_TABLE_ROWS'] = [ - 'disp_name' => __('Rows'), - 'format' => 'number', - 'footer' => 0, - ]; - $column_order['SCHEMA_DATA_LENGTH'] = [ - 'disp_name' => __('Data'), - 'format' => 'byte', - 'footer' => 0, - ]; - $column_order['SCHEMA_INDEX_LENGTH'] = [ - 'disp_name' => __('Indexes'), - 'format' => 'byte', - 'footer' => 0, - ]; - $column_order['SCHEMA_LENGTH'] = [ - 'disp_name' => __('Total'), - 'format' => 'byte', - 'footer' => 0, - ]; - $column_order['SCHEMA_DATA_FREE'] = [ - 'disp_name' => __('Overhead'), - 'format' => 'byte', - 'footer' => 0, - ]; + global $replication_info; - return $column_order; - } - - /** - * Returns the html for Database List - * - * @param array $dbColumnOrders databases column order - * @param array $replicationTypes replication types - * - * @return string - */ - private function _getHtmlForTableBody(array $dbColumnOrders, array $replicationTypes) - { - $html = '' . "\n"; - - foreach ($this->_databases as $current) { - $tr_class = ' db-row'; - if ($this->dbi->isSystemSchema($current['SCHEMA_NAME'], true)) { - $tr_class .= ' noclick'; - } - - $generated_html = $this->_buildHtmlForDb( - $current, - $dbColumnOrders[$current['SCHEMA_NAME']], - $replicationTypes, - $GLOBALS['replication_info'], - $tr_class - ); - $html .= $generated_html; - } // end foreach ($this->_databases as $key => $current) - $html .= ''; - - return $html; - } - - /** - * Builds the HTML for one database to display in the list - * of databases from server_databases.php - * - * @param array $current current database - * @param array $column_order column order - * @param array $replication_types replication types - * @param array $replication_info replication info - * @param string $tr_class HTMl class for the row - * - * @return string - */ - public function _buildHtmlForDb( - array $current, - array $column_order, - array $replication_types, - array $replication_info, - $tr_class = '' - ) { - $master_replication = $slave_replication = ''; - foreach ($replication_types as $type) { - if ($replication_info[$type]['status']) { - $out = ''; - $key = array_search( - $current["SCHEMA_NAME"], - $replication_info[$type]['Ignore_DB'] - ); - if (strlen((string) $key) > 0) { - $out = Util::getIcon( - 's_cancel', - __('Not replicated') - ); - } else { + $databases = []; + $totalStatistics = $this->getStatisticsColumns(); + foreach ($this->databases as $database) { + $replication = [ + 'master' => [ + 'status' => $replication_info['master']['status'], + ], + 'slave' => [ + 'status' => $replication_info['slave']['status'], + ], + ]; + foreach ($replicationTypes as $type) { + if ($replication_info[$type]['status']) { $key = array_search( - $current["SCHEMA_NAME"], - $replication_info[$type]['Do_DB'] + $database["SCHEMA_NAME"], + $replication_info[$type]['Ignore_DB'] ); - - if (strlen((string) $key) > 0 - || count($replication_info[$type]['Do_DB']) == 0 - ) { - // if ($key != null) did not work for index "0" - $out = Util::getIcon( - 's_success', - __('Replicated') + if (strlen((string) $key) > 0) { + $replication[$type]['is_replicated'] = false; + } else { + $key = array_search( + $database["SCHEMA_NAME"], + $replication_info[$type]['Do_DB'] ); + + if (strlen((string) $key) > 0 + || count($replication_info[$type]['Do_DB']) == 0 + ) { + // if ($key != null) did not work for index "0" + $replication[$type]['is_replicated'] = true; + } } } + } - if ($type == 'master') { - $master_replication = $out; - } elseif ($type == 'slave') { - $slave_replication = $out; + $statistics = $this->getStatisticsColumns(); + if ($this->hasStatistics) { + foreach (array_keys($statistics) as $key) { + $statistics[$key]['raw'] = $database[$key] ?? null; + $totalStatistics[$key]['raw'] += (int) $database[$key] ?? 0; } } + + $databases[] = [ + 'name' => $database['SCHEMA_NAME'], + 'collation' => [ + 'name' => $database['DEFAULT_COLLATION_NAME'], + 'description' => Charsets::getCollationDescr( + $database['DEFAULT_COLLATION_NAME'] + ), + ], + 'statistics' => $statistics, + 'replication' => $replication, + 'is_system_schema' => $this->dbi->isSystemSchema( + $database['SCHEMA_NAME'], + true + ), + ]; } - $values = []; - $units = []; - 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 [ + 'databases' => $databases, + 'total_statistics' => $totalStatistics, + ]; + } - return $this->template->render('server/databases/table_row', [ - 'current' => $current, - 'tr_class' => $tr_class, - 'column_order' => $column_order, - 'master_replication_status' => $GLOBALS['replication_info']['master']['status'], - 'master_replication' => $master_replication, - 'slave_replication_status' => $GLOBALS['replication_info']['slave']['status'], - 'slave_replication' => $slave_replication, - 'is_superuser' => $this->dbi->isSuperuser(), - '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, - ]); + /** + * Prepares the statistics columns + * + * @return array + */ + private function getStatisticsColumns(): array + { + return [ + 'SCHEMA_TABLES' => [ + 'title' => __('Tables'), + 'format' => 'number', + 'raw' => 0, + ], + 'SCHEMA_TABLE_ROWS' => [ + 'title' => __('Rows'), + 'format' => 'number', + 'raw' => 0, + ], + 'SCHEMA_DATA_LENGTH' => [ + 'title' => __('Data'), + 'format' => 'byte', + 'raw' => 0, + ], + 'SCHEMA_INDEX_LENGTH' => [ + 'title' => __('Indexes'), + 'format' => 'byte', + 'raw' => 0, + ], + 'SCHEMA_LENGTH' => [ + 'title' => __('Total'), + 'format' => 'byte', + 'raw' => 0, + ], + 'SCHEMA_DATA_FREE' => [ + 'title' => __('Overhead'), + 'format' => 'byte', + 'raw' => 0, + ], + ]; } } diff --git a/phpstan.neon b/phpstan.neon index 728a817db9..aa5fdbf12c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -24,7 +24,6 @@ parameters: - '#GisGeomTestCase::\$object#' - '#Undefined variable: \$array#' - '#Undefined variable: \$(cfg|db|table|url_query|text_dir|server|pmaThemeImage|action|sql_query|lang|export_type|err_url|collation_connection|filename_template|transform_key|cn|goto|partitionDetails|token_mismatch|auth_plugin|username|hostname|display_query|where_clause)#'#Others - - '#Undefined variable: \$(replication_types|selected)#'#Controllers/Server/ServerDatabasesController.php - '#Undefined variable: \$(dir|error_header|error_message)#'#error.inc.php - '#Undefined variable: \$_PMA_RTE#'#rte/rte_main.inc.php - '#Undefined variable: \$(unsaved_values|is_upload)#'#tbl_change.php @@ -40,7 +39,6 @@ parameters: - '#Variable \$time might not be defined#'#DatabaseInterface.php - '#Variable \$contentPath in isset\(\) always exists and is not nullable#'#DatabaseInterface.php - '#Variable \$server_info might not be defined#'#DatabaseInterface.php - # - '#Variable \$single_table always exists and is not nullable#'#Display/ExportTest.php - '#Function mysqli_get_client_info invoked with 0 parameters, 1 required#'#libraries/classes/Dbi/DbiMysqli.php - '#Variable \$default_fk_check_value might not be defined#'#libraries/mult_submits.inc.php - '#Variable \$http_response_header in isset\(\) always exists and is not nullable#' diff --git a/server_databases.php b/server_databases.php index 743ed140c6..41a7b9780f 100644 --- a/server_databases.php +++ b/server_databases.php @@ -7,6 +7,7 @@ */ declare(strict_types=1); +use PhpMyAdmin\CheckUserPrivileges; use PhpMyAdmin\Controllers\Server\ServerDatabasesController; use PhpMyAdmin\Di\Container; use PhpMyAdmin\Response; @@ -33,4 +34,37 @@ $controller = $container->get( 'ServerDatabasesController', [] ); -$controller->indexAction(); + +/** @var Response $response */ +$response = $container->get('response'); + +$checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']); +$checkUserPrivileges->getPrivileges(); + +if (isset($_POST['drop_selected_dbs']) + && $response->isAjax() + && ($GLOBALS['dbi']->isSuperuser() || $GLOBALS['cfg']['AllowUserDropDatabase']) +) { + $response->addJSON($controller->dropDatabasesAction([ + 'drop_selected_dbs' => $_POST['drop_selected_dbs'], + 'selected_dbs' => $_POST['selected_dbs'] ?? null, + ])); +} elseif (isset($_POST['new_db']) + && $response->isAjax() +) { + $response->addJSON($controller->createDatabaseAction([ + 'new_db' => $_POST['new_db'], + 'db_collation' => $_POST['db_collation'] ?? null, + ])); +} else { + $header = $response->getHeader(); + $scripts = $header->getScripts(); + $scripts->addFile('server_databases.js'); + + $response->addHTML($controller->indexAction([ + 'statistics' => $_REQUEST['statistics'] ?? null, + 'pos' => $_REQUEST['pos'] ?? null, + 'sort_by' => $_REQUEST['sort_by'] ?? null, + 'sort_order' => $_REQUEST['sort_order'] ?? null, + ])); +} diff --git a/templates/server/databases/databases_footer.twig b/templates/server/databases/databases_footer.twig deleted file mode 100644 index 6d2ae47bdb..0000000000 --- a/templates/server/databases/databases_footer.twig +++ /dev/null @@ -1,71 +0,0 @@ - - - {% if is_superuser or allow_user_drop_database %} - - {% endif %} - - {% trans 'Total' %}: - {{- database_count -}} - - - {% for stat_name, stat in column_order if stat_name in first_database|keys %} - - {% if stat['description_function'] is defined %} - - {{ values[stat_name] }} - - {% else %} - {{ values[stat_name] }} - {% endif %} - - {% if stat['format'] is same as('byte') %} - {{ units[stat_name] }} - {% endif %} - {% endfor %} - {% if master_replication %} - - {% endif %} - {% if slave_replication %} - - {% endif %} - - - - - - -{# Footer buttons #} -{% if is_superuser or allow_user_drop_database %} - {% include 'select_all.twig' with { - 'pma_theme_image': pma_theme_image, - 'text_dir': text_dir, - 'form_name': 'dbStatsForm' - } only %} - - {{ get_button_or_image( - '', - 'mult_submit ajax', - 'Drop'|trans, - 'b_deltbl' - ) }} -{% endif %} - -{# Enable statistics #} -{% if dbstats is empty %} - {{ 'Note: Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server.'|trans|notice }} - - {% set content %} - {% trans 'Enable statistics' %} - {% endset %} - {% set items = [{ - 'content': content, - 'class': 'li_switch_dbstats', - 'url': { - 'href': 'server_databases.php' ~ get_common({'dbstats': '1'}), - 'title': 'Enable statistics'|trans - } - }] %} - {% include 'list/unordered.twig' with {'items': items} only %} -{% endif %} - - diff --git a/templates/server/databases/index.twig b/templates/server/databases/index.twig index c8d521d03f..4f748a3a4d 100644 --- a/templates/server/databases/index.twig +++ b/templates/server/databases/index.twig @@ -1,123 +1,317 @@ -{# Displays the sub-page heading #} -{% include 'server/sub_page_header.twig' with { - 'type': dbstats ? 'database_statistics' : 'databases' -} only %} +

+ {{ get_image('s_db') }} + {% if has_statistics %} + {% trans 'Databases statistics' %} + {% else %} + {% trans 'Databases' %} + {% endif %} +

-{# Displays For Create database #} -{% if show_create_db %} -