Skip to content

Commit

Permalink
Use the router for normalization.php
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Aug 20, 2019
1 parent 74ac30f commit 4111f21
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
3 changes: 3 additions & 0 deletions index.php
Expand Up @@ -116,6 +116,9 @@
$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';
Expand Down
30 changes: 15 additions & 15 deletions js/normalization.js
Expand Up @@ -10,7 +10,7 @@
/* global centralColumnList:writable */ // js/functions.js

/**
* AJAX scripts for normalization.php
* AJAX scripts for normalization
*
*/

Expand All @@ -20,7 +20,7 @@ var dataParsed = null;

function appendHtmlColumnsList () {
$.post(
'normalization.php',
'index.php?route=/normalization',
{
'ajax_request': true,
'db': CommonParams.get('db'),
Expand All @@ -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'),
Expand Down Expand Up @@ -78,7 +78,7 @@ function goTo3NFStep1 (newTables) {

function goTo2NFStep1 () {
$.post(
'normalization.php',
'index.php?route=/normalization',
{
'ajax_request': true,
'db': CommonParams.get('db'),
Expand Down Expand Up @@ -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'),
Expand All @@ -151,7 +151,7 @@ function goToStep4 () {

function goToStep3 () {
$.post(
'normalization.php',
'index.php?route=/normalization',
{
'ajax_request': true,
'db': CommonParams.get('db'),
Expand All @@ -175,7 +175,7 @@ function goToStep3 () {

function goToStep2 (extra) {
$.post(
'normalization.php',
'index.php?route=/normalization',
{
'ajax_request': true,
'db': CommonParams.get('db'),
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -729,7 +729,7 @@ AJAX.registerOnload('normalization.js', function () {
$('#newCols').insertAfter('#mainContent h4');
$('#newCols').html('<div class="center">' + Messages.strLoading + '<br>' + Messages.strWaitForPd + '</div>');
$.post(
'normalization.php',
'index.php?route=/normalization',
{
'ajax_request': true,
'db': CommonParams.get('db'),
Expand Down
4 changes: 2 additions & 2 deletions libraries/classes/Normalization.php
Expand Up @@ -904,8 +904,8 @@ public function getHtmlFor3NFstep1($db, array $tables)
*/
public function getHtmlForNormalizeTable()
{
$htmlOutput = '<form method="post" action="normalization.php" '
. 'name="normalize" '
$htmlOutput = '<form method="post" action="' . Url::getFromRoute('/normalization')
. '" name="normalize" '
. 'id="normalizeTable" '
. '>'
. Url::getHiddenInputs($GLOBALS['db'], $GLOBALS['table'])
Expand Down
Expand Up @@ -13,14 +13,12 @@
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);

Expand Down
2 changes: 1 addition & 1 deletion templates/table/structure/display_structure.twig
Expand Up @@ -403,7 +403,7 @@
<a href="#" id="move_columns_anchor">
{{ get_icon('b_move', 'Move columns'|trans, true) }}
</a>
<a href="normalization.php{{ url_query|raw }}">
<a href="{{ url('/normalization', url_params) }}">
{{ get_icon('normalize', 'Normalize'|trans, true) }}
</a>
{% endif %}
Expand Down
5 changes: 3 additions & 2 deletions test/classes/NormalizationTest.php
Expand Up @@ -16,6 +16,7 @@
use PhpMyAdmin\Theme;
use PhpMyAdmin\Transformations;
use PhpMyAdmin\Types;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
Expand Down Expand Up @@ -536,8 +537,8 @@ public function testgetHtmlForNormalizeTable()
{
$result = $this->normalization->getHtmlForNormalizeTable();
$this->assertStringContainsString(
'<form method="post" action="normalization.php"'
. ' name="normalize" id="normalizeTable"',
'<form method="post" action="' . Url::getFromRoute('/normalization')
. '" name="normalize" id="normalizeTable"',
$result
);
$this->assertStringContainsString(
Expand Down

0 comments on commit 4111f21

Please sign in to comment.