Translated using Weblate (Ukrainian)
[phpmyadmin.git] / view_operations.php
blob9eb54d5318532af709dfcb0a9e018a3bf094c015
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * View manipulations
6 * @package PhpMyAdmin
7 */
8 use PhpMyAdmin\Message;
9 use PhpMyAdmin\Operations;
10 use PhpMyAdmin\Response;
11 use PhpMyAdmin\Table;
12 use PhpMyAdmin\Url;
13 use PhpMyAdmin\Util;
15 /**
18 require_once './libraries/common.inc.php';
20 $pma_table = new Table($GLOBALS['table'], $GLOBALS['db']);
22 /**
23 * Load JavaScript files
25 $response = Response::getInstance();
26 $header = $response->getHeader();
27 $scripts = $header->getScripts();
28 $scripts->addFile('tbl_operations.js');
30 /**
31 * Runs common work
33 require './libraries/tbl_common.inc.php';
34 $url_query .= '&amp;goto=view_operations.php&amp;back=view_operations.php';
35 $url_params['goto'] = $url_params['back'] = 'view_operations.php';
37 /**
38 * Updates if required
40 $_message = new Message;
41 $_type = 'success';
42 if (isset($_REQUEST['submitoptions'])) {
44 if (isset($_REQUEST['new_name'])) {
45 if ($pma_table->rename($_REQUEST['new_name'])) {
46 $_message->addText($pma_table->getLastMessage());
47 $result = true;
48 $GLOBALS['table'] = $pma_table->getName();
49 /* Force reread after rename */
50 $pma_table->getStatusInfo(null, true);
51 $reload = true;
52 } else {
53 $_message->addText($pma_table->getLastError());
54 $result = false;
58 $warning_messages = Operations::getWarningMessagesArray();
61 if (isset($result)) {
62 // set to success by default, because result set could be empty
63 // (for example, a table rename)
64 if (empty($_message->getString())) {
65 if ($result) {
66 $_message->addText(
67 __('Your SQL query has been executed successfully.')
69 } else {
70 $_message->addText(__('Error'));
72 // $result should exist, regardless of $_message
73 $_type = $result ? 'success' : 'error';
75 if (! empty($warning_messages)) {
76 $_message->addMessagesString($warning_messages);
77 $_message->isError(true);
78 unset($warning_messages);
80 echo Util::getMessage(
81 $_message, $sql_query, $_type
84 unset($_message, $_type);
86 $url_params['goto'] = 'view_operations.php';
87 $url_params['back'] = 'view_operations.php';
89 /**
90 * Displays the page
93 <!-- Table operations -->
94 <div>
95 <form method="post" action="view_operations.php">
96 <?php echo Url::getHiddenInputs($GLOBALS['db'], $GLOBALS['table']); ?>
97 <input type="hidden" name="reload" value="1" />
98 <fieldset>
99 <legend><?php echo __('Operations'); ?></legend>
101 <table>
102 <!-- Change view name -->
103 <tr><td><?php echo __('Rename view to'); ?></td>
104 <td><input type="text" name="new_name" onfocus="this.select()"
105 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>"
106 required />
107 </td>
108 </tr>
109 </table>
110 </fieldset>
111 <fieldset class="tblFooters">
112 <input type="hidden" name="submitoptions" value="1" />
113 <input type="submit" value="<?php echo __('Go'); ?>" />
114 </fieldset>
115 </form>
116 </div>
117 <?php
118 $drop_view_url_params = array_merge(
119 $url_params,
120 array(
121 'sql_query' => 'DROP VIEW ' . Util::backquote(
122 $GLOBALS['table']
124 'goto' => 'tbl_structure.php',
125 'reload' => '1',
126 'purge' => '1',
127 'message_to_show' => sprintf(
128 __('View %s has been dropped.'),
129 htmlspecialchars($GLOBALS['table'])
131 'table' => $GLOBALS['table']
134 echo '<div>';
135 echo '<fieldset class="caution">';
136 echo '<legend>' , __('Delete data or table') , '</legend>';
138 echo '<ul>';
139 echo Operations::getDeleteDataOrTablelink(
140 $drop_view_url_params,
141 'DROP VIEW',
142 __('Delete the view (DROP)'),
143 'drop_view_anchor'
145 echo '</ul>';
146 echo '</fieldset>';
147 echo '</div>';