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