Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / rte / rte_export.lib.php
bloba553ae9beb5f1ff1312ef9235dac2c847162b30d
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Common functions for the export functionality for Routines, Triggers and Events.
6 * @package PhpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
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 * @return void
21 function PMA_RTE_handleExport($item_name, $export_data)
23 global $db;
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);
34 exit;
35 } else {
36 echo "<fieldset>\n"
37 . "<legend>$title</legend>\n"
38 . $export_data
39 . "</fieldset>\n";
41 } else {
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);
50 exit;
51 } else {
52 $response->display();
55 } // end PMA_RTE_handleExport()
57 /**
58 * If necessary, prepares event information and passes
59 * it to PMA_RTE_handleExport() for the actual export.
61 * @return void
63 function PMA_EVN_handleExport()
65 global $_GET, $db;
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()
74 /**
75 * If necessary, prepares routine information and passes
76 * it to PMA_RTE_handleExport() for the actual export.
78 * @return void
80 function PMA_RTN_handleExport()
82 global $_GET, $db;
84 if ( ! empty($_GET['export_item'])
85 && ! empty($_GET['item_name'])
86 && ! empty($_GET['item_type'])
87 ) {
88 if ($_GET['item_type'] == 'FUNCTION' || $_GET['item_type'] == 'PROCEDURE') {
89 $export_data = PMA_DBI_get_definition(
90 $db,
91 $_GET['item_type'],
92 $_GET['item_name']
94 PMA_RTE_handleExport($_GET['item_name'], $export_data);
97 } // end PMA_RTN_handleExport()
99 /**
100 * If necessary, prepares trigger information and passes
101 * it to PMA_RTE_handleExport() for the actual export.
103 * @return void
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'];
116 break;
119 PMA_RTE_handleExport($item_name, $export_data);
121 } // end PMA_TRI_handleExport()