3 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * Central Columns view/edit
10 use PhpMyAdmin\CentralColumns
;
13 use PhpMyAdmin\Response
;
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') {
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
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);
53 if (isset($_POST['getColumnList'])) {
54 echo CentralColumns
::getListRaw($db, $_POST['cur_table']);
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);
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'])) {
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'];
98 $total_rows = CentralColumns
::getCount($db);
100 if (Core
::isValid($_REQUEST['pos'], 'integer')) {
101 $pos = intval($_REQUEST['pos']);
105 $addNewColumn = CentralColumns
::getHtmlForAddNewColumn($db, $total_rows);
106 $response->addHTML($addNewColumn);
107 if ($total_rows <= 0) {
110 'The central list of columns for the current database is empty.'
113 $columnAdd = CentralColumns
::getHtmlForAddCentralColumn($total_rows, $pos, $db);
114 $response->addHTML($columnAdd);
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" '
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);
140 foreach ($result as $row) {
141 $tableHtmlRow = CentralColumns
::getHtmlForCentralColumnsTableRow(
144 $response->addHTML($tableHtmlRow);
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) {