2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays form for editing and inserting new table rows
6 * register_globals_save (mark this file save for disabling register globals)
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/common.lib.php';
18 * Ensures db and table are valid, else moves to the "parent" script
20 require_once './libraries/db_table_exists.lib.php';
22 // load additional configuration variables
24 require_once './libraries/data_drizzle.inc.php';
26 require_once './libraries/data_mysql.inc.php';
30 * Sets global variables.
31 * Here it's better to use a if, instead of the '?' operator
32 * to avoid setting a variable to '' when it's not present in $_REQUEST
34 if (isset($_REQUEST['where_clause'])) {
35 $where_clause = $_REQUEST['where_clause'];
37 if (isset($_REQUEST['clause_is_unique'])) {
38 $clause_is_unique = $_REQUEST['clause_is_unique'];
40 if (isset($_SESSION['edit_next'])) {
41 $where_clause = $_SESSION['edit_next'];
42 unset($_SESSION['edit_next']);
43 $after_insert = 'edit_next';
45 if (isset($_REQUEST['sql_query'])) {
46 $sql_query = $_REQUEST['sql_query'];
48 if (isset($_REQUEST['ShowFunctionFields'])) {
49 $cfg['ShowFunctionFields'] = $_REQUEST['ShowFunctionFields'];
51 if (isset($_REQUEST['ShowFieldTypesInDataEditView'])) {
52 $cfg['ShowFieldTypesInDataEditView'] = $_REQUEST['ShowFieldTypesInDataEditView'];
54 if (isset($_REQUEST['default_action'])) {
55 $default_action = $_REQUEST['default_action'];
61 require_once './libraries/file_listing.php';
65 * Defines the url to return to in case of error in a sql statement
66 * (at this point, $GLOBALS['goto'] will be set but could be empty)
68 if (empty($GLOBALS['goto'])) {
70 // avoid a problem (see bug #2202709)
71 $GLOBALS['goto'] = 'tbl_sql.php';
73 $GLOBALS['goto'] = 'db_sql.php';
77 * @todo check if we could replace by "db_|tbl_" - please clarify!?
81 'sql_query' => $sql_query
84 if (preg_match('@^tbl_@', $GLOBALS['goto'])) {
85 $_url_params['table'] = $table;
88 $err_url = $GLOBALS['goto'] . PMA_generate_common_url($_url_params);
93 * Sets parameters for links
94 * where is this variable used?
95 * replace by PMA_generate_common_url($url_params);
97 $url_query = PMA_generate_common_url($url_params, 'html', '');
100 * get table information
101 * @todo should be done by a Table object
103 require_once './libraries/tbl_info.inc.php';
106 * Get comments for table fileds/columns
108 $comments_map = array();
110 if ($GLOBALS['cfg']['ShowPropertyComments']) {
111 $comments_map = PMA_getComments($db, $table);
115 * START REGULAR OUTPUT
119 * used in ./libraries/header.inc.php to load JavaScript library file
121 $GLOBALS['js_include'][] = 'functions.js';
122 $GLOBALS['js_include'][] = 'tbl_change.js';
123 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
124 $GLOBALS['js_include'][] = 'jquery/timepicker.js';
126 * HTTP and HTML headers
128 require_once './libraries/header.inc.php';
131 * Displays the query submitted and its result
133 * @todo where does $disp_message and $disp_query come from???
135 if (! empty($disp_message)) {
136 if (! isset($disp_query)) {
139 PMA_showMessage($disp_message, $disp_query);
143 * Displays top menu links
145 require_once './libraries/tbl_links.inc.php';
149 * Get the analysis of SHOW CREATE TABLE for this table
150 * @todo should be handled by class Table
152 $show_create_table = PMA_DBI_fetch_value(
153 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
155 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
156 unset($show_create_table);
159 * Get the list of the fields of the current table
161 PMA_DBI_select_db($db);
162 $table_fields = array_values(PMA_DBI_get_columns($db, $table));
164 if (isset($where_clause)) {
165 // when in edit mode load all selected rows from table
166 $insert_mode = false;
167 if (is_array($where_clause)) {
168 $where_clause_array = $where_clause;
170 $where_clause_array = array(0 => $where_clause);
174 $found_unique_key = false;
175 $where_clauses = array();
177 foreach ($where_clause_array as $key_id => $where_clause) {
178 $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';';
179 $result[$key_id] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE
);
180 $rows[$key_id] = PMA_DBI_fetch_assoc($result[$key_id]);
181 $where_clauses[$key_id] = str_replace('\\', '\\\\', $where_clause);
184 if (! $rows[$key_id]) {
185 unset($rows[$key_id], $where_clause_array[$key_id]);
186 PMA_showMessage(__('MySQL returned an empty result set (i.e. zero rows).'), $local_query);
188 require './libraries/footer.inc.php';
189 } else { // end if (no row returned)
190 $meta = PMA_DBI_get_fields_meta($result[$key_id]);
191 list($unique_condition, $tmp_clause_is_unique) = PMA_getUniqueCondition($result[$key_id], count($meta), $meta, $rows[$key_id], true);
192 if (! empty($unique_condition)) {
193 $found_unique_key = true;
195 unset($unique_condition, $tmp_clause_is_unique);
200 // no primary key given, just load first row - but what happens if table is empty?
202 $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE
);
203 $rows = array_fill(0, $cfg['InsertRows'], false);
206 // Copying a row - fetched data will be inserted as a new row, therefore the where clause is needless.
207 if (isset($default_action) && $default_action === 'insert') {
208 unset($where_clause, $where_clauses);
211 // retrieve keys into foreign fields, if any
212 $foreigners = PMA_getForeigners($db, $table);
218 // autocomplete feature of IE kills the "onchange" event handler and it
219 // must be replaced by the "onpropertychange" one in this case
220 $chg_evt_handler = (PMA_USR_BROWSER_AGENT
== 'IE' && PMA_USR_BROWSER_VER
>= 5 && PMA_USR_BROWSER_VER
< 7)
223 // Had to put the URI because when hosted on an https server,
224 // some browsers send wrongly this form to the http server.
227 <!-- Set on key handler
for moving using by Ctrl+arrows
-->
228 <script src
="./js/keyhandler.js" type
="text/javascript"></script
>
229 <script type
="text/javascript">
231 var switch_movement
= 0;
232 document
.onkeydown
= onKeyDownArrowsHandler
;
237 $_form_params = array(
240 'goto' => $GLOBALS['goto'],
241 'err_url' => $err_url,
242 'sql_query' => $sql_query,
244 if (isset($where_clauses)) {
245 foreach ($where_clause_array as $key_id => $where_clause) {
246 $_form_params['where_clause[' . $key_id . ']'] = trim($where_clause);
249 if (isset($clause_is_unique)) {
250 $_form_params['clause_is_unique'] = $clause_is_unique;
255 <!-- Insert
/Edit form
-->
256 <form id
="insertForm" method
="post" action
="tbl_replace.php" name
="insertForm" <?php
if ($is_upload) { echo ' enctype="multipart/form-data"'; } ?
>>
258 echo PMA_generate_common_hidden_inputs($_form_params);
260 $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
262 // Set if we passed the first timestamp field
264 $fields_cnt = count($table_fields);
267 $tabindex_for_function = +
3000;
268 $tabindex_for_null = +
6000;
269 $tabindex_for_value = 0;
271 $biggest_max_file_size = 0;
273 // user can toggle the display of Function column
274 // (currently does not work for multi-edits)
275 $url_params['db'] = $db;
276 $url_params['table'] = $table;
277 if (isset($where_clause)) {
278 $url_params['where_clause'] = trim($where_clause);
280 if (! empty($sql_query)) {
281 $url_params['sql_query'] = $sql_query;
284 if (! $cfg['ShowFunctionFields'] ||
! $cfg['ShowFieldTypesInDataEditView']) {
287 if (! $cfg['ShowFunctionFields']) {
288 $this_url_params = array_merge($url_params,
289 array('ShowFunctionFields' => 1, 'ShowFieldTypesInDataEditView' => $cfg['ShowFieldTypesInDataEditView'], 'goto' => 'sql.php'));
290 echo ' : <a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '">' . __('Function') . '</a>' . "\n";
292 if (! $cfg['ShowFieldTypesInDataEditView']) {
293 $this_other_url_params = array_merge($url_params,
294 array('ShowFieldTypesInDataEditView' => 1, 'ShowFunctionFields' => $cfg['ShowFunctionFields'], 'goto' => 'sql.php'));
295 echo ' : <a href="tbl_change.php' . PMA_generate_common_url($this_other_url_params) . '">' . __('Type') . '</a>' . "\n";
298 foreach ($rows as $row_id => $vrow) {
299 if ($vrow === false) {
304 $rownumber_param = '&rownumber=' . $row_id;
305 $vkey = '[multi_edit][' . $jsvkey . ']';
307 $vresult = (isset($result) && is_array($result) && isset($result[$row_id]) ?
$result[$row_id] : $result);
308 if ($insert_mode && $row_id > 0) {
309 echo '<input type="checkbox" checked="checked" name="insert_ignore_' . $row_id . '" id="insert_ignore_' . $row_id . '" />';
310 echo '<label for="insert_ignore_' . $row_id . '">' . __('Ignore') . '</label><br />' . "\n";
313 <table
class="insertRowTable">
316 <th
><?php
echo __('Column'); ?
></th
>
319 if ($cfg['ShowFieldTypesInDataEditView']) {
320 $this_url_params = array_merge($url_params,
321 array('ShowFieldTypesInDataEditView' => 0, 'ShowFunctionFields' => $cfg['ShowFunctionFields'], 'goto' => 'sql.php'));
322 echo ' <th><a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '" title="' . __('Hide') . '">' . __('Type') . '</a></th>' . "\n";
325 if ($cfg['ShowFunctionFields']) {
326 $this_url_params = array_merge($url_params,
327 array('ShowFunctionFields' => 0, 'ShowFieldTypesInDataEditView' => $cfg['ShowFieldTypesInDataEditView'], 'goto' => 'sql.php'));
328 echo ' <th><a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '" title="' . __('Hide') . '">' . __('Function') . '</a></th>' . "\n";
331 <th
><?php
echo __('Null'); ?
></th
>
332 <th
><?php
echo __('Value'); ?
></th
>
337 <th colspan
="5" align
="right" class="tblFooters">
338 <input type
="submit" value
="<?php echo __('Go'); ?>" />
344 // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one)
345 $m_rows = $o_rows +
1;
348 for ($i = 0; $i < $fields_cnt; $i++
) {
349 if (! isset($table_fields[$i]['processed'])) {
350 $table_fields[$i]['Field_html'] = htmlspecialchars($table_fields[$i]['Field']);
351 $table_fields[$i]['Field_md5'] = md5($table_fields[$i]['Field']);
352 // True_Type contains only the type (stops at first bracket)
353 $table_fields[$i]['True_Type'] = preg_replace('@\(.*@s', '', $table_fields[$i]['Type']);
357 // Current date should not be set as default if the field is NULL
358 // for the current row, but do not put here the current datetime
359 // if there is a default value (the real default value will be set
360 // in the Default value logic below)
362 // Note: (tested in MySQL 4.0.16): when lang is some UTF-8,
363 // $field['Default'] is not set if it contains NULL:
364 // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime)
365 // but, look what we get if we switch to iso: (Default is NULL)
366 // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime)
367 // so I force a NULL into it (I don't think it's possible
368 // to have an empty default value for DATETIME)
369 // then, the "if" after this one will work
370 if ($table_fields[$i]['Type'] == 'datetime'
371 && ! isset($table_fields[$i]['Default'])
372 && isset($table_fields[$i]['Null'])
373 && $table_fields[$i]['Null'] == 'YES') {
374 $table_fields[$i]['Default'] = null;
377 $table_fields[$i]['len'] =
378 preg_match('@float|double@', $table_fields[$i]['Type']) ?
100 : -1;
381 if (isset($comments_map[$table_fields[$i]['Field']])) {
382 $table_fields[$i]['Field_title'] = '<span style="border-bottom: 1px dashed black;" title="'
383 . htmlspecialchars($comments_map[$table_fields[$i]['Field']]) . '">'
384 . $table_fields[$i]['Field_html'] . '</span>';
386 $table_fields[$i]['Field_title'] = $table_fields[$i]['Field_html'];
390 // Fix for bug #3152931 'ENUM and SET cannot have "Binary" option'
391 // If check to ensure types such as "enum('one','two','binary',..)" or
392 // "enum('one','two','varbinary',..)" are not categorized as binary.
393 if (stripos($table_fields[$i]['Type'], 'binary') === 0
394 ||
stripos($table_fields[$i]['Type'], 'varbinary') === 0) {
395 $table_fields[$i]['is_binary'] = stristr($table_fields[$i]['Type'], 'binary');
397 $table_fields[$i]['is_binary'] = false;
400 // If check to ensure types such as "enum('one','two','blob',..)" or
401 // "enum('one','two','tinyblob',..)" etc. are not categorized as blob.
402 if (stripos($table_fields[$i]['Type'], 'blob') === 0
403 ||
stripos($table_fields[$i]['Type'], 'tinyblob') === 0
404 ||
stripos($table_fields[$i]['Type'], 'mediumblob') === 0
405 ||
stripos($table_fields[$i]['Type'], 'longblob') === 0) {
406 $table_fields[$i]['is_blob'] = stristr($table_fields[$i]['Type'], 'blob');
408 $table_fields[$i]['is_blob'] = false;
411 // If check to ensure types such as "enum('one','two','char',..)" or
412 // "enum('one','two','varchar',..)" are not categorized as char.
413 if (stripos($table_fields[$i]['Type'], 'char') === 0
414 ||
stripos($table_fields[$i]['Type'], 'varchar') === 0) {
415 $table_fields[$i]['is_char'] = stristr($table_fields[$i]['Type'], 'char');
417 $table_fields[$i]['is_char'] = false;
420 $table_fields[$i]['first_timestamp'] = false;
421 switch ($table_fields[$i]['True_Type']) {
423 $table_fields[$i]['pma_type'] = 'set';
424 $table_fields[$i]['wrap'] = '';
427 $table_fields[$i]['pma_type'] = 'enum';
428 $table_fields[$i]['wrap'] = '';
431 if (!$timestamp_seen) { // can only occur once per table
433 $table_fields[$i]['first_timestamp'] = true;
435 $table_fields[$i]['pma_type'] = $table_fields[$i]['Type'];
436 $table_fields[$i]['wrap'] = ' nowrap="nowrap"';
440 $table_fields[$i]['pma_type'] = $table_fields[$i]['Type'];
441 $table_fields[$i]['wrap'] = ' nowrap="nowrap"';
445 $field = $table_fields[$i];
446 $extracted_fieldspec = PMA_extractFieldSpec($field['Type']);
448 if (-1 === $field['len']) {
449 $field['len'] = PMA_DBI_field_len($vresult, $i);
451 //Call validation when the form submited...
452 $unnullify_trigger = $chg_evt_handler . "=\"return verificationsAfterFieldChange('". PMA_escapeJsString($field['Field_md5']) . "', '"
453 . PMA_escapeJsString($jsvkey) . "','".$field['pma_type']."')\"";
455 // Use an MD5 as an array index to avoid having special characters in the name atttibute (see bug #1746964 )
456 $field_name_appendix = $vkey . '[' . $field['Field_md5'] . ']';
458 if ($field['Type'] == 'datetime'
459 && ! isset($field['Default'])
460 && ! is_null($field['Default'])
461 && ($insert_mode ||
! isset($vrow[$field['Field']]))) {
463 // UPDATE case with an NULL value
464 $vrow[$field['Field']] = date('Y-m-d H:i:s', time());
467 <tr
class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
468 <td
<?php
echo ($cfg['LongtextDoubleTextarea'] && strstr($field['True_Type'], 'longtext') ?
'rowspan="2"' : ''); ?
> align
="center">
469 <?php
echo $field['Field_title']; ?
>
470 <input type
="hidden" name
="fields_name<?php echo $field_name_appendix; ?>" value
="<?php echo $field['Field_html']; ?>"/>
472 <?php
if ($cfg['ShowFieldTypesInDataEditView']) { ?
>
473 <td align
="center"<?php
echo $field['wrap']; ?
>><span
class="column_type"><?php
echo $field['pma_type']; ?
></span
>
478 // Prepares the field value
479 $real_null_value = false;
480 $special_chars_encoded = '';
483 if (is_null($vrow[$field['Field']])) {
484 $real_null_value = true;
485 $vrow[$field['Field']] = '';
487 $data = $vrow[$field['Field']];
488 } elseif ($field['True_Type'] == 'bit') {
489 $special_chars = PMA_printable_bit_value($vrow[$field['Field']], $extracted_fieldspec['spec_in_brackets']);
491 // special binary "characters"
492 if ($field['is_binary'] ||
($field['is_blob'] && ! $cfg['ProtectBinary'])) {
493 if ($_SESSION['tmp_user_values']['display_binary_as_hex'] && $cfg['ShowFunctionFields']) {
494 $vrow[$field['Field']] = bin2hex($vrow[$field['Field']]);
495 $field['display_binary_as_hex'] = true;
497 $vrow[$field['Field']] = PMA_replace_binary_contents($vrow[$field['Field']]);
500 $special_chars = htmlspecialchars($vrow[$field['Field']]);
502 //We need to duplicate the first \n or otherwise we will lose the first newline entered in a VARCHAR or TEXT column
503 $special_chars_encoded = PMA_duplicateFirstNewline($special_chars);
505 $data = $vrow[$field['Field']];
506 } // end if... else...
508 //when copying row, it is useful to empty auto-increment column to prevent duplicate key error
509 if (isset($default_action) && $default_action === 'insert') {
510 if ($field['Key'] === 'PRI' && strpos($field['Extra'], 'auto_increment') !== false) {
511 $data = $special_chars_encoded = $special_chars = null;
514 // If a timestamp field value is not included in an update
515 // statement MySQL auto-update it to the current timestamp;
516 // however, things have changed since MySQL 4.1, so
517 // it's better to set a fields_prev in this situation
518 $backup_field = '<input type="hidden" name="fields_prev'
519 . $field_name_appendix . '" value="'
520 . htmlspecialchars($vrow[$field['Field']]) . '" />';
522 // (we are inserting)
523 // display default values
524 if (! isset($field['Default'])) {
525 $field['Default'] = '';
526 $real_null_value = true;
529 $data = $field['Default'];
531 if ($field['True_Type'] == 'bit') {
532 $special_chars = PMA_convert_bit_default_value($field['Default']);
534 $special_chars = htmlspecialchars($field['Default']);
537 $special_chars_encoded = PMA_duplicateFirstNewline($special_chars);
538 // this will select the UNHEX function while inserting
539 if (($field['is_binary'] ||
($field['is_blob'] && ! $cfg['ProtectBinary'])) && $_SESSION['tmp_user_values']['display_binary_as_hex'] && $cfg['ShowFunctionFields']) {
540 $field['display_binary_as_hex'] = true;
544 $idindex = ($o_rows * $fields_cnt) +
$i +
1;
545 $tabindex = $idindex;
547 // Get a list of data types that are not yet supported.
548 $no_support_types = PMA_unsupportedDatatypes();
550 // The function column
551 // -------------------
552 // We don't want binary data to be destroyed
553 // Note: from the MySQL manual: "BINARY doesn't affect how the column is
554 // stored or retrieved" so it does not mean that the contents is
556 if ($cfg['ShowFunctionFields']) {
557 if (($cfg['ProtectBinary'] && $field['is_blob'] && !$is_upload)
558 ||
($cfg['ProtectBinary'] == 'all' && $field['is_binary'])) {
559 echo ' <td align="center">' . __('Binary') . '</td>' . "\n";
560 } elseif (strstr($field['True_Type'], 'enum') ||
strstr($field['True_Type'], 'set') ||
in_array($field['pma_type'], $no_support_types)) {
561 echo ' <td align="center">--</td>' . "\n";
565 <select name
="funcs<?php echo $field_name_appendix; ?>" <?php
echo $unnullify_trigger; ?
> tabindex
="<?php echo ($tabindex + $tabindex_for_function); ?>" id
="field_<?php echo $idindex; ?>_1">
567 echo PMA_getFunctionsForField($field, $insert_mode);
573 } // end if ($cfg['ShowFunctionFields'])
578 $foreignData = PMA_getForeignData($foreigners, $field['Field'], false, '', '');
580 if ($field['Null'] == 'YES') {
581 echo ' <input type="hidden" name="fields_null_prev' . $field_name_appendix . '"';
582 if ($real_null_value && !$field['first_timestamp']) {
587 echo ' <input type="checkbox" class="checkbox_null" tabindex="' . ($tabindex +
$tabindex_for_null) . '"'
588 . ' name="fields_null' . $field_name_appendix . '"';
589 if ($real_null_value && !$field['first_timestamp']) {
590 echo ' checked="checked"';
592 echo ' id="field_' . ($idindex) . '_2" />';
594 // nullify_code is needed by the js nullify() function
595 if (strstr($field['True_Type'], 'enum')) {
596 if (strlen($field['Type']) > 20) {
601 } elseif (strstr($field['True_Type'], 'set')) {
603 } elseif ($foreigners && isset($foreigners[$field['Field']]) && $foreignData['foreign_link'] == false) {
604 // foreign key in a drop-down
606 } elseif ($foreigners && isset($foreigners[$field['Field']]) && $foreignData['foreign_link'] == true) {
607 // foreign key with a browsing icon
612 // to be able to generate calls to nullify() in jQuery
613 echo '<input type="hidden" class="nullify_code" name="nullify_code' . $field_name_appendix . '" value="' . $nullify_code . '" />';
614 echo '<input type="hidden" class="hashed_field" name="hashed_field' . $field_name_appendix . '" value="' . $field['Field_md5'] . '" />';
615 echo '<input type="hidden" class="multi_edit" name="multi_edit' . $field_name_appendix . '" value="' . PMA_escapeJsString($vkey) . '" />';
617 echo ' </td>' . "\n";
619 // The value column (depends on type)
621 // See bug #1667887 for the reason why we don't use the maxlength
625 // Will be used by js/tbl_change.js to set the default value
626 // for the "Continue insertion" feature
627 echo '<span class="default_value hide">' . $special_chars . '</span>';
628 if ($foreignData['foreign_link'] == true) {
629 echo $backup_field . "\n";
631 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>"
633 <input type
="text" name
="fields<?php echo $field_name_appendix; ?>"
634 class="textfield" <?php
echo $unnullify_trigger; ?
>
635 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
636 id
="field_<?php echo ($idindex); ?>_3"
637 value
="<?php echo htmlspecialchars($data); ?>" />
638 <a
class="hide foreign_values_anchor" target
="_blank" onclick
="window.open(this.href, 'foreigners', 'width=640,height=240,scrollbars=yes,resizable=yes'); return false;" href
="browse_foreigners.php?<?php echo PMA_generate_common_url($db, $table); ?>&field=<?php echo PMA_escapeJsString(urlencode($field['Field']) . $rownumber_param); ?>"><?php
echo str_replace("'", "\'", $titles['Browse']); ?
></a
>
640 } elseif (is_array($foreignData['disp_row'])) {
641 echo $backup_field . "\n";
643 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>"
645 <select name
="fields<?php echo $field_name_appendix; ?>"
646 <?php
echo $unnullify_trigger; ?
>
648 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
649 id
="field_<?php echo ($idindex); ?>_3">
650 <?php
echo PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $data, $cfg['ForeignKeyMaxLimit']); ?
>
654 unset($foreignData['disp_row']);
655 } elseif ($cfg['LongtextDoubleTextarea'] && strstr($field['pma_type'], 'longtext')) {
659 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
660 <td colspan
="5" align
="right">
661 <?php
echo $backup_field . "\n"; ?
>
662 <textarea name
="fields<?php echo $field_name_appendix; ?>"
663 rows
="<?php echo ($cfg['TextareaRows']*2); ?>"
664 cols
="<?php echo ($cfg['TextareaCols']*2); ?>"
665 dir
="<?php echo $text_dir; ?>"
666 id
="field_<?php echo ($idindex); ?>_3"
667 <?php
echo $unnullify_trigger; ?
>
668 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
669 ><?php
echo $special_chars_encoded; ?
></textarea
>
671 } elseif (strstr($field['pma_type'], 'text')) {
672 echo $backup_field . "\n";
674 <textarea name
="fields<?php echo $field_name_appendix; ?>"
675 rows
="<?php echo $cfg['TextareaRows']; ?>"
676 cols
="<?php echo $cfg['TextareaCols']; ?>"
677 dir
="<?php echo $text_dir; ?>"
678 id
="field_<?php echo ($idindex); ?>_3"
679 <?php
echo $unnullify_trigger; ?
>
680 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
681 ><?php
echo $special_chars_encoded; ?
></textarea
>
684 if (strlen($special_chars) > 32000) {
686 echo ' <td>' . __(' Because of its length,<br /> this column might not be editable ');
688 } elseif ($field['pma_type'] == 'enum') {
689 if (! isset($table_fields[$i]['values'])) {
690 $table_fields[$i]['values'] = array();
691 foreach ($extracted_fieldspec['enum_set_values'] as $val) {
692 // Removes automatic MySQL escape format
693 $val = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $val));
694 $table_fields[$i]['values'][] = array(
696 'html' => htmlspecialchars($val),
700 $field_enum_values = $table_fields[$i]['values'];
702 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="enum" />
703 <input type
="hidden" name
="fields<?php echo $field_name_appendix; ?>" value
="" />
705 echo "\n" . ' ' . $backup_field . "\n";
707 // show dropdown or radio depend on length
708 if (strlen($field['Type']) > 20) {
710 <select name
="fields<?php echo $field_name_appendix; ?>"
711 <?php
echo $unnullify_trigger; ?
>
713 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
714 id
="field_<?php echo ($idindex); ?>_3">
715 <option value
=""> 
;</option
>
719 foreach ($field_enum_values as $enum_value) {
721 echo '<option value="' . $enum_value['html'] . '"';
722 if ($data == $enum_value['plain']
724 && (! isset($where_clause) ||
$field['Null'] != 'YES')
725 && isset($field['Default'])
726 && $enum_value['plain'] == $field['Default'])) {
727 echo ' selected="selected"';
729 echo '>' . $enum_value['html'] . '</option>' . "\n";
737 foreach ($field_enum_values as $enum_value) {
739 echo '<input type="radio" name="fields' . $field_name_appendix . '"';
740 echo ' class="textfield"';
741 echo ' value="' . $enum_value['html'] . '"';
742 echo ' id="field_' . ($idindex) . '_3_' . $j . '"';
743 echo $unnullify_trigger;
744 if ($data == $enum_value['plain']
746 && (! isset($where_clause) ||
$field['Null'] != 'YES')
747 && isset($field['Default'])
748 && $enum_value['plain'] == $field['Default'])) {
749 echo ' checked="checked"';
751 echo ' tabindex="' . ($tabindex +
$tabindex_for_value) . '" />';
752 echo '<label for="field_' . $idindex . '_3_' . $j . '">'
753 . $enum_value['html'] . '</label>' . "\n";
757 } elseif ($field['pma_type'] == 'set') {
758 if (! isset($table_fields[$i]['values'])) {
759 $table_fields[$i]['values'] = array();
760 foreach ($extracted_fieldspec['enum_set_values'] as $val) {
761 $table_fields[$i]['values'][] = array(
763 'html' => htmlspecialchars($val),
766 $table_fields[$i]['select_size'] = min(4, count($table_fields[$i]['values']));
768 $field_set_values = $table_fields[$i]['values'];
769 $select_size = $table_fields[$i]['select_size'];
771 $vset = array_flip(explode(',', $data));
772 echo $backup_field . "\n";
774 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="set" />
775 <select name
="fields<?php echo $field_name_appendix . '[]'; ?>"
777 size
="<?php echo $select_size; ?>"
778 multiple
="multiple" <?php
echo $unnullify_trigger; ?
>
779 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
780 id
="field_<?php echo ($idindex); ?>_3">
782 foreach ($field_set_values as $field_set_value) {
784 echo '<option value="' . $field_set_value['html'] . '"';
785 if (isset($vset[$field_set_value['plain']])) {
786 echo ' selected="selected"';
788 echo '>' . $field_set_value['html'] . '</option>' . "\n";
794 // We don't want binary data destroyed
795 elseif ($field['is_binary'] ||
$field['is_blob']) {
796 if (($cfg['ProtectBinary'] && $field['is_blob'])
797 ||
($cfg['ProtectBinary'] == 'all' && $field['is_binary'])) {
800 if (PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type) && PMA_BS_IsPBMSReference($data, $db))
802 echo '<input type="hidden" name="remove_blob_ref_' . $field['Field_md5'] . $vkey . '" value="' . $data . '" />';
803 echo '<input type="checkbox" name="remove_blob_repo_' . $field['Field_md5'] . $vkey . '" /> ' . __('Remove BLOB Repository Reference') . "<br />";
804 echo PMA_BS_CreateReferenceLink($data, $db);
809 echo __('Binary - do not edit');
811 $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
812 echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
816 } // end if (PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type) && PMA_BS_IsPBMSReference($data, $db))
818 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="protected" />
819 <input type
="hidden" name
="fields<?php echo $field_name_appendix; ?>" value
="" />
821 } elseif ($field['is_blob']) {
823 echo $backup_field . "\n";
825 <textarea name
="fields<?php echo $field_name_appendix; ?>"
826 rows
="<?php echo $cfg['TextareaRows']; ?>"
827 cols
="<?php echo $cfg['TextareaCols']; ?>"
828 dir
="<?php echo $text_dir; ?>"
829 id
="field_<?php echo ($idindex); ?>_3"
830 <?php
echo $unnullify_trigger; ?
>
831 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
832 ><?php
echo $special_chars_encoded; ?
></textarea
>
836 // field size should be at least 4 and max $cfg['LimitChars']
837 $fieldsize = min(max($field['len'], 4), $cfg['LimitChars']);
839 echo $backup_field . "\n";
841 <input type
="text" name
="fields<?php echo $field_name_appendix; ?>"
842 value
="<?php echo $special_chars; ?>" size
="<?php echo $fieldsize; ?>"
843 class="textfield" <?php
echo $unnullify_trigger; ?
>
844 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
845 id
="field_<?php echo ($idindex); ?>_3" />
847 } // end if...elseif...else
849 // Upload choice (only for BLOBs because the binary
850 // attribute does not imply binary contents)
851 // (displayed whatever value the ProtectBinary has)
853 if ($is_upload && $field['is_blob']) {
854 // check if field type is of longblob and if the table is PBMS enabled.
855 if (($field['pma_type'] == "longblob") && PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type)) {
857 echo '<input type="checkbox" name="upload_blob_repo' . $vkey . '[' . $field['Field_md5'] . ']" /> ' . __('Upload to BLOB repository');
861 echo '<input type="file" name="fields_upload' . $vkey . '[' . $field['Field_md5'] . ']" class="textfield" id="field_' . $idindex . '_3" size="10" ' . $unnullify_trigger . '/> ';
863 // find maximum upload size, based on field type
865 * @todo with functions this is not so easy, as you can basically
866 * process any data with function like MD5
868 $max_field_sizes = array(
871 'mediumblob' => '16777216',
872 'longblob' => '4294967296'); // yeah, really
874 $this_field_max_size = $max_upload_size; // from PHP max
875 if ($this_field_max_size > $max_field_sizes[$field['pma_type']]) {
876 $this_field_max_size = $max_field_sizes[$field['pma_type']];
878 echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n";
879 // do not generate here the MAX_FILE_SIZE, because we should
880 // put only one in the form to accommodate the biggest field
881 if ($this_field_max_size > $biggest_max_file_size) {
882 $biggest_max_file_size = $this_field_max_size;
886 if (!empty($cfg['UploadDir'])) {
887 $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']));
888 if ($files === false) {
889 echo ' <font color="red">' . __('Error') . '</font><br />' . "\n";
890 echo ' ' . __('The directory you set for upload work cannot be reached') . "\n";
891 } elseif (!empty($files)) {
893 echo ' <i>' . __('Or') . '</i>' . ' ' . __('web server upload directory') . ':<br />' . "\n";
894 echo ' <select size="1" name="fields_uploadlocal' . $vkey . '[' . $field['Field_md5'] . ']">' . "\n";
895 echo ' <option value="" selected="selected"></option>' . "\n";
897 echo ' </select>' . "\n";
899 } // end if (web-server upload directory)
900 } // end elseif (binary or blob)
902 elseif (in_array($field['pma_type'], $no_support_types)) {
903 // ignore this column to avoid changing it
906 // field size should be at least 4 and max 40
907 $fieldsize = min(max($field['len'], 4), 40);
908 echo $backup_field . "\n";
909 if ($field['is_char'] && ($cfg['CharEditing'] == 'textarea' ||
strpos($data, "\n") !== false)) {
912 <textarea name
="fields<?php echo $field_name_appendix; ?>"
913 rows
="<?php echo $cfg['CharTextareaRows']; ?>"
914 cols
="<?php echo $cfg['CharTextareaCols']; ?>"
915 dir
="<?php echo $text_dir; ?>"
916 id
="field_<?php echo ($idindex); ?>_3"
917 <?php
echo $unnullify_trigger; ?
>
918 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
919 ><?php
echo $special_chars_encoded; ?
></textarea
>
922 $the_class = 'textfield';
923 if ($field['pma_type'] == 'date') {
924 $the_class .= ' datefield';
925 } elseif ($field['pma_type'] == 'datetime' ||
substr($field['pma_type'], 0, 9) == 'timestamp') {
926 $the_class .= ' datetimefield';
929 <input type
="text" name
="fields<?php echo $field_name_appendix; ?>"
930 value
="<?php echo $special_chars; ?>" size
="<?php echo $fieldsize; ?>"
931 class="<?php echo $the_class; ?>" <?php
echo $unnullify_trigger; ?
>
932 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
933 id
="field_<?php echo ($idindex); ?>_3" />
935 if ($field['Extra'] == 'auto_increment') {
937 <input type
="hidden" name
="auto_increment<?php echo $field_name_appendix; ?>" value
="1" />
940 if (substr($field['pma_type'], 0, 9) == 'timestamp') {
942 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="timestamp" />
945 if (substr($field['pma_type'], 0, 8) == 'datetime') {
947 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="datetime" />
950 if ($field['True_Type'] == 'bit') {
952 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="bit" />
955 if ($field['pma_type'] == 'date' ||
$field['pma_type'] == 'datetime' ||
substr($field['pma_type'], 0, 9) == 'timestamp') {
956 // the _3 suffix points to the date field
957 // the _2 suffix points to the corresponding NULL checkbox
958 // in dateFormat, 'yy' means the year with 4 digits
966 $odd_row = !$odd_row;
969 echo ' </tbody></table><br />';
970 } // end foreach on multi-edit
974 <fieldset id
="actions_panel">
975 <table border
="0" cellpadding
="5" cellspacing
="0">
977 <td valign
="middle" nowrap
="nowrap">
978 <select name
="submit_type" class="control_at_footer" tabindex
="<?php echo ($tabindex + $tabindex_for_value + 1); ?>">
980 if (isset($where_clause)) {
982 <option value
="save"><?php
echo __('Save'); ?
></option
>
986 <option value
="insert"><?php
echo __('Insert as new row'); ?
></option
>
987 <option value
="insertignore"><?php
echo __('Insert as new row and ignore errors'); ?
></option
>
988 <option value
="showinsert"><?php
echo __('Show insert query'); ?
></option
>
993 if (! isset($after_insert)) {
994 $after_insert = 'back';
999  
; 
; 
;<strong
><?php
echo __('and then'); ?
></strong
> 
; 
; 
;
1001 <td valign
="middle" nowrap
="nowrap">
1002 <select name
="after_insert">
1003 <option value
="back" <?php
echo ($after_insert == 'back' ?
'selected="selected"' : ''); ?
>><?php
echo __('Go back to previous page'); ?
></option
>
1004 <option value
="new_insert" <?php
echo ($after_insert == 'new_insert' ?
'selected="selected"' : ''); ?
>><?php
echo __('Insert another new row'); ?
></option
>
1006 if (isset($where_clause)) {
1008 <option value
="same_insert" <?php
echo ($after_insert == 'same_insert' ?
'selected="selected"' : ''); ?
>><?php
echo __('Go back to this page'); ?
></option
>
1010 // If we have just numeric primary key, we can also edit next
1011 // in 2.8.2, we were looking for `field_name` = numeric_value
1012 //if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $where_clause)) {
1013 // in 2.9.0, we are looking for `table_name`.`field_name` = numeric_value
1014 if ($found_unique_key && preg_match('@^[\s]*`[^`]*`[\.]`[^`]*` = [0-9]+@', $where_clause)) {
1016 <option value
="edit_next" <?php
echo ($after_insert == 'edit_next' ?
'selected="selected"' : ''); ?
>><?php
echo __('Edit next row'); ?
></option
>
1027 <?php
echo PMA_showHint(__('Use TAB key to move from value to value, or CTRL+arrows to move anywhere')); ?
>
1029 <td colspan
="3" align
="right" valign
="middle">
1030 <input type
="submit" class="control_at_footer" value
="<?php echo __('Go'); ?>" tabindex
="<?php echo ($tabindex + $tabindex_for_value + 6); ?>" id
="buttonYes" />
1031 <input type
="reset" class="control_at_footer" value
="<?php echo __('Reset'); ?>" tabindex
="<?php echo ($tabindex + $tabindex_for_value + 7); ?>" />
1036 <?php
if ($biggest_max_file_size > 0) {
1037 echo ' ' . PMA_generateHiddenMaxFileSize($biggest_max_file_size) . "\n";
1043 <!-- Continue insertion form
-->
1044 <form id
="continueForm" method
="post" action
="tbl_replace.php" name
="continueForm" >
1045 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
1046 <input type
="hidden" name
="goto" value
="<?php echo htmlspecialchars($GLOBALS['goto']); ?>" />
1047 <input type
="hidden" name
="err_url" value
="<?php echo htmlspecialchars($err_url); ?>" />
1048 <input type
="hidden" name
="sql_query" value
="<?php echo htmlspecialchars($sql_query); ?>" />
1050 if (isset($where_clauses)) {
1051 foreach ($where_clause_array as $key_id => $where_clause) {
1052 echo '<input type="hidden" name="where_clause[' . $key_id . ']" value="' . htmlspecialchars(trim($where_clause)) . '" />'. "\n";
1055 $tmp = '<select name="insert_rows" id="insert_rows">' . "\n";
1056 $option_values = array(1,2,5,10,15,20,30,40);
1057 foreach ($option_values as $value) {
1058 $tmp .= '<option value="' . $value . '"';
1059 if ($value == $cfg['InsertRows']) {
1060 $tmp .= ' selected="selected"';
1062 $tmp .= '>' . $value . '</option>' . "\n";
1064 $tmp .= '</select>' . "\n";
1065 echo "\n" . sprintf(__('Continue insertion with %s rows'), $tmp);
1067 echo '<noscript><input type="submit" value="' . __('Go') . '" /></noscript>' . "\n";
1068 echo '</form>' . "\n";
1072 * Displays the footer
1074 require './libraries/footer.inc.php';