From 287d08c8260ad9e2f1d24300aa13e44b87073a39 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sat, 29 Mar 2014 17:04:42 +0100 Subject: [PATCH 1/2] Add message to warn the user if a form has too many fields. Signed-off-by: Hugues Peccatte --- js/ajax.js | 1 + js/common.js | 2 ++ js/functions.js | 20 ++++++++++++++++++++ js/messages.php | 9 +++++++++ 4 files changed, 32 insertions(+) diff --git a/js/ajax.js b/js/ajax.js index c11f9b7ee1..41043f559e 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -291,6 +291,7 @@ var AJAX = { "
" + data.message + "
" ); PMA_highlightSQL($('#page_content')); + checkNumberOfFields(); } if (data._selflink) { diff --git a/js/common.js b/js/common.js index 468036d4c6..22891bf854 100644 --- a/js/common.js +++ b/js/common.js @@ -11,6 +11,8 @@ $(function () { event.preventDefault(); PMA_querywindow.focus(); }); + + checkNumberOfFields(); }); /** diff --git a/js/functions.js b/js/functions.js index 5bdacba37b..5e0427ac17 100644 --- a/js/functions.js +++ b/js/functions.js @@ -4109,3 +4109,23 @@ function PMA_formatDateTime(date, seconds) { } ); } + +/** + * Check than forms have less fields than max allowed by PHP. + */ +function checkNumberOfFields() { + if (typeof maxInputVars === 'undefined') { + return false; + } + $('form').each(function() { + var nbInputs = $(this).find(':input').length; + if (nbInputs > maxInputVars) { + var warning = $.sprintf(PMA_messages.strTooManyInputs, maxInputVars); + PMA_ajaxShowMessage(warning); + return false; + } + return true; + }); + + return true; +} \ No newline at end of file diff --git a/js/messages.php b/js/messages.php index f62d3ecf57..8057c8dbfb 100644 --- a/js/messages.php +++ b/js/messages.php @@ -400,6 +400,12 @@ $js_messages['strIgnore'] = __("Ignore"); $js_messages['strTimeOutError'] = __( "Your export is incomplete, due to a low execution time limit at the PHP level!" ); + +$js_messages['strTooManyInputs'] = __( + "Warning: a form of the page as more than %d fields and could not being " + . "processed." +); + echo "var PMA_messages = new Array();\n"; foreach ($js_messages as $name => $js_message) { PMA_printJsValue("PMA_messages['" . $name . "']", $js_message); @@ -417,6 +423,9 @@ echo "var pmaversion = '" . PMA_VERSION . "';\n"; echo "var mysql_doc_template = '" . PMA_Util::getMySQLDocuURL('%s') . "';\n"; +//Max input vars allowed by PHP. +echo 'var maxInputVars = ' . ini_get('max_input_vars') . ';'; + echo "if ($.datepicker) {\n"; /* l10n: Display text for calendar close link */ PMA_printJsValue("$.datepicker.regional['']['closeText']", __('Done')); From eac47b0775c460d2e3f39bd313407090760b9c4f Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sat, 29 Mar 2014 18:54:54 +0100 Subject: [PATCH 2/2] Correct warning message. Signed-off-by: Hugues Peccatte --- js/messages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/messages.php b/js/messages.php index 8057c8dbfb..55110be72d 100644 --- a/js/messages.php +++ b/js/messages.php @@ -402,7 +402,7 @@ $js_messages['strTimeOutError'] = __( ); $js_messages['strTooManyInputs'] = __( - "Warning: a form of the page as more than %d fields and could not being " + "Warning: a form on this page has more than %d fields and could not be " . "processed." );