Translated using Weblate (German)
[phpmyadmin.git] / db_central_columns.php
blob84c71e3d5442e4fe66bd5c0cdeedab487b0f81f4
1 <?php
3 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 /**
5 * Central Columns view/edit
7 * @package PhpMyAdmin
8 */
9 declare(strict_types=1);
11 use PhpMyAdmin\CentralColumns;
12 use PhpMyAdmin\Core;
13 use PhpMyAdmin\Message;
14 use PhpMyAdmin\Response;
15 use PhpMyAdmin\Url;
17 /**
18 * Gets some core libraries
20 require_once 'libraries/common.inc.php';
22 $centralColumns = new CentralColumns($GLOBALS['dbi']);
24 if (isset($_POST['edit_save']) || isset($_POST['add_new_column'])) {
25 $col_name = $_POST['col_name'];
26 if (isset($_POST['edit_save'])) {
27 $orig_col_name = $_POST['orig_col_name'];
29 $col_default = $_POST['col_default'];
30 if ($col_default == 'NONE' && $_POST['col_default_sel'] != 'USER_DEFINED') {
31 $col_default = "";
33 $col_extra = isset($_POST['col_extra']) ? $_POST['col_extra'] : '';
34 $col_isNull = isset($_POST['col_isNull']) ? 1 : 0;
35 $col_length = $_POST['col_length'];
36 $col_attribute = $_POST['col_attribute'];
37 $col_type = $_POST['col_type'];
38 $collation = $_POST['collation'];
39 if (isset($orig_col_name) && $orig_col_name) {
40 echo $centralColumns->updateOneColumn(
41 $db,
42 $orig_col_name,
43 $col_name,
44 $col_type,
45 $col_attribute,
46 $col_length,
47 $col_isNull,
48 $collation,
49 $col_extra,
50 $col_default
52 exit;
53 } else {
54 $tmp_msg = $centralColumns->updateOneColumn(
55 $db,
56 "",
57 $col_name,
58 $col_type,
59 $col_attribute,
60 $col_length,
61 $col_isNull,
62 $collation,
63 $col_extra,
64 $col_default
68 if (isset($_POST['populateColumns'])) {
69 $selected_tbl = $_POST['selectedTable'];
70 echo $centralColumns->getHtmlForColumnDropdown(
71 $db,
72 $selected_tbl
74 exit;
76 if (isset($_POST['getColumnList'])) {
77 echo $centralColumns->getListRaw(
78 $db,
79 $_POST['cur_table']
81 exit;
83 if (isset($_POST['add_column'])) {
84 $selected_col = [];
85 $selected_tbl = $_POST['table-select'];
86 $selected_col[] = $_POST['column-select'];
87 $tmp_msg = $centralColumns->syncUniqueColumns(
88 $selected_col,
89 false,
90 $selected_tbl
93 $response = Response::getInstance();
94 $header = $response->getHeader();
95 $scripts = $header->getScripts();
96 $scripts->addFile('vendor/jquery/jquery.uitablefilter.js');
97 $scripts->addFile('vendor/jquery/jquery.tablesorter.js');
98 $scripts->addFile('db_central_columns.js');
99 $cfgCentralColumns = $centralColumns->getParams();
100 $pmadb = $cfgCentralColumns['db'];
101 $pmatable = $cfgCentralColumns['table'];
102 $max_rows = intval($GLOBALS['cfg']['MaxRows']);
104 if (isset($_REQUEST['edit_central_columns_page'])) {
105 $selected_fld = $_REQUEST['selected_fld'];
106 $selected_db = $_REQUEST['db'];
107 $edit_central_column_page = $centralColumns->getHtmlForEditingPage(
108 $selected_fld,
109 $selected_db
111 $response->addHTML($edit_central_column_page);
112 exit;
114 if (isset($_POST['multi_edit_central_column_save'])) {
115 $message = $centralColumns->updateMultipleColumn();
116 if (!is_bool($message)) {
117 $response->setRequestStatus(false);
118 $response->addJSON('message', $message);
121 if (isset($_POST['delete_save'])) {
122 $col_name = [];
123 parse_str($_POST['col_name'], $col_name);
124 $tmp_msg = $centralColumns->deleteColumnsFromList(
125 $col_name['selected_fld'],
126 false
129 if (!empty($_REQUEST['total_rows'])
130 && Core::isValid($_REQUEST['total_rows'], 'integer')
132 $total_rows = $_REQUEST['total_rows'];
133 } else {
134 $total_rows = $centralColumns->getCount($db);
136 if (Core::isValid($_REQUEST['pos'], 'integer')) {
137 $pos = intval($_REQUEST['pos']);
138 } else {
139 $pos = 0;
141 $main = $centralColumns->getHtmlForMain($db, $total_rows, $pos, $pmaThemeImage, $text_dir);
142 $response->addHTML($main);
144 $num_cols = $centralColumns->getColumnsCount($db, $pos, $max_rows);
145 $message = Message::success(
146 sprintf(__('Showing rows %1$s - %2$s.'), ($pos + 1), ($pos + $num_cols))
148 if (isset($tmp_msg) && $tmp_msg !== true) {
149 $message = $tmp_msg;