Translated using Weblate (Korean)
[phpmyadmin.git] / db_central_columns.php
blobd23aa1bcbaccf28f1237c1438e1590e43b99f41c
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\Url;
13 use PhpMyAdmin\Response;
15 /**
16 * Gets some core libraries
18 require_once 'libraries/common.inc.php';
20 if (isset($_POST['edit_save']) || isset($_POST['add_new_column'])) {
21 $col_name = $_POST['col_name'];
22 if (isset($_POST['edit_save'])) {
23 $orig_col_name = $_POST['orig_col_name'];
25 $col_default = $_POST['col_default'];
26 if ($col_default == 'NONE' && $_POST['col_default_sel'] != 'USER_DEFINED') {
27 $col_default = "";
29 $col_extra = isset($_POST['col_extra']) ? $_POST['col_extra'] : '';
30 $col_isNull = isset($_POST['col_isNull'])?1:0;
31 $col_length = $_POST['col_length'];
32 $col_attribute = $_POST['col_attribute'];
33 $col_type = $_POST['col_type'];
34 $collation = $_POST['collation'];
35 if (isset($orig_col_name) && $orig_col_name) {
36 echo CentralColumns::updateOneColumn(
37 $db, $orig_col_name, $col_name, $col_type, $col_attribute,
38 $col_length, $col_isNull, $collation, $col_extra, $col_default
40 exit;
41 } else {
42 $tmp_msg = CentralColumns::updateOneColumn(
43 $db, "", $col_name, $col_type, $col_attribute,
44 $col_length, $col_isNull, $collation, $col_extra, $col_default
48 if (isset($_POST['populateColumns'])) {
49 $selected_tbl = $_POST['selectedTable'];
50 echo CentralColumns::getHtmlForColumnDropdown($db, $selected_tbl);
51 exit;
53 if (isset($_POST['getColumnList'])) {
54 echo CentralColumns::getListRaw($db, $_POST['cur_table']);
55 exit;
57 if (isset($_POST['add_column'])) {
58 $selected_col = array();
59 $selected_tbl = $_POST['table-select'];
60 $selected_col[] = $_POST['column-select'];
61 $tmp_msg = CentralColumns::syncUniqueColumns($selected_col, false, $selected_tbl);
63 $response = Response::getInstance();
64 $header = $response->getHeader();
65 $scripts = $header->getScripts();
66 $scripts->addFile('vendor/jquery/jquery.uitablefilter.js');
67 $scripts->addFile('vendor/jquery/jquery.tablesorter.js');
68 $scripts->addFile('db_central_columns.js');
69 $cfgCentralColumns = CentralColumns::getParams();
70 $pmadb = $cfgCentralColumns['db'];
71 $pmatable = $cfgCentralColumns['table'];
72 $max_rows = intval($GLOBALS['cfg']['MaxRows']);
74 if (isset($_REQUEST['edit_central_columns_page'])) {
75 $selected_fld = $_REQUEST['selected_fld'];
76 $selected_db = $_REQUEST['db'];
77 $edit_central_column_page = CentralColumns::getHtmlForEditingPage(
78 $selected_fld, $selected_db
80 $response->addHTML($edit_central_column_page);
81 exit;
83 if (isset($_POST['multi_edit_central_column_save'])) {
84 $message = CentralColumns::updateMultipleColumn();
85 if (!is_bool($message)) {
86 $response->setRequestStatus(false);
87 $response->addJSON('message', $message);
90 if (isset($_POST['delete_save'])) {
91 $col_name = array();
92 parse_str($_POST['col_name'], $col_name);
93 $tmp_msg = CentralColumns::deleteColumnsFromList($col_name['selected_fld'], false);
95 if (isset($_REQUEST['total_rows']) && $_REQUEST['total_rows']) {
96 $total_rows = $_REQUEST['total_rows'];
97 } else {
98 $total_rows = CentralColumns::getCount($db);
100 if (Core::isValid($_REQUEST['pos'], 'integer')) {
101 $pos = intval($_REQUEST['pos']);
102 } else {
103 $pos = 0;
105 $addNewColumn = CentralColumns::getHtmlForAddNewColumn($db, $total_rows);
106 $response->addHTML($addNewColumn);
107 if ($total_rows <= 0) {
108 $response->addHTML(
109 '<fieldset>' . __(
110 'The central list of columns for the current database is empty.'
111 ) . '</fieldset>'
113 $columnAdd = CentralColumns::getHtmlForAddCentralColumn($total_rows, $pos, $db);
114 $response->addHTML($columnAdd);
115 exit;
117 $table_navigation_html = CentralColumns::getHtmlForTableNavigation($total_rows, $pos, $db);
118 $response->addHTML($table_navigation_html);
119 $columnAdd = CentralColumns::getHtmlForAddCentralColumn($total_rows, $pos, $db);
120 $response->addHTML($columnAdd);
121 $deleteRowForm = '<form method="post" id="del_form" action="db_central_columns.php">'
122 . Url::getHiddenInputs(
125 . '<input id="del_col_name" type="hidden" name="col_name" value="">'
126 . '<input type="hidden" name="pos" value="' . $pos . '">'
127 . '<input type="hidden" name="delete_save" value="delete"></form>';
128 $response->addHTML($deleteRowForm);
129 $table_struct = '<div id="tableslistcontainer">'
130 . '<form name="tableslistcontainer">'
131 . '<table id="table_columns" class="tablesorter" '
132 . 'class="data">';
133 $response->addHTML($table_struct);
134 $tableheader = CentralColumns::getTableHeader(
135 'column_heading', __('Click to sort.'), 2
137 $response->addHTML($tableheader);
138 $result = CentralColumns::getColumnsList($db, $pos, $max_rows);
139 $row_num = 0;
140 foreach ($result as $row) {
141 $tableHtmlRow = CentralColumns::getHtmlForCentralColumnsTableRow(
142 $row, $row_num, $db
144 $response->addHTML($tableHtmlRow);
145 $row_num++;
147 $response->addHTML('</table>');
148 $tablefooter = CentralColumns::getTableFooter($pmaThemeImage, $text_dir);
149 $response->addHTML($tablefooter);
150 $response->addHTML('</form></div>');
151 $message = PhpMyAdmin\Message::success(
152 sprintf(__('Showing rows %1$s - %2$s.'), ($pos + 1), ($pos + count($result)))
154 if (isset($tmp_msg) && $tmp_msg !== true) {
155 $message = $tmp_msg;