The branch, master has been updated via 64bac7dcdf1fbfb89528f5747223a928edc195d8 (commit) via c77216d53297f06605436814b07e7c6167198c21 (commit) from 97a5c047d135990f106d2db1918dbf34d2b4c49d (commit)
- Log ----------------------------------------------------------------- commit 64bac7dcdf1fbfb89528f5747223a928edc195d8 Author: Philip Frank bananer@users.sourceforge.net Date: Thu Apr 15 10:37:06 2010 +0200
These parameters are no longer needed.
commit c77216d53297f06605436814b07e7c6167198c21 Author: Philip Frank bananer@users.sourceforge.net Date: Thu Apr 15 10:36:23 2010 +0200
[interface] Convert upload progress bar to jQuery.
patch #2986073
-----------------------------------------------------------------------
Summary of changes: ChangeLog | 2 + db_import.php | 5 - import.php | 1 - libraries/display_import.lib.php | 378 +++++++++++++++++++------------------- libraries/header_scripts.inc.php | 3 +- querywindow.php | 3 - server_import.php | 6 - tbl_import.php | 5 - 8 files changed, 191 insertions(+), 212 deletions(-)
diff --git a/ChangeLog b/ChangeLog index 3f18b26..64695b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -67,6 +67,8 @@ $Id$ event, thanks to sutharshan. - [edit] CURRENT_TIMESTAMP is also valid for datetime fields. - patch #2985068 [engines] Fix parsing of PBXT status, thanks to Madhura Jayaratne. +- patch #2986073 [interface] Convert upload progress bar to jQuery, thanks to + Philip Frank.
3.3.3.0 (not yet released) - patch #2982480 [navi] Do not group if there would be one table in group, diff --git a/db_import.php b/db_import.php index d1c8247..bdcd5d6 100644 --- a/db_import.php +++ b/db_import.php @@ -12,11 +12,6 @@ require_once './libraries/common.inc.php';
/** - * Load mootools for upload progress bar - */ -$GLOBALS['js_include'][] = 'mootools-more.js'; - -/** * Gets tables informations and displays top links */ require './libraries/db_common.inc.php'; diff --git a/import.php b/import.php index 7f06ceb..32281b6 100644 --- a/import.php +++ b/import.php @@ -14,7 +14,6 @@ require_once './libraries/common.inc.php'; //require_once './libraries/display_import_functions.lib.php'; $GLOBALS['js_include'][] = 'functions.js'; -$GLOBALS['js_include'][] = 'mootools-more.js';
// reset import messages for ajax request $_SESSION['Import_message']['message'] = null; diff --git a/libraries/display_import.lib.php b/libraries/display_import.lib.php index 11bf9ef..c1d94c5 100644 --- a/libraries/display_import.lib.php +++ b/libraries/display_import.lib.php @@ -29,193 +29,191 @@ if (empty($import_list)) { <iframe id="import_upload_iframe" name="import_upload_iframe" width="1" height="1" style="display: none"></iframe> <div id="import_form_status" style="display: none;"></div> <div id="importmain"> -<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" /> -<script type="text/javascript"> -//<![CDATA[ -window.addEvent('domready', function() { - // add event when user click on "Go" button - $('buttonGo').addEvent('click', function() { - $('upload_form_form').setStyle("display", "none"); // hide form - $('upload_form_status').setStyle("display", "inline"); // show progress bar - $('upload_form_status_info').setStyle("display", "inline"); // - || - + <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" /> + <script type="text/javascript"> + //<![CDATA[ + $(document).ready( function() { + // add event when user click on "Go" button + $('#buttonGo').bind('click', function() { + $('#upload_form_form').css("display", "none"); // hide form + $('#upload_form_status').css("display", "inline"); // show progress bar + $('#upload_form_status_info').css("display", "inline"); // - || - <?php - if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") { -?> - $('upload_form_status').set('html', '<div class="upload_progress_bar_outer"><div id="status" class="upload_progress_bar_inner"></div></div>'); // add the progress bar +if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") { + ?> + $('#upload_form_status').html('<div class="upload_progress_bar_outer"><div id="status" class="upload_progress_bar_inner"></div></div>'); // add the progress bar
- var finished = false; - var percent = 0.0; - var total = 0; - var complete = 0; + var finished = false; + var percent = 0.0; + var total = 0; + var complete = 0;
- var perform_upload; - var periodical_upload; + var perform_upload; + var periodical_upload;
- var request_upload = new Request({ - url: 'import_status.php?id=<?php echo $upload_id ; ?>&<?php echo PMA_generate_common_url(); ?>', // the "&" is causing problems for webkit browsers - method: 'get', - update: 'upload_form_status', - onComplete: function(response) { - objectsReturned = JSON.decode(response); + var request_upload = [];
- $each(objectsReturned, function(item, index) { + perform_upload = function () { + new $.getJSON( + 'import_status.php?id=<?php echo $upload_id ; ?>&<?php echo PMA_generate_common_url(); ?>', + {}, + function(response) { + finished = response.finished; + percent = response.percent; + total = response.total; + complete = total.complete;
- if (index=="finished") { - finished = item; - if (finished==true) { - $clear(periodical_upload); - $('importmain').setStyle('display', 'none'); - $('import_form_status').setStyle('display', 'inline'); - $('import_form_status').set('html', '<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo $strImportProceedingFile; ?> '); - $('import_form_status').load('import_status.php?message=true&<?php echo PMA_generate_common_url(); ?>'); // loads the message, either success or mysql error - <?php - // reload the left sidebar when the import is finished - $GLOBALS['reload']=true; - PMA_reloadNavigation(true); - ?> - } // if finished==item - } // if index==finished - if (index=="percent") - percent = item; - if (index=="total") - total = item; - if (index=="complete") - complete = item; - }); // $each - if (total==0 && complete==0 && percent==0) { - $('upload_form_status_info').set('html', '<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo PMA_jsFormat($strImportLargeFileUploading); ?>'); - $('upload_form_status').setStyle("display", "none"); - } else { - $('upload_form_status_info').set('html', ' '+Math.round(percent)+'%, '+complete+'/'+total); - $('status').tween('width', Math.round(percent)*2+'px'); - } // else - } // onComplete - }); // [equest - perform_upload = function () { - request_upload.send('r=' + $time() + $random(0, 100)); // hack for IE7,8 & webkit (Safari, Chrome, Arora...) - } - periodical_upload = perform_upload.periodical(1000); - <?php - } else { - ?> - $('upload_form_status_info').set('html', '<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo $strImportUploadInfoNotAvailable . PMA_showDocu('faq2_9'); ?>'); - $('upload_form_status').setStyle("display", "none"); - <?php - } // else - ?> - }); // if click -}); // domready + if (total==0 && complete==0 && percent==0) { + $('#upload_form_status_info').html('<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo PMA_jsFormat($strImportLargeFileUploading); ?>'); + $('#upload_form_status').css("display", "none"); + } else { + $('#upload_form_status_info').html(' '+Math.round(percent)+'%, '+complete+'/'+total); + $('#status').animate({width: Math.round(percent)*2+'px'},150); + } // else
- document.write('<form action="import.php" method="post" enctype="multipart/form-data" name="import"<?php if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") echo ' target="import_upload_iframe"'; ?>>'); -//]]> -</script> -<noscript> - <form action="import.php" method="post" enctype="multipart/form-data" name="import"> -</noscript> -<input type="hidden" name="<?php echo $ID_KEY; ?>" value="<?php echo $upload_id ; ?>" /> -<?php -if ($import_type == 'server') { - echo PMA_generate_common_hidden_inputs('', '', 1); -} elseif ($import_type == 'database') { - echo PMA_generate_common_hidden_inputs($db, '', 1); -} else { - echo PMA_generate_common_hidden_inputs($db, $table, 1); -} -echo ' <input type="hidden" name="import_type" value="' . $import_type . '" />'."\n"; -echo PMA_pluginGetJavascript($import_list); + if (finished==true) { + $('#importmain').css('display', 'none'); + $('#import_form_status').css('display', 'inline'); + $('#import_form_status').html('<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo $strImportProceedingFile; ?> '); + $('#import_form_status').load('import_status.php?message=true&<?php echo PMA_generate_common_url(); ?>'); // loads the message, either success or mysql error + <?php + // reload the left sidebar when the import is finished + $GLOBALS['reload']=true; + PMA_reloadNavigation(true); + ?> + + } // if finished + else { + window.setTimeout(perform_upload, 1000); + } + + } + ); + + } + window.setTimeout(perform_upload, 1000); + + <?php +} else { // no plugin avaliable + ?> + $('#upload_form_status_info').html('<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo $strImportUploadInfoNotAvailable . PMA_showDocu('faq2_9'); ?>'); + $('#upload_form_status').css("display", "none"); + <?php +} // else ?> + }); // onclick + }); // domready + + document.write('<form action="import.php" method="post" enctype="multipart/form-data" name="import"<?php if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") echo ' target="import_upload_iframe"'; ?>>'); + //]]> + </script> + <noscript> + <form action="import.php" method="post" enctype="multipart/form-data" name="import"> + </noscript> + <input type="hidden" name="<?php echo $ID_KEY; ?>" value="<?php echo $upload_id ; ?>" /> + <?php + if ($import_type == 'server') { + echo PMA_generate_common_hidden_inputs('', '', 1); + } elseif ($import_type == 'database') { + echo PMA_generate_common_hidden_inputs($db, '', 1); + } else { + echo PMA_generate_common_hidden_inputs($db, $table, 1); + } + echo ' <input type="hidden" name="import_type" value="' . $import_type . '" />'."\n"; + echo PMA_pluginGetJavascript($import_list); + ?> <fieldset class="options"> <legend><?php echo $strFileToImport; ?></legend>
-<?php + <?php
-if ($GLOBALS['is_upload']) { - $uid = uniqid(""); - ?> + if ($GLOBALS['is_upload']) { + $uid = uniqid(""); + ?> <div class="formelementrow" id="upload_form"> - <div id="upload_form_status" style="display: none;"></div> - <div id="upload_form_status_info" style="display: none;"></div> - <div id="upload_form_form"> - <label for="input_import_file"><?php echo $strLocationTextfile; ?></label> - <input style="margin: 5px" type="file" name="import_file" id="input_import_file" onchange="match_file(this.value);" /> - <?php - echo PMA_displayMaximumUploadSize($max_upload_size) . "\n"; - // some browsers should respect this :) - echo PMA_generateHiddenMaxFileSize($max_upload_size) . "\n"; - ?> + <div id="upload_form_status" style="display: none;"></div> + <div id="upload_form_status_info" style="display: none;"></div> + <div id="upload_form_form"> + <label for="input_import_file"><?php echo $strLocationTextfile; ?></label> + <input style="margin: 5px" type="file" name="import_file" id="input_import_file" onchange="match_file(this.value);" /> + <?php + echo PMA_displayMaximumUploadSize($max_upload_size) . "\n"; + // some browsers should respect this :) + echo PMA_generateHiddenMaxFileSize($max_upload_size) . "\n"; + ?> + </div> </div> - </div> - <?php -} else { - PMA_Message::warning('strUploadsNotAllowed')->display(); -} -if (!empty($cfg['UploadDir'])) { - $extensions = ''; - foreach ($import_list as $key => $val) { - if (!empty($extensions)) { - $extensions .= '|'; + <?php + } else { + PMA_Message::warning('strUploadsNotAllowed')->display(); } - $extensions .= $val['extension']; - } - $matcher = '@.(' . $extensions . ')(.(' . PMA_supportedDecompressions() . '))?$@'; + if (!empty($cfg['UploadDir'])) { + $extensions = ''; + foreach ($import_list as $key => $val) { + if (!empty($extensions)) { + $extensions .= '|'; + } + $extensions .= $val['extension']; + } + $matcher = '@.(' . $extensions . ')(.(' . PMA_supportedDecompressions() . '))?$@';
- $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : ''); - echo '<div class="formelementrow">' . "\n"; - if ($files === FALSE) { - PMA_Message::error('strWebServerUploadDirectoryError')->display(); - } elseif (!empty($files)) { - echo "\n"; - echo ' <i>' . $strOr . '</i><br/><label for="select_local_import_file">' . $strWebServerUploadDirectory . '</label> : ' . "\n"; - echo ' <select style="margin: 5px" size="1" name="local_import_file" onchange="match_file(this.value)" id="select_local_import_file">' . "\n"; - echo ' <option value=""> </option>' . "\n"; - echo $files; - echo ' </select>' . "\n"; - } - echo '</div>' . "\n"; -} // end if (web-server upload directory) + $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : ''); + echo '<div class="formelementrow">' . "\n"; + if ($files === FALSE) { + PMA_Message::error('strWebServerUploadDirectoryError')->display(); + } elseif (!empty($files)) { + echo "\n"; + echo ' <i>' . $strOr . '</i><br/><label for="select_local_import_file">' . $strWebServerUploadDirectory . '</label> : ' . "\n"; + echo ' <select style="margin: 5px" size="1" name="local_import_file" onchange="match_file(this.value)" id="select_local_import_file">' . "\n"; + echo ' <option value=""> </option>' . "\n"; + echo $files; + echo ' </select>' . "\n"; + } + echo '</div>' . "\n"; + } // end if (web-server upload directory)
// charset of file -echo '<div class="formelementrow">' . "\n"; -if ($cfg['AllowAnywhereRecoding']) { - echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>'; - reset($cfg['AvailableCharsets']); - echo '<select id="charset_of_file" name="charset_of_file" size="1">'; - foreach ($cfg['AvailableCharsets'] as $temp_charset) { - echo '<option value="' . htmlentities($temp_charset) . '"'; - if ((empty($cfg['Import']['charset']) && $temp_charset == $charset) - || $temp_charset == $cfg['Import']['charset']) { - echo ' selected="selected"'; - } - echo '>' . htmlentities($temp_charset) . '</option>'; - } - echo ' </select><br />'; -} else { - echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>' . "\n"; - echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', 'charset_of_file', 'utf8', FALSE); -} // end if (recoding) -echo '</div>' . "\n"; + echo '<div class="formelementrow">' . "\n"; + if ($cfg['AllowAnywhereRecoding']) { + echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>'; + reset($cfg['AvailableCharsets']); + echo '<select id="charset_of_file" name="charset_of_file" size="1">'; + foreach ($cfg['AvailableCharsets'] as $temp_charset) { + echo '<option value="' . htmlentities($temp_charset) . '"'; + if ((empty($cfg['Import']['charset']) && $temp_charset == $charset) + || $temp_charset == $cfg['Import']['charset']) { + echo ' selected="selected"'; + } + echo '>' . htmlentities($temp_charset) . '</option>'; + } + echo ' </select><br />'; + } else { + echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>' . "\n"; + echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', 'charset_of_file', 'utf8', FALSE); + } // end if (recoding) + echo '</div>' . "\n";
// zip, gzip and bzip2 encode features -$compressions = $strNone; + $compressions = $strNone;
-if ($cfg['GZipDump'] && @function_exists('gzopen')) { - $compressions .= ', gzip'; -} -if ($cfg['BZipDump'] && @function_exists('bzopen')) { - $compressions .= ', bzip2'; -} -if ($cfg['ZipDump'] && @function_exists('zip_open')) { - $compressions .= ', zip'; -} + if ($cfg['GZipDump'] && @function_exists('gzopen')) { + $compressions .= ', gzip'; + } + if ($cfg['BZipDump'] && @function_exists('bzopen')) { + $compressions .= ', bzip2'; + } + if ($cfg['ZipDump'] && @function_exists('zip_open')) { + $compressions .= ', zip'; + }
// We don't have show anything about compression, when no supported -if ($compressions != $strNone) { - echo '<div class="formelementrow">' . "\n"; - printf($strCompressionWillBeDetected, $compressions); - echo '</div>' . "\n"; -} -echo "\n"; -?> + if ($compressions != $strNone) { + echo '<div class="formelementrow">' . "\n"; + printf($strCompressionWillBeDetected, $compressions); + echo '</div>' . "\n"; + } + echo "\n"; + ?> </fieldset> <fieldset class="options"> <legend><?php echo $strPartialImport; ?></legend> @@ -229,51 +227,51 @@ echo "\n"; } ?> <div class="formelementrow"> - <input type="checkbox" name="allow_interrupt" value="yes" - id="checkbox_allow_interrupt" <?php echo PMA_pluginCheckboxCheck('Import', 'allow_interrupt'); ?>/> - <label for="checkbox_allow_interrupt"><?php echo $strAllowInterrupt; ?></label><br /> + <input type="checkbox" name="allow_interrupt" value="yes" + id="checkbox_allow_interrupt" <?php echo PMA_pluginCheckboxCheck('Import', 'allow_interrupt'); ?>/> + <label for="checkbox_allow_interrupt"><?php echo $strAllowInterrupt; ?></label><br /> </div>
<?php if (! (isset($timeout_passed) && $timeout_passed)) { - ?> + ?> <div class="formelementrow"> - <label for="text_skip_queries"><?php echo $strSkipQueries; ?></label> - <input type="text" name="skip_queries" value="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id="text_skip_queries" /> + <label for="text_skip_queries"><?php echo $strSkipQueries; ?></label> + <input type="text" name="skip_queries" value="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id="text_skip_queries" /> </div> - <?php + <?php } else { - // If timeout has passed, - // do not show the Skip dialog to avoid the risk of someone - // entering a value here that would interfere with "skip" - ?> + // If timeout has passed, + // do not show the Skip dialog to avoid the risk of someone + // entering a value here that would interfere with "skip" + ?> <input type="hidden" name="skip_queries" value="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id="text_skip_queries" /> - <?php + <?php } ?> </fieldset>
<fieldset class="options"> <legend><?php echo $strImportFormat; ?></legend> -<?php + <?php // Let's show format options now -echo '<div style="float: left;">'; -echo PMA_pluginGetChoice('Import', 'format', $import_list); -echo '</div>'; + echo '<div style="float: left;">'; + echo PMA_pluginGetChoice('Import', 'format', $import_list); + echo '</div>';
-echo '<div style="float: left;">'; -echo PMA_pluginGetOptions('Import', $import_list); -echo '</div>'; -?> + echo '<div style="float: left;">'; + echo PMA_pluginGetOptions('Import', $import_list); + echo '</div>'; + ?> <div class="clearfloat"></div> </fieldset> -<?php + <?php // Encoding setting form appended by Y.Kawada -if (function_exists('PMA_set_enc_form')) { - echo PMA_set_enc_form(' '); -} -echo "\n"; -?> + if (function_exists('PMA_set_enc_form')) { + echo PMA_set_enc_form(' '); + } + echo "\n"; + ?> <fieldset class="tblFooters"> <input type="submit" value="<?php echo $strGo; ?>" id="buttonGo" /> </fieldset> diff --git a/libraries/header_scripts.inc.php b/libraries/header_scripts.inc.php index 55ebe47..bcb6528 100644 --- a/libraries/header_scripts.inc.php +++ b/libraries/header_scripts.inc.php @@ -73,7 +73,6 @@ if (isset($GLOBALS['db'])) { $GLOBALS['js_include'][] = 'messages.php' . PMA_generate_common_url($params);
$GLOBALS['js_events'][] = array( - 'object' => 'window', 'event' => 'load', 'function' => 'PMA_TT_init', ); @@ -101,7 +100,7 @@ if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknow
<?php foreach ($GLOBALS['js_events'] as $js_event) { - echo "window.parent.addEvent(" . $js_event['object'] . ", '" . $js_event['event'] . "', " + echo "$(window.parent).bind('" . $js_event['event'] . "', " . $js_event['function'] . ");\n"; } ?> diff --git a/querywindow.php b/querywindow.php index 630529e..6c69e41 100644 --- a/querywindow.php +++ b/querywindow.php @@ -171,14 +171,12 @@ $js_include[] = 'querywindow.js';
if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) { $js_events[] = array( - 'object' => 'window', 'event' => 'load', 'function' => 'PMA_queryAutoCommit', ); } if (PMA_isValid($_REQUEST['init'])) { $js_events[] = array( - 'object' => 'window', 'event' => 'load', 'function' => 'PMA_querywindowResize', ); @@ -186,7 +184,6 @@ if (PMA_isValid($_REQUEST['init'])) { // always set focus to the textarea if ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full') { $js_events[] = array( - 'object' => 'window', 'event' => 'load', 'function' => 'PMA_querywindowSetFocus', ); diff --git a/server_import.php b/server_import.php index 6406652..d0ec687 100644 --- a/server_import.php +++ b/server_import.php @@ -12,12 +12,6 @@ require_once './libraries/common.inc.php';
/** - * Load mootools for upload progress bar - */ -$GLOBALS['js_include'][] = 'mootools-more.js'; - - -/** * Does the common work */ require './libraries/server_common.inc.php'; diff --git a/tbl_import.php b/tbl_import.php index a1bc3a0..a0500fd 100644 --- a/tbl_import.php +++ b/tbl_import.php @@ -12,11 +12,6 @@ require_once './libraries/common.inc.php';
/** - * Load mootools for upload progress bar - */ -$GLOBALS['js_include'][] = 'mootools-more.js'; - -/** * Gets tables informations and displays top links */ require_once './libraries/tbl_common.php';
hooks/post-receive