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