diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-07-28 17:56:27 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-07-28 17:56:27 +0300 |
commit | 9c9ae5069e8bda601b8fe6eabd1f7b93b2810599 (patch) | |
tree | e212dfa393bfe4e59126f0c5002be2abee96742c /libraries | |
parent | 3c618c22a9a717212742dd9a6d01d5277f3ba5b1 (diff) |
Extract HTML from Normalization::getHtmlForNormalizeTable method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/classes/Controllers/NormalizationController.php | 39 | ||||
-rw-r--r-- | libraries/classes/Normalization.php | 46 |
2 files changed, 32 insertions, 53 deletions
diff --git a/libraries/classes/Controllers/NormalizationController.php b/libraries/classes/Controllers/NormalizationController.php index 22211836fd..4f318806b4 100644 --- a/libraries/classes/Controllers/NormalizationController.php +++ b/libraries/classes/Controllers/NormalizationController.php @@ -152,24 +152,49 @@ class NormalizationController extends AbstractController if (isset($_POST['step1'])) { $html = $this->normalization->getHtmlFor1NFStep1($GLOBALS['db'], $GLOBALS['table'], $normalForm); $this->response->addHTML($html); - } elseif (isset($_POST['step2'])) { + + return; + } + + if (isset($_POST['step2'])) { $res = $this->normalization->getHtmlContentsFor1NFStep2($GLOBALS['db'], $GLOBALS['table']); $this->response->addJSON($res); - } elseif (isset($_POST['step3'])) { + + return; + } + + if (isset($_POST['step3'])) { $res = $this->normalization->getHtmlContentsFor1NFStep3($GLOBALS['db'], $GLOBALS['table']); $this->response->addJSON($res); - } elseif (isset($_POST['step4'])) { + + return; + } + + if (isset($_POST['step4'])) { $res = $this->normalization->getHtmlContentsFor1NFStep4($GLOBALS['db'], $GLOBALS['table']); $this->response->addJSON($res); - } elseif (isset($_POST['step']) && $_POST['step'] == '2.1') { + + return; + } + + if (isset($_POST['step']) && $_POST['step'] == '2.1') { $res = $this->normalization->getHtmlFor2NFstep1($GLOBALS['db'], $GLOBALS['table']); $this->response->addJSON($res); - } elseif (isset($_POST['step']) && $_POST['step'] == '3.1') { + + return; + } + + if (isset($_POST['step']) && $_POST['step'] == '3.1') { $tables = $_POST['tables']; $res = $this->normalization->getHtmlFor3NFstep1($GLOBALS['db'], $tables); $this->response->addJSON($res); - } else { - $this->response->addHTML($this->normalization->getHtmlForNormalizeTable()); + + return; } + + $this->render('table/normalization/normalization', [ + 'db' => $GLOBALS['db'], + 'table' => $GLOBALS['table'], + ]); } } diff --git a/libraries/classes/Normalization.php b/libraries/classes/Normalization.php index c95c94fbc8..1d2a1a94f0 100644 --- a/libraries/classes/Normalization.php +++ b/libraries/classes/Normalization.php @@ -938,52 +938,6 @@ class Normalization } /** - * get html for options to normalize table - * - * @return string HTML - */ - public function getHtmlForNormalizeTable() - { - $htmlOutput = '<form method="post" action="' . Url::getFromRoute('/normalization') - . '" name="normalize" ' - . 'id="normalizeTable" ' - . '>' - . Url::getHiddenInputs($GLOBALS['db'], $GLOBALS['table']) - . '<input type="hidden" name="step1" value="1">'; - $htmlOutput .= '<fieldset class="pma-fieldset">'; - $htmlOutput .= '<legend>' - . __('Improve table structure (Normalization):') . '</legend>'; - $htmlOutput .= '<h3>' . __('Select up to what step you want to normalize') - . '</h3>'; - - $htmlOutput .= '<div><input type="radio" name="normalizeTo" id="normalizeToRadio1" value="1nf" checked>'; - $htmlOutput .= ' <label for="normalizeToRadio1">'; - $htmlOutput .= __('First step of normalization (1NF)'); - $htmlOutput .= '</label></div>'; - - $htmlOutput .= '<div><input type="radio" name="normalizeTo" id="normalizeToRadio2" value="2nf">'; - $htmlOutput .= ' <label for="normalizeToRadio2">'; - $htmlOutput .= __('Second step of normalization (1NF+2NF)'); - $htmlOutput .= '</label></div>'; - - $htmlOutput .= '<div><input type="radio" name="normalizeTo" id="normalizeToRadio3" value="3nf">'; - $htmlOutput .= ' <label for="normalizeToRadio3">'; - $htmlOutput .= __('Third step of normalization (1NF+2NF+3NF)'); - $htmlOutput .= '</label></div>'; - - $htmlOutput .= '</fieldset><fieldset class="pma-fieldset tblFooters">' - . "<span class='float-start'>" . __( - 'Hint: Please follow the procedure carefully in order to obtain correct normalization' - ) . '</span>' - . '<input class="btn btn-primary" type="submit" name="submit_normalize" value="' . __('Go') . '">' - . '</fieldset>' - . '</form>' - . '</div>'; - - return $htmlOutput; - } - - /** * find all the possible partial dependencies based on data in the table. * * @param string $table current table |