3 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * Central Columns view/edit
10 use PhpMyAdmin\CentralColumns
;
12 use PhpMyAdmin\Message
;
13 use PhpMyAdmin\Response
;
17 * Gets some core libraries
19 require_once 'libraries/common.inc.php';
21 $centralColumns = new CentralColumns($GLOBALS['dbi']);
23 if (isset($_POST['edit_save']) ||
isset($_POST['add_new_column'])) {
24 $col_name = $_POST['col_name'];
25 if (isset($_POST['edit_save'])) {
26 $orig_col_name = $_POST['orig_col_name'];
28 $col_default = $_POST['col_default'];
29 if ($col_default == 'NONE' && $_POST['col_default_sel'] != 'USER_DEFINED') {
32 $col_extra = isset($_POST['col_extra']) ?
$_POST['col_extra'] : '';
33 $col_isNull = isset($_POST['col_isNull'])?
1:0;
34 $col_length = $_POST['col_length'];
35 $col_attribute = $_POST['col_attribute'];
36 $col_type = $_POST['col_type'];
37 $collation = $_POST['collation'];
38 if (isset($orig_col_name) && $orig_col_name) {
39 echo $centralColumns->updateOneColumn(
40 $db, $orig_col_name, $col_name, $col_type, $col_attribute,
41 $col_length, $col_isNull, $collation, $col_extra, $col_default
45 $tmp_msg = $centralColumns->updateOneColumn(
46 $db, "", $col_name, $col_type, $col_attribute,
47 $col_length, $col_isNull, $collation, $col_extra, $col_default
51 if (isset($_POST['populateColumns'])) {
52 $selected_tbl = $_POST['selectedTable'];
53 echo $centralColumns->getHtmlForColumnDropdown(
59 if (isset($_POST['getColumnList'])) {
60 echo $centralColumns->getListRaw(
66 if (isset($_POST['add_column'])) {
67 $selected_col = array();
68 $selected_tbl = $_POST['table-select'];
69 $selected_col[] = $_POST['column-select'];
70 $tmp_msg = $centralColumns->syncUniqueColumns(
76 $response = Response
::getInstance();
77 $header = $response->getHeader();
78 $scripts = $header->getScripts();
79 $scripts->addFile('vendor/jquery/jquery.uitablefilter.js');
80 $scripts->addFile('vendor/jquery/jquery.tablesorter.js');
81 $scripts->addFile('db_central_columns.js');
82 $cfgCentralColumns = $centralColumns->getParams();
83 $pmadb = $cfgCentralColumns['db'];
84 $pmatable = $cfgCentralColumns['table'];
85 $max_rows = intval($GLOBALS['cfg']['MaxRows']);
87 if (isset($_POST['edit_central_columns_page'])) {
88 $selected_fld = $_POST['selected_fld'];
89 $selected_db = $_POST['db'];
90 $edit_central_column_page = $centralColumns->getHtmlForEditingPage(
94 $response->addHTML($edit_central_column_page);
97 if (isset($_POST['multi_edit_central_column_save'])) {
98 $message = $centralColumns->updateMultipleColumn();
99 if (!is_bool($message)) {
100 $response->setRequestStatus(false);
101 $response->addJSON('message', $message);
104 if (isset($_POST['delete_save'])) {
106 parse_str($_POST['col_name'], $col_name);
107 $tmp_msg = $centralColumns->deleteColumnsFromList(
108 $col_name['selected_fld'],
112 if (!empty($_POST['total_rows'])
113 && Core
::isValid($_POST['total_rows'], 'integer')
115 $total_rows = $_POST['total_rows'];
117 $total_rows = $centralColumns->getCount($db);
119 if (Core
::isValid($_POST['pos'], 'integer')) {
120 $pos = intval($_POST['pos']);
124 $addNewColumn = $centralColumns->getHtmlForAddNewColumn($db, $total_rows);
125 $response->addHTML($addNewColumn);
126 if ($total_rows <= 0) {
129 'The central list of columns for the current database is empty.'
132 $columnAdd = $centralColumns->getHtmlForAddColumn($total_rows, $pos, $db);
133 $response->addHTML($columnAdd);
136 $table_navigation_html = $centralColumns->getHtmlForTableNavigation(
141 $response->addHTML($table_navigation_html);
142 $columnAdd = $centralColumns->getHtmlForAddColumn($total_rows, $pos, $db);
143 $response->addHTML($columnAdd);
144 $deleteRowForm = '<form method="post" id="del_form" action="db_central_columns.php">'
145 . Url
::getHiddenInputs(
148 . '<input id="del_col_name" type="hidden" name="col_name" value="">'
149 . '<input type="hidden" name="pos" value="' . $pos . '">'
150 . '<input type="hidden" name="delete_save" value="delete"></form>';
151 $response->addHTML($deleteRowForm);
152 $table_struct = '<div id="tableslistcontainer">'
153 . '<form name="tableslistcontainer">'
154 . '<table id="table_columns" class="tablesorter" '
156 $response->addHTML($table_struct);
157 $tableheader = $centralColumns->getTableHeader(
158 'column_heading', __('Click to sort.'), 2
160 $response->addHTML($tableheader);
161 $result = $centralColumns->getColumnsList($db, $pos, $max_rows);
163 foreach ($result as $row) {
164 $tableHtmlRow = $centralColumns->getHtmlForTableRow(
169 $response->addHTML($tableHtmlRow);
172 $response->addHTML('</table>');
173 $tablefooter = $centralColumns->getTableFooter($pmaThemeImage, $text_dir);
174 $response->addHTML($tablefooter);
175 $response->addHTML('</form></div>');
176 $message = Message
::success(
177 sprintf(__('Showing rows %1$s - %2$s.'), ($pos +
1), ($pos +
count($result)))
179 if (isset($tmp_msg) && $tmp_msg !== true) {