Translated using Weblate (Slovenian)
[phpmyadmin.git] / tbl_change.php
blob2022abd487af9a6e1fedf4ea0fc94ee6310e00bb
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 */
10 use PMA\libraries\config\PageSettings;
11 use PMA\libraries\Response;
12 use PMA\libraries\Util;
14 /**
15 * Gets the variables sent or posted to this script and displays the header
17 require_once 'libraries/common.inc.php';
18 require_once 'libraries/config/user_preferences.forms.php';
19 require_once 'libraries/config/page_settings.forms.php';
21 PageSettings::showGroup('Edit');
23 /**
24 * Ensures db and table are valid, else moves to the "parent" script
26 require_once 'libraries/db_table_exists.lib.php';
28 /**
29 * functions implementation for this script
31 require_once 'libraries/insert_edit.lib.php';
32 require_once 'libraries/transformations.lib.php';
34 /**
35 * Determine whether Insert or Edit and set global variables
37 list(
38 $insert_mode, $where_clause, $where_clause_array, $where_clauses,
39 $result, $rows, $found_unique_key, $after_insert
40 ) = PMA_determineInsertOrEdit(
41 isset($where_clause) ? $where_clause : null, $db, $table
43 // Increase number of rows if unsaved rows are more
44 if (!empty($unsaved_values) && count($rows) < count($unsaved_values)) {
45 $rows = array_fill(0, count($unsaved_values), false);
47 /**
48 * file listing
50 require_once 'libraries/file_listing.lib.php';
52 /**
53 * Defines the url to return to in case of error in a sql statement
54 * (at this point, $GLOBALS['goto'] will be set but could be empty)
56 if (empty($GLOBALS['goto'])) {
57 if (mb_strlen($table)) {
58 // avoid a problem (see bug #2202709)
59 $GLOBALS['goto'] = 'tbl_sql.php';
60 } else {
61 $GLOBALS['goto'] = 'db_sql.php';
66 $_url_params = PMA_getUrlParameters($db, $table);
67 $err_url = $GLOBALS['goto'] . PMA_URL_getCommon($_url_params);
68 unset($_url_params);
70 $comments_map = PMA_getCommentsMap($db, $table);
72 /**
73 * START REGULAR OUTPUT
76 /**
77 * Load JavaScript files
79 $response = Response::getInstance();
80 $header = $response->getHeader();
81 $scripts = $header->getScripts();
82 $scripts->addFile('sql.js');
83 $scripts->addFile('tbl_change.js');
84 $scripts->addFile('big_ints.js');
85 $scripts->addFile('jquery/jquery-ui-timepicker-addon.js');
86 $scripts->addFile('jquery/jquery.validate.js');
87 $scripts->addFile('jquery/additional-methods.js');
88 $scripts->addFile('gis_data_editor.js');
90 /**
91 * Displays the query submitted and its result
93 * $disp_message come from tbl_replace.php
95 if (! empty($disp_message)) {
96 $response->addHTML(Util::getMessage($disp_message, null));
99 $table_columns = PMA_getTableColumns($db, $table);
101 // retrieve keys into foreign fields, if any
102 $foreigners = PMA_getForeigners($db, $table);
104 // Retrieve form parameters for insert/edit form
105 $_form_params = PMA_getFormParametersForInsertForm(
106 $db, $table, $where_clauses, $where_clause_array, $err_url
110 * Displays the form
112 // autocomplete feature of IE kills the "onchange" event handler and it
113 // must be replaced by the "onpropertychange" one in this case
114 $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE'
115 && PMA_USR_BROWSER_VER >= 5
116 && PMA_USR_BROWSER_VER < 7
118 ? 'onpropertychange'
119 : 'onchange';
120 // Had to put the URI because when hosted on an https server,
121 // some browsers send wrongly this form to the http server.
123 $html_output = '';
124 // Set if we passed the first timestamp field
125 $timestamp_seen = false;
126 $columns_cnt = count($table_columns);
128 $tabindex = 0;
129 $tabindex_for_function = +3000;
130 $tabindex_for_null = +6000;
131 $tabindex_for_value = 0;
132 $o_rows = 0;
133 $biggest_max_file_size = 0;
135 $url_params['db'] = $db;
136 $url_params['table'] = $table;
137 $url_params = PMA_urlParamsInEditMode(
138 $url_params, $where_clause_array, $where_clause
141 $has_blob_field = false;
142 foreach ($table_columns as $column) {
143 if (PMA_isColumn(
144 $column,
145 array('blob', 'tinyblob', 'mediumblob', 'longblob')
146 )) {
147 $has_blob_field = true;
148 break;
152 //Insert/Edit form
153 //If table has blob fields we have to disable ajax.
154 $html_output .= PMA_getHtmlForInsertEditFormHeader($has_blob_field, $is_upload);
156 $html_output .= PMA_URL_getHiddenInputs($_form_params);
158 $titles['Browse'] = Util::getIcon('b_browse.png', __('Browse foreign values'));
160 // user can toggle the display of Function column and column types
161 // (currently does not work for multi-edits)
162 if (! $cfg['ShowFunctionFields'] || ! $cfg['ShowFieldTypesInDataEditView']) {
163 $html_output .= __('Show');
166 if (! $cfg['ShowFunctionFields']) {
167 $html_output .= PMA_showTypeOrFunction('function', $url_params, false);
170 if (! $cfg['ShowFieldTypesInDataEditView']) {
171 $html_output .= PMA_showTypeOrFunction('type', $url_params, false);
174 $GLOBALS['plugin_scripts'] = array();
175 foreach ($rows as $row_id => $current_row) {
176 if (empty($current_row)) {
177 $current_row = array();
180 $jsvkey = $row_id;
181 $vkey = '[multi_edit][' . $jsvkey . ']';
183 $current_result = (isset($result) && is_array($result) && isset($result[$row_id])
184 ? $result[$row_id]
185 : $result);
186 $repopulate = array();
187 $checked = true;
188 if (isset($unsaved_values[$row_id])) {
189 $repopulate = $unsaved_values[$row_id];
190 $checked = false;
192 if ($insert_mode && $row_id > 0) {
193 $html_output .= PMA_getHtmlForIgnoreOption($row_id, $checked);
196 $html_output .= PMA_getHtmlForInsertEditRow(
197 $url_params, $table_columns, $comments_map, $timestamp_seen,
198 $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode,
199 $current_row, $o_rows, $tabindex, $columns_cnt,
200 $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null,
201 $tabindex_for_value, $table, $db, $row_id, $titles,
202 $biggest_max_file_size, $text_dir, $repopulate, $where_clause_array
204 } // end foreach on multi-edit
205 $scripts->addFiles($GLOBALS['plugin_scripts']);
206 unset($unsaved_values, $checked, $repopulate, $GLOBALS['plugin_scripts']);
208 if (! isset($after_insert)) {
209 $after_insert = 'back';
212 //action panel
213 $html_output .= PMA_getActionsPanel(
214 $where_clause, $after_insert, $tabindex,
215 $tabindex_for_value, $found_unique_key
218 if ($biggest_max_file_size > 0) {
219 $html_output .= ' '
220 . Util::generateHiddenMaxFileSize(
221 $biggest_max_file_size
222 ) . "\n";
224 $html_output .= '</form>';
226 $html_output .= PMA_getHtmlForGisEditor();
227 // end Insert/Edit form
229 if ($insert_mode) {
230 //Continue insertion form
231 $html_output .= PMA_getContinueInsertionForm(
232 $table, $db, $where_clause_array, $err_url
236 $response->addHTML($html_output);