From 4111f215c6b641204245d60905ef19e1877e93e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Mon, 19 Aug 2019 23:12:17 -0300 Subject: [PATCH] Use the router for normalization.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- index.php | 3 ++ js/normalization.js | 30 +++++++++---------- libraries/classes/Normalization.php | 4 +-- .../entry_points/normalization.php | 6 ++-- .../table/structure/display_structure.twig | 2 +- test/classes/NormalizationTest.php | 5 ++-- 6 files changed, 26 insertions(+), 24 deletions(-) rename normalization.php => libraries/entry_points/normalization.php (96%) diff --git a/index.php b/index.php index ce83987057..2f7048e9b8 100644 --- a/index.php +++ b/index.php @@ -116,6 +116,9 @@ if (isset($_GET['route']) || isset($_POST['route'])) { $routes->addRoute(['GET', 'POST'], '/navigation', function () { require_once ROOT_PATH . 'libraries/entry_points/navigation.php'; }); + $routes->addRoute(['GET', 'POST'], '/normalization', function () { + require_once ROOT_PATH . 'libraries/entry_points/normalization.php'; + }); $routes->addGroup('/server', function (RouteCollector $routes) { $routes->addRoute(['GET', 'POST'], '/binlog', function () { require_once ROOT_PATH . 'libraries/entry_points/server/binlog.php'; diff --git a/js/normalization.js b/js/normalization.js index 4a85319a21..9204266c72 100644 --- a/js/normalization.js +++ b/js/normalization.js @@ -10,7 +10,7 @@ /* global centralColumnList:writable */ // js/functions.js /** - * AJAX scripts for normalization.php + * AJAX scripts for normalization * */ @@ -20,7 +20,7 @@ var dataParsed = null; function appendHtmlColumnsList () { $.post( - 'normalization.php', + 'index.php?route=/normalization', { 'ajax_request': true, 'db': CommonParams.get('db'), @@ -42,7 +42,7 @@ function goTo3NFStep1 (newTables) { tables = [CommonParams.get('table')]; } $.post( - 'normalization.php', + 'index.php?route=/normalization', { 'ajax_request': true, 'db': CommonParams.get('db'), @@ -78,7 +78,7 @@ function goTo3NFStep1 (newTables) { function goTo2NFStep1 () { $.post( - 'normalization.php', + 'index.php?route=/normalization', { 'ajax_request': true, 'db': CommonParams.get('db'), @@ -128,7 +128,7 @@ function goToFinish1NF () { // eslint-disable-next-line no-unused-vars function goToStep4 () { $.post( - 'normalization.php', + 'index.php?route=/normalization', { 'ajax_request': true, 'db': CommonParams.get('db'), @@ -151,7 +151,7 @@ function goToStep4 () { function goToStep3 () { $.post( - 'normalization.php', + 'index.php?route=/normalization', { 'ajax_request': true, 'db': CommonParams.get('db'), @@ -175,7 +175,7 @@ function goToStep3 () { function goToStep2 (extra) { $.post( - 'normalization.php', + 'index.php?route=/normalization', { 'ajax_request': true, 'db': CommonParams.get('db'), @@ -223,7 +223,7 @@ function goTo2NFFinish (pd) { 'createNewTables2NF':1 }; $.ajax({ type: 'POST', - url: 'normalization.php', + url: 'index.php?route=/normalization', data: datastring, async:false, success: function (data) { @@ -268,7 +268,7 @@ function goTo3NFFinish (newTables) { 'createNewTables3NF':1 }; $.ajax({ type: 'POST', - url: 'normalization.php', + url: 'index.php?route=/normalization', data: datastring, async:false, success: function (data) { @@ -319,7 +319,7 @@ function goTo2NFStep2 (pd, primaryKey) { 'getNewTables2NF':1 }; $.ajax({ type: 'POST', - url: 'normalization.php', + url: 'index.php?route=/normalization', data: datastring, async:false, success: function (data) { @@ -368,7 +368,7 @@ function goTo3NFStep2 (pd, tablesTds) { 'getNewTables3NF':1 }; $.ajax({ type: 'POST', - url: 'normalization.php', + url: 'index.php?route=/normalization', data: datastring, async:false, success: function (data) { @@ -464,7 +464,7 @@ function moveRepeatingGroup (repeatingCols) { }; $.ajax({ type: 'POST', - url: 'normalization.php', + url: 'index.php?route=/normalization', data: datastring, async:false, success: function (data) { @@ -510,7 +510,7 @@ AJAX.registerOnload('normalization.js', function () { } var numField = $('#numField').val(); $.post( - 'normalization.php', + 'index.php?route=/normalization', { 'ajax_request': true, 'db': CommonParams.get('db'), @@ -583,7 +583,7 @@ AJAX.registerOnload('normalization.js', function () { $('#extra').on('click', '#addNewPrimary', function () { $.post( - 'normalization.php', + 'index.php?route=/normalization', { 'ajax_request': true, 'db': CommonParams.get('db'), @@ -729,7 +729,7 @@ AJAX.registerOnload('normalization.js', function () { $('#newCols').insertAfter('#mainContent h4'); $('#newCols').html('
' + Messages.strLoading + '
' + Messages.strWaitForPd + '
'); $.post( - 'normalization.php', + 'index.php?route=/normalization', { 'ajax_request': true, 'db': CommonParams.get('db'), diff --git a/libraries/classes/Normalization.php b/libraries/classes/Normalization.php index d088bebb45..be2ff6cf28 100644 --- a/libraries/classes/Normalization.php +++ b/libraries/classes/Normalization.php @@ -904,8 +904,8 @@ class Normalization */ public function getHtmlForNormalizeTable() { - $htmlOutput = '
' . Url::getHiddenInputs($GLOBALS['db'], $GLOBALS['table']) diff --git a/normalization.php b/libraries/entry_points/normalization.php similarity index 96% rename from normalization.php rename to libraries/entry_points/normalization.php index 27c9c6eb08..38d94ab100 100644 --- a/normalization.php +++ b/libraries/entry_points/normalization.php @@ -13,14 +13,12 @@ use PhpMyAdmin\Normalization; use PhpMyAdmin\Response; use PhpMyAdmin\Url; -if (! defined('ROOT_PATH')) { - define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR); +if (! defined('PHPMYADMIN')) { + exit; } global $containerBuilder, $db, $table; -require_once ROOT_PATH . 'libraries/common.inc.php'; - /** @var Response $response */ $response = $containerBuilder->get(Response::class); diff --git a/templates/table/structure/display_structure.twig b/templates/table/structure/display_structure.twig index 909e159274..dc6ee09e47 100644 --- a/templates/table/structure/display_structure.twig +++ b/templates/table/structure/display_structure.twig @@ -403,7 +403,7 @@ {{ get_icon('b_move', 'Move columns'|trans, true) }} - + {{ get_icon('normalize', 'Normalize'|trans, true) }} {% endif %} diff --git a/test/classes/NormalizationTest.php b/test/classes/NormalizationTest.php index b29e1ec813..4f4ec6deee 100644 --- a/test/classes/NormalizationTest.php +++ b/test/classes/NormalizationTest.php @@ -16,6 +16,7 @@ use PhpMyAdmin\Template; use PhpMyAdmin\Theme; use PhpMyAdmin\Transformations; use PhpMyAdmin\Types; +use PhpMyAdmin\Url; use PhpMyAdmin\Util; use PHPUnit\Framework\TestCase; use ReflectionClass; @@ -536,8 +537,8 @@ class NormalizationTest extends TestCase { $result = $this->normalization->getHtmlForNormalizeTable(); $this->assertStringContainsString( - 'assertStringContainsString(