diff --git a/db_events.php b/db_events.php index f65960770a..c4397e79b9 100644 --- a/db_events.php +++ b/db_events.php @@ -28,6 +28,7 @@ require_once './libraries/rte/rte_events.lib.php'; /** * Do the magic */ +$_PMA_RTE = 'EVN'; require_once './libraries/rte/rte_main.inc.php'; ?> diff --git a/db_routines.php b/db_routines.php index efac9ea380..739e69a5d2 100644 --- a/db_routines.php +++ b/db_routines.php @@ -30,6 +30,7 @@ require_once './libraries/rte/rte_routines.lib.php'; /** * Do the magic */ +$_PMA_RTE = 'RTN'; require_once './libraries/rte/rte_main.inc.php'; ?> diff --git a/db_triggers.php b/db_triggers.php index 1bd792ec41..aef164266d 100644 --- a/db_triggers.php +++ b/db_triggers.php @@ -27,6 +27,7 @@ require_once './libraries/rte/rte_triggers.lib.php'; /** * Do the magic */ +$_PMA_RTE = 'TRI'; require_once './libraries/rte/rte_main.inc.php'; ?> diff --git a/libraries/rte/rte_events.lib.php b/libraries/rte/rte_events.lib.php index 97ebcdd396..a449ff2e8d 100644 --- a/libraries/rte/rte_events.lib.php +++ b/libraries/rte/rte_events.lib.php @@ -43,34 +43,10 @@ function PMA_EVN_setGlobals() 'MINUTE_SECOND'); } -/** - * This function is defined in: rte_routines.lib.php, rte_triggers.lib.php and - * rte_events.lib.php. It is used to retreive some language strings that are - * used in functionalities that are common to routines, triggers and events. - * - * @param string $index The index of the string to get - * - * @return string The requested string or an empty string, if not available - */ -function PMA_RTE_getWord($index) -{ - $words = array( - 'add' => __('Add event'), - 'docu' => 'EVENTS', - 'export' => __('Export of event %s'), - 'human' => __('event'), - 'no_create' => __('You do not have the necessary privileges to create an event'), - 'not_found' => __('No event with name %1$s found in database %2$s'), - 'nothing' => __('There are no events to display.'), - 'title' => __('Events'), - ); - return isset($words[$index]) ? $words[$index] : ''; -} // end PMA_RTE_getWord() - /** * Main function for the events functionality */ -function PMA_RTE_main() +function PMA_EVN_main() { global $db; @@ -95,7 +71,7 @@ function PMA_RTE_main() * toggle the state of the event scheduler. */ echo PMA_EVN_getFooterLinks(); -} // end PMA_RTE_main() +} // end PMA_EVN_main() /** * Handles editor requests for adding or editing an item diff --git a/libraries/rte/rte_main.inc.php b/libraries/rte/rte_main.inc.php index dd3e4c0351..d2950bfca1 100644 --- a/libraries/rte/rte_main.inc.php +++ b/libraries/rte/rte_main.inc.php @@ -13,6 +13,7 @@ if (! defined('PHPMYADMIN')) { * Include all other files that are common * to routines, triggers and events. */ +require_once './libraries/rte/rte_words.lib.php'; require_once './libraries/rte/rte_export.lib.php'; require_once './libraries/rte/rte_list.lib.php'; require_once './libraries/rte/rte_footer.lib.php'; @@ -71,14 +72,21 @@ $titles = PMA_buildActionTitles(); */ $errors = array(); + /** - * The below function is defined in rte_routines.lib.php, - * rte_triggers.lib.php and rte_events.lib.php - * - * The appropriate function will now be called based on which one - * of these files was included earlier in the top-level folder + * Call the appropriate main function */ -PMA_RTE_main(); +switch ($_PMA_RTE) { +case 'RTN': + PMA_RTN_main(); + break; +case 'TRI': + PMA_TRI_main(); + break; +case 'EVN': + PMA_EVN_main(); + break; +} /** * Display the footer, if necessary diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php index 8c04d852bb..9a99b8c395 100644 --- a/libraries/rte/rte_routines.lib.php +++ b/libraries/rte/rte_routines.lib.php @@ -28,34 +28,10 @@ function PMA_RTN_setGlobals() 'MODIFIES SQL DATA'); } -/** - * This function is defined in: rte_routines.lib.php, rte_triggers.lib.php and - * rte_events.lib.php. It is used to retreive some language strings that are - * used in functionalities that are common to routines, triggers and events. - * - * @param string $index The index of the string to get - * - * @return string The requested string or an empty string, if not available - */ -function PMA_RTE_getWord($index) -{ - $words = array( - 'add' => __('Add routine'), - 'docu' => 'STORED_ROUTINES', - 'export' => __('Export of routine %s'), - 'human' => __('routine'), - 'no_create' => __('You do not have the necessary privileges to create a routine'), - 'not_found' => __('No routine with name %1$s found in database %2$s'), - 'nothing' => __('There are no routines to display.'), - 'title' => __('Routines'), - ); - return isset($words[$index]) ? $words[$index] : ''; -} // end PMA_RTE_getWord() - /** * Main function for the routines functionality */ -function PMA_RTE_main() +function PMA_RTN_main() { global $db; @@ -93,7 +69,7 @@ function PMA_RTE_main() E_USER_WARNING ); } -} // end PMA_RTE_main() +} // end PMA_RTN_main() /** * This function parses a string containing one parameter of a routine, @@ -130,8 +106,7 @@ function PMA_RTN_parseOneParameter($value) $param_opts = array(); for ($i=$pos; $i<$parsed_param['len']; $i++) { if (($parsed_param[$i]['type'] == 'alpha_columnType' - || $parsed_param[$i]['type'] == 'alpha_functionName') // "CHAR" seems to be mistaken for a function by the parser - && $depth == 0 + || $parsed_param[$i]['type'] == 'alpha_functionName') && $depth == 0 // "CHAR" seems to be mistaken for a function by the parser ) { $retval[2] = strtoupper($parsed_param[$i]['data']); } else if ($parsed_param[$i]['type'] == 'punct_bracket_open_round' && $depth == 0) { @@ -452,7 +427,7 @@ function PMA_RTN_getDataFromRequest() $retval['item_param_length'] = array(); $retval['item_param_opts_num'] = array(); $retval['item_param_opts_text'] = array(); - if (isset($_REQUEST['item_param_name']) + if ( isset($_REQUEST['item_param_name']) && isset($_REQUEST['item_param_type']) && isset($_REQUEST['item_param_length']) && isset($_REQUEST['item_param_opts_num']) @@ -464,65 +439,30 @@ function PMA_RTN_getDataFromRequest() && is_array($_REQUEST['item_param_opts_text']) ) { if ($_REQUEST['item_type'] == 'PROCEDURE') { - $temp_num_params = 0; $retval['item_param_dir'] = $_REQUEST['item_param_dir']; foreach ($retval['item_param_dir'] as $key => $value) { if (! in_array($value, $param_directions, true)) { $retval['item_param_dir'][$key] = ''; } - $retval['item_num_params']++; - } - if ($temp_num_params > $retval['item_num_params']) { - $retval['item_num_params'] = $temp_num_params; } } - $temp_num_params = 0; $retval['item_param_name'] = $_REQUEST['item_param_name']; - foreach ($retval['item_param_name'] as $key => $value) { - $retval['item_param_name'][$key] = $value; - $temp_num_params++; - } - if ($temp_num_params > $retval['item_num_params']) { - $retval['item_num_params'] = $temp_num_params; - } - $temp_num_params = 0; $retval['item_param_type'] = $_REQUEST['item_param_type']; foreach ($retval['item_param_type'] as $key => $value) { if (! in_array($value, PMA_getSupportedDatatypes(), true)) { $retval['item_param_type'][$key] = ''; } - $temp_num_params++; } - if ($temp_num_params > $retval['item_num_params']) { - $retval['item_num_params'] = $temp_num_params; - } - $temp_num_params = 0; - $retval['item_param_length'] = $_REQUEST['item_param_length']; - foreach ($retval['item_param_length'] as $key => $value) { - $retval['item_param_length'][$key] = $value; - $temp_num_params++; - } - if ($temp_num_params > $retval['item_num_params']) { - $retval['item_num_params'] = $temp_num_params; - } - $temp_num_params = 0; - $retval['item_param_opts_num'] = $_REQUEST['item_param_opts_num']; - foreach ($retval['item_param_opts_num'] as $key => $value) { - $retval['item_param_opts_num'][$key] = $value; - $temp_num_params++; - } - if ($temp_num_params > $retval['item_num_params']) { - $retval['item_num_params'] = $temp_num_params; - } - $temp_num_params = 0; + $retval['item_param_length'] = $_REQUEST['item_param_length']; + $retval['item_param_opts_num'] = $_REQUEST['item_param_opts_num']; $retval['item_param_opts_text'] = $_REQUEST['item_param_opts_text']; - foreach ($retval['item_param_opts_text'] as $key => $value) { - $retval['item_param_opts_text'][$key] = $value; - $temp_num_params++; - } - if ($temp_num_params > $retval['item_num_params']) { - $retval['item_num_params'] = $temp_num_params; - } + $retval['item_num_params'] = max( + count($retval['item_param_name']), + count($retval['item_param_type']), + count($retval['item_param_length']), + count($retval['item_param_opts_num']), + count($retval['item_param_opts_text']) + ); } $retval['item_returntype'] = ''; if (isset($_REQUEST['item_returntype']) @@ -1032,7 +972,9 @@ function PMA_RTN_getEditorForm($mode, $operation, $routine) */ function PMA_RTN_getQueryFromRequest() { - global $_REQUEST, $cfg, $errors, $param_sqldataaccess, $param_opts_num; + global $_REQUEST, $cfg, $errors, $param_sqldataaccess, $param_opts_num, $param_directions; + + $_REQUEST['item_type'] = isset($_REQUEST['item_type']) ? $_REQUEST['item_type'] : ''; $query = 'CREATE '; if (! empty($_REQUEST['item_definer'])) { @@ -1052,7 +994,7 @@ function PMA_RTN_getQueryFromRequest() $errors[] = sprintf(__('Invalid routine type: "%s"'), htmlspecialchars($_REQUEST['item_type'])); } if (! empty($_REQUEST['item_name'])) { - $query .= PMA_backquote($_REQUEST['item_name']) . ' '; + $query .= PMA_backquote($_REQUEST['item_name']); } else { $errors[] = __('You must provide a routine name'); } @@ -1069,7 +1011,10 @@ function PMA_RTN_getQueryFromRequest() ) { for ($i=0; $i __('Add trigger'), - 'docu' => 'TRIGGERS', - 'export' => __('Export of trigger %s'), - 'human' => __('trigger'), - 'no_create' => __('You do not have the necessary privileges to create a trigger'), - 'not_found' => __('No trigger with name %1$s found in database %2$s'), - 'nothing' => __('There are no triggers to display.'), - 'title' => __('Triggers'), - ); - return isset($words[$index]) ? $words[$index] : ''; -} // end PMA_RTE_getWord() - /** * Main function for the triggers functionality */ -function PMA_RTE_main() +function PMA_TRI_main() { global $db, $table; @@ -71,7 +47,7 @@ function PMA_RTE_main() * if the user has the necessary privileges */ echo PMA_TRI_getFooterLinks(); -} // end PMA_RTE_main() +} // end PMA_TRI_main() /** * Handles editor requests for adding or editing an item diff --git a/libraries/rte/rte_words.lib.php b/libraries/rte/rte_words.lib.php new file mode 100644 index 0000000000..6e7836afd4 --- /dev/null +++ b/libraries/rte/rte_words.lib.php @@ -0,0 +1,60 @@ + __('Add routine'), + 'docu' => 'STORED_ROUTINES', + 'export' => __('Export of routine %s'), + 'human' => __('routine'), + 'no_create' => __('You do not have the necessary privileges to create a routine'), + 'not_found' => __('No routine with name %1$s found in database %2$s'), + 'nothing' => __('There are no routines to display.'), + 'title' => __('Routines'), + ); + break; + case 'TRI': + $words = array( + 'add' => __('Add trigger'), + 'docu' => 'TRIGGERS', + 'export' => __('Export of trigger %s'), + 'human' => __('trigger'), + 'no_create' => __('You do not have the necessary privileges to create a trigger'), + 'not_found' => __('No trigger with name %1$s found in database %2$s'), + 'nothing' => __('There are no triggers to display.'), + 'title' => __('Triggers'), + ); + break; + case 'EVN': + $words = array( + 'add' => __('Add event'), + 'docu' => 'EVENTS', + 'export' => __('Export of event %s'), + 'human' => __('event'), + 'no_create' => __('You do not have the necessary privileges to create an event'), + 'not_found' => __('No event with name %1$s found in database %2$s'), + 'nothing' => __('There are no events to display.'), + 'title' => __('Events'), + ); + break; + default: + $words = array(); + break; + } + + return isset($words[$index]) ? $words[$index] : ''; +} // end PMA_RTE_getWord() + +?>