1NF: initial commit
Signed-off-by: Smita Kumari <kumarismita62@gmail.com> step 1 to 1NF complete Signed-off-by: Smita Kumari <kumarismita62@gmail.com> added layout for step2 and step3 Signed-off-by: Smita Kumari <kumarismita62@gmail.com> basic 1NF complete Signed-off-by: Smita Kumari <kumarismita62@gmail.com> fix coding style Signed-off-by: Smita Kumari <kumarismita62@gmail.com> added doc comment Signed-off-by: Smita Kumari <kumarismita62@gmail.com> fix coding style Signed-off-by: Smita Kumari <kumarismita62@gmail.com> error handling plus during split shows my string type columns Signed-off-by: Smita Kumari <kumarismita62@gmail.com> removing unnecessory code Signed-off-by: Smita Kumari <kumarismita62@gmail.com> removing unnecessory code Signed-off-by: Smita Kumari <kumarismita62@gmail.com> code refactoring plus translatable message format Signed-off-by: Smita Kumari <kumarismita62@gmail.com> added events on cancel and added unbind function calls Signed-off-by: Smita Kumari <kumarismita62@gmail.com> hide default textarea when value NONE Signed-off-by: Smita Kumari <kumarismita62@gmail.com> remove unnecesory alert Signed-off-by: Smita Kumari <kumarismita62@gmail.com> create unique column screen fixed plus starting link for normalization on tbl_structure page Signed-off-by: Smita Kumari <kumarismita62@gmail.com> added hint to follow steps carefully and finish message changes Signed-off-by: Smita Kumari <kumarismita62@gmail.com> Fix coding style plus messages Signed-off-by: Smita Kumari <kumarismita62@gmail.com> added wand icon for normalization Signed-off-by: Smita Kumari <kumarismita62@gmail.com> bug fix: dont go next step if any index other than primary/unique is crated Signed-off-by: Smita Kumari <kumarismita62@gmail.com> bug fix: replace .live with .on plus others Signed-off-by: Smita Kumari <kumarismita62@gmail.com> change show central column message plus refresh central column list on split save Signed-off-by: Smita Kumari <kumarismita62@gmail.com>
This commit is contained in:
parent
70b446e517
commit
1e971f3263
@ -2931,6 +2931,10 @@ AJAX.registerOnload('functions.js', function () {
|
||||
var db = PMA_commonParams.get('db');
|
||||
var table = PMA_commonParams.get('table');
|
||||
var maxRows = $(this).data('maxrows');
|
||||
var pick = $(this).data('pick');
|
||||
if(pick !== false) {
|
||||
pick = true;
|
||||
}
|
||||
var params = {
|
||||
'ajax_request' : true,
|
||||
'token' : PMA_commonParams.get('token'),
|
||||
@ -2962,7 +2966,11 @@ AJAX.registerOnload('functions.js', function () {
|
||||
fields += '('+escapeHtml(central_column_list[db+'_'+table][i].col_length)+') ';
|
||||
}
|
||||
fields += escapeHtml(central_column_list[db+'_'+table][i].col_extra)+'</span>'+
|
||||
'</div></td><td><input class="pick" style="width:100%" type="submit" value="'+PMA_messages.pickColumn+'" onclick="autoPopulate(\''+colid+'\','+i+')"/></td></tr>';
|
||||
'</div></td>';
|
||||
if (pick) {
|
||||
fields += '<td><input class="pick" style="width:100%" type="submit" value="'+PMA_messages.pickColumn+'" onclick="autoPopulate(\''+colid+'\','+i+')"/></td>';
|
||||
}
|
||||
fields += '</tr>';
|
||||
}
|
||||
var result_pointer = i;
|
||||
var search_in = '<input type="text" class="filter_rows" placeholder="'+PMA_messages.searchList+'">';
|
||||
@ -3012,7 +3020,11 @@ AJAX.registerOnload('functions.js', function () {
|
||||
fields += '('+central_column_list[db+'_'+table][i].col_length+') ';
|
||||
}
|
||||
fields += central_column_list[db+'_'+table][i].col_extra+'</span>'+
|
||||
'</div></td><td><input class="pick" style="width:100%" type="submit" value="'+PMA_messages.pickColumn+'" onclick="autoPopulate(\''+colid+'\','+i+')"/></td></tr>';
|
||||
'</div></td>';
|
||||
if (pick) {
|
||||
fields += '<td><input class="pick" style="width:100%" type="submit" value="'+PMA_messages.pickColumn+'" onclick="autoPopulate(\''+colid+'\','+i+')"/></td>';
|
||||
}
|
||||
fields += '</tr>';
|
||||
}
|
||||
$("#col_list").append(fields);
|
||||
result_pointer = i;
|
||||
@ -3032,6 +3044,9 @@ AJAX.registerOnload('functions.js', function () {
|
||||
return false;
|
||||
});
|
||||
|
||||
// $('a.show_central_list').live('click',function(e) {
|
||||
|
||||
// });
|
||||
// When "add a new value" is clicked, append an empty text field
|
||||
$("input.add_value").live('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
@ -293,6 +293,13 @@ $js_messages['confirmTitle'] = __('Are you sure?');
|
||||
$js_messages['makeConsistentMessage'] = __('This action may change some of the columns definition.<br/>Are you sure you want to continue?');
|
||||
$js_messages['strContinue'] = __('Continue');
|
||||
|
||||
/** For normalization */
|
||||
$js_messages['strAddUniqueIndex'] = __('Add unique/primary index');
|
||||
$js_messages['uniqueColAdded'] = __('Unique column(s) added.');
|
||||
$js_messages['toNextStep'] = __('Taking you to next step ...');
|
||||
$js_messages['strFinishMsg'] = __("The first step of normalization is complete for table '%s'.");
|
||||
$js_messages['strEndStep'] = __("End of step");
|
||||
|
||||
/* For server_variables.js */
|
||||
$js_messages['strSave'] = __('Save');
|
||||
|
||||
|
||||
271
js/normalization.js
Normal file
271
js/normalization.js
Normal file
@ -0,0 +1,271 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* @fileoverview events handling from normalization page
|
||||
* @name normalization
|
||||
*
|
||||
* @requires jQuery
|
||||
*/
|
||||
|
||||
/**
|
||||
* AJAX scripts for normalization.php
|
||||
*
|
||||
*/
|
||||
|
||||
function appendHtmlColumnsList()
|
||||
{
|
||||
$.get(
|
||||
"normalization.php",
|
||||
{
|
||||
"token": PMA_commonParams.get('token'),
|
||||
"ajax_request": true,
|
||||
"db": PMA_commonParams.get('db'),
|
||||
"table": PMA_commonParams.get('table'),
|
||||
"getColumns": true
|
||||
},
|
||||
function(data) {
|
||||
if (data.success === true) {
|
||||
$('select[name=makeAtomic]').html(data.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function goToFinish()
|
||||
{
|
||||
$("#mainContent legend").html(PMA_messages.strEndStep);
|
||||
$("#mainContent h4").html(
|
||||
"<h3>"+$.sprintf(PMA_messages.strFinishMsg, PMA_commonParams.get('table'))+"</h3>"
|
||||
);
|
||||
$("#mainContent p").html('');
|
||||
$("#mainContent #extra").html('');
|
||||
$("#mainContent #newCols").html('');
|
||||
$('.tblFooters').html('');
|
||||
}
|
||||
|
||||
function goToStep3()
|
||||
{
|
||||
$.post(
|
||||
"normalization.php",
|
||||
{
|
||||
"token": PMA_commonParams.get('token'),
|
||||
"ajax_request": true,
|
||||
"db": PMA_commonParams.get('db'),
|
||||
"table": PMA_commonParams.get('table'),
|
||||
"step3": true
|
||||
}, function(data) {
|
||||
$("#mainContent legend").html(data.legendText);
|
||||
$("#mainContent h4").html(data.headText);
|
||||
$("#mainContent p").html(data.subText);
|
||||
$("#mainContent #extra").html(data.extra);
|
||||
$("#mainContent #newCols").html('');
|
||||
$('.tblFooters').html('');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function goToStep2(extra)
|
||||
{
|
||||
$.post(
|
||||
"normalization.php",
|
||||
{
|
||||
"token": PMA_commonParams.get('token'),
|
||||
"ajax_request": true,
|
||||
"db": PMA_commonParams.get('db'),
|
||||
"table": PMA_commonParams.get('table'),
|
||||
"step2": true
|
||||
}, function(data) {
|
||||
$("#mainContent legend").html(data.legendText);
|
||||
$("#mainContent h4").html(data.headText);
|
||||
$("#mainContent p").html(data.subText);
|
||||
$("#mainContent #extra,#mainContent #newCols").html('');
|
||||
$('.tblFooters').html('');
|
||||
if (data.hasPrimaryKey === "1") {
|
||||
if(extra === 'goToStep3') {
|
||||
$("#mainContent h4").html(PMA_messages.uniqueColAdded);
|
||||
$("#mainContent p").html(PMA_messages.toNextStep);
|
||||
}
|
||||
if(extra === 'gotoFinish') {
|
||||
goToFinish();
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
goToStep3();
|
||||
}, 3000);
|
||||
}
|
||||
} else {
|
||||
//form to select columns to make primary
|
||||
$("#mainContent #extra").html(data.extra);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
AJAX.registerTeardown('normalization.js', function () {
|
||||
$("#extra").off("click", "#selectNonAtomicCol");
|
||||
$("#splitGo").unbind('click');
|
||||
$('.tblFooters').off("click", "#saveSplit");
|
||||
$("#extra").off("click", "#addNewPrimary");
|
||||
$(".tblFooters").off("click", "#saveNewPrimary");
|
||||
$("#extra").off("click", "#removeRedundant");
|
||||
$("#mainContent p").off("click", "#createUniqueColumns");
|
||||
});
|
||||
|
||||
AJAX.registerOnload('normalization.js', function() {
|
||||
var selectedCol;
|
||||
$("#extra").on("click", "#selectNonAtomicCol", function() {
|
||||
if ($(this).val() === 'no_such_col') {
|
||||
goToStep2();
|
||||
} else {
|
||||
selectedCol = $(this).val();
|
||||
}
|
||||
});
|
||||
|
||||
$("#splitGo").click(function() {
|
||||
if(!selectedCol || selectedCol === '') {
|
||||
return false;
|
||||
}
|
||||
var numField = $("#numField").val();
|
||||
$.get(
|
||||
"normalization.php",
|
||||
{
|
||||
"token": PMA_commonParams.get('token'),
|
||||
"ajax_request": true,
|
||||
"db": PMA_commonParams.get('db'),
|
||||
"table": PMA_commonParams.get('table'),
|
||||
"splitColumn": true,
|
||||
"numFields": numField
|
||||
},
|
||||
function(data) {
|
||||
if (data.success === true) {
|
||||
$('#newCols').html(data.message);
|
||||
$('.default_value').hide();
|
||||
$('.enum_notice').hide();
|
||||
$('.tblFooters').html("<input type='submit' id='saveSplit' value='"+PMA_messages.strSave+"'/>" +
|
||||
"<input type='submit' id='cancelSplit' value='"+PMA_messages.strCancel+"' "+
|
||||
"onclick=\"$('#newCols').html('');$(this).parent().html('')\"/>");
|
||||
}
|
||||
}
|
||||
);
|
||||
return false;
|
||||
});
|
||||
$('.tblFooters').on("click","#saveSplit", function() {
|
||||
central_column_list = [];
|
||||
if ($("#newCols #field_0_1").val() === '') {
|
||||
$("#newCols #field_0_1").focus();
|
||||
return false;
|
||||
}
|
||||
datastring = $('#newCols :input').serialize();
|
||||
datastring += "&ajax_request=1&do_save_data=1&field_where=last";
|
||||
$.post("tbl_addfield.php", datastring, function(data) {
|
||||
if (data.success) {
|
||||
$.get(
|
||||
"sql.php",
|
||||
{
|
||||
"token": PMA_commonParams.get('token'),
|
||||
"ajax_request": true,
|
||||
"db": PMA_commonParams.get('db'),
|
||||
"table": PMA_commonParams.get('table'),
|
||||
"dropped_column": selectedCol,
|
||||
"sql_query": 'ALTER TABLE `' + PMA_commonParams.get('table') + '` DROP `' + selectedCol + '`;',
|
||||
"is_js_confirmed": 1
|
||||
},
|
||||
function(data) {
|
||||
if (data.success === true) {
|
||||
appendHtmlColumnsList();
|
||||
$('#newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
selectedCol = '';
|
||||
}
|
||||
);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#extra").on("click", "#addNewPrimary", function() {
|
||||
$.get(
|
||||
"normalization.php",
|
||||
{
|
||||
"token": PMA_commonParams.get('token'),
|
||||
"ajax_request": true,
|
||||
"db": PMA_commonParams.get('db'),
|
||||
"table": PMA_commonParams.get('table'),
|
||||
"addNewPrimary": true
|
||||
},
|
||||
function(data) {
|
||||
if (data.success === true) {
|
||||
$('#newCols').html(data.message);
|
||||
$('.default_value').hide();
|
||||
$('.enum_notice').hide();
|
||||
$('.tblFooters').html("<input type='submit' id='saveNewPrimary' value='"+PMA_messages.strSave+"'/>" +
|
||||
"<input type='submit' id='cancelSplit' value='"+PMA_messages.strCancel+"' "+
|
||||
"onclick=\"$('#newCols').html('');$(this).parent().html('')\"/>");
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
);
|
||||
return false;
|
||||
});
|
||||
$(".tblFooters").on("click", "#saveNewPrimary", function() {
|
||||
datastring = $('#newCols :input').serialize();
|
||||
datastring += "&field_key[0]=primary_0&ajax_request=1&do_save_data=1&field_where=last";
|
||||
$.post("tbl_addfield.php", datastring, function(data) {
|
||||
if (data.success === true) {
|
||||
$("#mainContent h4").html(PMA_messages.uniqueColAdded);
|
||||
$("#mainContent p").html(PMA_messages.toNextStep);
|
||||
$("#mainContent #extra").html('');
|
||||
$("#mainContent #newCols").html('');
|
||||
$('.tblFooters').html('');
|
||||
setTimeout(function() {
|
||||
goToStep3();
|
||||
}, 2000);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
$("#extra").on("click", "#removeRedundant", function() {
|
||||
var dropQuery = 'ALTER TABLE `' + PMA_commonParams.get('table') + '` ';
|
||||
$("#extra input[type=checkbox]:checked").each(function() {
|
||||
dropQuery += 'DROP `' + $(this).val() + '`, ';
|
||||
});
|
||||
dropQuery = dropQuery.slice(0, -2);
|
||||
$.get(
|
||||
"sql.php",
|
||||
{
|
||||
"token": PMA_commonParams.get('token'),
|
||||
"ajax_request": true,
|
||||
"db": PMA_commonParams.get('db'),
|
||||
"table": PMA_commonParams.get('table'),
|
||||
"sql_query": dropQuery,
|
||||
"is_js_confirmed": 1
|
||||
},
|
||||
function(data) {
|
||||
if (data.success === true) {
|
||||
goToStep2('gotoFinish');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
$("#mainContent p").on("click", "#createUniqueColumns", function(event) {
|
||||
event.preventDefault();
|
||||
var url = 'create_index=1&server=' + PMA_commonParams.get('server')
|
||||
+ '&db='+PMA_commonParams.get('db')+'&table='+PMA_commonParams.get('table')+'&added_fields=1'
|
||||
+ '&token=' +PMA_commonParams.get('token')+'&ajax_request=true';
|
||||
var title = PMA_messages.strAddUniqueIndex;
|
||||
indexEditorDialog(url, title, function(){
|
||||
//on success
|
||||
$("#sqlqueryresults").remove();
|
||||
$('#result_query').remove();
|
||||
$('.tblFooters').html('');
|
||||
goToStep2('goToStep3');
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
276
libraries/normalization.lib.php
Normal file
276
libraries/normalization.lib.php
Normal file
@ -0,0 +1,276 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* set of functions used for normalization
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* build the html for columns of $colTypeCategory catgory
|
||||
* in form of given $listType in a table
|
||||
*
|
||||
* @param string $db current databse
|
||||
* @param string $table current table
|
||||
* @param string $colTypeCategory supported all|numeric|string|spatial|date and time
|
||||
* @param string $listType type of list to buld, supported dropdown|checkbox
|
||||
*
|
||||
* @return HTML for list of columns in form of given list types
|
||||
*/
|
||||
function PMA_getHtmlForColumnsList(
|
||||
$db, $table, $colTypeCategory='all', $listType='dropdown'
|
||||
) {
|
||||
$columnTypeList = array();
|
||||
if ($colTypeCategory != 'all') {
|
||||
$types = $GLOBALS['PMA_Types']->getColumns();
|
||||
$columnTypeList = $types[ucfirst($colTypeCategory)];
|
||||
}
|
||||
$GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
|
||||
$columns = (array) $GLOBALS['dbi']->getColumns(
|
||||
$db, $table, null,
|
||||
true, $GLOBALS['userlink']
|
||||
);
|
||||
$type = "";
|
||||
$selectColHtml = "";
|
||||
foreach ($columns as $column=>$def) {
|
||||
if (isset($def['Type'])) {
|
||||
$extracted_columnspec = PMA_Util::extractColumnSpec($def['Type']);
|
||||
$type = $extracted_columnspec['type'];
|
||||
}
|
||||
if (empty($columnTypeList) || in_array(strtoupper($type), $columnTypeList)) {
|
||||
if ($listType == 'checkbox') {
|
||||
$selectColHtml .= '<input type="checkbox" value="'
|
||||
. htmlspecialchars($column) . '"/>'
|
||||
. htmlspecialchars($column) . ' [ ' . $def['Type'] . ' ]</br>';
|
||||
} else {
|
||||
$selectColHtml .= '<option value="' . htmlspecialchars($column) . ''
|
||||
. '">' . htmlspecialchars($column) . ' [ ' . $def['Type'] . ' ]'
|
||||
. '</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $selectColHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to check if any unique column or group of columns exist or not
|
||||
*
|
||||
* @param string $db current database
|
||||
* @param string $table current table
|
||||
*
|
||||
* @return "1" if the unique columns exist, otherwise "0"
|
||||
*/
|
||||
function PMA_checkUniqueColumn($db, $table)
|
||||
{
|
||||
$query = "SELECT EXISTS(
|
||||
SELECT 1
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = '" . $db . "'
|
||||
and table_name='" . $table . "'
|
||||
and column_key = 'PRI'
|
||||
) As HasUniqueKey";
|
||||
$result = $GLOBALS['dbi']->fetchResult($query, null, null, $GLOBALS['userlink']);
|
||||
return $result[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* get the html of the form to add the new column to given table
|
||||
*
|
||||
* @param integer $num_fields number of columns to add
|
||||
* @param string $db current database
|
||||
* @param string $table current table
|
||||
* @param array $columnMeta array containing default values for the fields
|
||||
*
|
||||
* @return HTML
|
||||
*/
|
||||
function PMA_getHtmlForCreateNewColumn(
|
||||
$num_fields, $db, $table, $columnMeta=array()
|
||||
) {
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
$content_cells = array();
|
||||
$available_mime = array();
|
||||
$mime_map = array();
|
||||
$header_cells = PMA_getHeaderCells(
|
||||
true, null,
|
||||
$cfgRelation['mimework'], $db, $table
|
||||
);
|
||||
if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
|
||||
$mime_map = PMA_getMIME($db, $table);
|
||||
$available_mime = PMA_getAvailableMIMEtypes();
|
||||
}
|
||||
$comments_map = PMA_getComments($db, $table);
|
||||
for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
|
||||
$content_cells[$columnNumber] = PMA_getHtmlForColumnAttributes(
|
||||
$columnNumber, $columnMeta, '',
|
||||
8, '', null, array(), null, null, null,
|
||||
$comments_map, null, true,
|
||||
array(), $cfgRelation,
|
||||
$available_mime, $mime_map
|
||||
);
|
||||
}
|
||||
return PMA_getHtmlForTableFieldDefinitions($header_cells, $content_cells);
|
||||
}
|
||||
/**
|
||||
* buld the html for step 1.1 of normalization
|
||||
*
|
||||
* @param string $db current database
|
||||
* @param string $table current table
|
||||
*
|
||||
* @return HTML for step 1.1
|
||||
*/
|
||||
function PMA_getHtmlFor1NFStep1($db, $table)
|
||||
{
|
||||
$step = 1;
|
||||
$stepTxt = __('Make all columns atomic');
|
||||
$html = "<h3 style='text-align:center'>"
|
||||
. __('First step of normalization (1NF)') . "</h3>";
|
||||
$html .= "<div id='mainContent'>" .
|
||||
"<fieldset>" .
|
||||
"<legend>" . __('Step 1.') . $step . " " . $stepTxt . "</legend>" .
|
||||
"<h4>" . __(
|
||||
'Do you have any column which can be split into more than'
|
||||
. ' one column, '
|
||||
. 'For example: address can be split into street, city, country and zip.'
|
||||
)
|
||||
. "</br>(<a class='central_columns_dialog' data-maxrows='25' "
|
||||
. "data-pick=false href='#'> "
|
||||
. __('Show me the central list of columns that are not already in this table') . " </a>)</h4>"
|
||||
. "<p style='font-style:italic'>" . __(
|
||||
'Select a column which can be split into more '
|
||||
. 'than one. (on select of \'no such column\', it\'ll move to next step)'
|
||||
)
|
||||
. "</p>"
|
||||
. "<div id='extra'>"
|
||||
. "<select id='selectNonAtomicCol' name='makeAtomic'>"
|
||||
. "<option selected disabled>" . __('Select one ...') . "</option>" .
|
||||
"<option value='no_such_col'>" . __('No such column') . "</option>" .
|
||||
PMA_getHtmlForColumnsList($db, $table, 'string') .
|
||||
"</select>"
|
||||
. "<span>" . __('split into ')
|
||||
. "</span><input id='numField' type='number' value='2'>"
|
||||
. "<input type='submit' id='splitGo' value='" . __('Go') . "'/></div>"
|
||||
. "<div id='newCols'></div>"
|
||||
. "</fieldset><fieldset class='tblFooters'>"
|
||||
. "</fieldset>"
|
||||
. "</div>";
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* build the html contents of various html elements in step 1.2
|
||||
*
|
||||
* @param string $db current database
|
||||
* @param string $table current table
|
||||
*
|
||||
* @return HTML contents for step 1.2
|
||||
*/
|
||||
function PMA_getHtmlContentsFor1NFStep2($db, $table)
|
||||
{
|
||||
$step = 2;
|
||||
$stepTxt = __('Have unique columns');
|
||||
$hasPrimaryKey = PMA_checkUniqueColumn($db, $table);
|
||||
$legendText = __('Step 1.') . $step . " " . $stepTxt;
|
||||
$extra = '';
|
||||
if ($hasPrimaryKey) {
|
||||
$headText = __("Unique column(s) already exist");
|
||||
$subText = __("Taking you to next step ...");
|
||||
} else {
|
||||
$headText = __(
|
||||
"There are no unique columns. Add an unique column "
|
||||
. "(or combination of columns) that uniquely identify all rows. "
|
||||
);
|
||||
$subText = '<a href="#" id="createUniqueColumns">'
|
||||
. PMA_Util::getIcon(
|
||||
'b_index_add.png', __(
|
||||
'Add unique/primary index on existing column(s)'
|
||||
)
|
||||
)
|
||||
. '</a>';
|
||||
$extra = __(
|
||||
"If it's not possible to make existing "
|
||||
. "column combinations as unique then"
|
||||
) . "<br/>"
|
||||
. '<a href="#" id="addNewPrimary">'
|
||||
. __('+ Add a new unique column (primary key)') . '</a>';
|
||||
}
|
||||
$res = array('legendText'=>$legendText, 'headText'=>$headText,
|
||||
'subText'=>$subText, 'hasPrimaryKey'=>$hasPrimaryKey, 'extra'=>$extra);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* build the html contents of various html elements in step 1.3
|
||||
*
|
||||
* @param string $db current database
|
||||
* @param string $table current table
|
||||
*
|
||||
* @return HTML contents for step 1.3
|
||||
*/
|
||||
function PMA_getHtmlContentsFor1NFStep3($db, $table)
|
||||
{
|
||||
$step = 3;
|
||||
$stepTxt = __('Remove redundant columns');
|
||||
$legendText = __('Step 1.') . $step . " " . $stepTxt;
|
||||
$headText = __(
|
||||
"Do you have group of columns which on combining gives an existing
|
||||
column. for ex. if have first_name, last_name and full_name then
|
||||
combining first_name and last_name gives full_name which is redundant"
|
||||
);
|
||||
$subText = __(
|
||||
"Check the columns which are redundant and click on remove. "
|
||||
. "If no redundant column, click on 'No redundant column'"
|
||||
);
|
||||
$extra = PMA_getHtmlForColumnsList($db, $table, 'all', "checkbox") . "</br>"
|
||||
. '<input type="submit" id="removeRedundant" value="'
|
||||
. __('Remove selected') . '"/>'
|
||||
. '<input type="submit" value="' . __('No redundant column')
|
||||
. '" onclick="goToFinish();"'
|
||||
. '/>';
|
||||
$res = array(
|
||||
'legendText'=>$legendText, 'headText'=>$headText,
|
||||
'subText'=>$subText, 'extra'=>$extra
|
||||
);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* get html for options to normalize table
|
||||
*
|
||||
* @return HTML
|
||||
*/
|
||||
function PMA_getHtmlForNormalizetable()
|
||||
{
|
||||
$html_output = '<form method="post" action="normalization.php" '
|
||||
. 'name="normalize" '
|
||||
. 'id="normalizeTable" '
|
||||
. ' class="ajax" >'
|
||||
. PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table'])
|
||||
. '<input type="hidden" name="step1" value="1">';
|
||||
$html_output .= '<fieldset>';
|
||||
$html_output .= '<legend>'
|
||||
. __('Improve table structure (Normalization):') . '</legend>';
|
||||
$html_output .= '<h3>' . __('Select up to what step you want to normalize') . '</h3>';
|
||||
$choices = array(
|
||||
'1nf' => __('First step of normalization (1NF)'),
|
||||
'2nf' => __('Second step of normalization (1NF+2NF)'),
|
||||
'3nf' => __('Third step of normalization (1NF+2NF+3NF)'));
|
||||
|
||||
$html_output .= PMA_Util::getRadioFields(
|
||||
'normalizeTo', $choices, '1nf', true
|
||||
);
|
||||
$html_output .= '</fieldset><fieldset class="tblFooters">'
|
||||
. "<span style='float:left'>" . __(
|
||||
'Hint: Please follow the procedure carefully in order '
|
||||
. 'to obtain correct normalizarion'
|
||||
) . "</span>"
|
||||
. '<input type="submit" name="submit_normalize" value="' . __('Go') . '" />'
|
||||
. '</fieldset>'
|
||||
. '</form>'
|
||||
. '</div>';
|
||||
|
||||
return $html_output;
|
||||
}
|
||||
@ -1615,6 +1615,9 @@ function PMA_getHtmlForOptionalActionLinks($url_query, $tbl_is_view,
|
||||
$html_output .= '<a href="#" id="move_columns_anchor">'
|
||||
. PMA_Util::getIcon('b_move.png', __('Move columns'), true)
|
||||
. '</a>';
|
||||
$html_output .= '<a href="normalization.php?' . $url_query . '">'
|
||||
. PMA_Util::getIcon('normalize.png', __('Improve table structure'), true)
|
||||
. '</a>';
|
||||
}
|
||||
|
||||
return $html_output;
|
||||
|
||||
72
normalization.php
Normal file
72
normalization.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Normalization process (temporarily specific to 1NF)
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/transformations.lib.php';
|
||||
require_once 'libraries/normalization.lib.php';
|
||||
require_once 'libraries/tbl_columns_definition_form.lib.php';
|
||||
|
||||
if (isset($_REQUEST['getColumns'])) {
|
||||
$html = '<option selected disabled>' . __('Select one ...') . '</option>'
|
||||
. '<option value="no_such_col">' . __('No such column') . '</option>';
|
||||
//get column whose datatype falls under string category
|
||||
$html .= PMA_getHtmlForColumnsList($db, $table, 'string');
|
||||
echo $html;
|
||||
exit;
|
||||
}
|
||||
if (isset($_REQUEST['splitColumn'])) {
|
||||
$num_fields = $_REQUEST['numFields'];
|
||||
$html = PMA_getHtmlForCreateNewColumn($num_fields, $db, $table);
|
||||
$html .= PMA_URL_getHiddenInputs($db, $table);
|
||||
echo $html;
|
||||
exit;
|
||||
}
|
||||
if (isset($_REQUEST['addNewPrimary'])) {
|
||||
$num_fields = 1;
|
||||
$columnMeta = array('Field'=>$table . "_id", 'Extra'=>'auto_increment');
|
||||
$html = PMA_getHtmlForCreateNewColumn(
|
||||
$num_fields, $db, $table, $columnMeta
|
||||
);
|
||||
$html .= PMA_URL_getHiddenInputs($db, $table);
|
||||
echo $html;
|
||||
exit;
|
||||
}
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('normalization.js');
|
||||
$scripts->addFile('jquery/jquery.uitablefilter.js');
|
||||
if (isset($_REQUEST['normalizeTo'])) {
|
||||
$normalForm = $_REQUEST['normalizeTo'];
|
||||
if ($normalForm != '1nf') {
|
||||
$response->addHTML(
|
||||
'<h3 style="text-align:center">'
|
||||
. __('Second/Third step of normalization') . '</h3>'
|
||||
. '<fieldset>'
|
||||
. '<legend>Coming soon...</legend>'
|
||||
. 'Wait is worth it :-)</fieldset>'
|
||||
);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['step1'])) {
|
||||
$html = PMA_getHtmlFor1NFStep1($db, $table);
|
||||
$response->addHTML($html);
|
||||
} else if (isset($_REQUEST['step2'])) {
|
||||
$res = PMA_getHtmlContentsFor1NFStep2($db, $table);
|
||||
$response->addJSON($res);
|
||||
} else if (isset($_REQUEST['step3'])) {
|
||||
$res = PMA_getHtmlContentsFor1NFStep3($db, $table);
|
||||
$response->addJSON($res);
|
||||
} else {
|
||||
$response->addHTML(PMA_getHtmlForNormalizetable());
|
||||
}
|
||||
@ -93,6 +93,7 @@ if (isset($_REQUEST['do_save_data'])) {
|
||||
} else {
|
||||
$error_message_html = PMA_Util::mysqlDie('', '', false, $err_url, false);
|
||||
$response->addHTML($error_message_html);
|
||||
$response->isSuccess(false);
|
||||
exit;
|
||||
}
|
||||
} // end do alter table
|
||||
|
||||
@ -18,7 +18,6 @@ require_once 'libraries/operations.lib.php';
|
||||
|
||||
$pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
|
||||
$response = PMA_Response::getInstance();
|
||||
|
||||
/**
|
||||
* Runs common work
|
||||
*/
|
||||
|
||||
BIN
themes/original/img/normalize.png
Normal file
BIN
themes/original/img/normalize.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 695 B |
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
@ -535,158 +535,163 @@ function PMA_sprites()
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
'pause' => array(
|
||||
'normalize' => array(
|
||||
'position' => '105',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
'play' => array(
|
||||
'pause' => array(
|
||||
'position' => '106',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_asc' => array(
|
||||
'play' => array(
|
||||
'position' => '107',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_asc' => array(
|
||||
'position' => '108',
|
||||
'width' => '11',
|
||||
'height' => '9'
|
||||
),
|
||||
's_asci' => array(
|
||||
'position' => '108',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_cancel' => array(
|
||||
'position' => '109',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_cog' => array(
|
||||
's_cancel' => array(
|
||||
'position' => '110',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_db' => array(
|
||||
's_cog' => array(
|
||||
'position' => '111',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_desc' => array(
|
||||
's_db' => array(
|
||||
'position' => '112',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_desc' => array(
|
||||
'position' => '113',
|
||||
'width' => '11',
|
||||
'height' => '9'
|
||||
),
|
||||
's_error' => array(
|
||||
'position' => '113',
|
||||
'position' => '114',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_error2' => array(
|
||||
'position' => '114',
|
||||
'position' => '115',
|
||||
'width' => '11',
|
||||
'height' => '11'
|
||||
),
|
||||
's_host' => array(
|
||||
'position' => '115',
|
||||
'position' => '116',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_info' => array(
|
||||
'position' => '116',
|
||||
'position' => '117',
|
||||
'width' => '11',
|
||||
'height' => '11'
|
||||
),
|
||||
's_lang' => array(
|
||||
'position' => '117',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_lock' => array(
|
||||
'position' => '118',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_loggoff' => array(
|
||||
's_lock' => array(
|
||||
'position' => '119',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_notice' => array(
|
||||
's_loggoff' => array(
|
||||
'position' => '120',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_passwd' => array(
|
||||
's_notice' => array(
|
||||
'position' => '121',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_really' => array(
|
||||
's_passwd' => array(
|
||||
'position' => '122',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_really' => array(
|
||||
'position' => '123',
|
||||
'width' => '11',
|
||||
'height' => '11'
|
||||
),
|
||||
's_reload' => array(
|
||||
'position' => '123',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_replication' => array(
|
||||
'position' => '124',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_rights' => array(
|
||||
's_replication' => array(
|
||||
'position' => '125',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_sortable' => array(
|
||||
's_rights' => array(
|
||||
'position' => '126',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_sortable' => array(
|
||||
'position' => '127',
|
||||
'width' => '11',
|
||||
'height' => '15'
|
||||
),
|
||||
's_status' => array(
|
||||
'position' => '127',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_success' => array(
|
||||
'position' => '128',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_sync' => array(
|
||||
's_success' => array(
|
||||
'position' => '129',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_tbl' => array(
|
||||
's_sync' => array(
|
||||
'position' => '130',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_theme' => array(
|
||||
's_tbl' => array(
|
||||
'position' => '131',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_top' => array(
|
||||
's_theme' => array(
|
||||
'position' => '132',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_vars' => array(
|
||||
's_top' => array(
|
||||
'position' => '133',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_views' => array(
|
||||
's_vars' => array(
|
||||
'position' => '134',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_views' => array(
|
||||
'position' => '135',
|
||||
'width' => '10',
|
||||
'height' => '10'
|
||||
),
|
||||
'window-new' => array(
|
||||
'position' => '135',
|
||||
'position' => '136',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
|
||||
BIN
themes/pmahomme/img/normalize.png
Normal file
BIN
themes/pmahomme/img/normalize.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 695 B |
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 44 KiB |
@ -600,186 +600,191 @@ function PMA_sprites()
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
'pause' => array(
|
||||
'normalize' => array(
|
||||
'position' => '118',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
'php_sym' => array(
|
||||
'pause' => array(
|
||||
'position' => '119',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
'play' => array(
|
||||
'php_sym' => array(
|
||||
'position' => '120',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_asc' => array(
|
||||
'play' => array(
|
||||
'position' => '121',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_asci' => array(
|
||||
's_asc' => array(
|
||||
'position' => '122',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_attention' => array(
|
||||
's_asci' => array(
|
||||
'position' => '123',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_cancel' => array(
|
||||
's_attention' => array(
|
||||
'position' => '124',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_cancel2' => array(
|
||||
's_cancel' => array(
|
||||
'position' => '125',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_cog' => array(
|
||||
's_cancel2' => array(
|
||||
'position' => '126',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_db' => array(
|
||||
's_cog' => array(
|
||||
'position' => '127',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_desc' => array(
|
||||
's_db' => array(
|
||||
'position' => '128',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_error' => array(
|
||||
's_desc' => array(
|
||||
'position' => '129',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_error2' => array(
|
||||
's_error' => array(
|
||||
'position' => '130',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_error2' => array(
|
||||
'position' => '131',
|
||||
'width' => '11',
|
||||
'height' => '11'
|
||||
),
|
||||
's_host' => array(
|
||||
'position' => '131',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_info' => array(
|
||||
'position' => '132',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_lang' => array(
|
||||
's_info' => array(
|
||||
'position' => '133',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_lock' => array(
|
||||
's_lang' => array(
|
||||
'position' => '134',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_loggoff' => array(
|
||||
's_lock' => array(
|
||||
'position' => '135',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_notice' => array(
|
||||
's_loggoff' => array(
|
||||
'position' => '136',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_okay' => array(
|
||||
's_notice' => array(
|
||||
'position' => '137',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_passwd' => array(
|
||||
's_okay' => array(
|
||||
'position' => '138',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_process' => array(
|
||||
's_passwd' => array(
|
||||
'position' => '139',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_really' => array(
|
||||
's_process' => array(
|
||||
'position' => '140',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_really' => array(
|
||||
'position' => '141',
|
||||
'width' => '11',
|
||||
'height' => '11'
|
||||
),
|
||||
's_reload' => array(
|
||||
'position' => '141',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_replication' => array(
|
||||
'position' => '142',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_rights' => array(
|
||||
's_replication' => array(
|
||||
'position' => '143',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_sortable' => array(
|
||||
's_rights' => array(
|
||||
'position' => '144',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_status' => array(
|
||||
's_sortable' => array(
|
||||
'position' => '145',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_success' => array(
|
||||
's_status' => array(
|
||||
'position' => '146',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_sync' => array(
|
||||
's_success' => array(
|
||||
'position' => '147',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_tbl' => array(
|
||||
's_sync' => array(
|
||||
'position' => '148',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_theme' => array(
|
||||
's_tbl' => array(
|
||||
'position' => '149',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_top' => array(
|
||||
's_theme' => array(
|
||||
'position' => '150',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_vars' => array(
|
||||
's_top' => array(
|
||||
'position' => '151',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
's_views' => array(
|
||||
's_vars' => array(
|
||||
'position' => '152',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
'window-new' => array(
|
||||
's_views' => array(
|
||||
'position' => '153',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
'window-new' => array(
|
||||
'position' => '154',
|
||||
'width' => '16',
|
||||
'height' => '16'
|
||||
),
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user