path fix for public images
[openemr.git] / phpmyadmin / db_central_columns.php
blob2e9aac73bbf5e34b3f7bc6e8c9cc10aca1468596
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/central_columns.lib.php';
15 if (isset($_POST['edit_save']) || isset($_POST['add_new_column'])) {
16 $col_name = $_POST['col_name'];
17 if (isset($_POST['edit_save'])) {
18 $orig_col_name = $_POST['orig_col_name'];
20 $col_default = $_POST['col_default'];
21 if ($col_default == 'NONE' && $_POST['col_default_sel'] != 'USER_DEFINED') {
22 $col_default = "";
24 $col_extra = isset($_POST['col_extra']) ? $_POST['col_extra'] : '';
25 $col_isNull = isset($_POST['col_isNull'])?1:0;
26 $col_length = $_POST['col_length'];
27 $col_attribute = $_POST['col_attribute'];
28 $col_type = $_POST['col_type'];
29 $collation = $_POST['collation'];
30 if (isset($orig_col_name) && $orig_col_name) {
31 echo PMA_updateOneColumn(
32 $db, $orig_col_name, $col_name, $col_type, $col_attribute,
33 $col_length, $col_isNull, $collation, $col_extra, $col_default
35 exit;
36 } else {
37 $tmp_msg = PMA_updateOneColumn(
38 $db, "", $col_name, $col_type, $col_attribute,
39 $col_length, $col_isNull, $collation, $col_extra, $col_default
43 if (isset($_POST['populateColumns'])) {
44 $selected_tbl = $_POST['selectedTable'];
45 echo PMA_getHTMLforColumnDropdown($db, $selected_tbl);
46 exit;
48 if (isset($_POST['getColumnList'])) {
49 echo PMA_getCentralColumnsListRaw($db, $_POST['cur_table']);
50 exit;
52 if (isset($_POST['add_column'])) {
53 $selected_col = array();
54 $selected_tbl = $_POST['table-select'];
55 $selected_col[] = $_POST['column-select'];
56 $tmp_msg = PMA_syncUniqueColumns($selected_col, false, $selected_tbl);
58 $response = PMA_Response::getInstance();
59 $header = $response->getHeader();
60 $scripts = $header->getScripts();
61 $scripts->addFile('jquery/jquery.uitablefilter.js');
62 $scripts->addFile('jquery/jquery.tablesorter.js');
63 $scripts->addFile('db_central_columns.js');
64 $cfgCentralColumns = PMA_centralColumnsGetParams();
65 $pmadb = $cfgCentralColumns['db'];
66 $pmatable = $cfgCentralColumns['table'];
67 $max_rows = $GLOBALS['cfg']['MaxRows'];
69 if (isset($_REQUEST['edit_central_columns_page'])) {
70 $selected_fld = $_REQUEST['selected_fld'];
71 $selected_db = $_REQUEST['db'];
72 $edit_central_column_page = PMA_getHTMLforEditingPage(
73 $selected_fld, $selected_db
75 $response->addHTML($edit_central_column_page);
76 exit;
78 if (isset($_POST['multi_edit_central_column_save'])) {
79 $message = PMA_updateMultipleColumn();
80 if (!is_bool($message)) {
81 $response->isSuccess(false);
82 $response->addJSON('message', $message);
85 if (isset($_POST['delete_save'])) {
86 $col_name = array();
87 parse_str($_POST['col_name'], $col_name);
88 $tmp_msg = PMA_deleteColumnsFromList($col_name['selected_fld'], false);
90 if (isset($_REQUEST['total_rows']) && $_REQUEST['total_rows']) {
91 $total_rows = $_REQUEST['total_rows'];
92 } else {
93 $total_rows = PMA_getCentralColumnsCount($db);
95 if (isset($_REQUEST['pos'])) {
96 $pos = $_REQUEST['pos'];
97 } else {
98 $pos = 0;
100 $addNewColumn = PMA_getHTMLforAddNewColumn($db);
101 $response->addHTML($addNewColumn);
102 if ($total_rows <= 0) {
103 $response->addHTML(
104 '<fieldset>' . __(
105 'The central list of columns for the current database is empty.'
106 ) . '</fieldset>'
108 $columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db);
109 $response->addHTML($columnAdd);
110 exit;
112 $table_navigation_html = PMA_getHTMLforTableNavigation($total_rows, $pos, $db);
113 $response->addHTML($table_navigation_html);
114 $columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db);
115 $response->addHTML($columnAdd);
116 $deleteRowForm = '<form method="post" id="del_form" action="db_central_columns.php">'
117 . PMA_URL_getHiddenInputs(
120 . '<input id="del_col_name" type="hidden" name="col_name" value="">'
121 . '<input type="hidden" name="pos" value="' . $pos . '">'
122 . '<input type="hidden" name="delete_save" value="delete"></form>';
123 $response->addHTML($deleteRowForm);
124 $table_struct = '<div id="tableslistcontainer">'
125 . '<form name="tableslistcontainer">'
126 . '<table id="table_columns" class="tablesorter" '
127 . 'style="min-width:100%" class="data">';
128 $response->addHTML($table_struct);
129 $tableheader = PMA_getCentralColumnsTableHeader(
130 'column_heading', __('Click to sort.'), 2
132 $response->addHTML($tableheader);
133 $result = PMA_getColumnsList($db, $pos, $max_rows);
134 $odd_row = true;
135 $row_num = 0;
136 foreach ($result as $row) {
137 $tableHtmlRow = PMA_getHTMLforCentralColumnsTableRow(
138 $row, $odd_row, $row_num, $db
140 $response->addHTML($tableHtmlRow);
141 $odd_row = !$odd_row;
142 $row_num++;
144 $response->addHTML('</table>');
145 $tablefooter = PMA_getCentralColumnsTableFooter($pmaThemeImage, $text_dir);
146 $response->addHTML($tablefooter);
147 $response->addHTML('</form></div>');
148 $message = PMA_Message::success(
149 sprintf(__('Showing rows %1$s - %2$s.'), ($pos + 1), ($pos + count($result)))
151 if (isset($tmp_msg) && $tmp_msg !== true) {
152 $message = $tmp_msg;