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