Translated using Weblate (Interlingua)
[phpmyadmin.git] / tbl_change.php
blobcc0eb13c50f87b4cd0e5fe55d4ddcd95dca9c7bd
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';
20 PageSettings::showGroup('Edit');
22 /**
23 * Ensures db and table are valid, else moves to the "parent" script
25 require_once 'libraries/db_table_exists.inc.php';
27 /**
28 * Determine whether Insert or Edit and set global variables
30 list(
31 $insert_mode, $where_clause, $where_clause_array, $where_clauses,
32 $result, $rows, $found_unique_key, $after_insert
33 ) = InsertEdit::determineInsertOrEdit(
34 isset($where_clause) ? $where_clause : null, $db, $table
36 // Increase number of rows if unsaved rows are more
37 if (!empty($unsaved_values) && count($rows) < count($unsaved_values)) {
38 $rows = array_fill(0, count($unsaved_values), false);
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) > 0) {
47 // avoid a problem (see bug #2202709)
48 $GLOBALS['goto'] = 'tbl_sql.php';
49 } else {
50 $GLOBALS['goto'] = 'db_sql.php';
55 $_url_params = InsertEdit::getUrlParameters($db, $table);
56 $err_url = $GLOBALS['goto'] . Url::getCommon($_url_params);
57 unset($_url_params);
59 $comments_map = InsertEdit::getCommentsMap($db, $table);
61 /**
62 * START REGULAR OUTPUT
65 /**
66 * Load JavaScript files
68 $response = Response::getInstance();
69 $header = $response->getHeader();
70 $scripts = $header->getScripts();
71 $scripts->addFile('sql.js');
72 $scripts->addFile('tbl_change.js');
73 $scripts->addFile('vendor/jquery/jquery-ui-timepicker-addon.js');
74 $scripts->addFile('vendor/jquery/jquery.validate.js');
75 $scripts->addFile('vendor/jquery/additional-methods.js');
76 $scripts->addFile('gis_data_editor.js');
78 /**
79 * Displays the query submitted and its result
81 * $disp_message come from tbl_replace.php
83 if (! empty($disp_message)) {
84 $response->addHTML(Util::getMessage($disp_message, null));
87 $table_columns = InsertEdit::getTableColumns($db, $table);
89 // retrieve keys into foreign fields, if any
90 $foreigners = Relation::getForeigners($db, $table);
92 // Retrieve form parameters for insert/edit form
93 $_form_params = InsertEdit::getFormParametersForInsertForm(
94 $db, $table, $where_clauses, $where_clause_array, $err_url
97 /**
98 * Displays the form
100 // autocomplete feature of IE kills the "onchange" event handler and it
101 // must be replaced by the "onpropertychange" one in this case
102 $chg_evt_handler = 'onchange';
103 // Had to put the URI because when hosted on an https server,
104 // some browsers send wrongly this form to the http server.
106 $html_output = '';
107 // Set if we passed the first timestamp field
108 $timestamp_seen = false;
109 $columns_cnt = count($table_columns);
111 $tabindex = 0;
112 $tabindex_for_function = +3000;
113 $tabindex_for_null = +6000;
114 $tabindex_for_value = 0;
115 $o_rows = 0;
116 $biggest_max_file_size = 0;
118 $url_params['db'] = $db;
119 $url_params['table'] = $table;
120 $url_params = InsertEdit::urlParamsInEditMode(
121 $url_params, $where_clause_array, $where_clause
124 $has_blob_field = false;
125 foreach ($table_columns as $column) {
126 if (InsertEdit::isColumn(
127 $column,
128 array('blob', 'tinyblob', 'mediumblob', 'longblob')
129 )) {
130 $has_blob_field = true;
131 break;
135 //Insert/Edit form
136 //If table has blob fields we have to disable ajax.
137 $html_output .= InsertEdit::getHtmlForInsertEditFormHeader($has_blob_field, $is_upload);
139 $html_output .= Url::getHiddenInputs($_form_params);
141 $titles['Browse'] = Util::getIcon('b_browse.png', __('Browse foreign values'));
143 // user can toggle the display of Function column and column types
144 // (currently does not work for multi-edits)
145 if (! $cfg['ShowFunctionFields'] || ! $cfg['ShowFieldTypesInDataEditView']) {
146 $html_output .= __('Show');
149 if (! $cfg['ShowFunctionFields']) {
150 $html_output .= InsertEdit::showTypeOrFunction('function', $url_params, false);
153 if (! $cfg['ShowFieldTypesInDataEditView']) {
154 $html_output .= InsertEdit::showTypeOrFunction('type', $url_params, false);
157 $GLOBALS['plugin_scripts'] = array();
158 foreach ($rows as $row_id => $current_row) {
159 if (empty($current_row)) {
160 $current_row = array();
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 $repopulate = array();
170 $checked = true;
171 if (isset($unsaved_values[$row_id])) {
172 $repopulate = $unsaved_values[$row_id];
173 $checked = false;
175 if ($insert_mode && $row_id > 0) {
176 $html_output .= InsertEdit::getHtmlForIgnoreOption($row_id, $checked);
179 $html_output .= InsertEdit::getHtmlForInsertEditRow(
180 $url_params, $table_columns, $comments_map, $timestamp_seen,
181 $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode,
182 $current_row, $o_rows, $tabindex, $columns_cnt,
183 $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null,
184 $tabindex_for_value, $table, $db, $row_id, $titles,
185 $biggest_max_file_size, $text_dir, $repopulate, $where_clause_array
187 } // end foreach on multi-edit
188 $scripts->addFiles($GLOBALS['plugin_scripts']);
189 unset($unsaved_values, $checked, $repopulate, $GLOBALS['plugin_scripts']);
191 if (! isset($after_insert)) {
192 $after_insert = 'back';
195 //action panel
196 $html_output .= InsertEdit::getActionsPanel(
197 $where_clause, $after_insert, $tabindex,
198 $tabindex_for_value, $found_unique_key
201 if ($biggest_max_file_size > 0) {
202 $html_output .= ' '
203 . Util::generateHiddenMaxFileSize(
204 $biggest_max_file_size
205 ) . "\n";
207 $html_output .= '</form>';
209 $html_output .= InsertEdit::getHtmlForGisEditor();
210 // end Insert/Edit form
212 if ($insert_mode) {
213 //Continue insertion form
214 $html_output .= InsertEdit::getContinueInsertionForm(
215 $table, $db, $where_clause_array, $err_url
219 $response->addHTML($html_output);