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';
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(
24 _pgettext('string types', 'String')
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);
36 if (isset($_REQUEST['addNewPrimary'])) {
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);
46 if (isset($_REQUEST['findPdl'])) {
47 $html = PMA_findPartialDependencies($table, $db);
52 if (isset($_REQUEST['getNewTables2NF'])) {
53 $partialDependencies = json_decode($_REQUEST['pd']);
54 $html = PMA_getHtmlForNewTables2NF($partialDependencies, $table);
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 PMA_Response
::getInstance()->disable();
65 echo json_encode($newTables);
69 $response = PMA_Response
::getInstance();
70 $header = $response->getHeader();
71 $scripts = $header->getScripts();
72 $scripts->addFile('normalization.js');
73 $scripts->addFile('jquery/jquery.uitablefilter.js');
75 if (isset($_REQUEST['normalizeTo'])) {
76 $normalForm = $_REQUEST['normalizeTo'];
78 if (isset($_REQUEST['createNewTables2NF'])) {
79 $partialDependencies = json_decode($_REQUEST['pd']);
80 $tablesName = json_decode($_REQUEST['newTablesName']);
81 $res = PMA_createNewTablesFor2NF($partialDependencies, $tablesName, $table, $db);
82 $response->addJSON($res);
85 if (isset($_REQUEST['createNewTables3NF'])) {
86 $newtables = json_decode($_REQUEST['newTables']);
87 $res = PMA_createNewTablesFor3NF($newtables, $db);
88 $response->addJSON($res);
91 if (isset($_POST['repeatingColumns'])) {
92 $repeatingColumns = $_POST['repeatingColumns'];
93 $newTable = $_POST['newTable'];
94 $newColumn = $_POST['newColumn'];
95 $primary_columns = $_POST['primary_columns'];
96 $res = PMA_moveRepeatingGroup(
97 $repeatingColumns, $primary_columns, $newTable, $newColumn, $table, $db
99 $response->addJSON($res);
102 if (isset($_REQUEST['step1'])) {
103 $html = PMA_getHtmlFor1NFStep1($db, $table, $normalForm);
104 $response->addHTML($html);
105 } else if (isset($_REQUEST['step2'])) {
106 $res = PMA_getHtmlContentsFor1NFStep2($db, $table);
107 $response->addJSON($res);
108 } else if (isset($_REQUEST['step3'])) {
109 $res = PMA_getHtmlContentsFor1NFStep3($db, $table);
110 $response->addJSON($res);
111 } else if (isset ($_REQUEST['step4'])) {
112 $res = PMA_getHtmlContentsFor1NFStep4($db, $table);
113 $response->addJSON($res);
114 } else if (isset($_REQUEST['step']) && $_REQUEST['step'] == 2.1) {
115 $res = PMA_getHtmlFor2NFstep1($db, $table);
116 $response->addJSON($res);
117 } else if (isset($_REQUEST['step']) && $_REQUEST['step'] == 3.1) {
118 $tables = $_REQUEST['tables'];
119 $res = PMA_getHtmlFor3NFstep1($db, $tables);
120 $response->addJSON($res);
122 $response->addHTML(PMA_getHtmlForNormalizetable());