diff --git a/ChangeLog b/ChangeLog index 531abce06..513d9f4cc 100755 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,10 @@ $Source$ - db with only table specific rights where not displayed if there was not at least one db with db specfic rights - javascript errors + * function.js, db_details_structure.php, tbl_properties_structure.php, + display_tbl.lib.php, server_databases.php: + - added js:markAllRows(), js:unMarkAllRows() + - check/uncheck all rows now sets mark color for this rows 2005-11-08 Sebastian Mendel * Documentation.html, browse_foreigners.php, error.php, diff --git a/db_details_structure.php b/db_details_structure.php index 8e446a4ef..095720b60 100644 --- a/db_details_structure.php +++ b/db_details_structure.php @@ -134,7 +134,7 @@ if ( true == $cfg['PropertiesIconic'] ) { * Displays the tables list */ ?> -
+ " width="38" height="22" alt="" /> + onclick="if ( markAllRows('tablesForm') ) return false;"> / + onclick="if ( unMarkAllRows('tablesForm') ) return false;"> / diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 5fc9b475c..fef4b0639 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -454,7 +454,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ global $db, $table, $goto, $dontlimitchars; global $sql_query, $num_rows, $pos, $session_max_rows; global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns; - + if ($analyzed_sql == '') { $analyzed_sql = array(); } @@ -573,7 +573,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ // Start of form for multi-rows delete if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp' ) { - echo '' . "\n"; + echo '' . "\n"; echo PMA_generate_common_hidden_inputs($db, $table, 1); echo '' . "\n"; echo '' . "\n"; @@ -584,7 +584,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ } echo '' . "\n" - . ' builds the // "primary" key to use in links @@ -1844,7 +1844,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) $delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill']; $propicon = (string)$GLOBALS['cfg']['PropertiesIconic']; - + $uncheckall_url = 'sql.php?' . PMA_generate_common_url($db, $table) . '&sql_query=' . urlencode($sql_query) @@ -1856,8 +1856,8 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) . '&goto=' . $goto . '&dontlimitchars=' . $dontlimitchars; $checkall_url = $uncheckall_url . '&checkall=1'; - $checkall_params['onclick'] = 'setCheckboxesRange(\'rowsDeleteForm\', true, \'id_rows_to_delete\', 0, ' . $num_rows . '); return false;'; - $uncheckall_params['onclick'] = 'setCheckboxesRange(\'rowsDeleteForm\', false, \'id_rows_to_delete\', 0, ' . $num_rows . '); return false;'; + $checkall_params['onclick'] = 'if ( markAllRows(\'rowsDeleteForm\') ) return false;'; + $uncheckall_params['onclick'] = 'if ( unMarkAllRows(\'rowsDeleteForm\') ) return false;'; $checkall_link = PMA_linkOrButton( $checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false ); $uncheckall_link = PMA_linkOrButton( $uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false ); ?> diff --git a/libraries/functions.js b/libraries/functions.js index f31b88e0e..66b1470e8 100644 --- a/libraries/functions.js +++ b/libraries/functions.js @@ -23,13 +23,13 @@ function selectContent( element, lock, only_once ) { if ( only_once && only_once_elements[element.name] ) { return; } - + only_once_elements[element.name] = true; - + if ( lock ) { return; - } - + } + element.select(); } @@ -89,9 +89,9 @@ function confirmLink(theLink, theSqlQuery) /** - * Displays an confirmation box before doing some action + * Displays an confirmation box before doing some action * - * @param object the message to display + * @param object the message to display * * @return boolean whether to run the query or not */ @@ -254,7 +254,7 @@ function checkSqlQuery(theForm) /** - * Check if a form's element is empty + * Check if a form's element is empty * should be * * @param object the form @@ -379,7 +379,7 @@ function checkTableEditForm(theForm, fieldsCnt) if (!emptyCheckTheField(theForm, id)) { atLeastOneField = 1; } - } + } } if (atLeastOneField == 0) { var theField = theForm.elements["field_0_1"]; @@ -490,8 +490,8 @@ function PMA_markRowsInit() { rows[i].onmousedown = function() { var unique_id; var checkbox; - - var checkbox = this.getElementsByTagName( 'input' )[0]; + + checkbox = this.getElementsByTagName( 'input' )[0]; if ( checkbox && checkbox.type == 'checkbox' ) { unique_id = checkbox.name + checkbox.value; } else if ( this.id.length > 0 ) { @@ -499,24 +499,24 @@ function PMA_markRowsInit() { } else { return; } - + if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) { marked_row[unique_id] = true; } else { marked_row[unique_id] = false; } - + if ( marked_row[unique_id] ) { this.className += ' marked'; } else { this.className = this.className.replace(' marked', ''); } - + if ( checkbox && checkbox.disabled == false ) { checkbox.checked = marked_row[unique_id]; } } - + // ... and disable label ... var labeltag = rows[i].getElementsByTagName('label')[0]; if ( labeltag ) { @@ -536,6 +536,62 @@ function PMA_markRowsInit() { } window.onload=PMA_markRowsInit; +/** + * marks all rows and selects its first checkbox inside the given element + * the given element is usaly a table or a div containing the table or tables + * + * @param container DOM element + */ +function markAllRows( container_id ) { + var rows = document.getElementById(container_id).getElementsByTagName('tr'); + var unique_id; + var checkbox; + + for ( var i = 0; i < rows.length; i++ ) { + + checkbox = rows[i].getElementsByTagName( 'input' )[0]; + + if ( checkbox && checkbox.type == 'checkbox' ) { + unique_id = checkbox.name + checkbox.value; + if ( checkbox.disabled == false ) { + checkbox.checked = true; + if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) { + rows[i].className += ' marked'; + marked_row[unique_id] = true; + } + } + } + } + + return true; +} + +/** + * marks all rows and selects its first checkbox inside the given element + * the given element is usaly a table or a div containing the table or tables + * + * @param container DOM element + */ +function unMarkAllRows( container_id ) { + var rows = document.getElementById(container_id).getElementsByTagName('tr'); + var unique_id; + var checkbox; + + for ( var i = 0; i < rows.length; i++ ) { + + checkbox = rows[i].getElementsByTagName( 'input' )[0]; + + if ( checkbox && checkbox.type == 'checkbox' ) { + unique_id = checkbox.name + checkbox.value; + checkbox.checked = false; + rows[i].className = rows[i].className.replace(' marked', ''); + marked_row[unique_id] = false; + } + } + + return true; +} + /** * Sets/unsets the pointer and marker in browse mode * @@ -609,7 +665,7 @@ function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerCol currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16); } } - + // 4. Defines the new color // 4.1 Current color is the default one if (currentColor == '' diff --git a/server_databases.php b/server_databases.php index 813c54d9d..9a9c4b38b 100644 --- a/server_databases.php +++ b/server_databases.php @@ -164,7 +164,7 @@ if ( count($databases) > 0 ) { 'footer' => 0, ); - echo '' . "\n" + echo '' . "\n" . PMA_generate_common_hidden_inputs('', '', 1) . '' . "\n" . '' . "\n" @@ -292,26 +292,20 @@ if ( count($databases) > 0 ) { echo ' ' . "\n"; } echo '' . "\n"; - unset( $column_order, $stat_name, $stat, $databases ); + echo '' . "\n" + .'
 
' . "\n"; + unset( $column_order, $stat_name, $stat, $databases, $table_columns ); if ($is_superuser || $cfg['AllowUserDropDatabase']) { $common_url_query = PMA_generate_common_url() . '&sort_by=' . $sort_by . '&sort_order=' . $sort_order . '&dbstats=' . $dbstats; - echo '' . "\n" - . ' ' . $strWithChecked . '' . "\n" - . ' ' . "\n" - . ' ' . $strCheckAll - . ' / ' . "\n" - . ' ' . "\n" - . ' ' . $strUncheckAll - . ' ' . "\n" - . ' ' . $strWithChecked . '' . "\n"; + echo '' . $strWithChecked . '' . "\n" + . '' . "\n" + . ' ' . $strCheckAll . ' / ' . "\n" + . '' . "\n" + . ' ' . $strUncheckAll . '' . "\n" + . '' . $strWithChecked . '' . "\n"; PMA_buttonOrImage( 'drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', $strDrop, 'b_deltbl.png' ); - echo ' ' . "\n" - . '' . "\n"; } - echo '' . "\n" - .'' . "\n"; - unset( $table_columns ); if ( $GLOBALS['cfg']['PropertiesIconic'] ) { // iconic view diff --git a/tbl_properties_structure.php b/tbl_properties_structure.php index 1821d5ff1..99532352b 100644 --- a/tbl_properties_structure.php +++ b/tbl_properties_structure.php @@ -85,7 +85,7 @@ $fields_cnt = PMA_DBI_num_rows($fields_rs); // the info given by SHOW FULL FIELDS FROM. // // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since -// SHOW FULL FIELDS says NULL and SHOW CREATE TABLE says NOT NULL (tested +// SHOW FULL FIELDS says NULL and SHOW CREATE TABLE says NOT NULL (tested // in MySQL 4.0.25). $show_create_table = PMA_DBI_fetch_value( @@ -155,7 +155,7 @@ if ( $cfg['PropertiesIconic'] == true ) { // table header $i = 0; ?> - + @@ -220,7 +220,7 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) { // for the case ENUM('–','“') $type = htmlspecialchars($type); - + $type_nowrap = ''; $binary = 0; @@ -291,14 +291,14 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) { if ($zerofill) { $attribute = 'UNSIGNED ZEROFILL'; } - + // MySQL 4.1.2+ TIMESTAMP options // (if on_update_current_timestamp is set, then it's TRUE) if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) { $attribute = 'ON UPDATE CURRENT_TIMESTAMP'; } - // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the + // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe // the latter. if (!empty($analyzed_sql[0]['create_table_fields'][$row['Field']]['type']) && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null']) { @@ -443,11 +443,11 @@ $checkall_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db,$t <?php echo $strWithChecked; ?> + onclick="if ( markAllRows('fieldsForm') ) return false;"> / + onclick="if ( unMarkAllRows('fieldsForm') ) return false;">