/** * Creates the HTML code that shows the routine execution dialog. * * @param array $routine Data for the routine returned by * PMA_RTN_getDataFromName() * * @return string HTML code for the routine execution dialog. */ function PMA_RTN_getExecuteForm($routine) { global $db, $cfg; // Escape special characters $routine['item_name'] = htmlentities($routine['item_name'], ENT_QUOTES); for ($i = 0; $i < $routine['item_num_params']; $i++) { $routine['item_param_name'][$i] = htmlentities($routine['item_param_name'][$i], ENT_QUOTES); } // Create the output $retval = ""; $retval .= "<!-- START ROUTINE EXECUTE FORM -->\n\n"; $retval .= "<form action='db_routines.php' method='post'\n"; $retval .= " class='rte_form ajax' onsubmit='return false'>\n"; $retval .= "<input type='hidden' name='item_name'\n"; $retval .= " value='{$routine['item_name']}' />\n"; $retval .= "<input type='hidden' name='item_type'\n"; $retval .= " value='{$routine['item_type']}' />\n"; $retval .= PMA_URL_getHiddenInputs($db) . "\n"; $retval .= "<fieldset>\n"; if ($GLOBALS['is_ajax_request'] != true) { $retval .= "<legend>{$routine['item_name']}</legend>\n"; $retval .= "<table class='rte_table'>\n"; $retval .= "<caption class='tblHeaders'>\n"; $retval .= __('Routine parameters'); $retval .= "</caption>\n"; } else { $retval .= "<legend>" . __('Routine parameters') . "</legend>\n"; $retval .= "<table class='rte_table' style='width: 100%;'>\n"; } $retval .= "<tr>\n"; $retval .= "<th>" . __('Name') . "</th>\n"; $retval .= "<th>" . __('Type') . "</th>\n"; if ($cfg['ShowFunctionFields']) { $retval .= "<th>" . __('Function') . "</th>\n"; } $retval .= "<th>" . __('Value') . "</th>\n"; $retval .= "</tr>\n"; // Get a list of data types that are not yet supported. $no_support_types = PMA\libraries\Util::unsupportedDatatypes(); for ($i = 0; $i < $routine['item_num_params']; $i++) { // Each parameter if ($routine['item_type'] == 'PROCEDURE' && $routine['item_param_dir'][$i] == 'OUT') { continue; } $rowclass = $i % 2 == 0 ? 'even' : 'odd'; $retval .= "\n<tr class='{$rowclass}'>\n"; $retval .= "<td>{$routine['item_param_name'][$i]}</td>\n"; $retval .= "<td>{$routine['item_param_type'][$i]}</td>\n"; if ($cfg['ShowFunctionFields']) { $retval .= "<td>\n"; if (stristr($routine['item_param_type'][$i], 'enum') || stristr($routine['item_param_type'][$i], 'set') || in_array(mb_strtolower($routine['item_param_type'][$i]), $no_support_types)) { $retval .= "--\n"; } else { $field = array('True_Type' => mb_strtolower($routine['item_param_type'][$i]), 'Type' => '', 'Key' => '', 'Field' => '', 'Default' => '', 'first_timestamp' => false); $retval .= "<select name='funcs[" . $routine['item_param_name'][$i] . "]'>"; $retval .= PMA\libraries\Util::getFunctionsForField($field, false, array()); $retval .= "</select>"; } $retval .= "</td>\n"; } // Append a class to date/time fields so that // jQuery can attach a datepicker to them $class = ''; if ($routine['item_param_type'][$i] == 'DATETIME' || $routine['item_param_type'][$i] == 'TIMESTAMP') { $class = 'datetimefield'; } else { if ($routine['item_param_type'][$i] == 'DATE') { $class = 'datefield'; } } $retval .= "<td class='nowrap'>\n"; if (in_array($routine['item_param_type'][$i], array('ENUM', 'SET'))) { if ($routine['item_param_type'][$i] == 'ENUM') { $input_type = 'radio'; } else { $input_type = 'checkbox'; } foreach ($routine['item_param_length_arr'][$i] as $value) { $value = htmlentities(PMA\libraries\Util::unquote($value), ENT_QUOTES); $retval .= "<input name='params[" . $routine['item_param_name'][$i] . "][]' " . "value='" . $value . "' type='" . $input_type . "' />" . $value . "<br />\n"; } } else { if (in_array(mb_strtolower($routine['item_param_type'][$i]), $no_support_types)) { $retval .= "\n"; } else { $retval .= "<input class='{$class}' type='text' name='params[" . $routine['item_param_name'][$i] . "]' />\n"; } } $retval .= "</td>\n"; $retval .= "</tr>\n"; } $retval .= "\n</table>\n"; if ($GLOBALS['is_ajax_request'] != true) { $retval .= "</fieldset>\n\n"; $retval .= "<fieldset class='tblFooters'>\n"; $retval .= " <input type='submit' name='execute_routine'\n"; $retval .= " value='" . __('Go') . "' />\n"; $retval .= "</fieldset>\n"; } else { $retval .= "<input type='hidden' name='execute_routine' value='true' />"; $retval .= "<input type='hidden' name='ajax_request' value='true' />"; } $retval .= "</form>\n\n"; $retval .= "<!-- END ROUTINE EXECUTE FORM -->\n\n"; return $retval; }