Translated using Weblate (Portuguese (Brazil))
[phpmyadmin.git] / normalization.php
blobc7f7229013d42e91bc8074349233fcfc55f6072b
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/tbl_columns_definition_form.lib.php';
16 require_once 'libraries/Index.class.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 = $_REQUEST['numFields'];
32 $html = PMA_getHtmlForCreateNewColumn($num_fields, $db, $table);
33 $html .= PMA_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 .= PMA_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 if (isset($_REQUEST['getNewTables3NF'])) {
61 $dependencies = json_decode($_REQUEST['pd']);
62 $tables = json_decode($_REQUEST['tables']);
63 $newTables = PMA_getHtmlForNewTables3NF($dependencies, $tables, $db);
64 echo json_encode($newTables);
65 exit;
68 $response = PMA_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 (isset($_REQUEST['normalizeTo'])) {
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());