3 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * Central Columns view/edit
9 declare(strict_types
=1);
11 use PhpMyAdmin\CentralColumns
;
13 use PhpMyAdmin\Message
;
14 use PhpMyAdmin\Response
;
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') {
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(
54 $tmp_msg = $centralColumns->updateOneColumn(
68 if (isset($_POST['populateColumns'])) {
69 $selected_tbl = $_POST['selectedTable'];
70 echo $centralColumns->getHtmlForColumnDropdown(
76 if (isset($_POST['getColumnList'])) {
77 echo $centralColumns->getListRaw(
83 if (isset($_POST['add_column'])) {
85 $selected_tbl = $_POST['table-select'];
86 $selected_col[] = $_POST['column-select'];
87 $tmp_msg = $centralColumns->syncUniqueColumns(
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(
111 $response->addHTML($edit_central_column_page);
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'])) {
123 parse_str($_POST['col_name'], $col_name);
124 $tmp_msg = $centralColumns->deleteColumnsFromList(
125 $col_name['selected_fld'],
129 if (!empty($_REQUEST['total_rows'])
130 && Core
::isValid($_REQUEST['total_rows'], 'integer')
132 $total_rows = $_REQUEST['total_rows'];
134 $total_rows = $centralColumns->getCount($db);
136 if (Core
::isValid($_REQUEST['pos'], 'integer')) {
137 $pos = intval($_REQUEST['pos']);
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) {