3 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * Central Columns view/edit
12 * Gets some core libraries
14 require_once 'libraries/common.inc.php';
15 require_once 'libraries/central_columns.lib.php';
17 if (isset($_POST['edit_save']) ||
isset($_POST['add_new_column'])) {
18 $col_name = $_POST['col_name'];
19 if (isset($_POST['edit_save'])) {
20 $orig_col_name = $_POST['orig_col_name'];
22 $col_default = $_POST['col_default'];
23 if ($col_default == 'NONE' && $_POST['col_default_sel'] != 'USER_DEFINED') {
26 $col_extra = isset($_POST['col_extra']) ?
$_POST['col_extra'] : '';
27 $col_isNull = isset($_POST['col_isNull'])?
1:0;
28 $col_length = $_POST['col_length'];
29 $col_attribute = $_POST['col_attribute'];
30 $col_type = $_POST['col_type'];
31 $collation = $_POST['collation'];
32 if (isset($orig_col_name) && $orig_col_name) {
33 echo PMA_updateOneColumn(
34 $db, $orig_col_name, $col_name, $col_type, $col_attribute,
35 $col_length, $col_isNull, $collation, $col_extra, $col_default
39 $tmp_msg = PMA_updateOneColumn(
40 $db, "", $col_name, $col_type, $col_attribute,
41 $col_length, $col_isNull, $collation, $col_extra, $col_default
45 if (isset($_POST['populateColumns'])) {
46 $selected_tbl = $_POST['selectedTable'];
47 echo PMA_getHTMLforColumnDropdown($db, $selected_tbl);
50 if (isset($_POST['getColumnList'])) {
51 echo PMA_getCentralColumnsListRaw($db, $_POST['cur_table']);
54 if (isset($_POST['add_column'])) {
55 $selected_col = array();
56 $selected_tbl = $_POST['table-select'];
57 $selected_col[] = $_POST['column-select'];
58 $tmp_msg = PMA_syncUniqueColumns($selected_col, false, $selected_tbl);
60 $response = PMA\libraries\Response
::getInstance();
61 $header = $response->getHeader();
62 $scripts = $header->getScripts();
63 $scripts->addFile('jquery/jquery.uitablefilter.js');
64 $scripts->addFile('jquery/jquery.tablesorter.js');
65 $scripts->addFile('db_central_columns.js');
66 $cfgCentralColumns = PMA_centralColumnsGetParams();
67 $pmadb = $cfgCentralColumns['db'];
68 $pmatable = $cfgCentralColumns['table'];
69 $max_rows = $GLOBALS['cfg']['MaxRows'];
71 if (isset($_REQUEST['edit_central_columns_page'])) {
72 $selected_fld = $_REQUEST['selected_fld'];
73 $selected_db = $_REQUEST['db'];
74 $edit_central_column_page = PMA_getHTMLforEditingPage(
75 $selected_fld, $selected_db
77 $response->addHTML($edit_central_column_page);
80 if (isset($_POST['multi_edit_central_column_save'])) {
81 $message = PMA_updateMultipleColumn();
82 if (!is_bool($message)) {
83 $response->setRequestStatus(false);
84 $response->addJSON('message', $message);
87 if (isset($_POST['delete_save'])) {
89 parse_str($_POST['col_name'], $col_name);
90 $tmp_msg = PMA_deleteColumnsFromList($col_name['selected_fld'], false);
92 if (isset($_REQUEST['total_rows']) && $_REQUEST['total_rows']) {
93 $total_rows = $_REQUEST['total_rows'];
95 $total_rows = PMA_getCentralColumnsCount($db);
97 if (isset($_REQUEST['pos'])) {
98 $pos = $_REQUEST['pos'];
102 $addNewColumn = PMA_getHTMLforAddNewColumn($db);
103 $response->addHTML($addNewColumn);
104 if ($total_rows <= 0) {
107 'The central list of columns for the current database is empty.'
110 $columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db);
111 $response->addHTML($columnAdd);
114 $table_navigation_html = PMA_getHTMLforTableNavigation($total_rows, $pos, $db);
115 $response->addHTML($table_navigation_html);
116 $columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db);
117 $response->addHTML($columnAdd);
118 $deleteRowForm = '<form method="post" id="del_form" action="db_central_columns.php">'
119 . URL
::getHiddenInputs(
122 . '<input id="del_col_name" type="hidden" name="col_name" value="">'
123 . '<input type="hidden" name="pos" value="' . $pos . '">'
124 . '<input type="hidden" name="delete_save" value="delete"></form>';
125 $response->addHTML($deleteRowForm);
126 $table_struct = '<div id="tableslistcontainer">'
127 . '<form name="tableslistcontainer">'
128 . '<table id="table_columns" class="tablesorter" '
129 . 'style="min-width:100%" class="data">';
130 $response->addHTML($table_struct);
131 $tableheader = PMA_getCentralColumnsTableHeader(
132 'column_heading', __('Click to sort.'), 2
134 $response->addHTML($tableheader);
135 $result = PMA_getColumnsList($db, $pos, $max_rows);
138 foreach ($result as $row) {
139 $tableHtmlRow = PMA_getHTMLforCentralColumnsTableRow(
140 $row, $odd_row, $row_num, $db
142 $response->addHTML($tableHtmlRow);
143 $odd_row = !$odd_row;
146 $response->addHTML('</table>');
147 $tablefooter = PMA_getCentralColumnsTableFooter($pmaThemeImage, $text_dir);
148 $response->addHTML($tablefooter);
149 $response->addHTML('</form></div>');
150 $message = PMA\libraries\Message
::success(
151 sprintf(__('Showing rows %1$s - %2$s.'), ($pos +
1), ($pos +
count($result)))
153 if (isset($tmp_msg) && $tmp_msg !== true) {