Translated using Weblate (Portuguese)
[phpmyadmin.git] / db_central_columns.php
blob2cf8615786d4172f275fbac9034fc20481a2384a
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Central Columns view/edit
6 * @package PhpMyAdmin
7 */
8 declare(strict_types=1);
10 if (! defined('ROOT_PATH')) {
11 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
14 use PhpMyAdmin\CentralColumns;
15 use PhpMyAdmin\Controllers\Database\CentralColumnsController;
16 use PhpMyAdmin\Core;
17 use PhpMyAdmin\Message;
18 use PhpMyAdmin\Response;
20 require_once ROOT_PATH . 'libraries/common.inc.php';
22 /** @var Response $response */
23 $response = $containerBuilder->get(Response::class);
25 /** @var CentralColumns $centralColumns */
26 $centralColumns = $containerBuilder->get('central_columns');
28 /** @var CentralColumnsController $controller */
29 $controller = $containerBuilder->get(CentralColumnsController::class);
31 /** @var string $db */
32 $db = $containerBuilder->getParameter('db');
34 if (isset($_POST['edit_save'])) {
35 echo $controller->editSave([
36 'col_name' => $_POST['col_name'] ?? null,
37 'orig_col_name' => $_POST['orig_col_name'] ?? null,
38 'col_default' => $_POST['col_default'] ?? null,
39 'col_default_sel' => $_POST['col_default_sel'] ?? null,
40 'col_extra' => $_POST['col_extra'] ?? null,
41 'col_isNull' => $_POST['col_isNull'] ?? null,
42 'col_length' => $_POST['col_length'] ?? null,
43 'col_attribute' => $_POST['col_attribute'] ?? null,
44 'col_type' => $_POST['col_type'] ?? null,
45 'collation' => $_POST['collation'] ?? null,
46 ]);
47 exit;
48 } elseif (isset($_POST['add_new_column'])) {
49 $tmp_msg = $controller->addNewColumn([
50 'col_name' => $_POST['col_name'] ?? null,
51 'col_default' => $_POST['col_default'] ?? null,
52 'col_default_sel' => $_POST['col_default_sel'] ?? null,
53 'col_extra' => $_POST['col_extra'] ?? null,
54 'col_isNull' => $_POST['col_isNull'] ?? null,
55 'col_length' => $_POST['col_length'] ?? null,
56 'col_attribute' => $_POST['col_attribute'] ?? null,
57 'col_type' => $_POST['col_type'] ?? null,
58 'collation' => $_POST['collation'] ?? null,
59 ]);
61 if (isset($_POST['populateColumns'])) {
62 $response->addHTML($controller->populateColumns([
63 'selectedTable' => $_POST['selectedTable'],
64 ]));
65 exit;
67 if (isset($_POST['getColumnList'])) {
68 $response->addJSON('message', $controller->getColumnList([
69 'cur_table' => $_POST['cur_table'] ?? null,
70 ]));
71 exit;
73 if (isset($_POST['add_column'])) {
74 $tmp_msg = $controller->addColumn([
75 'table-select' => $_POST['table-select'] ?? null,
76 'column-select' => $_POST['column-select'] ?? null,
77 ]);
80 $header = $response->getHeader();
81 $scripts = $header->getScripts();
82 $scripts->addFile('vendor/jquery/jquery.uitablefilter.js');
83 $scripts->addFile('vendor/jquery/jquery.tablesorter.js');
84 $scripts->addFile('database/central_columns.js');
86 if (isset($_POST['edit_central_columns_page'])) {
87 $response->addHTML($controller->editPage([
88 'selected_fld' => $_POST['selected_fld'] ?? null,
89 'db' => $_POST['db'] ?? null,
90 ]));
91 exit;
93 if (isset($_POST['multi_edit_central_column_save'])) {
94 $message = $controller->updateMultipleColumn([
95 'db' => $_POST['db'] ?? null,
96 'orig_col_name' => $_POST['orig_col_name'] ?? null,
97 'field_name' => $_POST['field_name'] ?? null,
98 'field_default_type' => $_POST['field_default_type'] ?? null,
99 'field_default_value' => $_POST['field_default_value'] ?? null,
100 'field_length' => $_POST['field_length'] ?? null,
101 'field_attribute' => $_POST['field_attribute'] ?? null,
102 'field_type' => $_POST['field_type'] ?? null,
103 'field_collation' => $_POST['field_collation'] ?? null,
104 'field_null' => $_POST['field_null'] ?? null,
105 'col_extra' => $_POST['col_extra'] ?? null,
107 if (! is_bool($message)) {
108 $response->setRequestStatus(false);
109 $response->addJSON('message', $message);
112 if (isset($_POST['delete_save'])) {
113 $tmp_msg = $controller->deleteSave([
114 'db' => $_POST['db'] ?? null,
115 'col_name' => $_POST['col_name'] ?? null,
119 $response->addHTML($controller->index([
120 'pos' => $_POST['pos'] ?? null,
121 'total_rows' => $_POST['total_rows'] ?? null,
122 ]));
124 $pos = 0;
125 if (Core::isValid($_POST['pos'], 'integer')) {
126 $pos = (int) $_POST['pos'];
128 $num_cols = $centralColumns->getColumnsCount(
129 $db,
130 $pos,
131 (int) $GLOBALS['cfg']['MaxRows']
133 $message = Message::success(
134 sprintf(__('Showing rows %1$s - %2$s.'), $pos + 1, $pos + $num_cols)
136 if (isset($tmp_msg) && $tmp_msg !== true) {
137 $message = $tmp_msg;