Translated using Weblate (Czech)
[phpmyadmin.git] / db_central_columns.php
blob6eebb40a0a04277fd88bc8a7a7ab8afbfe09a12a
1 <?php
3 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 /**
5 * Central Columns view/edit
7 * @package PhpMyAdmin
8 */
10 use PhpMyAdmin\CentralColumns;
11 use PhpMyAdmin\Core;
12 use PhpMyAdmin\Message;
13 use PhpMyAdmin\Response;
14 use PhpMyAdmin\Url;
16 /**
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') {
30 $col_default = "";
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
43 exit;
44 } else {
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(
54 $db,
55 $selected_tbl
57 exit;
59 if (isset($_POST['getColumnList'])) {
60 echo $centralColumns->getListRaw(
61 $db,
62 $_POST['cur_table']
64 exit;
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(
71 $selected_col,
72 false,
73 $selected_tbl
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(
91 $selected_fld,
92 $selected_db
94 $response->addHTML($edit_central_column_page);
95 exit;
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'])) {
105 $col_name = array();
106 parse_str($_POST['col_name'], $col_name);
107 $tmp_msg = $centralColumns->deleteColumnsFromList(
108 $col_name['selected_fld'],
109 false
112 if (!empty($_POST['total_rows'])
113 && Core::isValid($_POST['total_rows'], 'integer')
115 $total_rows = $_POST['total_rows'];
116 } else {
117 $total_rows = $centralColumns->getCount($db);
119 if (Core::isValid($_POST['pos'], 'integer')) {
120 $pos = intval($_POST['pos']);
121 } else {
122 $pos = 0;
124 $addNewColumn = $centralColumns->getHtmlForAddNewColumn($db, $total_rows);
125 $response->addHTML($addNewColumn);
126 if ($total_rows <= 0) {
127 $response->addHTML(
128 '<fieldset>' . __(
129 'The central list of columns for the current database is empty.'
130 ) . '</fieldset>'
132 $columnAdd = $centralColumns->getHtmlForAddColumn($total_rows, $pos, $db);
133 $response->addHTML($columnAdd);
134 exit;
136 $table_navigation_html = $centralColumns->getHtmlForTableNavigation(
137 $total_rows,
138 $pos,
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" '
155 . 'class="data">';
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);
162 $row_num = 0;
163 foreach ($result as $row) {
164 $tableHtmlRow = $centralColumns->getHtmlForTableRow(
165 $row,
166 $row_num,
169 $response->addHTML($tableHtmlRow);
170 $row_num++;
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) {
180 $message = $tmp_msg;