Translated using Weblate (Traditional Chinese)
[phpmyadmin.git] / tbl_change.php
blobc98d76d9c4b913a596c2c63101cdabe643334351
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));
86 $table_columns = PMA_getTableColumns($db, $table);
88 // retrieve keys into foreign fields, if any
89 $foreigners = PMA_getForeigners($db, $table);
91 // Retrieve form parameters for insert/edit form
92 $_form_params = PMA_getFormParametersForInsertForm(
93 $db, $table, $where_clauses, $where_clause_array, $err_url
96 /**
97 * Displays the form
99 // autocomplete feature of IE kills the "onchange" event handler and it
100 // must be replaced by the "onpropertychange" one in this case
101 $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE'
102 && PMA_USR_BROWSER_VER >= 5
103 && PMA_USR_BROWSER_VER < 7
105 ? 'onpropertychange'
106 : 'onchange';
107 // Had to put the URI because when hosted on an https server,
108 // some browsers send wrongly this form to the http server.
110 $html_output = '';
111 // Set if we passed the first timestamp field
112 $timestamp_seen = false;
113 $columns_cnt = count($table_columns);
115 $tabindex = 0;
116 $tabindex_for_function = +3000;
117 $tabindex_for_null = +6000;
118 $tabindex_for_value = 0;
119 $o_rows = 0;
120 $biggest_max_file_size = 0;
122 $url_params['db'] = $db;
123 $url_params['table'] = $table;
124 $url_params = PMA_urlParamsInEditMode(
125 $url_params, $where_clause_array, $where_clause
128 $has_blob_field = false;
129 foreach ($table_columns as $column) {
130 if (PMA_isColumnBlob($column)) {
131 $has_blob_field = true;
132 break;
136 //Insert/Edit form
137 //If table has blob fields we have to disable ajax.
138 $html_output .= PMA_getHtmlForInsertEditFormHeader($has_blob_field, $is_upload);
140 $html_output .= PMA_URL_getHiddenInputs($_form_params);
142 $titles['Browse'] = PMA_Util::getIcon('b_browse.png', __('Browse foreign values'));
144 // user can toggle the display of Function column and column types
145 // (currently does not work for multi-edits)
146 if (! $cfg['ShowFunctionFields'] || ! $cfg['ShowFieldTypesInDataEditView']) {
147 $html_output .= __('Show');
150 if (! $cfg['ShowFunctionFields']) {
151 $html_output .= PMA_showFunctionFieldsInEditMode($url_params, false);
154 if (! $cfg['ShowFieldTypesInDataEditView']) {
155 $html_output .= PMA_showColumnTypesInDataEditView($url_params, false);
158 foreach ($rows as $row_id => $current_row) {
159 if ($current_row === false) {
160 unset($current_row);
163 $jsvkey = $row_id;
164 $vkey = '[multi_edit][' . $jsvkey . ']';
166 $current_result = (isset($result) && is_array($result) && isset($result[$row_id])
167 ? $result[$row_id]
168 : $result);
169 if ($insert_mode && $row_id > 0) {
170 $html_output .= PMA_getHtmlForIgnoreOption($row_id);
173 $html_output .= PMA_getHtmlForInsertEditRow(
174 $url_params, $table_columns, $column, $comments_map, $timestamp_seen,
175 $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode,
176 isset($current_row) ? $current_row : null, $o_rows, $tabindex, $columns_cnt,
177 $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null,
178 $tabindex_for_value, $table, $db, $row_id, $titles,
179 $biggest_max_file_size, $text_dir
181 } // end foreach on multi-edit
183 $html_output .= PMA_getHtmlForGisEditor();
185 if (! isset($after_insert)) {
186 $after_insert = 'back';
189 //action panel
190 $html_output .= PMA_getActionsPanel(
191 $where_clause, $after_insert, $tabindex,
192 $tabindex_for_value, $found_unique_key
195 if ($biggest_max_file_size > 0) {
196 $html_output .= ' '
197 . PMA_Util::generateHiddenMaxFileSize(
198 $biggest_max_file_size
199 ) . "\n";
201 $html_output .= '</form>';
202 // end Insert/Edit form
204 if ($insert_mode) {
205 //Continue insertion form
206 $html_output .= PMA_getContinueInsertionForm(
207 $table, $db, $where_clause_array, $err_url
211 $response->addHTML($html_output);