added japanese language
[openemr.git] / phpmyadmin / tbl_change.php
blobb42340dbd1119d8b83e4d695d4f881790089eb4a
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Displays form for editing and inserting new table rows
6 * register_globals_save (mark this file save for disabling register globals)
8 * @package PhpMyAdmin
9 */
11 /**
12 * Gets the variables sent or posted to this script and displays the header
14 require_once 'libraries/common.inc.php';
16 /**
17 * Ensures db and table are valid, else moves to the "parent" script
19 require_once 'libraries/db_table_exists.lib.php';
21 /**
22 * functions implementation for this script
24 require_once 'libraries/insert_edit.lib.php';
26 /**
27 * Determine whether Insert or Edit and set global variables
29 list(
30 $insert_mode, $where_clause, $where_clause_array, $where_clauses,
31 $result, $rows, $found_unique_key, $after_insert
32 ) = PMA_determineInsertOrEdit(
33 isset($where_clause) ? $where_clause : null, $db, $table
36 /**
37 * file listing
39 require_once 'libraries/file_listing.lib.php';
41 /**
42 * Defines the url to return to in case of error in a sql statement
43 * (at this point, $GLOBALS['goto'] will be set but could be empty)
45 if (empty($GLOBALS['goto'])) {
46 if (strlen($table)) {
47 // avoid a problem (see bug #2202709)
48 $GLOBALS['goto'] = 'tbl_sql.php';
49 } else {
50 $GLOBALS['goto'] = 'db_sql.php';
55 $_url_params = PMA_getUrlParameters($db, $table);
56 $err_url = $GLOBALS['goto'] . PMA_URL_getCommon($_url_params);
57 unset($_url_params);
59 $comments_map = PMA_getCommentsMap($db, $table);
61 /**
62 * START REGULAR OUTPUT
65 /**
66 * Load JavaScript files
68 $response = PMA_Response::getInstance();
69 $header = $response->getHeader();
70 $scripts = $header->getScripts();
71 $scripts->addFile('functions.js');
72 $scripts->addFile('tbl_change.js');
73 $scripts->addFile('jquery/jquery-ui-timepicker-addon.js');
74 $scripts->addFile('gis_data_editor.js');
76 /**
77 * Displays the query submitted and its result
79 * $disp_message come from tbl_replace.php
81 if (! empty($disp_message)) {
82 $response->addHTML(PMA_Util::getMessage($disp_message, null));
85 // used as a global by PMA_Util::getDefaultFunctionForField()
86 $analyzed_sql = PMA_Table::analyzeStructure($db, $table);
88 $table_columns = PMA_getTableColumns($db, $table);
90 // retrieve keys into foreign fields, if any
91 $foreigners = PMA_getForeigners($db, $table);
93 // Retrieve form parameters for insert/edit form
94 $_form_params = PMA_getFormParametersForInsertForm(
95 $db, $table, $where_clauses, $where_clause_array, $err_url
98 /**
99 * Displays the form
101 // autocomplete feature of IE kills the "onchange" event handler and it
102 // must be replaced by the "onpropertychange" one in this case
103 $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE'
104 && PMA_USR_BROWSER_VER >= 5
105 && PMA_USR_BROWSER_VER < 7
107 ? 'onpropertychange'
108 : 'onchange';
109 // Had to put the URI because when hosted on an https server,
110 // some browsers send wrongly this form to the http server.
112 $html_output = '';
113 // Set if we passed the first timestamp field
114 $timestamp_seen = false;
115 $columns_cnt = count($table_columns);
117 $tabindex = 0;
118 $tabindex_for_function = +3000;
119 $tabindex_for_null = +6000;
120 $tabindex_for_value = 0;
121 $o_rows = 0;
122 $biggest_max_file_size = 0;
124 $url_params['db'] = $db;
125 $url_params['table'] = $table;
126 $url_params = PMA_urlParamsInEditMode(
127 $url_params, $where_clause_array, $where_clause
130 $has_blob_field = false;
131 foreach ($table_columns as $column) {
132 if (PMA_isColumnBlob($column)) {
133 $has_blob_field = true;
134 break;
138 //Insert/Edit form
139 //If table has blob fields we have to disable ajax.
140 $html_output .= PMA_getHtmlForInsertEditFormHeader($has_blob_field, $is_upload);
142 $html_output .= PMA_URL_getHiddenInputs($_form_params);
144 $titles['Browse'] = PMA_Util::getIcon('b_browse.png', __('Browse foreign values'));
146 // user can toggle the display of Function column and column types
147 // (currently does not work for multi-edits)
148 if (! $cfg['ShowFunctionFields'] || ! $cfg['ShowFieldTypesInDataEditView']) {
149 $html_output .= __('Show');
152 if (! $cfg['ShowFunctionFields']) {
153 $html_output .= PMA_showFunctionFieldsInEditMode($url_params, false);
156 if (! $cfg['ShowFieldTypesInDataEditView']) {
157 $html_output .= PMA_showColumnTypesInDataEditView($url_params, false);
160 foreach ($rows as $row_id => $current_row) {
161 if ($current_row === false) {
162 unset($current_row);
165 $jsvkey = $row_id;
166 $vkey = '[multi_edit][' . $jsvkey . ']';
168 $current_result = (isset($result) && is_array($result) && isset($result[$row_id])
169 ? $result[$row_id]
170 : $result);
171 if ($insert_mode && $row_id > 0) {
172 $html_output .= PMA_getHtmlForIgnoreOption($row_id);
175 $html_output .= PMA_getHtmlForInsertEditRow(
176 $url_params, $table_columns, $column, $comments_map, $timestamp_seen,
177 $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode,
178 isset($current_row) ? $current_row : null, $o_rows, $tabindex, $columns_cnt,
179 $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null,
180 $tabindex_for_value, $table, $db, $row_id, $titles,
181 $biggest_max_file_size, $text_dir
183 } // end foreach on multi-edit
185 $html_output .= PMA_getHtmlForGisEditor();
187 if (! isset($after_insert)) {
188 $after_insert = 'back';
191 //action panel
192 $html_output .= PMA_getActionsPanel(
193 $where_clause, $after_insert, $tabindex,
194 $tabindex_for_value, $found_unique_key
197 if ($biggest_max_file_size > 0) {
198 $html_output .= ' '
199 . PMA_Util::generateHiddenMaxFileSize(
200 $biggest_max_file_size
201 ) . "\n";
203 $html_output .= '</form>';
204 // end Insert/Edit form
206 if ($insert_mode) {
207 //Continue insertion form
208 $html_output .= PMA_getContinueInsertionForm(
209 $table, $db, $where_clause_array, $err_url
213 $response->addHTML($html_output);