Translated using Weblate (Dutch)
[phpmyadmin.git] / db_central_columns.php
blob0d9bdc8b9502b24eaf2455223ec9178f5921167d
1 <?php
3 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 /**
5 * Central Columns view/edit
7 * @package PhpMyAdmin
8 */
9 /**
10 * Gets some core libraries
12 require_once 'libraries/common.inc.php';
13 require_once 'libraries/tbl_columns_definition_form.lib.php';
14 require_once 'libraries/central_columns.lib.php';
16 if (isset($_POST['edit_save']) || isset($_POST['add_new_column'])) {
17 $col_name = $_POST['col_name'];
18 if (isset($_POST['edit_save'])) {
19 $orig_col_name = $_POST['orig_col_name'];
21 $col_default = $_POST['col_default'];
22 if ($col_default == 'NONE' && $_POST['col_default_sel'] != 'USER_DEFINED') {
23 $col_default = "";
25 $col_extra = isset($_POST['col_extra']) ? $_POST['col_extra'] : '';
26 $col_isNull = isset($_POST['col_isNull'])?1:0;
27 $col_length = $_POST['col_length'];
28 $col_attribute = $_POST['col_attribute'];
29 $col_type = $_POST['col_type'];
30 $collation = $_POST['collation'];
31 if (isset($orig_col_name) && $orig_col_name) {
32 echo PMA_updateOneColumn(
33 $db, $orig_col_name, $col_name, $col_type,$col_attribute,
34 $col_length, $col_isNull, $collation, $col_extra, $col_default
36 exit;
37 } else {
38 $tmp_msg = PMA_updateOneColumn(
39 $db, "", $col_name, $col_type,$col_attribute,
40 $col_length, $col_isNull, $collation, $col_extra, $col_default
44 if (isset($_POST['populateColumns'])) {
45 $selected_tbl = $_POST['selectedTable'];
46 echo PMA_getHTMLforColumnDropdown($db, $selected_tbl);
47 exit;
49 if (isset($_POST['getColumnList'])) {
50 echo PMA_getCentralColumnsListRaw($db, $_POST['cur_table']);
51 exit;
53 if (isset($_POST['add_column'])) {
54 $selected_col = array();
55 $selected_tbl = $_POST['table-select'];
56 $selected_col[] = $_POST['column-select'];
57 $tmp_msg = PMA_syncUniqueColumns($selected_col, false, $selected_tbl);
59 $response = PMA_Response::getInstance();
60 $header = $response->getHeader();
61 $scripts = $header->getScripts();
62 $scripts->addFile('jquery/jquery.uitablefilter.js');
63 $scripts->addFile('jquery/jquery.tablesorter.js');
64 $scripts->addFile('db_central_columns.js');
65 $cfgCentralColumns = PMA_centralColumnsGetParams();
66 $pmadb = $cfgCentralColumns['db'];
67 $pmatable = $cfgCentralColumns['table'];
68 $max_rows = $GLOBALS['cfg']['MaxRows'];
70 if (isset($_REQUEST['edit_central_columns_page'])) {
71 $selected_fld = $_REQUEST['selected_fld'];
72 $selected_db = $_REQUEST['db'];
73 $edit_central_column_page = PMA_getHTMLforEditingPage($selected_fld, $selected_db);
74 $response->addHTML($edit_central_column_page);
75 exit;
77 if (isset($_POST['multi_edit_central_column_save'])) {
78 $message = PMA_updateMultipleColumn();
79 if (!is_bool($message)) {
80 $response->isSuccess(false);
81 $response->addJSON('message', $message);
84 if (isset($_POST['delete_save'])) {
85 $col_name = array();
86 parse_str($_POST['col_name'], $col_name);
87 $tmp_msg = PMA_deleteColumnsFromList($col_name['selected_fld'], false);
89 if (isset($_REQUEST['total_rows']) && $_REQUEST['total_rows']) {
90 $total_rows = $_REQUEST['total_rows'];
91 } else {
92 $total_rows = PMA_getCentralColumnsCount($db);
94 if (isset($_REQUEST['pos'])) {
95 $pos = $_REQUEST['pos'];
96 } else {
97 $pos = 0;
99 $addNewColumn = PMA_getHTMLforAddNewColumn($db);
100 $response->addHTML($addNewColumn);
101 if ($total_rows <= 0) {
102 $response->addHTML(
103 '<fieldset>' . __(
104 'The central list of columns for the current database is empty.'
105 ) . '</fieldset>'
107 $columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db);
108 $response->addHTML($columnAdd);
109 exit;
111 $table_navigation_html = PMA_getHTMLforTableNavigation($total_rows, $pos, $db);
112 $response->addHTML($table_navigation_html);
113 $columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db);
114 $response->addHTML($columnAdd);
115 $deleteRowForm = '<form method="post" id="del_form" action="db_central_columns.php">'
116 . PMA_URL_getHiddenInputs(
119 . '<input id="del_col_name" type="hidden" name="col_name" value="">'
120 . '<input type="hidden" name="pos" value="' . $pos . '">'
121 . '<input type="hidden" name="delete_save" value="delete"></form>';
122 $response->addHTML($deleteRowForm);
123 $table_struct = '<div id="tableslistcontainer">'
124 . '<form name="tableslistcontainer">'
125 . '<table id="table_columns" class="tablesorter" '
126 . 'style="min-width:100%" class="data">';
127 $response->addHTML($table_struct);
128 $tableheader = PMA_getCentralColumnsTableHeader(
129 'column_heading', __('Click to sort.'), 2
131 $response->addHTML($tableheader);
132 $result = PMA_getColumnsList($db, $pos, $max_rows);
133 $odd_row = true;
134 $row_num=0;
135 foreach ($result as $row) {
136 $tableHtmlRow = PMA_getHTMLforCentralColumnsTableRow(
137 $row, $odd_row, $row_num, $db
139 $response->addHTML($tableHtmlRow);
140 $odd_row = !$odd_row;
141 $row_num++;
143 $response->addHTML('</table>');
144 $tablefooter = PMA_getCentralColumnsTableFooter($pmaThemeImage, $text_dir);
145 $response->addHTML($tablefooter);
146 $response->addHTML('</form></div>');
147 $message = PMA_Message::success(
148 sprintf(__('Showing rows %1$s - %2$s.'), ($pos + 1), ($pos + count($result)))
150 if (isset($tmp_msg) && $tmp_msg !== true) {
151 $message = $tmp_msg;