Translated using Weblate (Turkish)
[phpmyadmin.git] / tbl_change.php
blobac6100c60d4e31d50b195cabef40b0ce1984abb4
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\Response;
10 use PhpMyAdmin\Util;
11 use PhpMyAdmin\Url;
13 /**
14 * Gets the variables sent or posted to this script and displays the header
16 require_once 'libraries/common.inc.php';
17 require_once 'libraries/config/user_preferences.forms.php';
18 require_once 'libraries/config/page_settings.forms.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 * functions implementation for this script
30 require_once 'libraries/insert_edit.lib.php';
32 /**
33 * Determine whether Insert or Edit and set global variables
35 list(
36 $insert_mode, $where_clause, $where_clause_array, $where_clauses,
37 $result, $rows, $found_unique_key, $after_insert
38 ) = PMA_determineInsertOrEdit(
39 isset($where_clause) ? $where_clause : null, $db, $table
41 // Increase number of rows if unsaved rows are more
42 if (!empty($unsaved_values) && count($rows) < count($unsaved_values)) {
43 $rows = array_fill(0, count($unsaved_values), false);
45 /**
46 * file listing
48 require_once 'libraries/file_listing.lib.php';
50 /**
51 * Defines the url to return to in case of error in a sql statement
52 * (at this point, $GLOBALS['goto'] will be set but could be empty)
54 if (empty($GLOBALS['goto'])) {
55 if (strlen($table) > 0) {
56 // avoid a problem (see bug #2202709)
57 $GLOBALS['goto'] = 'tbl_sql.php';
58 } else {
59 $GLOBALS['goto'] = 'db_sql.php';
64 $_url_params = PMA_getUrlParameters($db, $table);
65 $err_url = $GLOBALS['goto'] . Url::getCommon($_url_params);
66 unset($_url_params);
68 $comments_map = PMA_getCommentsMap($db, $table);
70 /**
71 * START REGULAR OUTPUT
74 /**
75 * Load JavaScript files
77 $response = Response::getInstance();
78 $header = $response->getHeader();
79 $scripts = $header->getScripts();
80 $scripts->addFile('sql.js');
81 $scripts->addFile('tbl_change.js');
82 $scripts->addFile('vendor/jquery/jquery-ui-timepicker-addon.js');
83 $scripts->addFile('vendor/jquery/jquery.validate.js');
84 $scripts->addFile('vendor/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(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 = 'onchange';
112 // Had to put the URI because when hosted on an https server,
113 // some browsers send wrongly this form to the http server.
115 $html_output = '';
116 // Set if we passed the first timestamp field
117 $timestamp_seen = false;
118 $columns_cnt = count($table_columns);
120 $tabindex = 0;
121 $tabindex_for_function = +3000;
122 $tabindex_for_null = +6000;
123 $tabindex_for_value = 0;
124 $o_rows = 0;
125 $biggest_max_file_size = 0;
127 $url_params['db'] = $db;
128 $url_params['table'] = $table;
129 $url_params = PMA_urlParamsInEditMode(
130 $url_params, $where_clause_array, $where_clause
133 $has_blob_field = false;
134 foreach ($table_columns as $column) {
135 if (PMA_isColumn(
136 $column,
137 array('blob', 'tinyblob', 'mediumblob', 'longblob')
138 )) {
139 $has_blob_field = true;
140 break;
144 //Insert/Edit form
145 //If table has blob fields we have to disable ajax.
146 $html_output .= PMA_getHtmlForInsertEditFormHeader($has_blob_field, $is_upload);
148 $html_output .= Url::getHiddenInputs($_form_params);
150 $titles['Browse'] = Util::getIcon('b_browse.png', __('Browse foreign values'));
152 // user can toggle the display of Function column and column types
153 // (currently does not work for multi-edits)
154 if (! $cfg['ShowFunctionFields'] || ! $cfg['ShowFieldTypesInDataEditView']) {
155 $html_output .= __('Show');
158 if (! $cfg['ShowFunctionFields']) {
159 $html_output .= PMA_showTypeOrFunction('function', $url_params, false);
162 if (! $cfg['ShowFieldTypesInDataEditView']) {
163 $html_output .= PMA_showTypeOrFunction('type', $url_params, false);
166 $GLOBALS['plugin_scripts'] = array();
167 foreach ($rows as $row_id => $current_row) {
168 if (empty($current_row)) {
169 $current_row = array();
172 $jsvkey = $row_id;
173 $vkey = '[multi_edit][' . $jsvkey . ']';
175 $current_result = (isset($result) && is_array($result) && isset($result[$row_id])
176 ? $result[$row_id]
177 : $result);
178 $repopulate = array();
179 $checked = true;
180 if (isset($unsaved_values[$row_id])) {
181 $repopulate = $unsaved_values[$row_id];
182 $checked = false;
184 if ($insert_mode && $row_id > 0) {
185 $html_output .= PMA_getHtmlForIgnoreOption($row_id, $checked);
188 $html_output .= PMA_getHtmlForInsertEditRow(
189 $url_params, $table_columns, $comments_map, $timestamp_seen,
190 $current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode,
191 $current_row, $o_rows, $tabindex, $columns_cnt,
192 $is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null,
193 $tabindex_for_value, $table, $db, $row_id, $titles,
194 $biggest_max_file_size, $text_dir, $repopulate, $where_clause_array
196 } // end foreach on multi-edit
197 $scripts->addFiles($GLOBALS['plugin_scripts']);
198 unset($unsaved_values, $checked, $repopulate, $GLOBALS['plugin_scripts']);
200 if (! isset($after_insert)) {
201 $after_insert = 'back';
204 //action panel
205 $html_output .= PMA_getActionsPanel(
206 $where_clause, $after_insert, $tabindex,
207 $tabindex_for_value, $found_unique_key
210 if ($biggest_max_file_size > 0) {
211 $html_output .= ' '
212 . Util::generateHiddenMaxFileSize(
213 $biggest_max_file_size
214 ) . "\n";
216 $html_output .= '</form>';
218 $html_output .= PMA_getHtmlForGisEditor();
219 // end Insert/Edit form
221 if ($insert_mode) {
222 //Continue insertion form
223 $html_output .= PMA_getContinueInsertionForm(
224 $table, $db, $where_clause_array, $err_url
228 $response->addHTML($html_output);