Translated using Weblate (Indonesian)
[phpmyadmin.git] / view_operations.php
blobe85a87a377a924fbd4d29c742ea1c6e66e18147a
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 * Gets tables information
43 require './libraries/tbl_info.inc.php';
44 $reread_info = false;
46 /**
47 * Updates if required
49 $_message = new PMA\libraries\Message;
50 $_type = 'success';
51 if (isset($_REQUEST['submitoptions'])) {
53 if (isset($_REQUEST['new_name'])) {
54 if ($pma_table->rename($_REQUEST['new_name'])) {
55 $_message->addText($pma_table->getLastMessage());
56 $result = true;
57 $GLOBALS['table'] = $pma_table->getName();
58 $reread_info = true;
59 $reload = true;
60 } else {
61 $_message->addText($pma_table->getLastError());
62 $result = false;
66 $warning_messages = PMA_getWarningMessagesArray();
69 if (isset($result)) {
70 // set to success by default, because result set could be empty
71 // (for example, a table rename)
72 if (empty($_message->getString())) {
73 if ($result) {
74 $_message->addText(
75 __('Your SQL query has been executed successfully.')
77 } else {
78 $_message->addText(__('Error'));
80 // $result should exist, regardless of $_message
81 $_type = $result ? 'success' : 'error';
83 if (! empty($warning_messages)) {
84 $_message->addMessagesString($warning_messages);
85 $_message->isError(true);
86 unset($warning_messages);
88 echo PMA\libraries\Util::getMessage(
89 $_message, $sql_query, $_type
92 unset($_message, $_type);
94 $url_params['goto'] = 'view_operations.php';
95 $url_params['back'] = 'view_operations.php';
97 /**
98 * Displays the page
101 <!-- Table operations -->
102 <div class="operations_half_width">
103 <form method="post" action="view_operations.php">
104 <?php echo URL::getHiddenInputs($GLOBALS['db'], $GLOBALS['table']); ?>
105 <input type="hidden" name="reload" value="1" />
106 <fieldset>
107 <legend><?php echo __('Operations'); ?></legend>
109 <table>
110 <!-- Change view name -->
111 <tr><td><?php echo __('Rename view to'); ?></td>
112 <td><input type="text" size="20" name="new_name" onfocus="this.select()"
113 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>"
114 required />
115 </td>
116 </tr>
117 </table>
118 </fieldset>
119 <fieldset class="tblFooters">
120 <input type="hidden" name="submitoptions" value="1" />
121 <input type="submit" value="<?php echo __('Go'); ?>" />
122 </fieldset>
123 </form>
124 </div>
125 <?php
126 $drop_view_url_params = array_merge(
127 $url_params,
128 array(
129 'sql_query' => 'DROP VIEW ' . PMA\libraries\Util::backquote(
130 $GLOBALS['table']
132 'goto' => 'tbl_structure.php',
133 'reload' => '1',
134 'purge' => '1',
135 'message_to_show' => sprintf(
136 __('View %s has been dropped.'),
137 htmlspecialchars($GLOBALS['table'])
139 'table' => $GLOBALS['table']
142 echo '<div class="operations_half_width">';
143 echo '<fieldset class="caution">';
144 echo '<legend>' , __('Delete data or table') , '</legend>';
146 echo '<ul>';
147 echo PMA_getDeleteDataOrTableLink(
148 $drop_view_url_params,
149 'DROP VIEW',
150 __('Delete the view (DROP)'),
151 'drop_view_anchor'
153 echo '</ul>';
154 echo '</fieldset>';
155 echo '</div>';