Translated using Weblate (Korean)
[phpmyadmin.git] / tbl_change.php
blobfcd71bf58929edceb646afb6b15d4f98f5a811c8
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Displays form for editing and inserting new table rows
6 * @package PhpMyAdmin
7 */
8 use PhpMyAdmin\Config\PageSettings;
9 use PhpMyAdmin\InsertEdit;
10 use PhpMyAdmin\Relation;
11 use PhpMyAdmin\Response;
12 use PhpMyAdmin\Util;
13 use PhpMyAdmin\Url;
15 /**
16 * Gets the variables sent or posted to this script and displays the header
18 require_once 'libraries/common.inc.php';
19 require_once 'libraries/config/user_preferences.forms.php';
20 require_once 'libraries/config/page_settings.forms.php';
22 PageSettings::showGroup('Edit');
24 /**
25 * Ensures db and table are valid, else moves to the "parent" script
27 require_once 'libraries/db_table_exists.inc.php';
29 /**
30 * Determine whether Insert or Edit and set global variables
32 list(
33 $insert_mode, $where_clause, $where_clause_array, $where_clauses,
34 $result, $rows, $found_unique_key, $after_insert
35 ) = InsertEdit::determineInsertOrEdit(
36 isset($where_clause) ? $where_clause : null, $db, $table
38 // Increase number of rows if unsaved rows are more
39 if (!empty($unsaved_values) && count($rows) < count($unsaved_values)) {
40 $rows = array_fill(0, count($unsaved_values), false);
42 /**
43 * file listing
45 require_once 'libraries/file_listing.lib.php';
47 /**
48 * Defines the url to return to in case of error in a sql statement
49 * (at this point, $GLOBALS['goto'] will be set but could be empty)
51 if (empty($GLOBALS['goto'])) {
52 if (strlen($table) > 0) {
53 // avoid a problem (see bug #2202709)
54 $GLOBALS['goto'] = 'tbl_sql.php';
55 } else {
56 $GLOBALS['goto'] = 'db_sql.php';
61 $_url_params = InsertEdit::getUrlParameters($db, $table);
62 $err_url = $GLOBALS['goto'] . Url::getCommon($_url_params);
63 unset($_url_params);
65 $comments_map = InsertEdit::getCommentsMap($db, $table);
67 /**
68 * START REGULAR OUTPUT
71 /**
72 * Load JavaScript files
74 $response = Response::getInstance();
75 $header = $response->getHeader();
76 $scripts = $header->getScripts();
77 $scripts->addFile('sql.js');
78 $scripts->addFile('tbl_change.js');
79 $scripts->addFile('vendor/jquery/jquery-ui-timepicker-addon.js');
80 $scripts->addFile('vendor/jquery/jquery.validate.js');
81 $scripts->addFile('vendor/jquery/additional-methods.js');
82 $scripts->addFile('gis_data_editor.js');
84 /**
85 * Displays the query submitted and its result
87 * $disp_message come from tbl_replace.php
89 if (! empty($disp_message)) {
90 $response->addHTML(Util::getMessage($disp_message, null));
93 $table_columns = InsertEdit::getTableColumns($db, $table);
95 // retrieve keys into foreign fields, if any
96 $foreigners = Relation::getForeigners($db, $table);
98 // Retrieve form parameters for insert/edit form
99 $_form_params = InsertEdit::getFormParametersForInsertForm(
100 $db, $table, $where_clauses, $where_clause_array, $err_url
104 * Displays the form
106 // autocomplete feature of IE kills the "onchange" event handler and it
107 // must be replaced by the "onpropertychange" one in this case
108 $chg_evt_handler = '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 = InsertEdit::urlParamsInEditMode(
127 $url_params, $where_clause_array, $where_clause
130 $has_blob_field = false;
131 foreach ($table_columns as $column) {
132 if (InsertEdit::isColumn(
133 $column,
134 array('blob', 'tinyblob', 'mediumblob', 'longblob')
135 )) {
136 $has_blob_field = true;
137 break;
141 //Insert/Edit form
142 //If table has blob fields we have to disable ajax.
143 $html_output .= InsertEdit::getHtmlForInsertEditFormHeader($has_blob_field, $is_upload);
145 $html_output .= Url::getHiddenInputs($_form_params);
147 $titles['Browse'] = Util::getIcon('b_browse.png', __('Browse foreign values'));
149 // user can toggle the display of Function column and column types
150 // (currently does not work for multi-edits)
151 if (! $cfg['ShowFunctionFields'] || ! $cfg['ShowFieldTypesInDataEditView']) {
152 $html_output .= __('Show');
155 if (! $cfg['ShowFunctionFields']) {
156 $html_output .= InsertEdit::showTypeOrFunction('function', $url_params, false);
159 if (! $cfg['ShowFieldTypesInDataEditView']) {
160 $html_output .= InsertEdit::showTypeOrFunction('type', $url_params, false);
163 $GLOBALS['plugin_scripts'] = array();
164 foreach ($rows as $row_id => $current_row) {
165 if (empty($current_row)) {
166 $current_row = array();
169 $jsvkey = $row_id;
170 $vkey = '[multi_edit][' . $jsvkey . ']';
172 $current_result = (isset($result) && is_array($result) && isset($result[$row_id])
173 ? $result[$row_id]
174 : $result);
175 $repopulate = array();
176 $checked = true;
177 if (isset($unsaved_values[$row_id])) {
178 $repopulate = $unsaved_values[$row_id];
179 $checked = false;
181 if ($insert_mode && $row_id > 0) {
182 $html_output .= InsertEdit::getHtmlForIgnoreOption($row_id, $checked);
185 $html_output .= InsertEdit::getHtmlForInsertEditRow(
186 $url_params, $table_columns, $comments_map, $timestamp_seen,
187 $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode,
188 $current_row, $o_rows, $tabindex, $columns_cnt,
189 $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null,
190 $tabindex_for_value, $table, $db, $row_id, $titles,
191 $biggest_max_file_size, $text_dir, $repopulate, $where_clause_array
193 } // end foreach on multi-edit
194 $scripts->addFiles($GLOBALS['plugin_scripts']);
195 unset($unsaved_values, $checked, $repopulate, $GLOBALS['plugin_scripts']);
197 if (! isset($after_insert)) {
198 $after_insert = 'back';
201 //action panel
202 $html_output .= InsertEdit::getActionsPanel(
203 $where_clause, $after_insert, $tabindex,
204 $tabindex_for_value, $found_unique_key
207 if ($biggest_max_file_size > 0) {
208 $html_output .= ' '
209 . Util::generateHiddenMaxFileSize(
210 $biggest_max_file_size
211 ) . "\n";
213 $html_output .= '</form>';
215 $html_output .= InsertEdit::getHtmlForGisEditor();
216 // end Insert/Edit form
218 if ($insert_mode) {
219 //Continue insertion form
220 $html_output .= InsertEdit::getContinueInsertionForm(
221 $table, $db, $where_clause_array, $err_url
225 $response->addHTML($html_output);