2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Central Columns view/edit
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
;
17 use PhpMyAdmin\Message
;
18 use PhpMyAdmin\Response
;
20 require_once ROOT_PATH
. 'libraries/common.inc.php';
22 $response = Response
::getInstance();
23 $centralColumns = new CentralColumns($GLOBALS['dbi']);
25 $controller = new CentralColumnsController(
32 if (isset($_POST['edit_save'])) {
33 echo $controller->editSave([
34 'col_name' => $_POST['col_name'] ??
null,
35 'orig_col_name' => $_POST['orig_col_name'] ??
null,
36 'col_default' => $_POST['col_default'] ??
null,
37 'col_default_sel' => $_POST['col_default_sel'] ??
null,
38 'col_extra' => $_POST['col_extra'] ??
null,
39 'col_isNull' => $_POST['col_isNull'] ??
null,
40 'col_length' => $_POST['col_length'] ??
null,
41 'col_attribute' => $_POST['col_attribute'] ??
null,
42 'col_type' => $_POST['col_type'] ??
null,
43 'collation' => $_POST['collation'] ??
null,
46 } elseif (isset($_POST['add_new_column'])) {
47 $tmp_msg = $controller->addNewColumn([
48 'col_name' => $_POST['col_name'] ??
null,
49 'col_default' => $_POST['col_default'] ??
null,
50 'col_default_sel' => $_POST['col_default_sel'] ??
null,
51 'col_extra' => $_POST['col_extra'] ??
null,
52 'col_isNull' => $_POST['col_isNull'] ??
null,
53 'col_length' => $_POST['col_length'] ??
null,
54 'col_attribute' => $_POST['col_attribute'] ??
null,
55 'col_type' => $_POST['col_type'] ??
null,
56 'collation' => $_POST['collation'] ??
null,
59 if (isset($_POST['populateColumns'])) {
60 $response->addHTML($controller->populateColumns([
61 'selectedTable' => $_POST['selectedTable'],
65 if (isset($_POST['getColumnList'])) {
66 $response->addJSON($controller->getColumnList([
67 'cur_table' => $_POST['cur_table'] ??
null,
71 if (isset($_POST['add_column'])) {
72 $tmp_msg = $controller->addColumn([
73 'table-select' => $_POST['table-select'] ??
null,
74 'column-select' => $_POST['column-select'] ??
null,
78 $header = $response->getHeader();
79 $scripts = $header->getScripts();
80 $scripts->addFile('vendor/jquery/jquery.uitablefilter.js');
81 $scripts->addFile('vendor/jquery/jquery.tablesorter.js');
82 $scripts->addFile('db_central_columns.js');
84 if (isset($_POST['edit_central_columns_page'])) {
85 $response->addHTML($controller->editPage([
86 'selected_fld' => $_POST['selected_fld'] ??
null,
87 'db' => $_POST['db'] ??
null,
91 if (isset($_POST['multi_edit_central_column_save'])) {
92 $message = $controller->updateMultipleColumn([
93 'db' => $_POST['db'] ??
null,
94 'orig_col_name' => $_POST['orig_col_name'] ??
null,
95 'field_name' => $_POST['field_name'] ??
null,
96 'field_default_type' => $_POST['field_default_type'] ??
null,
97 'field_default_value' => $_POST['field_default_value'] ??
null,
98 'field_length' => $_POST['field_length'] ??
null,
99 'field_attribute' => $_POST['field_attribute'] ??
null,
100 'field_type' => $_POST['field_type'] ??
null,
101 'field_collation' => $_POST['field_collation'] ??
null,
102 'field_null' => $_POST['field_null'] ??
null,
103 'col_extra' => $_POST['col_extra'] ??
null,
105 if (! is_bool($message)) {
106 $response->setRequestStatus(false);
107 $response->addJSON('message', $message);
110 if (isset($_POST['delete_save'])) {
111 $tmp_msg = $controller->deleteSave([
112 'db' => $_POST['db'] ??
null,
113 'col_name' => $_POST['col_name'] ??
null,
117 $response->addHTML($controller->index([
118 'pos' => $_POST['pos'] ??
null,
119 'total_rows' => $_POST['total_rows'] ??
null,
123 if (Core
::isValid($_POST['pos'], 'integer')) {
124 $pos = (int) $_POST['pos'];
126 $num_cols = $centralColumns->getColumnsCount(
129 (int) $GLOBALS['cfg']['MaxRows']
131 $message = Message
::success(
132 sprintf(__('Showing rows %1$s - %2$s.'), $pos +
1, $pos +
$num_cols)
134 if (isset($tmp_msg) && $tmp_msg !== true) {