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
21 function PMA_RTE_handleExport($item_name, $export_data)
25 $item_name = htmlspecialchars(PMA_Util
::backquote($_GET['item_name']));
26 if ($export_data !== false) {
27 $export_data = '<textarea cols="40" rows="15" style="width: 100%;">'
28 . htmlspecialchars(trim($export_data)) . '</textarea>';
29 $title = sprintf(PMA_RTE_getWord('export'), $item_name);
30 if ($GLOBALS['is_ajax_request'] == true) {
31 $response = PMA_Response
::getInstance();
32 $response->addJSON('message', $export_data);
33 $response->addJSON('title', $title);
37 . "<legend>$title</legend>\n"
42 $_db = htmlspecialchars(PMA_Util
::backquote($db));
43 $response = __('Error in Processing Request') . ' : '
44 . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db);
45 $response = PMA_message
::error($response);
46 if ($GLOBALS['is_ajax_request'] == true) {
47 $response = PMA_Response
::getInstance();
48 $response->isSuccess(false);
49 $response->addJSON('message', $response);
55 } // end PMA_RTE_handleExport()
58 * If necessary, prepares event information and passes
59 * it to PMA_RTE_handleExport() for the actual export.
63 function PMA_EVN_handleExport()
67 if (! empty($_GET['export_item']) && ! empty($_GET['item_name'])) {
68 $item_name = $_GET['item_name'];
69 $export_data = PMA_DBI_get_definition($db, 'EVENT', $item_name);
70 PMA_RTE_handleExport($item_name, $export_data);
72 } // end PMA_EVN_handleExport()
75 * If necessary, prepares routine information and passes
76 * it to PMA_RTE_handleExport() for the actual export.
80 function PMA_RTN_handleExport()
84 if ( ! empty($_GET['export_item'])
85 && ! empty($_GET['item_name'])
86 && ! empty($_GET['item_type'])
88 if ($_GET['item_type'] == 'FUNCTION' ||
$_GET['item_type'] == 'PROCEDURE') {
89 $export_data = PMA_DBI_get_definition(
94 PMA_RTE_handleExport($_GET['item_name'], $export_data);
97 } // end PMA_RTN_handleExport()
100 * If necessary, prepares trigger information and passes
101 * it to PMA_RTE_handleExport() for the actual export.
105 function PMA_TRI_handleExport()
107 global $_GET, $db, $table;
109 if (! empty($_GET['export_item']) && ! empty($_GET['item_name'])) {
110 $item_name = $_GET['item_name'];
111 $triggers = PMA_DBI_get_triggers($db, $table, '');
112 $export_data = false;
113 foreach ($triggers as $trigger) {
114 if ($trigger['name'] === $item_name) {
115 $export_data = $trigger['create'];
119 PMA_RTE_handleExport($item_name, $export_data);
121 } // end PMA_TRI_handleExport()