Translated using Weblate (Dutch)
[phpmyadmin.git] / view_operations.php
blob153249a3df7979b6bc5f6cdf881017cf7d16138e
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * View manipulations
6 * @package PhpMyAdmin
7 */
9 /**
12 require_once './libraries/common.inc.php';
14 $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
16 /**
17 * functions implementation for this script
19 require_once 'libraries/operations.lib.php';
21 /**
22 * Runs common work
24 require './libraries/tbl_common.inc.php';
25 $url_query .= '&amp;goto=view_operations.php&amp;back=view_operations.php';
26 $url_params['goto'] = $url_params['back'] = 'view_operations.php';
28 /**
29 * Gets tables informations
32 require './libraries/tbl_info.inc.php';
33 $reread_info = false;
35 /**
36 * Updates if required
38 if (isset($_REQUEST['submitoptions'])) {
39 $_message = '';
40 $warning_messages = array();
42 if (isset($_REQUEST['new_name'])) {
43 if ($pma_table->rename($_REQUEST['new_name'])) {
44 $_message .= $pma_table->getLastMessage();
45 $result = true;
46 $GLOBALS['table'] = $pma_table->getName();
47 $reread_info = true;
48 $reload = true;
49 } else {
50 $_message .= $pma_table->getLastError();
51 $result = false;
56 if (isset($result)) {
57 // set to success by default, because result set could be empty
58 // (for example, a table rename)
59 $_type = 'success';
60 if (empty($_message)) {
61 $_message = $result
62 ? __('Your SQL query has been executed successfully.')
63 : __('Error');
64 // $result should exist, regardless of $_message
65 $_type = $result ? 'success' : 'error';
67 if (! empty($warning_messages)) {
68 $_message = new PMA_Message;
69 $_message->addMessages($warning_messages);
70 $_message->isError(true);
71 unset($warning_messages);
73 echo PMA_Util::getMessage(
74 $_message, $sql_query, $_type, $is_view = true
76 unset($_message, $_type);
79 $url_params['goto'] = 'view_operations.php';
80 $url_params['back'] = 'view_operations.php';
82 /**
83 * Displays the page
86 <!-- Table operations -->
87 <div class="operations_half_width">
88 <form method="post" action="view_operations.php">
89 <?php echo PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']); ?>
90 <input type="hidden" name="reload" value="1" />
91 <fieldset>
92 <legend><?php echo __('Operations'); ?></legend>
94 <table>
95 <!-- Change view name -->
96 <tr><td><?php echo __('Rename view to'); ?></td>
97 <td><input type="text" size="20" name="new_name" onfocus="this.select()"
98 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>"
99 required />
100 </td>
101 </tr>
102 </table>
103 </fieldset>
104 <fieldset class="tblFooters">
105 <input type="hidden" name="submitoptions" value="1" />
106 <input type="submit" value="<?php echo __('Go'); ?>" />
107 </fieldset>
108 </form>
109 </div>
110 <?php
111 $drop_view_url_params = array_merge(
112 $url_params,
113 array(
114 'sql_query' => 'DROP VIEW ' . PMA_Util::backquote($GLOBALS['table']),
115 'goto' => 'tbl_structure.php',
116 'reload' => '1',
117 'purge' => '1',
118 'message_to_show' => sprintf(
119 __('View %s has been dropped.'),
120 htmlspecialchars($GLOBALS['table'])
122 'table' => $GLOBALS['table']
125 echo '<div class="operations_half_width">';
126 echo '<fieldset class="caution">';
127 echo '<legend>' . __('Delete data or table') . '</legend>';
129 echo '<ul>';
130 echo PMA_getDeleteDataOrTableLink(
131 $drop_view_url_params,
132 'DROP VIEW',
133 __('Delete the view (DROP)'),
134 'drop_view_anchor'
136 echo '</ul>';
137 echo '</fieldset>';
138 echo '</div>';