diff --git a/libraries/classes/Rte/Events.php b/libraries/classes/Rte/Events.php
index ccad0e1d26..41d61f6eb8 100644
--- a/libraries/classes/Rte/Events.php
+++ b/libraries/classes/Rte/Events.php
@@ -12,6 +12,7 @@ use PhpMyAdmin\Response;
use PhpMyAdmin\Rte\Export;
use PhpMyAdmin\Rte\Footer;
use PhpMyAdmin\Rte\General;
+use PhpMyAdmin\Rte\RteList;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -77,7 +78,7 @@ class Events
* Display a list of available events
*/
$items = $GLOBALS['dbi']->getEvents($db);
- echo PMA_RTE_getList('event', $items);
+ echo RteList::get('event', $items);
/**
* Display a link for adding a new event, if
* the user has the privileges and a link to
@@ -201,7 +202,7 @@ class Events
mb_strtoupper($_REQUEST['item_name'])
)
);
- $response->addJSON('new_row', PMA_EVN_getRowForList($event));
+ $response->addJSON('new_row', RteList::getEventRow($event));
$response->addJSON('insert', ! empty($event));
$response->addJSON('message', $output);
} else {
diff --git a/libraries/classes/Rte/RteList.php b/libraries/classes/Rte/RteList.php
new file mode 100644
index 0000000000..a283816618
--- /dev/null
+++ b/libraries/classes/Rte/RteList.php
@@ -0,0 +1,491 @@
+\n";
+ $retval .= '
\n";
+ $retval .= "\n";
+
+ return $retval;
+ } // end self::get()
+
+ /**
+ * Creates the contents for a row in the list of routines
+ *
+ * @param array $routine An array of routine data
+ * @param string $rowclass Additional class
+ *
+ * @return string HTML code of a row for the list of routines
+ */
+ public static function getRoutineRow($routine, $rowclass = '')
+ {
+ global $ajax_class, $url_query, $db, $titles;
+
+ $sql_drop = sprintf(
+ 'DROP %s IF EXISTS %s',
+ $routine['type'],
+ Util::backquote($routine['name'])
+ );
+ $type_link = "item_type={$routine['type']}";
+
+ $retval = "
\n";
+
+ // this is for our purpose to decide whether to
+ // show the edit link or not, so we need the DEFINER for the routine
+ $where = "ROUTINE_SCHEMA " . Util::getCollateForIS() . "="
+ . "'" . $GLOBALS['dbi']->escapeString($db) . "' "
+ . "AND SPECIFIC_NAME='" . $GLOBALS['dbi']->escapeString($routine['name']) . "'"
+ . "AND ROUTINE_TYPE='" . $GLOBALS['dbi']->escapeString($routine['type']) . "'";
+ $query = "SELECT `DEFINER` FROM INFORMATION_SCHEMA.ROUTINES WHERE $where;";
+ $routine_definer = $GLOBALS['dbi']->fetchValue($query);
+
+ $curr_user = $GLOBALS['dbi']->getCurrentUser();
+
+ // Since editing a procedure involved dropping and recreating, check also for
+ // CREATE ROUTINE privilege to avoid lost procedures.
+ if ((Util::currentUserHasPrivilege('CREATE ROUTINE', $db)
+ && $curr_user == $routine_definer)
+ || $GLOBALS['is_superuser']
+ ) {
+ $retval .= ' ' . $titles['Edit'] . "\n";
+ } else {
+ $retval .= " {$titles['NoEdit']}\n";
+ }
+ $retval .= "
\n";
+ $retval .= "
\n";
+
+ // There is a problem with Util::currentUserHasPrivilege():
+ // it does not detect all kinds of privileges, for example
+ // a direct privilege on a specific routine. So, at this point,
+ // we show the Execute link, hoping that the user has the correct rights.
+ // Also, information_schema might be hiding the ROUTINE_DEFINITION
+ // but a routine with no input parameters can be nonetheless executed.
+
+ // Check if the routine has any input parameters. If it does,
+ // we will show a dialog to get values for these parameters,
+ // otherwise we can execute it directly.
+
+ $definition = $GLOBALS['dbi']->getDefinition(
+ $db, $routine['type'], $routine['name']
+ );
+ if ($definition !== false) {
+ $parser = new Parser($definition);
+
+ /**
+ * @var CreateStatement $stmt
+ */
+ $stmt = $parser->statements[0];
+
+ $params = Routine::getParameters($stmt);
+
+ if (Util::currentUserHasPrivilege('EXECUTE', $db)) {
+ $execute_action = 'execute_routine';
+ for ($i = 0; $i < $params['num']; $i++) {
+ if ($routine['type'] == 'PROCEDURE'
+ && $params['dir'][$i] == 'OUT'
+ ) {
+ continue;
+ }
+ $execute_action = 'execute_dialog';
+ break;
+ }
+ $retval .= ' ' . $titles['Execute'] . "\n";
+ } else {
+ $retval .= " {$titles['NoExecute']}\n";
+ }
+ }
+
+ $retval .= "
\n";
+
+ return $retval;
+ } // end self::getRoutineRow()
+
+ /**
+ * Creates the contents for a row in the list of triggers
+ *
+ * @param array $trigger An array of routine data
+ * @param string $rowclass Additional class
+ *
+ * @return string HTML code of a cell for the list of triggers
+ */
+ public static function getTriggerRow($trigger, $rowclass = '')
+ {
+ global $ajax_class, $url_query, $db, $table, $titles;
+
+ $retval = "
\n";
+
+ return $retval;
+ } // end self::getTriggerRow()
+
+ /**
+ * Creates the contents for a row in the list of events
+ *
+ * @param array $event An array of routine data
+ * @param string $rowclass Additional class
+ *
+ * @return string HTML code of a cell for the list of events
+ */
+ public static function getEventRow($event, $rowclass = '')
+ {
+ global $ajax_class, $url_query, $db, $titles;
+
+ $sql_drop = sprintf(
+ 'DROP EVENT IF EXISTS %s',
+ Util::backquote($event['name'])
+ );
+
+ $retval = "
\n";
-
- // this is for our purpose to decide whether to
- // show the edit link or not, so we need the DEFINER for the routine
- $where = "ROUTINE_SCHEMA " . PhpMyAdmin\Util::getCollateForIS() . "="
- . "'" . $GLOBALS['dbi']->escapeString($db) . "' "
- . "AND SPECIFIC_NAME='" . $GLOBALS['dbi']->escapeString($routine['name']) . "'"
- . "AND ROUTINE_TYPE='" . $GLOBALS['dbi']->escapeString($routine['type']) . "'";
- $query = "SELECT `DEFINER` FROM INFORMATION_SCHEMA.ROUTINES WHERE $where;";
- $routine_definer = $GLOBALS['dbi']->fetchValue($query);
-
- $curr_user = $GLOBALS['dbi']->getCurrentUser();
-
- // Since editing a procedure involved dropping and recreating, check also for
- // CREATE ROUTINE privilege to avoid lost procedures.
- if ((PhpMyAdmin\Util::currentUserHasPrivilege('CREATE ROUTINE', $db)
- && $curr_user == $routine_definer)
- || $GLOBALS['is_superuser']
- ) {
- $retval .= ' ' . $titles['Edit'] . "\n";
- } else {
- $retval .= " {$titles['NoEdit']}\n";
- }
- $retval .= "
\n";
- $retval .= "
\n";
-
- // There is a problem with PhpMyAdmin\Util::currentUserHasPrivilege():
- // it does not detect all kinds of privileges, for example
- // a direct privilege on a specific routine. So, at this point,
- // we show the Execute link, hoping that the user has the correct rights.
- // Also, information_schema might be hiding the ROUTINE_DEFINITION
- // but a routine with no input parameters can be nonetheless executed.
-
- // Check if the routine has any input parameters. If it does,
- // we will show a dialog to get values for these parameters,
- // otherwise we can execute it directly.
-
- $definition = $GLOBALS['dbi']->getDefinition(
- $db, $routine['type'], $routine['name']
- );
- if ($definition !== false) {
- $parser = new PhpMyAdmin\SqlParser\Parser($definition);
-
- /**
- * @var CreateStatement $stmt
- */
- $stmt = $parser->statements[0];
-
- $params = PhpMyAdmin\SqlParser\Utils\Routine::getParameters($stmt);
-
- if (PhpMyAdmin\Util::currentUserHasPrivilege('EXECUTE', $db)) {
- $execute_action = 'execute_routine';
- for ($i = 0; $i < $params['num']; $i++) {
- if ($routine['type'] == 'PROCEDURE'
- && $params['dir'][$i] == 'OUT'
- ) {
- continue;
- }
- $execute_action = 'execute_dialog';
- break;
- }
- $retval .= ' ' . $titles['Execute'] . "\n";
- } else {
- $retval .= " {$titles['NoExecute']}\n";
- }
- }
-
- $retval .= "
\n";
-
- return $retval;
-} // end PMA_RTN_getRowForList()
-
-/**
- * Creates the contents for a row in the list of triggers
- *
- * @param array $trigger An array of routine data
- * @param string $rowclass Additional class
- *
- * @return string HTML code of a cell for the list of triggers
- */
-function PMA_TRI_getRowForList($trigger, $rowclass = '')
-{
- global $ajax_class, $url_query, $db, $table, $titles;
-
- $retval = "
\n";
-
- return $retval;
-} // end PMA_TRI_getRowForList()
-
-/**
- * Creates the contents for a row in the list of events
- *
- * @param array $event An array of routine data
- * @param string $rowclass Additional class
- *
- * @return string HTML code of a cell for the list of events
- */
-function PMA_EVN_getRowForList($event, $rowclass = '')
-{
- global $ajax_class, $url_query, $db, $titles;
-
- $sql_drop = sprintf(
- 'DROP EVENT IF EXISTS %s',
- PhpMyAdmin\Util::backquote($event['name'])
- );
-
- $retval = "
\n";
-
- return $retval;
-} // end PMA_EVN_getRowForList()
diff --git a/libraries/rte/rte_main.inc.php b/libraries/rte/rte_main.inc.php
index d27d4b6cbe..447c6e69f7 100644
--- a/libraries/rte/rte_main.inc.php
+++ b/libraries/rte/rte_main.inc.php
@@ -18,7 +18,6 @@ if (! defined('PHPMYADMIN')) {
* to routines, triggers and events.
*/
require_once './libraries/rte/rte_words.lib.php';
-require_once './libraries/rte/rte_list.lib.php';
$response = Response::getInstance();
diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php
index f5881fc804..201e9ff3ae 100644
--- a/libraries/rte/rte_routines.lib.php
+++ b/libraries/rte/rte_routines.lib.php
@@ -12,6 +12,7 @@ use PhpMyAdmin\Response;
use PhpMyAdmin\Rte\Export;
use PhpMyAdmin\Rte\Footer;
use PhpMyAdmin\Rte\General;
+use PhpMyAdmin\Rte\RteList;
use PhpMyAdmin\SqlParser\Statements\CreateStatement;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -68,7 +69,7 @@ function PMA_RTN_main($type)
$type = null;
}
$items = $GLOBALS['dbi']->getRoutines($db, $type);
- echo PMA_RTE_getList('routine', $items);
+ echo RteList::get('routine', $items);
/**
* Display the form for adding a new routine, if the user has the privileges.
*/
@@ -309,7 +310,7 @@ function PMA_RTN_handleRequestCreateOrEdit($errors, $db)
mb_strtoupper($_REQUEST['item_name'])
)
);
- $response->addJSON('new_row', PMA_RTN_getRowForList($routine));
+ $response->addJSON('new_row', RteList::getRoutineRow($routine));
$response->addJSON('insert', !empty($routine));
$response->addJSON('message', $output);
exit;
diff --git a/libraries/rte/rte_triggers.lib.php b/libraries/rte/rte_triggers.lib.php
index 1beeeacaea..d46c59941d 100644
--- a/libraries/rte/rte_triggers.lib.php
+++ b/libraries/rte/rte_triggers.lib.php
@@ -9,6 +9,7 @@ use PhpMyAdmin\Response;
use PhpMyAdmin\Rte\Export;
use PhpMyAdmin\Rte\Footer;
use PhpMyAdmin\Rte\General;
+use PhpMyAdmin\Rte\RteList;
use PhpMyAdmin\Url;
if (! defined('PHPMYADMIN')) {
@@ -51,7 +52,7 @@ function PMA_TRI_main()
* Display a list of available triggers
*/
$items = $GLOBALS['dbi']->getTriggers($db, $table);
- echo PMA_RTE_getList('trigger', $items);
+ echo RteList::get('trigger', $items);
/**
* Display a link for adding a new trigger,
* if the user has the necessary privileges
@@ -174,7 +175,7 @@ function PMA_TRI_handleEditor()
|| ($trigger !== false && $table == $trigger['table'])
) {
$insert = true;
- $response->addJSON('new_row', PMA_TRI_getRowForList($trigger));
+ $response->addJSON('new_row', RteList::getTriggerRow($trigger));
$response->addJSON(
'name',
htmlspecialchars(