3 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * Central Columns view/edit
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') {
25 $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
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);
49 if (isset($_POST['getColumnList'])) {
50 echo PMA_getCentralColumnsListRaw($db, $_POST['cur_table']);
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'];
69 if (isset($_POST['delete_save'])) {
71 $col_name[] = $_REQUEST['col_name'];
72 $tmp_msg = PMA_deleteColumnsFromList($col_name, false);
74 if (isset($_REQUEST['total_rows']) && $_REQUEST['total_rows']) {
75 $total_rows = $_REQUEST['total_rows'];
77 $total_rows = PMA_getCentralColumnsCount($db);
79 if (isset($_REQUEST['pos'])) {
80 $pos = $_REQUEST['pos'];
84 $addNewColumn = PMA_getHTMLforAddNewColumn($db);
85 $response->addHTML($addNewColumn);
86 if ($total_rows <= 0) {
89 'The central list of columns for the current database is empty.'
92 $columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db);
93 $response->addHTML($columnAdd);
96 $table_navigation_html = PMA_getHTMLforTableNavigation($total_rows, $pos, $db);
97 $response->addHTML($table_navigation_html);
98 $columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db);
99 $response->addHTML($columnAdd);
100 $deleteRowForm = '<form method="post" id="del_form" action="db_central_columns.php">'
101 . PMA_URL_getHiddenInputs(
104 . '<input id="del_col_name" type="hidden" name="col_name" value="">'
105 . '<input type="hidden" name="pos" value="' . $pos . '">'
106 . '<input type="hidden" name="delete_save" value="delete"></form>';
107 $response->addHTML($deleteRowForm);
108 $table_struct = '<div id="tableslistcontainer">'
109 . '<table id="table_columns" class="tablesorter" '
110 . 'style="min-width:100%" class="data">';
111 $response->addHTML($table_struct);
112 $tableheader = PMA_getCentralColumnsTableHeader(
113 'column_heading', __('Click to sort.'), 2
115 $response->addHTML($tableheader);
116 $result = PMA_getColumnsList($db, $pos, $max_rows);
119 foreach ($result as $row) {
120 $tableHtmlRow = PMA_getHTMLforCentralColumnsTableRow(
121 $row, $odd_row, $row_num, $db
123 $response->addHTML($tableHtmlRow);
124 $odd_row = !$odd_row;
127 $response->addHTML('</table></div>');
128 $message = PMA_Message
::success(
129 sprintf(__('Showing rows %1$s - %2$s.'), ($pos +
1), ($pos +
count($result)))
131 if (isset($tmp_msg) && $tmp_msg !== true) {