Translated using Weblate (Portuguese)
[phpmyadmin.git] / view_operations.php
blobe4a1a814455c215fd08c37b33b79d6e4b5f15477
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * View manipulations
6 * @package PhpMyAdmin
7 */
8 declare(strict_types=1);
10 use PhpMyAdmin\Message;
11 use PhpMyAdmin\Operations;
12 use PhpMyAdmin\Relation;
13 use PhpMyAdmin\Response;
14 use PhpMyAdmin\Table;
15 use PhpMyAdmin\Template;
16 use PhpMyAdmin\Url;
17 use PhpMyAdmin\Util;
19 if (! defined('ROOT_PATH')) {
20 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
23 /**
26 require_once ROOT_PATH . 'libraries/common.inc.php';
28 $pma_table = new Table($GLOBALS['table'], $GLOBALS['db']);
30 /**
31 * Load JavaScript files
33 $response = Response::getInstance();
34 $header = $response->getHeader();
35 $scripts = $header->getScripts();
36 $scripts->addFile('tbl_operations.js');
38 $template = new Template();
40 /**
41 * Runs common work
43 require ROOT_PATH . 'libraries/tbl_common.inc.php';
44 $url_query .= '&amp;goto=view_operations.php&amp;back=view_operations.php';
45 $url_params['goto'] = $url_params['back'] = 'view_operations.php';
47 $relation = new Relation($GLOBALS['dbi']);
48 $operations = new Operations($GLOBALS['dbi'], $relation);
50 /**
51 * Updates if required
53 $_message = new Message();
54 $_type = 'success';
55 if (isset($_POST['submitoptions'])) {
56 if (isset($_POST['new_name'])) {
57 if ($pma_table->rename($_POST['new_name'])) {
58 $_message->addText($pma_table->getLastMessage());
59 $result = true;
60 $GLOBALS['table'] = $pma_table->getName();
61 /* Force reread after rename */
62 $pma_table->getStatusInfo(null, true);
63 $reload = true;
64 } else {
65 $_message->addText($pma_table->getLastError());
66 $result = false;
70 $warning_messages = $operations->getWarningMessagesArray();
73 if (isset($result)) {
74 // set to success by default, because result set could be empty
75 // (for example, a table rename)
76 if (empty($_message->getString())) {
77 if ($result) {
78 $_message->addText(
79 __('Your SQL query has been executed successfully.')
81 } else {
82 $_message->addText(__('Error'));
84 // $result should exist, regardless of $_message
85 $_type = $result ? 'success' : 'error';
87 if (! empty($warning_messages)) {
88 $_message->addMessagesString($warning_messages);
89 $_message->isError(true);
90 unset($warning_messages);
92 echo Util::getMessage(
93 $_message,
94 $sql_query,
95 $_type
98 unset($_message, $_type);
100 $url_params['goto'] = 'view_operations.php';
101 $url_params['back'] = 'view_operations.php';
103 $drop_view_url_params = array_merge(
104 $url_params,
106 'sql_query' => 'DROP VIEW ' . Util::backquote($GLOBALS['table']),
107 'goto' => 'tbl_structure.php',
108 'reload' => '1',
109 'purge' => '1',
110 'message_to_show' => sprintf(
111 __('View %s has been dropped.'),
112 $GLOBALS['table']
114 'table' => $GLOBALS['table']
118 echo $template->render('table/operations/view', [
119 'db' => $GLOBALS['db'],
120 'table' => $GLOBALS['table'],
121 'delete_data_or_table_link' => $operations->getDeleteDataOrTablelink(
122 $drop_view_url_params,
123 'DROP VIEW',
124 __('Delete the view (DROP)'),
125 'drop_view_anchor'