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