Translated using Weblate (Korean)
[phpmyadmin.git] / tbl_change.php
blob0f2fc5e17dfc933fca6999868e7f62993b777719
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';
15 require_once 'libraries/config/page_settings.class.php';
17 PMA_PageSettings::showGroup('Edit');
19 /**
20 * Ensures db and table are valid, else moves to the "parent" script
22 require_once 'libraries/db_table_exists.lib.php';
24 /**
25 * functions implementation for this script
27 require_once 'libraries/insert_edit.lib.php';
28 require_once 'libraries/transformations.lib.php';
30 /**
31 * Determine whether Insert or Edit and set global variables
33 list(
34 $insert_mode, $where_clause, $where_clause_array, $where_clauses,
35 $result, $rows, $found_unique_key, $after_insert
36 ) = PMA_determineInsertOrEdit(
37 isset($where_clause) ? $where_clause : null, $db, $table
39 // Increase number of rows if unsaved rows are more
40 if (!empty($unsaved_values) && count($rows) < count($unsaved_values)) {
41 $rows = array_fill(0, count($unsaved_values), false);
43 /**
44 * file listing
46 require_once 'libraries/file_listing.lib.php';
48 /**
49 * Defines the url to return to in case of error in a sql statement
50 * (at this point, $GLOBALS['goto'] will be set but could be empty)
52 if (empty($GLOBALS['goto'])) {
53 if (/*overload*/mb_strlen($table)) {
54 // avoid a problem (see bug #2202709)
55 $GLOBALS['goto'] = 'tbl_sql.php';
56 } else {
57 $GLOBALS['goto'] = 'db_sql.php';
62 $_url_params = PMA_getUrlParameters($db, $table);
63 $err_url = $GLOBALS['goto'] . PMA_URL_getCommon($_url_params);
64 unset($_url_params);
66 $comments_map = PMA_getCommentsMap($db, $table);
68 /**
69 * START REGULAR OUTPUT
72 /**
73 * Load JavaScript files
75 $response = PMA_Response::getInstance();
76 $header = $response->getHeader();
77 $scripts = $header->getScripts();
78 $scripts->addFile('functions.js');
79 $scripts->addFile('sql.js');
80 $scripts->addFile('tbl_change.js');
81 $scripts->addFile('big_ints.js');
82 $scripts->addFile('jquery/jquery-ui-timepicker-addon.js');
83 $scripts->addFile('jquery/jquery.validate.js');
84 $scripts->addFile('jquery/additional-methods.js');
85 $scripts->addFile('gis_data_editor.js');
87 /**
88 * Displays the query submitted and its result
90 * $disp_message come from tbl_replace.php
92 if (! empty($disp_message)) {
93 $response->addHTML(PMA_Util::getMessage($disp_message, null));
96 $table_columns = PMA_getTableColumns($db, $table);
98 // retrieve keys into foreign fields, if any
99 $foreigners = PMA_getForeigners($db, $table);
101 // Retrieve form parameters for insert/edit form
102 $_form_params = PMA_getFormParametersForInsertForm(
103 $db, $table, $where_clauses, $where_clause_array, $err_url
107 * Displays the form
109 // autocomplete feature of IE kills the "onchange" event handler and it
110 // must be replaced by the "onpropertychange" one in this case
111 $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE'
112 && PMA_USR_BROWSER_VER >= 5
113 && PMA_USR_BROWSER_VER < 7
115 ? 'onpropertychange'
116 : 'onchange';
117 // Had to put the URI because when hosted on an https server,
118 // some browsers send wrongly this form to the http server.
120 $html_output = '';
121 // Set if we passed the first timestamp field
122 $timestamp_seen = false;
123 $columns_cnt = count($table_columns);
125 $tabindex = 0;
126 $tabindex_for_function = +3000;
127 $tabindex_for_null = +6000;
128 $tabindex_for_value = 0;
129 $o_rows = 0;
130 $biggest_max_file_size = 0;
132 $url_params['db'] = $db;
133 $url_params['table'] = $table;
134 $url_params = PMA_urlParamsInEditMode(
135 $url_params, $where_clause_array, $where_clause
138 $has_blob_field = false;
139 foreach ($table_columns as $column) {
140 if (PMA_isColumn(
141 $column,
142 array('blob', 'tinyblob', 'mediumblob', 'longblob')
143 )) {
144 $has_blob_field = true;
145 break;
149 //Insert/Edit form
150 //If table has blob fields we have to disable ajax.
151 $html_output .= PMA_getHtmlForInsertEditFormHeader($has_blob_field, $is_upload);
153 $html_output .= PMA_URL_getHiddenInputs($_form_params);
155 $titles['Browse'] = PMA_Util::getIcon('b_browse.png', __('Browse foreign values'));
157 // user can toggle the display of Function column and column types
158 // (currently does not work for multi-edits)
159 if (! $cfg['ShowFunctionFields'] || ! $cfg['ShowFieldTypesInDataEditView']) {
160 $html_output .= __('Show');
163 if (! $cfg['ShowFunctionFields']) {
164 $html_output .= PMA_showTypeOrFunction('function', $url_params, false);
167 if (! $cfg['ShowFieldTypesInDataEditView']) {
168 $html_output .= PMA_showTypeOrFunction('type', $url_params, false);
171 $GLOBALS['plugin_scripts'] = array();
172 foreach ($rows as $row_id => $current_row) {
173 if (empty($current_row)) {
174 $current_row = array();
177 $jsvkey = $row_id;
178 $vkey = '[multi_edit][' . $jsvkey . ']';
180 $current_result = (isset($result) && is_array($result) && isset($result[$row_id])
181 ? $result[$row_id]
182 : $result);
183 $repopulate = array();
184 $checked = true;
185 if (isset($unsaved_values[$row_id])) {
186 $repopulate = $unsaved_values[$row_id];
187 $checked = false;
189 if ($insert_mode && $row_id > 0) {
190 $html_output .= PMA_getHtmlForIgnoreOption($row_id, $checked);
193 $html_output .= PMA_getHtmlForInsertEditRow(
194 $url_params, $table_columns, $comments_map, $timestamp_seen,
195 $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode,
196 $current_row, $o_rows, $tabindex, $columns_cnt,
197 $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null,
198 $tabindex_for_value, $table, $db, $row_id, $titles,
199 $biggest_max_file_size, $text_dir, $repopulate, $where_clause_array
201 } // end foreach on multi-edit
202 $scripts->addFiles($GLOBALS['plugin_scripts']);
203 unset($unsaved_values, $checked, $repopulate, $GLOBALS['plugin_scripts']);
205 if (! isset($after_insert)) {
206 $after_insert = 'back';
209 //action panel
210 $html_output .= PMA_getActionsPanel(
211 $where_clause, $after_insert, $tabindex,
212 $tabindex_for_value, $found_unique_key
215 if ($biggest_max_file_size > 0) {
216 $html_output .= ' '
217 . PMA_Util::generateHiddenMaxFileSize(
218 $biggest_max_file_size
219 ) . "\n";
221 $html_output .= '</form>';
223 $html_output .= PMA_getHtmlForGisEditor();
224 // end Insert/Edit form
226 if ($insert_mode) {
227 //Continue insertion form
228 $html_output .= PMA_getContinueInsertionForm(
229 $table, $db, $where_clause_array, $err_url
233 $response->addHTML($html_output);