Use the router for database structure page
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
ffdc2cf7bf
commit
682e7a160e
@ -293,7 +293,7 @@ if ($import_type == 'table') {
|
||||
if (strlen($table) > 0 && strlen($db) > 0) {
|
||||
$goto = 'tbl_structure.php';
|
||||
} elseif (strlen($db) > 0) {
|
||||
$goto = 'db_structure.php';
|
||||
$goto = Url::getFromRoute('/database/structure');
|
||||
} else {
|
||||
$goto = 'server_sql.php';
|
||||
}
|
||||
|
||||
@ -25,6 +25,9 @@ if (isset($_GET['route']) || isset($_POST['route'])) {
|
||||
require_once ROOT_PATH . 'libraries/entry_points/home.php';
|
||||
});
|
||||
$routes->addGroup('/database', function (RouteCollector $routes) {
|
||||
$routes->addRoute(['GET', 'POST'], '/structure', function () {
|
||||
require_once ROOT_PATH . 'libraries/entry_points/database/structure.php';
|
||||
});
|
||||
$routes->addRoute(['GET', 'POST'], '/tracking', function () {
|
||||
require_once ROOT_PATH . 'libraries/entry_points/database/tracking.php';
|
||||
});
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
var DatabaseStructure = {};
|
||||
|
||||
/**
|
||||
* AJAX scripts for db_structure.php
|
||||
* AJAX scripts for /database/structure
|
||||
*
|
||||
* Actions ajaxified here:
|
||||
* Drop Database
|
||||
@ -245,7 +245,7 @@ AJAX.registerOnload('database/structure.js', function () {
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'db_structure.php',
|
||||
url: 'index.php?route=/database/structure',
|
||||
dataType: 'html',
|
||||
data: formData
|
||||
|
||||
|
||||
@ -2845,7 +2845,7 @@ AJAX.registerTeardown('functions.js', function () {
|
||||
|
||||
/**
|
||||
* jQuery coding for 'Create Table'. Used on db_operations.php,
|
||||
* db_structure.php and /database/tracking (i.e., wherever
|
||||
* /database/structure and /database/tracking (i.e., wherever
|
||||
* PhpMyAdmin\Display\CreateTable is used)
|
||||
*
|
||||
* Attach Ajax Event handlers for Create Table
|
||||
@ -2941,7 +2941,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
}
|
||||
var tableStructureUrl = 'tbl_structure.php?server=' + data.params.server +
|
||||
argsep + 'db=' + data.params.db + argsep + 'token=' + data.params.token +
|
||||
argsep + 'goto=db_structure.php' + argsep + 'table=' + data.params.table + '';
|
||||
argsep + 'goto=' + encodeURIComponent('index.php?route=/database/structure') + argsep + 'table=' + data.params.table + '';
|
||||
$.get(tableStructureUrl, params12, AJAX.responseHandler);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(
|
||||
|
||||
@ -745,7 +745,7 @@ $js_messages['strConsoleDebugShowArgs'] = __('Show arguments');
|
||||
$js_messages['strConsoleDebugHideArgs'] = __('Hide arguments');
|
||||
$js_messages['strConsoleDebugTimeTaken'] = __('Time taken:');
|
||||
$js_messages['strNoLocalStorage'] = __('There was a problem accessing your browser storage, some features may not work properly for you. It is likely that the browser doesn\'t support storage or the quota limit has been reached. In Firefox, corrupted storage can also cause such a problem, clearing your "Offline Website Data" might help. In Safari, such problem is commonly caused by "Private Mode Browsing".');
|
||||
// For modals in db_structure.php
|
||||
// For modals in /database/structure
|
||||
$js_messages['strCopyTablesTo'] = __('Copy tables to');
|
||||
$js_messages['strAddPrefix'] = __('Add table prefix');
|
||||
$js_messages['strReplacePrefix'] = __('Replace table with prefix');
|
||||
|
||||
@ -137,11 +137,11 @@ class StructureController extends AbstractController
|
||||
// If there are no tables, the user is redirected to the last page
|
||||
// having any.
|
||||
if ($this->totalNumTables > 0 && $this->position > $this->totalNumTables) {
|
||||
$uri = './db_structure.php' . Url::getCommonRaw([
|
||||
$uri = './index.php?route=/database/structure' . Url::getCommonRaw([
|
||||
'db' => $this->db,
|
||||
'pos' => max(0, $this->totalNumTables - $cfg['MaxTableList']),
|
||||
'reload' => 1,
|
||||
]);
|
||||
], '&');
|
||||
Core::sendHeaderLocation($uri);
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ class StructureController extends AbstractController
|
||||
$this->totalNumTables,
|
||||
$this->position,
|
||||
$urlParams,
|
||||
'db_structure.php',
|
||||
Url::getFromRoute('/database/structure'),
|
||||
'frame_content',
|
||||
$cfg['MaxTableList']
|
||||
);
|
||||
@ -313,14 +313,13 @@ class StructureController extends AbstractController
|
||||
*/
|
||||
public function multiSubmitAction(): void
|
||||
{
|
||||
$action = 'db_structure.php';
|
||||
$err_url = 'db_structure.php' . Url::getCommon(
|
||||
['db' => $this->db]
|
||||
);
|
||||
// for mult_submits.inc.php
|
||||
$action = Url::getFromRoute('/database/structure');
|
||||
$err_url = Url::getFromRoute('/database/structure', ['db' => $this->db]);
|
||||
|
||||
// see bug #2794840; in this case, code path is:
|
||||
// db_structure.php -> libraries/mult_submits.inc.php -> sql.php
|
||||
// -> db_structure.php and if we got an error on the multi submit,
|
||||
// /database/structure -> libraries/mult_submits.inc.php -> sql.php
|
||||
// -> /database/structure and if we got an error on the multi submit,
|
||||
// we must display it here and not call again mult_submits.inc.php
|
||||
if (! isset($_POST['error']) || false === $_POST['error']) {
|
||||
include ROOT_PATH . 'libraries/mult_submits.inc.php';
|
||||
@ -617,7 +616,7 @@ class StructureController extends AbstractController
|
||||
'db_is_system_schema' => $this->dbIsSystemSchema,
|
||||
'replication' => $GLOBALS['replication_info']['slave']['status'],
|
||||
'properties_num_columns' => $GLOBALS['cfg']['PropertiesNumColumns'],
|
||||
'is_show_stats' => $GLOBALS['is_show_stats'],
|
||||
'is_show_stats' => $this->isShowStats,
|
||||
'show_charset' => $GLOBALS['cfg']['ShowDbStructureCharset'],
|
||||
'show_comment' => $GLOBALS['cfg']['ShowDbStructureComment'],
|
||||
'show_creation' => $GLOBALS['cfg']['ShowDbStructureCreation'],
|
||||
|
||||
@ -33,7 +33,6 @@ class Core
|
||||
'db_importdocsql.php',
|
||||
'db_multi_table_query.php',
|
||||
'db_qbe.php',
|
||||
'db_structure.php',
|
||||
'db_import.php',
|
||||
'db_operations.php',
|
||||
'db_search.php',
|
||||
|
||||
@ -9,18 +9,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin;
|
||||
|
||||
use PhpMyAdmin\Encoding;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\SqlParser\Parser;
|
||||
use PhpMyAdmin\SqlParser\Statements\DeleteStatement;
|
||||
use PhpMyAdmin\SqlParser\Statements\InsertStatement;
|
||||
use PhpMyAdmin\SqlParser\Statements\ReplaceStatement;
|
||||
use PhpMyAdmin\SqlParser\Statements\UpdateStatement;
|
||||
use PhpMyAdmin\SqlParser\Utils\Query;
|
||||
use PhpMyAdmin\Table;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
* Library that provides common import functions that are used by import plugins
|
||||
@ -1235,7 +1229,7 @@ class Import
|
||||
}
|
||||
|
||||
$params = ['db' => $db_name];
|
||||
$db_url = 'db_structure.php' . Url::getCommon($params);
|
||||
$db_url = Url::getFromRoute('/database/structure', $params);
|
||||
$db_ops_url = 'db_operations.php' . Url::getCommon($params);
|
||||
|
||||
$message = '<br><br>';
|
||||
|
||||
@ -459,9 +459,10 @@ class Menu
|
||||
|
||||
$tabs = [];
|
||||
|
||||
$tabs['structure']['link'] = 'db_structure.php';
|
||||
$tabs['structure']['link'] = Url::getFromRoute('/database/structure');
|
||||
$tabs['structure']['text'] = __('Structure');
|
||||
$tabs['structure']['icon'] = 'b_props';
|
||||
$tabs['structure']['active'] = isset($_REQUEST['route']) && $_REQUEST['route'] === '/database/structure';
|
||||
|
||||
$tabs['sql']['link'] = 'db_sql.php';
|
||||
$tabs['sql']['text'] = __('SQL');
|
||||
|
||||
@ -47,9 +47,10 @@ class NodeDatabase extends Node
|
||||
$GLOBALS['cfg']['DefaultTabDatabase'],
|
||||
'database'
|
||||
);
|
||||
$hasRoute = strpos($scriptName, '?');
|
||||
$this->links = [
|
||||
'text' => $scriptName
|
||||
. '?server=' . $GLOBALS['server']
|
||||
'text' => $scriptName . ($hasRoute === false ? '?' : '&')
|
||||
. 'server=' . $GLOBALS['server']
|
||||
. '&db=%1$s',
|
||||
'icon' => 'db_operations.php?server=' . $GLOBALS['server']
|
||||
. '&db=%1$s&',
|
||||
|
||||
@ -10,6 +10,7 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
@ -27,10 +28,16 @@ class NodeTableContainer extends NodeDatabaseChildContainer
|
||||
parent::__construct(__('Tables'), Node::CONTAINER);
|
||||
$this->icon = Util::getImage('b_browse', __('Tables'));
|
||||
$this->links = [
|
||||
'text' => 'db_structure.php?server=' . $GLOBALS['server']
|
||||
. '&db=%1$s&tbl_type=table',
|
||||
'icon' => 'db_structure.php?server=' . $GLOBALS['server']
|
||||
. '&db=%1$s&tbl_type=table',
|
||||
'text' => Url::getFromRoute('/database/structure', [
|
||||
'server' => $GLOBALS['server'],
|
||||
'db' => '%1\$s',
|
||||
'tbl_type' => 'table',
|
||||
]),
|
||||
'icon' => Url::getFromRoute('/database/structure', [
|
||||
'server' => $GLOBALS['server'],
|
||||
'db' => '%1\$s',
|
||||
'tbl_type' => 'table',
|
||||
]),
|
||||
];
|
||||
$this->realName = 'tables';
|
||||
$this->classes = 'tableContainer subContainer';
|
||||
|
||||
@ -10,6 +10,7 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use PhpMyAdmin\Navigation\NodeFactory;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
@ -27,10 +28,16 @@ class NodeViewContainer extends NodeDatabaseChildContainer
|
||||
parent::__construct(__('Views'), Node::CONTAINER);
|
||||
$this->icon = Util::getImage('b_views', __('Views'));
|
||||
$this->links = [
|
||||
'text' => 'db_structure.php?server=' . $GLOBALS['server']
|
||||
. '&db=%1$s&tbl_type=view',
|
||||
'icon' => 'db_structure.php?server=' . $GLOBALS['server']
|
||||
. '&db=%1$s&tbl_type=view',
|
||||
'text' => Url::getFromRoute('/database/structure', [
|
||||
'server' => $GLOBALS['server'],
|
||||
'db' => '%1\$s',
|
||||
'tbl_type' => 'view',
|
||||
]),
|
||||
'icon' => Url::getFromRoute('/database/structure', [
|
||||
'server' => $GLOBALS['server'],
|
||||
'db' => '%1\$s',
|
||||
'tbl_type' => 'view',
|
||||
]),
|
||||
];
|
||||
$this->classes = 'viewContainer subContainer';
|
||||
$this->realName = 'views';
|
||||
|
||||
@ -204,14 +204,12 @@ class RecentFavoriteTable
|
||||
$html .= '<li class="warp_link">';
|
||||
|
||||
$html .= '<a class="ajax favorite_table_anchor" ';
|
||||
$fav_params = [
|
||||
'db' => $table['db'],
|
||||
'ajax_request' => true,
|
||||
'favorite_table' => $table['table'],
|
||||
$fav_rm_url = Url::getFromRoute('/database/structure', [
|
||||
'db' => $table['db'],
|
||||
'ajax_request' => true,
|
||||
'favorite_table' => $table['table'],
|
||||
'remove_favorite' => true,
|
||||
];
|
||||
$fav_rm_url = 'db_structure.php'
|
||||
. Url::getCommon($fav_params);
|
||||
]);
|
||||
$html .= 'href="' . $fav_rm_url
|
||||
. '" title="' . __("Remove from Favorites")
|
||||
. '" data-favtargetn="'
|
||||
@ -353,12 +351,11 @@ class RecentFavoriteTable
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
// Not to show this once list is synchronized.
|
||||
if ($cfgRelation['favoritework'] && ! isset($_SESSION['tmpval']['favorites_synced'][$server_id])) {
|
||||
$params = [
|
||||
$url = Url::getFromRoute('/database/structure', [
|
||||
'ajax_request' => true,
|
||||
'favorite_table' => true,
|
||||
'sync_favorite_tables' => true,
|
||||
];
|
||||
$url = 'db_structure.php' . Url::getCommon($params);
|
||||
]);
|
||||
$retval = '<a class="hide" id="sync_favorite_tables"';
|
||||
$retval .= ' href="' . $url . '"></a>';
|
||||
}
|
||||
|
||||
@ -39,7 +39,6 @@ class Sanitize
|
||||
'./index.php?',
|
||||
'./server_status.php?',
|
||||
'./server_privileges.php?',
|
||||
'./db_structure.php?',
|
||||
'./db_sql.php?',
|
||||
'./db_search.php?',
|
||||
'./db_operations.php?',
|
||||
|
||||
@ -3139,7 +3139,7 @@ class Util
|
||||
* $cfg['NavigationTreeDefaultTabTable2'],
|
||||
* $cfg['DefaultTabTable'] or $cfg['DefaultTabDatabase']
|
||||
*
|
||||
* @return string Title for the $cfg value
|
||||
* @return string|bool Title for the $cfg value
|
||||
*/
|
||||
public static function getTitleForTarget($target)
|
||||
{
|
||||
@ -3150,22 +3150,8 @@ class Util
|
||||
'insert' => __('Insert'),
|
||||
'browse' => __('Browse'),
|
||||
'operations' => __('Operations'),
|
||||
|
||||
// For backward compatiblity
|
||||
|
||||
// Values for $cfg['DefaultTabTable']
|
||||
'tbl_structure.php' => __('Structure'),
|
||||
'tbl_sql.php' => __('SQL'),
|
||||
'tbl_select.php' => __('Search'),
|
||||
'tbl_change.php' => __('Insert'),
|
||||
'sql.php' => __('Browse'),
|
||||
// Values for $cfg['DefaultTabDatabase']
|
||||
'db_structure.php' => __('Structure'),
|
||||
'db_sql.php' => __('SQL'),
|
||||
'db_search.php' => __('Search'),
|
||||
'db_operations.php' => __('Operations'),
|
||||
];
|
||||
return isset($mapping[$target]) ? $mapping[$target] : false;
|
||||
return $mapping[$target] ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3201,7 +3187,7 @@ class Util
|
||||
// Values for $cfg['DefaultTabDatabase']
|
||||
switch ($target) {
|
||||
case 'structure':
|
||||
return 'db_structure.php';
|
||||
return Url::getFromRoute('/database/structure');
|
||||
case 'sql':
|
||||
return 'db_sql.php';
|
||||
case 'search':
|
||||
@ -4951,7 +4937,7 @@ class Util
|
||||
$urlParams['tbl_group'] = $_REQUEST['tbl_group'];
|
||||
}
|
||||
|
||||
$url = 'db_structure.php' . Url::getCommon($urlParams);
|
||||
$url = Url::getFromRoute('/database/structure', $urlParams);
|
||||
|
||||
return self::linkOrButton($url, $title . $orderImg, $orderLinkParams);
|
||||
}
|
||||
|
||||
@ -11,11 +11,12 @@ use PhpMyAdmin\Controllers\Database\StructureController;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Response;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
global $containerBuilder;
|
||||
|
||||
require_once ROOT_PATH . 'libraries/db_common.inc.php';
|
||||
|
||||
/** @var Response $response */
|
||||
@ -72,7 +72,7 @@ if ($dbi->getColumns($db, $table)) {
|
||||
sprintf(__('Table %s already exists!'), htmlspecialchars($table)),
|
||||
'',
|
||||
false,
|
||||
'db_structure.php' . Url::getCommon(['db' => $db])
|
||||
Url::getFromRoute('/database/structure', ['db' => $db])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -28,8 +28,7 @@
|
||||
{% endif %}
|
||||
{% if approx_rows %}
|
||||
{% set cell_text -%}
|
||||
<a href="db_structure.php
|
||||
{{- get_common(row_sum_url) }}" class="ajax row_count_sum">~
|
||||
<a href="{{ get_url_from_route('/database/structure', row_sum_url) }}" class="ajax row_count_sum">~
|
||||
{{- row_count_sum -}}
|
||||
</a>
|
||||
{%- endset %}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<a id="{{ table_name_hash }}_favorite_anchor"
|
||||
class="ajax favorite_table_anchor"
|
||||
href="db_structure.php{{ get_common(fav_params) }}"
|
||||
href="{{ get_url_from_route('/database/structure', fav_params) }}"
|
||||
title="{{ already_favorite ? 'Remove from Favorites'|trans : 'Add to Favorites'|trans }}"
|
||||
data-favtargets="{{ db_table_name_hash }}" >
|
||||
{{ already_favorite ? titles['Favorite']|raw : titles['NoFavorite']|raw }}
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<a href="#" id="printView">
|
||||
{{ get_icon('b_print', 'Print'|trans, true) }}
|
||||
</a>
|
||||
<a href="db_datadict.php{{ get_common({'db': database, 'goto': 'db_structure.php'}) }}" target="print_view">
|
||||
<a href="db_datadict.php{{ get_common({'db': database, 'goto': get_url_from_route('/database/structure')}) }}" target="print_view">
|
||||
{{ get_icon('b_tblanalyse', 'Data dictionary'|trans, true) }}
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@ -95,11 +95,11 @@
|
||||
<td class="value tbl_rows"
|
||||
data-table="{{ current_table['TABLE_NAME'] }}">
|
||||
{% if approx_rows %}
|
||||
<a href="db_structure.php{{ get_common({
|
||||
<a href="{{ get_url_from_route('/database/structure', {
|
||||
'ajax_request': true,
|
||||
'db': db,
|
||||
'table': current_table['TABLE_NAME'],
|
||||
'real_row_count': 'true'
|
||||
'real_row_count': true
|
||||
}) }}" class="ajax real_row_count">
|
||||
<bdi>
|
||||
~{{ row_count }}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<form method="post" action="db_structure.php" name="tablesForm" id="tablesForm">
|
||||
<form method="post" action="{{ get_url_from_route('/database/structure') }}" name="tablesForm" id="tablesForm">
|
||||
{{ get_hidden_inputs(db) }}
|
||||
<div class="responsivetable">
|
||||
<table id="structureTable" class="data">
|
||||
|
||||
@ -47,7 +47,7 @@ class NodeDatabaseTest extends PmaTestCase
|
||||
$parent->links
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'db_structure.php',
|
||||
'index.php?route=/database/structure',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertStringContainsString('database', $parent->classes);
|
||||
|
||||
@ -48,7 +48,7 @@ class NodeTableContainerTest extends PmaTestCase
|
||||
$parent->links
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'db_structure.php',
|
||||
'index.php?route=/database/structure',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertEquals('tables', $parent->realName);
|
||||
|
||||
@ -48,7 +48,7 @@ class NodeViewContainerTest extends PmaTestCase
|
||||
$parent->links
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'db_structure.php',
|
||||
'index.php?route=/database/structure',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertEquals('views', $parent->realName);
|
||||
|
||||
@ -2000,39 +2000,27 @@ class UtilTest extends PmaTestCase
|
||||
{
|
||||
return [
|
||||
[
|
||||
'tbl_structure.php',
|
||||
'structure',
|
||||
__('Structure'),
|
||||
],
|
||||
[
|
||||
'tbl_sql.php',
|
||||
'sql',
|
||||
__('SQL'),
|
||||
],
|
||||
[
|
||||
'tbl_select.php',
|
||||
'search',
|
||||
__('Search'),
|
||||
],
|
||||
[
|
||||
'tbl_change.php',
|
||||
'insert',
|
||||
__('Insert'),
|
||||
],
|
||||
[
|
||||
'sql.php',
|
||||
'browse',
|
||||
__('Browse'),
|
||||
],
|
||||
[
|
||||
'db_structure.php',
|
||||
__('Structure'),
|
||||
],
|
||||
[
|
||||
'db_sql.php',
|
||||
__('SQL'),
|
||||
],
|
||||
[
|
||||
'db_search.php',
|
||||
__('Search'),
|
||||
],
|
||||
[
|
||||
'db_operations.php',
|
||||
'operations',
|
||||
__('Operations'),
|
||||
],
|
||||
];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user