Translated using Weblate (Slovenian)
[phpmyadmin.git] / normalization.php
blob30003b8591ffe678f1cec8dd4bd1297558b08f04
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 /**
12 require_once 'libraries/common.inc.php';
13 require_once 'libraries/transformations.lib.php';
14 require_once 'libraries/normalization.lib.php';
16 if (isset($_REQUEST['getColumns'])) {
17 $html = '<option selected disabled>' . __('Select oneā€¦') . '</option>'
18 . '<option value="no_such_col">' . __('No such column') . '</option>';
19 //get column whose datatype falls under string category
20 $html .= PMA_getHtmlForColumnsList(
21 $db,
22 $table,
23 _pgettext('string types', 'String')
25 echo $html;
26 exit;
28 if (isset($_REQUEST['splitColumn'])) {
29 $num_fields = min(4096, intval($_REQUEST['numFields']));
30 $html = PMA_getHtmlForCreateNewColumn($num_fields, $db, $table);
31 $html .= PMA_URL_getHiddenInputs($db, $table);
32 echo $html;
33 exit;
35 if (isset($_REQUEST['addNewPrimary'])) {
36 $num_fields = 1;
37 $columnMeta = array('Field'=>$table . "_id", 'Extra'=>'auto_increment');
38 $html = PMA_getHtmlForCreateNewColumn(
39 $num_fields, $db, $table, $columnMeta
41 $html .= PMA_URL_getHiddenInputs($db, $table);
42 echo $html;
43 exit;
45 if (isset($_REQUEST['findPdl'])) {
46 $html = PMA_findPartialDependencies($table, $db);
47 echo $html;
48 exit;
51 if (isset($_REQUEST['getNewTables2NF'])) {
52 $partialDependencies = json_decode($_REQUEST['pd']);
53 $html = PMA_getHtmlForNewTables2NF($partialDependencies, $table);
54 echo $html;
55 exit;
58 if (isset($_REQUEST['getNewTables3NF'])) {
59 $dependencies = json_decode($_REQUEST['pd']);
60 $tables = json_decode($_REQUEST['tables']);
61 $newTables = PMA_getHtmlForNewTables3NF($dependencies, $tables, $db);
62 PMA\libraries\Response::getInstance()->disable();
63 PMA_headerJSON();
64 echo json_encode($newTables);
65 exit;
68 $response = PMA\libraries\Response::getInstance();
69 $header = $response->getHeader();
70 $scripts = $header->getScripts();
71 $scripts->addFile('normalization.js');
72 $scripts->addFile('jquery/jquery.uitablefilter.js');
73 $normalForm = '1nf';
74 if (PMA_isValid($_REQUEST['normalizeTo'], array('1nf', '2nf', '3nf'))) {
75 $normalForm = $_REQUEST['normalizeTo'];
77 if (isset($_REQUEST['createNewTables2NF'])) {
78 $partialDependencies = json_decode($_REQUEST['pd']);
79 $tablesName = json_decode($_REQUEST['newTablesName']);
80 $res = PMA_createNewTablesFor2NF($partialDependencies, $tablesName, $table, $db);
81 $response->addJSON($res);
82 exit;
84 if (isset($_REQUEST['createNewTables3NF'])) {
85 $newtables = json_decode($_REQUEST['newTables']);
86 $res = PMA_createNewTablesFor3NF($newtables, $db);
87 $response->addJSON($res);
88 exit;
90 if (isset($_POST['repeatingColumns'])) {
91 $repeatingColumns = $_POST['repeatingColumns'];
92 $newTable = $_POST['newTable'];
93 $newColumn = $_POST['newColumn'];
94 $primary_columns = $_POST['primary_columns'];
95 $res = PMA_moveRepeatingGroup(
96 $repeatingColumns, $primary_columns, $newTable, $newColumn, $table, $db
98 $response->addJSON($res);
99 exit;
101 if (isset($_REQUEST['step1'])) {
102 $html = PMA_getHtmlFor1NFStep1($db, $table, $normalForm);
103 $response->addHTML($html);
104 } else if (isset($_REQUEST['step2'])) {
105 $res = PMA_getHtmlContentsFor1NFStep2($db, $table);
106 $response->addJSON($res);
107 } else if (isset($_REQUEST['step3'])) {
108 $res = PMA_getHtmlContentsFor1NFStep3($db, $table);
109 $response->addJSON($res);
110 } else if (isset($_REQUEST['step4'])) {
111 $res = PMA_getHtmlContentsFor1NFStep4($db, $table);
112 $response->addJSON($res);
113 } else if (isset($_REQUEST['step']) && $_REQUEST['step'] == '2.1') {
114 $res = PMA_getHtmlFor2NFstep1($db, $table);
115 $response->addJSON($res);
116 } else if (isset($_REQUEST['step']) && $_REQUEST['step'] == '3.1') {
117 $tables = $_REQUEST['tables'];
118 $res = PMA_getHtmlFor3NFstep1($db, $tables);
119 $response->addJSON($res);
120 } else {
121 $response->addHTML(PMA_getHtmlForNormalizetable());