Translated using Weblate (Portuguese (Brazil))
[phpmyadmin.git] / view_operations.php
blob57732793aaeaf5c126a12333fdbceb89d00e3e19
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * View manipulations
6 * @package PhpMyAdmin
7 */
8 use PMA\libraries\Table;
9 use PMA\libraries\Response;
10 use PMA\libraries\URL;
12 /**
15 require_once './libraries/common.inc.php';
17 $pma_table = new Table($GLOBALS['table'], $GLOBALS['db']);
19 /**
20 * functions implementation for this script
22 require_once 'libraries/operations.lib.php';
24 /**
25 * Load JavaScript files
27 $response = Response::getInstance();
28 $header = $response->getHeader();
29 $scripts = $header->getScripts();
30 $scripts->addFile('tbl_operations.js');
32 /**
33 * Runs common work
35 require './libraries/tbl_common.inc.php';
36 $url_query .= '&amp;goto=view_operations.php&amp;back=view_operations.php';
37 $url_params['goto'] = $url_params['back'] = 'view_operations.php';
39 /**
40 * Updates if required
42 $_message = new PMA\libraries\Message;
43 $_type = 'success';
44 if (isset($_REQUEST['submitoptions'])) {
46 if (isset($_REQUEST['new_name'])) {
47 if ($pma_table->rename($_REQUEST['new_name'])) {
48 $_message->addText($pma_table->getLastMessage());
49 $result = true;
50 $GLOBALS['table'] = $pma_table->getName();
51 /* Force reread after rename */
52 $pma_table->getStatusInfo(null, true);
53 $reload = true;
54 } else {
55 $_message->addText($pma_table->getLastError());
56 $result = false;
60 $warning_messages = PMA_getWarningMessagesArray();
63 if (isset($result)) {
64 // set to success by default, because result set could be empty
65 // (for example, a table rename)
66 if (empty($_message->getString())) {
67 if ($result) {
68 $_message->addText(
69 __('Your SQL query has been executed successfully.')
71 } else {
72 $_message->addText(__('Error'));
74 // $result should exist, regardless of $_message
75 $_type = $result ? 'success' : 'error';
77 if (! empty($warning_messages)) {
78 $_message->addMessagesString($warning_messages);
79 $_message->isError(true);
80 unset($warning_messages);
82 echo PMA\libraries\Util::getMessage(
83 $_message, $sql_query, $_type
86 unset($_message, $_type);
88 $url_params['goto'] = 'view_operations.php';
89 $url_params['back'] = 'view_operations.php';
91 /**
92 * Displays the page
95 <!-- Table operations -->
96 <div class="operations_half_width">
97 <form method="post" action="view_operations.php">
98 <?php echo URL::getHiddenInputs($GLOBALS['db'], $GLOBALS['table']); ?>
99 <input type="hidden" name="reload" value="1" />
100 <fieldset>
101 <legend><?php echo __('Operations'); ?></legend>
103 <table>
104 <!-- Change view name -->
105 <tr><td><?php echo __('Rename view to'); ?></td>
106 <td><input type="text" size="20" name="new_name" onfocus="this.select()"
107 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>"
108 required />
109 </td>
110 </tr>
111 </table>
112 </fieldset>
113 <fieldset class="tblFooters">
114 <input type="hidden" name="submitoptions" value="1" />
115 <input type="submit" value="<?php echo __('Go'); ?>" />
116 </fieldset>
117 </form>
118 </div>
119 <?php
120 $drop_view_url_params = array_merge(
121 $url_params,
122 array(
123 'sql_query' => 'DROP VIEW ' . PMA\libraries\Util::backquote(
124 $GLOBALS['table']
126 'goto' => 'tbl_structure.php',
127 'reload' => '1',
128 'purge' => '1',
129 'message_to_show' => sprintf(
130 __('View %s has been dropped.'),
131 htmlspecialchars($GLOBALS['table'])
133 'table' => $GLOBALS['table']
136 echo '<div class="operations_half_width">';
137 echo '<fieldset class="caution">';
138 echo '<legend>' , __('Delete data or table') , '</legend>';
140 echo '<ul>';
141 echo PMA_getDeleteDataOrTableLink(
142 $drop_view_url_params,
143 'DROP VIEW',
144 __('Delete the view (DROP)'),
145 'drop_view_anchor'
147 echo '</ul>';
148 echo '</fieldset>';
149 echo '</div>';