Merge branch 'rte'

This commit is contained in:
Rouslan Placella 2011-07-16 19:35:45 +01:00
commit 8a2d7fbc22
8 changed files with 111 additions and 155 deletions

View File

@ -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';
?>

View File

@ -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';
?>

View File

@ -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';
?>

View File

@ -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

View File

@ -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

View File

@ -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<count($_REQUEST['item_param_name']); $i++) {
if (! empty($_REQUEST['item_param_name'][$i]) && ! empty($_REQUEST['item_param_type'][$i])) {
if ($_REQUEST['item_type'] == 'PROCEDURE' && ! empty($_REQUEST['item_param_dir'][$i])) {
if ($_REQUEST['item_type'] == 'PROCEDURE'
&& ! empty($_REQUEST['item_param_dir'][$i])
&& in_array($_REQUEST['item_param_dir'][$i], $param_directions)
) {
$params .= $_REQUEST['item_param_dir'][$i] . " " . PMA_backquote($_REQUEST['item_param_name'][$i]) . " "
. $_REQUEST['item_param_type'][$i];
} else if ($_REQUEST['item_type'] == 'FUNCTION') {
@ -1093,19 +1038,13 @@ function PMA_RTN_getQueryFromRequest()
}
}
if (! empty($_REQUEST['item_param_opts_text'][$i])) {
if (isset($cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_param_type'][$i])])) {
$group = $cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_param_type'][$i])];
if ($group == 'FUNC_CHAR') {
$params .= ' CHARSET ' . strtolower($_REQUEST['item_param_opts_text'][$i]);
}
if (in_array($_REQUEST['item_param_type'][$i], $cfg['ColumnTypes']['STRING'])) {
$params .= ' CHARSET ' . strtolower($_REQUEST['item_param_opts_text'][$i]);
}
}
if (! empty($_REQUEST['item_param_opts_num'][$i])) {
if (isset($cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_param_type'][$i])])) {
$group = $cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_param_type'][$i])];
if ($group == 'FUNC_NUMBER' && in_array($_REQUEST['item_param_opts_num'][$i], $param_opts_num)) {
$params .= ' ' . strtoupper($_REQUEST['item_param_opts_num'][$i]);
}
if (in_array($_REQUEST['item_param_type'][$i], $cfg['ColumnTypes']['NUMERIC'])) {
$params .= ' ' . strtoupper($_REQUEST['item_param_opts_num'][$i]);
}
}
if ($i != count($_REQUEST['item_param_name'])-1) {
@ -1118,7 +1057,7 @@ function PMA_RTN_getQueryFromRequest()
}
}
}
$query .= " (" . $params . ") ";
$query .= "(" . $params . ") ";
if ($_REQUEST['item_type'] == 'FUNCTION') {
if (! empty($_REQUEST['item_returntype']) && in_array($_REQUEST['item_returntype'], PMA_getSupportedDatatypes())) {
$query .= "RETURNS {$_REQUEST['item_returntype']}";
@ -1137,19 +1076,13 @@ function PMA_RTN_getQueryFromRequest()
}
}
if (! empty($_REQUEST['item_returnopts_text'])) {
if (isset($cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_returntype'])])) {
$group = $cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_returntype'])];
if ($group == 'FUNC_CHAR') {
$query .= ' CHARSET ' . strtolower($_REQUEST['item_returnopts_text']);
}
if (in_array($_REQUEST['item_returntype'], $cfg['ColumnTypes']['STRING'])) {
$query .= ' CHARSET ' . strtolower($_REQUEST['item_returnopts_text']);
}
}
if (! empty($_REQUEST['item_returnopts_num'])) {
if (isset($cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_returntype'])])) {
$group = $cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_returntype'])];
if ($group == 'FUNC_NUMBER' && in_array($_REQUEST['item_returnopts_num'], $param_opts_num)) {
$query .= ' ' . strtoupper($_REQUEST['item_returnopts_num']);
}
if (in_array($_REQUEST['item_returntype'], $cfg['ColumnTypes']['NUMERIC'])) {
$query .= ' ' . strtoupper($_REQUEST['item_returnopts_num']);
}
}
$query .= ' ';

View File

@ -24,34 +24,10 @@ function PMA_TRI_setGlobals()
'DELETE');
}
/**
* 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 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

View File

@ -0,0 +1,60 @@
<?php
/**
* This function 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)
{
global $_PMA_RTE;
switch ($_PMA_RTE) {
case 'RTN':
$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'),
);
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()
?>