2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Common functions for the export functionality for Routines, Triggers and Events.
8 if (! defined('PHPMYADMIN')) {
13 * This function is called from one of the other functions in this file
14 * and it completes the handling of the export functionality.
16 * @param string $item_name The name of the item that we are exporting
17 * @param string $export_data The SQL query to create the requested item
19 function PMA_RTE_handleExport($item_name, $export_data)
23 $item_name = htmlspecialchars(PMA_backquote($_GET['item_name']));
24 if ($export_data !== false) {
25 $export_data = '<textarea cols="40" rows="15" style="width: 100%;">'
26 . htmlspecialchars(trim($export_data)) . '</textarea>';
27 $title = sprintf(PMA_RTE_getWord('export'), $item_name);
28 if ($GLOBALS['is_ajax_request'] == true) {
29 $extra_data = array('title' => $title);
30 PMA_ajaxResponse($export_data, true, $extra_data);
33 . "<legend>$title</legend>\n"
38 $_db = htmlspecialchars(PMA_backquote($db));
39 $response = __('Error in Processing Request') . ' : '
40 . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db);
41 $response = PMA_message
::error($response);
42 if ($GLOBALS['is_ajax_request'] == true) {
43 PMA_ajaxResponse($response, false);
48 } // end PMA_RTE_handleExport()
51 * If necessary, prepares event information and passes
52 * it to PMA_RTE_handleExport() for the actual export.
54 function PMA_EVN_handleExport()
58 if (! empty($_GET['export_item']) && ! empty($_GET['item_name'])) {
59 $item_name = $_GET['item_name'];
60 $export_data = PMA_DBI_get_definition($db, 'EVENT', $item_name);
61 PMA_RTE_handleExport($item_name, $export_data);
63 } // end PMA_EVN_handleExport()
66 * If necessary, prepares routine information and passes
67 * it to PMA_RTE_handleExport() for the actual export.
69 function PMA_RTN_handleExport()
73 if ( ! empty($_GET['export_item'])
74 && ! empty($_GET['item_name'])
75 && ! empty($_GET['item_type'])
77 if ($_GET['item_type'] == 'FUNCTION' ||
$_GET['item_type'] == 'PROCEDURE') {
78 $export_data = PMA_DBI_get_definition(
82 PMA_RTE_handleExport($_GET['item_name'], $export_data);
85 } // end PMA_RTN_handleExport()
88 * If necessary, prepares trigger information and passes
89 * it to PMA_RTE_handleExport() for the actual export.
91 function PMA_TRI_handleExport()
93 global $_GET, $db, $table;
95 if (! empty($_GET['export_item']) && ! empty($_GET['item_name'])) {
96 $item_name = $_GET['item_name'];
97 $triggers = PMA_DBI_get_triggers($db, $table, '');
99 foreach ($triggers as $trigger) {
100 if ($trigger['name'] === $item_name) {
101 $export_data = $trigger['create'];
105 PMA_RTE_handleExport($item_name, $export_data);
107 } // end PMA_TRI_handleExport()