Start PHP from main script for selenium tests
[phpmyadmin.git] / db_central_columns.php
blob2d3a2c301bf2f0f5b5087a2aae75735465732f28
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 $col_extra = $_POST['col_extra'];
23 $col_isNull = isset($_POST['col_isNull'])?1:0;
24 $col_length = $_POST['col_length'];
25 $col_type = $_POST['col_type'];
26 $collation = $_POST['collation'];
27 if (isset($orig_col_name) && $orig_col_name) {
28 echo PMA_updateOneColumn(
29 $db, $orig_col_name, $col_name, $col_type,
30 $col_length, $col_isNull, $collation, $col_extra, $col_default
32 exit;
33 } else {
34 $tmp_msg = PMA_updateOneColumn(
35 $db, "", $col_name, $col_type,
36 $col_length, $col_isNull, $collation, $col_extra, $col_default
40 if (isset($_POST['populateColumns'])) {
41 $selected_tbl = $_POST['selectedTable'];
42 echo PMA_getHTMLforColumnDropdown($db, $selected_tbl);
43 exit;
45 if (isset($_POST['getColumnList'])) {
46 echo PMA_getCentralColumnsListRaw($db, $_POST['cur_table']);
47 exit;
49 if (isset($_POST['add_column'])) {
50 $selected_col = array();
51 $selected_tbl = $_POST['table-select'];
52 $selected_col[] = $_POST['column-select'];
53 $tmp_msg = PMA_syncUniqueColumns($selected_col, false, $selected_tbl);
55 $response = PMA_Response::getInstance();
56 $header = $response->getHeader();
57 $scripts = $header->getScripts();
58 $scripts->addFile('jquery/jquery.uitablefilter.js');
59 $scripts->addFile('jquery/jquery.tablesorter.js');
60 $scripts->addFile('db_central_columns.js');
61 $cfgCentralColumns = PMA_centralColumnsGetParams();
62 $pmadb = $cfgCentralColumns['db'];
63 $pmatable = $cfgCentralColumns['table'];
64 $max_rows = $GLOBALS['cfg']['MaxRows'];
65 if (isset($_POST['delete_save'])) {
66 $col_name = array();
67 $col_name[] = $_REQUEST['col_name'];
68 $tmp_msg = PMA_deleteColumnsFromList($col_name, false);
70 if (isset($_REQUEST['total_rows']) && $_REQUEST['total_rows']) {
71 $total_rows = $_REQUEST['total_rows'];
72 } else {
73 $total_rows = PMA_getCentralColumnsCount($db);
75 if (isset($_REQUEST['pos'])) {
76 $pos = $_REQUEST['pos'];
77 } else {
78 $pos = 0;
80 $addNewColumn = PMA_getHTMLforAddNewColumn($db);
81 $response->addHTML($addNewColumn);
82 if ($total_rows <= 0) {
83 $response->addHTML(
84 '<fieldset>' . __(
85 'The central list of columns for the current database is empty.'
86 ) . '</fieldset>'
88 $columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db);
89 $response->addHTML($columnAdd);
90 exit;
92 $table_navigation_html = PMA_getHTMLforTableNavigation($total_rows, $pos, $db);
93 $response->addHTML($table_navigation_html);
94 $columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db);
95 $response->addHTML($columnAdd);
96 $deleteRowForm = '<form method="post" id="del_form" action="db_central_columns.php">'
97 . PMA_URL_getHiddenInputs(
98 $db
100 . '<input id="del_col_name" type="hidden" name="col_name" value="">'
101 . '<input type="hidden" name="pos" value="' . $pos . '">'
102 . '<input type="hidden" name="delete_save" value="delete"></form>';
103 $response->addHTML($deleteRowForm);
104 $table_struct = '<div id="tableslistcontainer">'
105 . '<table id="table_columns" class="tablesorter" '
106 . 'style="min-width:100%" class="data">';
107 $response->addHTML($table_struct);
108 $tableheader = PMA_getCentralColumnsTableHeader(
109 'column_heading', __('Click to sort.'), 2
111 $response->addHTML($tableheader);
112 $result = PMA_getColumnsList($db, $pos, $max_rows);
113 $odd_row = false;
114 $row_num=0;
115 foreach ($result as $row) {
116 $tableHtmlRow = PMA_getHTMLforCentralColumnsTableRow(
117 $row, $odd_row, $row_num, $db
119 $response->addHTML($tableHtmlRow);
120 $odd_row = !$odd_row;
121 $row_num++;
123 $response->addHTML('</table></div>');
124 $message = PMA_Message::success(
125 sprintf(__('Showing rows %1$s - %2$s.'), ($pos + 1), ($pos + count($result)))
127 if (isset($tmp_msg) && $tmp_msg !== true) {
128 $message = $tmp_msg;