Translated using Weblate (Filipino)
[phpmyadmin.git] / db_central_columns.php
blob8b8d2e7216ded6096574ec2b49b65de2fe6fd217
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($_REQUEST['edit_central_columns_page'])) {
88 $selected_fld = $_REQUEST['selected_fld'];
89 $selected_db = $_REQUEST['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 (isset($_REQUEST['total_rows']) && $_REQUEST['total_rows']) {
113 $total_rows = $_REQUEST['total_rows'];
114 } else {
115 $total_rows = $centralColumns->getCount($db);
117 if (Core::isValid($_REQUEST['pos'], 'integer')) {
118 $pos = intval($_REQUEST['pos']);
119 } else {
120 $pos = 0;
122 $addNewColumn = $centralColumns->getHtmlForAddNewColumn($db, $total_rows);
123 $response->addHTML($addNewColumn);
124 if ($total_rows <= 0) {
125 $response->addHTML(
126 '<fieldset>' . __(
127 'The central list of columns for the current database is empty.'
128 ) . '</fieldset>'
130 $columnAdd = $centralColumns->getHtmlForAddColumn($total_rows, $pos, $db);
131 $response->addHTML($columnAdd);
132 exit;
134 $table_navigation_html = $centralColumns->getHtmlForTableNavigation(
135 $total_rows,
136 $pos,
139 $response->addHTML($table_navigation_html);
140 $columnAdd = $centralColumns->getHtmlForAddColumn($total_rows, $pos, $db);
141 $response->addHTML($columnAdd);
142 $deleteRowForm = '<form method="post" id="del_form" action="db_central_columns.php">'
143 . Url::getHiddenInputs(
146 . '<input id="del_col_name" type="hidden" name="col_name" value="">'
147 . '<input type="hidden" name="pos" value="' . $pos . '">'
148 . '<input type="hidden" name="delete_save" value="delete"></form>';
149 $response->addHTML($deleteRowForm);
150 $table_struct = '<div id="tableslistcontainer">'
151 . '<form name="tableslistcontainer">'
152 . '<table id="table_columns" class="tablesorter" '
153 . 'class="data">';
154 $response->addHTML($table_struct);
155 $tableheader = $centralColumns->getTableHeader(
156 'column_heading', __('Click to sort.'), 2
158 $response->addHTML($tableheader);
159 $result = $centralColumns->getColumnsList($db, $pos, $max_rows);
160 $row_num = 0;
161 foreach ($result as $row) {
162 $tableHtmlRow = $centralColumns->getHtmlForTableRow(
163 $row,
164 $row_num,
167 $response->addHTML($tableHtmlRow);
168 $row_num++;
170 $response->addHTML('</table>');
171 $tablefooter = $centralColumns->getTableFooter($pmaThemeImage, $text_dir);
172 $response->addHTML($tablefooter);
173 $response->addHTML('</form></div>');
174 $message = Message::success(
175 sprintf(__('Showing rows %1$s - %2$s.'), ($pos + 1), ($pos + count($result)))
177 if (isset($tmp_msg) && $tmp_msg !== true) {
178 $message = $tmp_msg;