2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Normalization process (temporarily specific to 1NF)
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(
23 _pgettext('string types', 'String')
28 if (isset($_REQUEST['splitColumn'])) {
29 $num_fields = $_REQUEST['numFields'];
30 $html = PMA_getHtmlForCreateNewColumn($num_fields, $db, $table);
31 $html .= PMA_URL_getHiddenInputs($db, $table);
35 if (isset($_REQUEST['addNewPrimary'])) {
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);
45 if (isset($_REQUEST['findPdl'])) {
46 $html = PMA_findPartialDependencies($table, $db);
51 if (isset($_REQUEST['getNewTables2NF'])) {
52 $partialDependencies = json_decode($_REQUEST['pd']);
53 $html = PMA_getHtmlForNewTables2NF($partialDependencies, $table);
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 echo json_encode($newTables);
66 $response = PMA\libraries\Response
::getInstance();
67 $header = $response->getHeader();
68 $scripts = $header->getScripts();
69 $scripts->addFile('normalization.js');
70 $scripts->addFile('jquery/jquery.uitablefilter.js');
72 if (isset($_REQUEST['normalizeTo'])) {
73 $normalForm = $_REQUEST['normalizeTo'];
75 if (isset($_REQUEST['createNewTables2NF'])) {
76 $partialDependencies = json_decode($_REQUEST['pd']);
77 $tablesName = json_decode($_REQUEST['newTablesName']);
78 $res = PMA_createNewTablesFor2NF($partialDependencies, $tablesName, $table, $db);
79 $response->addJSON($res);
82 if (isset($_REQUEST['createNewTables3NF'])) {
83 $newtables = json_decode($_REQUEST['newTables']);
84 $res = PMA_createNewTablesFor3NF($newtables, $db);
85 $response->addJSON($res);
88 if (isset($_POST['repeatingColumns'])) {
89 $repeatingColumns = $_POST['repeatingColumns'];
90 $newTable = $_POST['newTable'];
91 $newColumn = $_POST['newColumn'];
92 $primary_columns = $_POST['primary_columns'];
93 $res = PMA_moveRepeatingGroup(
94 $repeatingColumns, $primary_columns, $newTable, $newColumn, $table, $db
96 $response->addJSON($res);
99 if (isset($_REQUEST['step1'])) {
100 $html = PMA_getHtmlFor1NFStep1($db, $table, $normalForm);
101 $response->addHTML($html);
102 } else if (isset($_REQUEST['step2'])) {
103 $res = PMA_getHtmlContentsFor1NFStep2($db, $table);
104 $response->addJSON($res);
105 } else if (isset($_REQUEST['step3'])) {
106 $res = PMA_getHtmlContentsFor1NFStep3($db, $table);
107 $response->addJSON($res);
108 } else if (isset($_REQUEST['step4'])) {
109 $res = PMA_getHtmlContentsFor1NFStep4($db, $table);
110 $response->addJSON($res);
111 } else if (isset($_REQUEST['step']) && $_REQUEST['step'] == '2.1') {
112 $res = PMA_getHtmlFor2NFstep1($db, $table);
113 $response->addJSON($res);
114 } else if (isset($_REQUEST['step']) && $_REQUEST['step'] == '3.1') {
115 $tables = $_REQUEST['tables'];
116 $res = PMA_getHtmlFor3NFstep1($db, $tables);
117 $response->addJSON($res);
119 $response->addHTML(PMA_getHtmlForNormalizetable());