From 14c02c1e67b1fbf019e4752fc50f8f4f2c612c2c Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 26 Sep 2010 07:22:58 -0400 Subject: [PATCH 1/4] to avoid undefined attribute errors, give different ids to the create table form and add fields form; then use the .live() method directly after a selector as recommended --- js/functions.js | 140 +++++++++++++++++-------------- libraries/tbl_properties.inc.php | 2 +- 2 files changed, 79 insertions(+), 63 deletions(-) diff --git a/js/functions.js b/js/functions.js index 292e54406..f3278843b 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2035,17 +2035,85 @@ $(document).ready(function() { }); /** - * Attach event handler for submission of create table form + * Attach event handler for submission of create table form (save) * * @uses PMA_ajaxShowMessage() * @uses $.PMA_sort_table() * @uses window.parent.refreshNavigation() * - * The create_table_form whose action is tbl_create.php is the - * one which is ajaxified; in this form the action could be - * tbl_addfield.php but it's not ajaxified yet. */ - $("#create_table_form").attr('action').is('tbl_create.php').find("input[name=submit_num_fields], input[name=do_save_data]").live('click', function(event) { + // .live() must be called after a selector, see http://api.jquery.com/live + $("#create_table_form input[name=do_save_data]").live('click', function(event) { + event.preventDefault(); + + /** + * @var the_form object referring to the create table form + */ + var the_form = $("#create_table_form"); + + PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); + $(the_form).append(''); + //User wants to submit the form + $.post($(the_form).attr('action'), $(the_form).serialize() + "&do_save_data=" + $(this).val(), function(data) { + if(data.success == true) { + PMA_ajaxShowMessage(data.message); + $("#create_table_dialog").dialog("close").remove(); + + /** + * @var tables_table Object referring to the element that holds the list of tables + */ + var tables_table = $("#tablesForm").find("tbody").not("#tbl_summary_row"); + + /** + * @var curr_last_row Object referring to the last element in {@link tables_table} + */ + var curr_last_row = $(tables_table).find('tr:last'); + /** + * @var curr_last_row_index_string String containing the index of {@link curr_last_row} + */ + var curr_last_row_index_string = $(curr_last_row).find('input:checkbox').attr('id').match(/\d+/)[0]; + /** + * @var curr_last_row_index Index of {@link curr_last_row} + */ + var curr_last_row_index = parseFloat(curr_last_row_index_string); + /** + * @var new_last_row_index Index of the new row to be appended to {@link tables_table} + */ + var new_last_row_index = curr_last_row_index + 1; + /** + * @var new_last_row_id String containing the id of the row to be appended to {@link tables_table} + */ + var new_last_row_id = 'checkbox_tbl_' + new_last_row_index; + + //append to table + $(data.new_table_string) + .find('input:checkbox') + .val(new_last_row_id) + .end() + .appendTo(tables_table); + + //Sort the table + $(tables_table).PMA_sort_table('th'); + + //Refresh navigation frame as a new table has been added + window.parent.refreshNavigation(); + } + else { + PMA_ajaxShowMessage(data.error); + } + }) // end $.post() + }) // end create table form (save) + + /** + * Attach event handler for create table form (add fields) + * + * @uses PMA_ajaxShowMessage() + * @uses $.PMA_sort_table() + * @uses window.parent.refreshNavigation() + * + */ + // .live() must be called after a selector, see http://api.jquery.com/live + $("#create_table_form input[name=submit_num_fields]").live('click', function(event) { event.preventDefault(); /** @@ -2056,64 +2124,12 @@ $(document).ready(function() { PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); $(the_form).append(''); - if($(this).attr('name') == 'submit_num_fields') { - //User wants to add more fields to the table - $.post($(the_form).attr('action'), $(the_form).serialize() + "&submit_num_fields=" + $(this).val(), function(data) { - $("#create_table_dialog").html(data); - }) //end $.post() - } - else if($(this).attr('name') == 'do_save_data') { - //User wants to submit the form - $.post($(the_form).attr('action'), $(the_form).serialize() + "&do_save_data=" + $(this).val(), function(data) { - if(data.success == true) { - PMA_ajaxShowMessage(data.message); - $("#create_table_dialog").dialog("close").remove(); + //User wants to add more fields to the table + $.post($(the_form).attr('action'), $(the_form).serialize() + "&submit_num_fields=" + $(this).val(), function(data) { + $("#create_table_dialog").html(data); + }) //end $.post() - /** - * @var tables_table Object referring to the element that holds the list of tables - */ - var tables_table = $("#tablesForm").find("tbody").not("#tbl_summary_row"); - - /** - * @var curr_last_row Object referring to the last element in {@link tables_table} - */ - var curr_last_row = $(tables_table).find('tr:last'); - /** - * @var curr_last_row_index_string String containing the index of {@link curr_last_row} - */ - var curr_last_row_index_string = $(curr_last_row).find('input:checkbox').attr('id').match(/\d+/)[0]; - /** - * @var curr_last_row_index Index of {@link curr_last_row} - */ - var curr_last_row_index = parseFloat(curr_last_row_index_string); - /** - * @var new_last_row_index Index of the new row to be appended to {@link tables_table} - */ - var new_last_row_index = curr_last_row_index + 1; - /** - * @var new_last_row_id String containing the id of the row to be appended to {@link tables_table} - */ - var new_last_row_id = 'checkbox_tbl_' + new_last_row_index; - - //append to table - $(data.new_table_string) - .find('input:checkbox') - .val(new_last_row_id) - .end() - .appendTo(tables_table); - - //Sort the table - $(tables_table).PMA_sort_table('th'); - - //Refresh navigation frame as a new table has been added - window.parent.refreshNavigation(); - } - else { - PMA_ajaxShowMessage(data.error); - } - }) // end $.post() - } // end elseif() - }) // end create table form submit button actions + }) // end create table form (add fields) }, 'top.frame_content'); //end $(document).ready for 'Create Table' diff --git a/libraries/tbl_properties.inc.php b/libraries/tbl_properties.inc.php index c093635fe..0127ae2d5 100644 --- a/libraries/tbl_properties.inc.php +++ b/libraries/tbl_properties.inc.php @@ -610,7 +610,7 @@ document.onkeydown = onKeyDownArrowsHandler; } ?> -
+ Date: Sun, 26 Sep 2010 07:29:49 -0400 Subject: [PATCH 2/4] XHTML compliance --- libraries/tbl_properties.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/tbl_properties.inc.php b/libraries/tbl_properties.inc.php index 0127ae2d5..001fea6d1 100644 --- a/libraries/tbl_properties.inc.php +++ b/libraries/tbl_properties.inc.php @@ -369,7 +369,7 @@ for ($i = 0; $i < $num_fields; $i++) { . ' class="textfield" />' . '

'; $content_cells[$i][$ci] .= __('ENUM or SET data too long?') - . ' ' + . ' ' . __('Get more editing space') . '

'; $ci++; From ddc99a3deeab80db72cf52f88ddbe685b68e52d1 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 26 Sep 2010 07:39:37 -0400 Subject: [PATCH 3/4] renaming mysql db does not make sense --- db_operations.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db_operations.php b/db_operations.php index c17d372ff..2f8935142 100644 --- a/db_operations.php +++ b/db_operations.php @@ -343,6 +343,7 @@ if (!$is_information_schema) { /** * rename database */ +if ($db != 'mysql') { ?> @@ -383,9 +384,11 @@ if (!$is_information_schema) {
From eef35043dd2524b0f8ea2a2e840a24784fd75fd8 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 26 Sep 2010 08:39:28 -0400 Subject: [PATCH 4/4] bug #3072502 Text not shown for icons after creating table --- db_structure.php | 42 +--------------------- libraries/build_action_titles.inc.php | 51 +++++++++++++++++++++++++++ tbl_create.php | 21 +++++------ 3 files changed, 61 insertions(+), 53 deletions(-) create mode 100644 libraries/build_action_titles.inc.php diff --git a/db_structure.php b/db_structure.php index f16654778..5ebabd9bc 100644 --- a/db_structure.php +++ b/db_structure.php @@ -70,47 +70,7 @@ $db_collation = PMA_getDbCollation($db); // in a separate file to avoid redeclaration of functions in some code paths require_once './libraries/db_structure.lib.php'; - -$titles = array(); -if (true == $cfg['PropertiesIconic']) { - $titles['Browse'] = '' . __('Browse') . ''; - $titles['NoBrowse'] = '' . __('Browse') . ''; - $titles['Search'] = '' . __('Search') . ''; - $titles['NoSearch'] = '' . __('Search') . ''; - $titles['Insert'] = '' . __('Insert') . ''; - $titles['NoInsert'] = '' . __('Insert') . ''; - $titles['Structure'] = '' . __('Structure') . ''; - $titles['Drop'] = '' . __('Drop') . ''; - $titles['NoDrop'] = '' . __('Drop') . ''; - $titles['Empty'] = '' . __('Empty') . ''; - $titles['NoEmpty'] = '' . __('Empty') . ''; - - if ('both' === $cfg['PropertiesIconic']) { - $titles['Browse'] .= __('Browse'); - $titles['Search'] .= __('Search'); - $titles['NoBrowse'] .= __('Browse'); - $titles['NoSearch'] .= __('Search'); - $titles['Insert'] .= __('Insert'); - $titles['NoInsert'] .= __('Insert'); - $titles['Structure'] .= __('Structure'); - $titles['Drop'] .= __('Drop'); - $titles['NoDrop'] .= __('Drop'); - $titles['Empty'] .= __('Empty'); - $titles['NoEmpty'] .= __('Empty'); - } -} else { - $titles['Browse'] = __('Browse'); - $titles['Search'] = __('Search'); - $titles['NoBrowse'] = __('Browse'); - $titles['NoSearch'] = __('Search'); - $titles['Insert'] = __('Insert'); - $titles['NoInsert'] = __('Insert'); - $titles['Structure'] = __('Structure'); - $titles['Drop'] = __('Drop'); - $titles['NoDrop'] = __('Drop'); - $titles['Empty'] = __('Empty'); - $titles['NoEmpty'] = __('Empty'); -} +require_once './libraries/build_action_titles.inc.php'; /** * Displays the tables list diff --git a/libraries/build_action_titles.inc.php b/libraries/build_action_titles.inc.php new file mode 100644 index 000000000..e9da5f65f --- /dev/null +++ b/libraries/build_action_titles.inc.php @@ -0,0 +1,51 @@ +'; + $titles['NoBrowse'] = '' . __('Browse') . ''; + $titles['Search'] = '' . __('Search') . ''; + $titles['NoSearch'] = '' . __('Search') . ''; + $titles['Insert'] = '' . __('Insert') . ''; + $titles['NoInsert'] = '' . __('Insert') . ''; + $titles['Structure'] = '' . __('Structure') . ''; + $titles['Drop'] = '' . __('Drop') . ''; + $titles['NoDrop'] = '' . __('Drop') . ''; + $titles['Empty'] = '' . __('Empty') . ''; + $titles['NoEmpty'] = '' . __('Empty') . ''; + + if ('both' === $cfg['PropertiesIconic']) { + $titles['Browse'] .= __('Browse'); + $titles['Search'] .= __('Search'); + $titles['NoBrowse'] .= __('Browse'); + $titles['NoSearch'] .= __('Search'); + $titles['Insert'] .= __('Insert'); + $titles['NoInsert'] .= __('Insert'); + $titles['Structure'] .= __('Structure'); + $titles['Drop'] .= __('Drop'); + $titles['NoDrop'] .= __('Drop'); + $titles['Empty'] .= __('Empty'); + $titles['NoEmpty'] .= __('Empty'); + } +} else { + $titles['Browse'] = __('Browse'); + $titles['Search'] = __('Search'); + $titles['NoBrowse'] = __('Browse'); + $titles['NoSearch'] = __('Search'); + $titles['Insert'] = __('Insert'); + $titles['NoInsert'] = __('Insert'); + $titles['Structure'] = __('Structure'); + $titles['Drop'] = __('Drop'); + $titles['NoDrop'] = __('Drop'); + $titles['Empty'] = __('Empty'); + $titles['NoEmpty'] = __('Empty'); +} +?> diff --git a/tbl_create.php b/tbl_create.php index 0d15822ac..807755018 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -38,6 +38,7 @@ require_once './libraries/common.inc.php'; $action = 'tbl_create.php'; require_once './libraries/header.inc.php'; +require_once './libraries/build_action_titles.inc.php'; // Check parameters PMA_checkParameters(array('db')); @@ -299,25 +300,21 @@ if (isset($_REQUEST['do_save_data'])) { } $new_table_string .= '' . "\n"; - $new_table_string .= ' ' . __('Browse') . ' ' . "\n"; + $new_table_string .= '' . $titles['NoBrowse'] . '' . "\n"; - $new_table_string .= ' '; - $new_table_string .= '' . __('Structure') . ''; - $new_table_string .= ' ' . "\n"; + $new_table_string .= '' . $titles['Structure'] . '' . "\n"; - $new_table_string .= ' ' . __('Search') . ' ' . "\n"; + $new_table_string .= '' . $titles['NoSearch'] . '' . "\n"; - $new_table_string .= ' '; - $new_table_string .= '' . __('Insert') . ''; - $new_table_string .= ' ' . "\n"; + $new_table_string .= '' . $titles['Insert'] . '' . "\n"; - $new_table_string .= ' ' . __('Empty') . ' ' . "\n"; + $new_table_string .= '' . $titles['NoEmpty'] . '' . "\n"; - $new_table_string .= ' '; - $new_table_string .= '' . __('Drop') . ''; - $new_table_string .= ' ' . "\n"; + $new_table_string .= $titles['Drop']; + $new_table_string .= '' . "\n"; $new_table_string .= '' . $tbl_stats['Rows'] . '' . "\n";