Translated using Weblate (Indonesian)
[phpmyadmin.git] / normalization.php
blob14d21371207db314445f1a20654d295d9140f472
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Normalization process (temporarily specific to 1NF)
6 * @package PhpMyAdmin
7 */
9 use PhpMyAdmin\Core;
10 use PhpMyAdmin\Url;
11 use PhpMyAdmin\Response;
13 /**
16 require_once 'libraries/common.inc.php';
17 require_once 'libraries/normalization.lib.php';
19 if (isset($_REQUEST['getColumns'])) {
20 $html = '<option selected disabled>' . __('Select oneā€¦') . '</option>'
21 . '<option value="no_such_col">' . __('No such column') . '</option>';
22 //get column whose datatype falls under string category
23 $html .= PMA_getHtmlForColumnsList(
24 $db,
25 $table,
26 _pgettext('string types', 'String')
28 echo $html;
29 exit;
31 if (isset($_REQUEST['splitColumn'])) {
32 $num_fields = min(4096, intval($_REQUEST['numFields']));
33 $html = PMA_getHtmlForCreateNewColumn($num_fields, $db, $table);
34 $html .= Url::getHiddenInputs($db, $table);
35 echo $html;
36 exit;
38 if (isset($_REQUEST['addNewPrimary'])) {
39 $num_fields = 1;
40 $columnMeta = array('Field'=>$table . "_id", 'Extra'=>'auto_increment');
41 $html = PMA_getHtmlForCreateNewColumn(
42 $num_fields, $db, $table, $columnMeta
44 $html .= Url::getHiddenInputs($db, $table);
45 echo $html;
46 exit;
48 if (isset($_REQUEST['findPdl'])) {
49 $html = PMA_findPartialDependencies($table, $db);
50 echo $html;
51 exit;
54 if (isset($_REQUEST['getNewTables2NF'])) {
55 $partialDependencies = json_decode($_REQUEST['pd']);
56 $html = PMA_getHtmlForNewTables2NF($partialDependencies, $table);
57 echo $html;
58 exit;
61 $response = Response::getInstance();
63 if (isset($_REQUEST['getNewTables3NF'])) {
64 $dependencies = json_decode($_REQUEST['pd']);
65 $tables = json_decode($_REQUEST['tables']);
66 $newTables = PMA_getHtmlForNewTables3NF($dependencies, $tables, $db);
67 $response->disable();
68 Core::headerJSON();
69 echo json_encode($newTables);
70 exit;
73 $header = $response->getHeader();
74 $scripts = $header->getScripts();
75 $scripts->addFile('normalization.js');
76 $scripts->addFile('vendor/jquery/jquery.uitablefilter.js');
77 $normalForm = '1nf';
78 if (Core::isValid($_REQUEST['normalizeTo'], array('1nf', '2nf', '3nf'))) {
79 $normalForm = $_REQUEST['normalizeTo'];
81 if (isset($_REQUEST['createNewTables2NF'])) {
82 $partialDependencies = json_decode($_REQUEST['pd']);
83 $tablesName = json_decode($_REQUEST['newTablesName']);
84 $res = PMA_createNewTablesFor2NF($partialDependencies, $tablesName, $table, $db);
85 $response->addJSON($res);
86 exit;
88 if (isset($_REQUEST['createNewTables3NF'])) {
89 $newtables = json_decode($_REQUEST['newTables']);
90 $res = PMA_createNewTablesFor3NF($newtables, $db);
91 $response->addJSON($res);
92 exit;
94 if (isset($_POST['repeatingColumns'])) {
95 $repeatingColumns = $_POST['repeatingColumns'];
96 $newTable = $_POST['newTable'];
97 $newColumn = $_POST['newColumn'];
98 $primary_columns = $_POST['primary_columns'];
99 $res = PMA_moveRepeatingGroup(
100 $repeatingColumns, $primary_columns, $newTable, $newColumn, $table, $db
102 $response->addJSON($res);
103 exit;
105 if (isset($_REQUEST['step1'])) {
106 $html = PMA_getHtmlFor1NFStep1($db, $table, $normalForm);
107 $response->addHTML($html);
108 } else if (isset($_REQUEST['step2'])) {
109 $res = PMA_getHtmlContentsFor1NFStep2($db, $table);
110 $response->addJSON($res);
111 } else if (isset($_REQUEST['step3'])) {
112 $res = PMA_getHtmlContentsFor1NFStep3($db, $table);
113 $response->addJSON($res);
114 } else if (isset($_REQUEST['step4'])) {
115 $res = PMA_getHtmlContentsFor1NFStep4($db, $table);
116 $response->addJSON($res);
117 } else if (isset($_REQUEST['step']) && $_REQUEST['step'] == '2.1') {
118 $res = PMA_getHtmlFor2NFstep1($db, $table);
119 $response->addJSON($res);
120 } else if (isset($_REQUEST['step']) && $_REQUEST['step'] == '3.1') {
121 $tables = $_REQUEST['tables'];
122 $res = PMA_getHtmlFor3NFstep1($db, $tables);
123 $response->addJSON($res);
124 } else {
125 $response->addHTML(PMA_getHtmlForNormalizetable());