Translated using Weblate (Chinese (Traditional))
[phpmyadmin.git] / libraries / rte / rte_general.lib.php
blob08d50965805212bd742be1af596569c777d29ac0
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * General functions.
6 * @package PhpMyAdmin
7 */
8 use PMA\libraries\Message;
9 use PMA\libraries\Response;
11 if (! defined('PHPMYADMIN')) {
12 exit;
15 /**
16 * Check result
18 * @param resource|bool $result Query result
19 * @param string $error Error to add
20 * @param string $createStatement Query
21 * @param array $errors Errors
23 * @return array
25 function checkResult($result, $error, $createStatement, $errors)
27 if ($result) {
28 return $errors;
31 // OMG, this is really bad! We dropped the query,
32 // failed to create a new one
33 // and now even the backup query does not execute!
34 // This should not happen, but we better handle
35 // this just in case.
36 $errors[] = $error . '<br />'
37 . __('The backed up query was:')
38 . "\"" . htmlspecialchars($createStatement) . "\"" . '<br />'
39 . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
41 return $errors;
44 /**
45 * Send TRI or EVN editor via ajax or by echoing.
47 * @param string $type TRI or EVN
48 * @param string $mode Editor mode 'add' or 'edit'
49 * @param array $item Data necessary to create the editor
50 * @param string $title Title of the editor
51 * @param string $db Database
52 * @param string $operation Operation 'change' or ''
54 * @return void
56 function PMA_RTE_sendEditor($type, $mode, $item, $title, $db, $operation = null)
58 $response = Response::getInstance();
59 if ($item !== false) {
60 // Show form
61 if ($type == 'TRI') {
62 $editor = PMA_TRI_getEditorForm($mode, $item);
63 } else { // EVN
64 $editor = PMA_EVN_getEditorForm($mode, $operation, $item);
66 if ($response->isAjax()) {
67 $response->addJSON('message', $editor);
68 $response->addJSON('title', $title);
69 } else {
70 echo "\n\n<h2>$title</h2>\n\n$editor";
71 unset($_POST);
73 exit;
74 } else {
75 $message = __('Error in processing request:') . ' ';
76 $message .= sprintf(
77 PMA_RTE_getWord('not_found'),
78 htmlspecialchars(PMA\libraries\Util::backquote($_REQUEST['item_name'])),
79 htmlspecialchars(PMA\libraries\Util::backquote($db))
81 $message = Message::error($message);
82 if ($response->isAjax()) {
83 $response->setRequestStatus(false);
84 $response->addJSON('message', $message);
85 exit;
86 } else {
87 $message->display();