From 11e3b20a9e5a7fbe492fd3af9d80350d85558773 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Fri, 10 Jun 2011 15:26:49 +0100 Subject: [PATCH] Some small improvements to the AJAX integration of the Routines Editor --- js/db_routines.js | 4 +--- libraries/db_routines.inc.php | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/js/db_routines.js b/js/db_routines.js index b0b71da5cb..8cd9273264 100644 --- a/js/db_routines.js +++ b/js/db_routines.js @@ -198,7 +198,7 @@ $(document).ready(function() { /** * @var data Form data to be sent in the AJAX request. */ - var data = $('.rte_form').last().serialize() + "&routine_process_"+mode+"routine=1&ajax_request=true"; + var data = $('.rte_form').last().serialize(); $msg = PMA_ajaxShowMessage(PMA_messages['strLoading']); $.post('db_routines.php', data, function (data) { if(data.success == true) { @@ -278,8 +278,6 @@ $(document).ready(function() { if ($('input[name=routine_process_editroutine]').length > 0) { mode = 'edit'; } - // No need for 2 submit buttons - $('fieldset.routineEditorSubmit').remove(); // Cache the template for a parameter table row param_template = data.param_template; // Make adjustments in the dialog to make it AJAX compatible diff --git a/libraries/db_routines.inc.php b/libraries/db_routines.inc.php index dd1686c2e6..dd7377cf25 100644 --- a/libraries/db_routines.inc.php +++ b/libraries/db_routines.inc.php @@ -615,6 +615,7 @@ function getFormInputFromRequest() * @param array $errors If the editor was already invoked and there * has been an error while processing the request * this array will hold the errors. + * @param bool $is_ajax True, if called from an ajax request * * @return string HTML code for the routine editor. * @@ -625,8 +626,8 @@ function getFormInputFromRequest() * @uses sprintf() * @uses getSupportedDatatypes() */ -function displayRoutineEditor($mode, $operation, $routine, $errors) { - global $db, $table, $titles, $url_query, $param_directions, $param_sqldataaccess, $param_opts_num; +function displayRoutineEditor($mode, $operation, $routine, $errors, $is_ajax) { + global $db, $titles, $param_directions, $param_sqldataaccess, $param_opts_num; // Handle some logic first if ($operation == 'change') { @@ -676,10 +677,10 @@ function displayRoutineEditor($mode, $operation, $routine, $errors) { // Create the output $retval = ""; $retval .= "\n\n"; - $retval .= "
\n"; + $retval .= "\n"; $retval .= "\n"; $retval .= $original_routine; - $retval .= PMA_generate_common_hidden_inputs($db, $table) . "\n"; + $retval .= PMA_generate_common_hidden_inputs($db) . "\n"; $retval .= "
\n"; $retval .= "" . __('Details') . "\n"; $retval .= "\n"; @@ -832,15 +833,20 @@ function displayRoutineEditor($mode, $operation, $routine, $errors) { $retval .= "\n"; $retval .= "
\n"; $retval .= "
\n"; - $retval .= "
\n"; - $retval .= " \n"; - $retval .= "
\n"; + if ($is_ajax) { + $retval .= "\n"; + $retval .= "\n"; + } else { + $retval .= "
\n"; + $retval .= " \n"; + $retval .= "
\n"; + } $retval .= "
\n\n"; $retval .= "\n\n"; return $retval; -} // displayRoutineEditor() +} // end displayRoutineEditor() /** * Creates the HTML code that shows the routine execution dialog. @@ -1294,8 +1300,7 @@ if (! empty($_REQUEST['execute_routine']) && ! empty($_REQUEST['routine_name'])) } $message = PMA_message::success($message); - // Pass the sql query through the "pretty printer" - // and display it. + // Pass the SQL queries through the "pretty printer" $output = ''; $output .= PMA_SQP_formatHtml(PMA_SQP_parse(implode($queries))); $output .= ''; @@ -1512,7 +1517,7 @@ if (count($routine_errors) || ( empty($_REQUEST['routine_process_addroutine']) & } if ($routine !== false) { // Show form - $editor = displayRoutineEditor($mode, $operation, $routine, $routine_errors); + $editor = displayRoutineEditor($mode, $operation, $routine, $routine_errors, $_REQUEST['ajax_request']); if (! empty($_REQUEST['ajax_request'])) { $template = " \n"; $template .= "