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
23 require_once './libraries/data_mysql.inc.php';
26 * Sets global variables.
27 * Here it's better to use a if, instead of the '?' operator
28 * to avoid setting a variable to '' when it's not present in $_REQUEST
30 if (isset($_REQUEST['where_clause'])) {
31 $where_clause = $_REQUEST['where_clause'];
33 if (isset($_REQUEST['clause_is_unique'])) {
34 $clause_is_unique = $_REQUEST['clause_is_unique'];
36 if (isset($_SESSION['edit_next'])) {
37 $where_clause = $_SESSION['edit_next'];
38 unset($_SESSION['edit_next']);
39 $after_insert = 'edit_next';
41 if (isset($_REQUEST['sql_query'])) {
42 $sql_query = $_REQUEST['sql_query'];
44 if (isset($_REQUEST['ShowFunctionFields'])) {
45 $cfg['ShowFunctionFields'] = $_REQUEST['ShowFunctionFields'];
47 if (isset($_REQUEST['ShowFieldTypesInDataEditView'])) {
48 $cfg['ShowFieldTypesInDataEditView'] = $_REQUEST['ShowFieldTypesInDataEditView'];
50 if (isset($_REQUEST['default_action'])) {
51 $default_action = $_REQUEST['default_action'];
57 require_once './libraries/file_listing.php';
61 * Defines the url to return to in case of error in a sql statement
62 * (at this point, $GLOBALS['goto'] will be set but could be empty)
64 if (empty($GLOBALS['goto'])) {
66 // avoid a problem (see bug #2202709)
67 $GLOBALS['goto'] = 'tbl_sql.php';
69 $GLOBALS['goto'] = 'db_sql.php';
73 * @todo check if we could replace by "db_|tbl_" - please clarify!?
77 'sql_query' => $sql_query
80 if (preg_match('@^tbl_@', $GLOBALS['goto'])) {
81 $_url_params['table'] = $table;
84 $err_url = $GLOBALS['goto'] . PMA_generate_common_url($_url_params);
89 * Sets parameters for links
90 * where is this variable used?
91 * replace by PMA_generate_common_url($url_params);
93 $url_query = PMA_generate_common_url($url_params, 'html', '');
96 * get table information
97 * @todo should be done by a Table object
99 require_once './libraries/tbl_info.inc.php';
102 * Get comments for table fileds/columns
104 $comments_map = array();
106 if ($GLOBALS['cfg']['ShowPropertyComments']) {
107 $comments_map = PMA_getComments($db, $table);
111 * START REGULAR OUTPUT
115 * used in ./libraries/header.inc.php to load JavaScript library file
117 $GLOBALS['js_include'][] = 'functions.js';
118 $GLOBALS['js_include'][] = 'tbl_change.js';
119 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
120 $GLOBALS['js_include'][] = 'jquery/timepicker.js';
122 * HTTP and HTML headers
124 require_once './libraries/header.inc.php';
127 * Displays the query submitted and its result
129 * @todo where does $disp_message and $disp_query come from???
131 if (! empty($disp_message)) {
132 if (! isset($disp_query)) {
135 PMA_showMessage($disp_message, $disp_query);
139 * Displays top menu links
141 require_once './libraries/tbl_links.inc.php';
145 * Get the analysis of SHOW CREATE TABLE for this table
146 * @todo should be handled by class Table
148 $show_create_table = PMA_DBI_fetch_value(
149 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
151 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
152 unset($show_create_table);
155 * Get the list of the fields of the current table
157 PMA_DBI_select_db($db);
158 $table_fields = PMA_DBI_fetch_result('SHOW FIELDS FROM ' . PMA_backquote($table) . ';',
159 null, null, null, PMA_DBI_QUERY_STORE
);
161 if (isset($where_clause)) {
162 // when in edit mode load all selected rows from table
163 $insert_mode = false;
164 if (is_array($where_clause)) {
165 $where_clause_array = $where_clause;
167 $where_clause_array = array(0 => $where_clause);
171 $found_unique_key = false;
172 $where_clauses = array();
174 foreach ($where_clause_array as $key_id => $where_clause) {
175 $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';';
176 $result[$key_id] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE
);
177 $rows[$key_id] = PMA_DBI_fetch_assoc($result[$key_id]);
178 $where_clauses[$key_id] = str_replace('\\', '\\\\', $where_clause);
181 if (! $rows[$key_id]) {
182 unset($rows[$key_id], $where_clause_array[$key_id]);
183 PMA_showMessage(__('MySQL returned an empty result set (i.e. zero rows).'), $local_query);
185 require './libraries/footer.inc.php';
186 } else { // end if (no row returned)
187 $meta = PMA_DBI_get_fields_meta($result[$key_id]);
188 list($unique_condition, $tmp_clause_is_unique) = PMA_getUniqueCondition($result[$key_id], count($meta), $meta, $rows[$key_id], true);
189 if (! empty($unique_condition)) {
190 $found_unique_key = true;
192 unset($unique_condition, $tmp_clause_is_unique);
197 // no primary key given, just load first row - but what happens if table is empty?
199 $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE
);
200 $rows = array_fill(0, $cfg['InsertRows'], false);
203 // Copying a row - fetched data will be inserted as a new row, therefore the where clause is needless.
204 if (isset($default_action) && $default_action === 'insert') {
205 unset($where_clause, $where_clauses);
208 // retrieve keys into foreign fields, if any
209 $foreigners = PMA_getForeigners($db, $table);
215 // autocomplete feature of IE kills the "onchange" event handler and it
216 // must be replaced by the "onpropertychange" one in this case
217 $chg_evt_handler = (PMA_USR_BROWSER_AGENT
== 'IE' && PMA_USR_BROWSER_VER
>= 5 && PMA_USR_BROWSER_VER
< 7)
220 // Had to put the URI because when hosted on an https server,
221 // some browsers send wrongly this form to the http server.
224 <!-- Set on key handler
for moving using by Ctrl+arrows
-->
225 <script src
="./js/keyhandler.js" type
="text/javascript"></script
>
226 <script type
="text/javascript">
228 var switch_movement
= 0;
229 document
.onkeydown
= onKeyDownArrowsHandler
;
234 $_form_params = array(
237 'goto' => $GLOBALS['goto'],
238 'err_url' => $err_url,
239 'sql_query' => $sql_query,
241 if (isset($where_clauses)) {
242 foreach ($where_clause_array as $key_id => $where_clause) {
243 $_form_params['where_clause[' . $key_id . ']'] = trim($where_clause);
246 if (isset($clause_is_unique)) {
247 $_form_params['clause_is_unique'] = $clause_is_unique;
252 <!-- Insert
/Edit form
-->
253 <form id
="insertForm" method
="post" action
="tbl_replace.php" name
="insertForm" <?php
if ($is_upload) { echo ' enctype="multipart/form-data"'; } ?
>>
255 echo PMA_generate_common_hidden_inputs($_form_params);
257 $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
259 // Set if we passed the first timestamp field
261 $fields_cnt = count($table_fields);
264 $tabindex_for_function = +
3000;
265 $tabindex_for_null = +
6000;
266 $tabindex_for_value = 0;
268 $biggest_max_file_size = 0;
270 // user can toggle the display of Function column
271 // (currently does not work for multi-edits)
272 $url_params['db'] = $db;
273 $url_params['table'] = $table;
274 if (isset($where_clause)) {
275 $url_params['where_clause'] = trim($where_clause);
277 if (! empty($sql_query)) {
278 $url_params['sql_query'] = $sql_query;
281 if (! $cfg['ShowFunctionFields'] ||
! $cfg['ShowFieldTypesInDataEditView']) {
284 if (! $cfg['ShowFunctionFields']) {
285 $this_url_params = array_merge($url_params,
286 array('ShowFunctionFields' => 1, 'ShowFieldTypesInDataEditView' => $cfg['ShowFieldTypesInDataEditView'], 'goto' => 'sql.php'));
287 echo ' : <a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '">' . __('Function') . '</a>' . "\n";
289 if (! $cfg['ShowFieldTypesInDataEditView']) {
290 $this_other_url_params = array_merge($url_params,
291 array('ShowFieldTypesInDataEditView' => 1, 'ShowFunctionFields' => $cfg['ShowFunctionFields'], 'goto' => 'sql.php'));
292 echo ' : <a href="tbl_change.php' . PMA_generate_common_url($this_other_url_params) . '">' . __('Type') . '</a>' . "\n";
295 foreach ($rows as $row_id => $vrow) {
296 if ($vrow === false) {
301 $rownumber_param = '&rownumber=' . $row_id;
302 $vkey = '[multi_edit][' . $jsvkey . ']';
304 $vresult = (isset($result) && is_array($result) && isset($result[$row_id]) ?
$result[$row_id] : $result);
305 if ($insert_mode && $row_id > 0) {
306 echo '<input type="checkbox" checked="checked" name="insert_ignore_' . $row_id . '" id="insert_ignore_' . $row_id . '" />';
307 echo '<label for="insert_ignore_' . $row_id . '">' . __('Ignore') . '</label><br />' . "\n";
310 <table
class="insertRowTable">
313 <th
><?php
echo __('Column'); ?
></th
>
316 if ($cfg['ShowFieldTypesInDataEditView']) {
317 $this_url_params = array_merge($url_params,
318 array('ShowFieldTypesInDataEditView' => 0, 'ShowFunctionFields' => $cfg['ShowFunctionFields'], 'goto' => 'sql.php'));
319 echo ' <th><a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '" title="' . __('Hide') . '">' . __('Type') . '</a></th>' . "\n";
322 if ($cfg['ShowFunctionFields']) {
323 $this_url_params = array_merge($url_params,
324 array('ShowFunctionFields' => 0, 'ShowFieldTypesInDataEditView' => $cfg['ShowFieldTypesInDataEditView'], 'goto' => 'sql.php'));
325 echo ' <th><a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '" title="' . __('Hide') . '">' . __('Function') . '</a></th>' . "\n";
328 <th
><?php
echo __('Null'); ?
></th
>
329 <th
><?php
echo __('Value'); ?
></th
>
334 <th colspan
="5" align
="right" class="tblFooters">
335 <input type
="submit" value
="<?php echo __('Go'); ?>" />
341 // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one)
342 $m_rows = $o_rows +
1;
345 for ($i = 0; $i < $fields_cnt; $i++
) {
346 if (! isset($table_fields[$i]['processed'])) {
347 $table_fields[$i]['Field_html'] = htmlspecialchars($table_fields[$i]['Field']);
348 $table_fields[$i]['Field_md5'] = md5($table_fields[$i]['Field']);
349 // True_Type contains only the type (stops at first bracket)
350 $table_fields[$i]['True_Type'] = preg_replace('@\(.*@s', '', $table_fields[$i]['Type']);
354 // Current date should not be set as default if the field is NULL
355 // for the current row, but do not put here the current datetime
356 // if there is a default value (the real default value will be set
357 // in the Default value logic below)
359 // Note: (tested in MySQL 4.0.16): when lang is some UTF-8,
360 // $field['Default'] is not set if it contains NULL:
361 // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime)
362 // but, look what we get if we switch to iso: (Default is NULL)
363 // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime)
364 // so I force a NULL into it (I don't think it's possible
365 // to have an empty default value for DATETIME)
366 // then, the "if" after this one will work
367 if ($table_fields[$i]['Type'] == 'datetime'
368 && ! isset($table_fields[$i]['Default'])
369 && isset($table_fields[$i]['Null'])
370 && $table_fields[$i]['Null'] == 'YES') {
371 $table_fields[$i]['Default'] = null;
374 $table_fields[$i]['len'] =
375 preg_match('@float|double@', $table_fields[$i]['Type']) ?
100 : -1;
378 if (isset($comments_map[$table_fields[$i]['Field']])) {
379 $table_fields[$i]['Field_title'] = '<span style="border-bottom: 1px dashed black;" title="'
380 . htmlspecialchars($comments_map[$table_fields[$i]['Field']]) . '">'
381 . $table_fields[$i]['Field_html'] . '</span>';
383 $table_fields[$i]['Field_title'] = $table_fields[$i]['Field_html'];
387 // Fix for bug #3152931 'ENUM and SET cannot have "Binary" option'
388 // If check to ensure types such as "enum('one','two','binary',..)" or
389 // "enum('one','two','varbinary',..)" are not categorized as binary.
390 if (stripos($table_fields[$i]['Type'], 'binary') === 0
391 ||
stripos($table_fields[$i]['Type'], 'varbinary') === 0) {
392 $table_fields[$i]['is_binary'] = stristr($table_fields[$i]['Type'], 'binary');
394 $table_fields[$i]['is_binary'] = false;
397 // If check to ensure types such as "enum('one','two','blob',..)" or
398 // "enum('one','two','tinyblob',..)" etc. are not categorized as blob.
399 if (stripos($table_fields[$i]['Type'], 'blob') === 0
400 ||
stripos($table_fields[$i]['Type'], 'tinyblob') === 0
401 ||
stripos($table_fields[$i]['Type'], 'mediumblob') === 0
402 ||
stripos($table_fields[$i]['Type'], 'longblob') === 0) {
403 $table_fields[$i]['is_blob'] = stristr($table_fields[$i]['Type'], 'blob');
405 $table_fields[$i]['is_blob'] = false;
408 // If check to ensure types such as "enum('one','two','char',..)" or
409 // "enum('one','two','varchar',..)" are not categorized as char.
410 if (stripos($table_fields[$i]['Type'], 'char') === 0
411 ||
stripos($table_fields[$i]['Type'], 'varchar') === 0) {
412 $table_fields[$i]['is_char'] = stristr($table_fields[$i]['Type'], 'char');
414 $table_fields[$i]['is_char'] = false;
417 $table_fields[$i]['first_timestamp'] = false;
418 switch ($table_fields[$i]['True_Type']) {
420 $table_fields[$i]['pma_type'] = 'set';
421 $table_fields[$i]['wrap'] = '';
424 $table_fields[$i]['pma_type'] = 'enum';
425 $table_fields[$i]['wrap'] = '';
428 if (!$timestamp_seen) { // can only occur once per table
430 $table_fields[$i]['first_timestamp'] = true;
432 $table_fields[$i]['pma_type'] = $table_fields[$i]['Type'];
433 $table_fields[$i]['wrap'] = ' nowrap="nowrap"';
437 $table_fields[$i]['pma_type'] = $table_fields[$i]['Type'];
438 $table_fields[$i]['wrap'] = ' nowrap="nowrap"';
442 $field = $table_fields[$i];
443 $extracted_fieldspec = PMA_extractFieldSpec($field['Type']);
445 if (-1 === $field['len']) {
446 $field['len'] = PMA_DBI_field_len($vresult, $i);
448 //Call validation when the form submited...
449 $unnullify_trigger = $chg_evt_handler . "=\"return verificationsAfterFieldChange('". PMA_escapeJsString($field['Field_md5']) . "', '"
450 . PMA_escapeJsString($jsvkey) . "','".$field['pma_type']."')\"";
452 // Use an MD5 as an array index to avoid having special characters in the name atttibute (see bug #1746964 )
453 $field_name_appendix = $vkey . '[' . $field['Field_md5'] . ']';
455 if ($field['Type'] == 'datetime'
456 && ! isset($field['Default'])
457 && ! is_null($field['Default'])
458 && ($insert_mode ||
! isset($vrow[$field['Field']]))) {
460 // UPDATE case with an NULL value
461 $vrow[$field['Field']] = date('Y-m-d H:i:s', time());
464 <tr
class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
465 <td
<?php
echo ($cfg['LongtextDoubleTextarea'] && strstr($field['True_Type'], 'longtext') ?
'rowspan="2"' : ''); ?
> align
="center">
466 <?php
echo $field['Field_title']; ?
>
467 <input type
="hidden" name
="fields_name<?php echo $field_name_appendix; ?>" value
="<?php echo $field['Field_html']; ?>"/>
469 <?php
if ($cfg['ShowFieldTypesInDataEditView']) { ?
>
470 <td align
="center"<?php
echo $field['wrap']; ?
>><span
class="column_type"><?php
echo $field['pma_type']; ?
></span
>
475 // Prepares the field value
476 $real_null_value = false;
477 $special_chars_encoded = '';
480 if (is_null($vrow[$field['Field']])) {
481 $real_null_value = true;
482 $vrow[$field['Field']] = '';
484 $data = $vrow[$field['Field']];
485 } elseif ($field['True_Type'] == 'bit') {
486 $special_chars = PMA_printable_bit_value($vrow[$field['Field']], $extracted_fieldspec['spec_in_brackets']);
488 // special binary "characters"
489 if ($field['is_binary'] ||
($field['is_blob'] && ! $cfg['ProtectBinary'])) {
490 if ($_SESSION['tmp_user_values']['display_binary_as_hex'] && $cfg['ShowFunctionFields']) {
491 $vrow[$field['Field']] = bin2hex($vrow[$field['Field']]);
492 $field['display_binary_as_hex'] = true;
494 $vrow[$field['Field']] = PMA_replace_binary_contents($vrow[$field['Field']]);
497 $special_chars = htmlspecialchars($vrow[$field['Field']]);
499 //We need to duplicate the first \n or otherwise we will lose the first newline entered in a VARCHAR or TEXT column
500 $special_chars_encoded = PMA_duplicateFirstNewline($special_chars);
502 $data = $vrow[$field['Field']];
503 } // end if... else...
505 //when copying row, it is useful to empty auto-increment column to prevent duplicate key error
506 if (isset($default_action) && $default_action === 'insert') {
507 if ($field['Key'] === 'PRI' && strpos($field['Extra'], 'auto_increment') !== false) {
508 $data = $special_chars_encoded = $special_chars = NULL;
511 // If a timestamp field value is not included in an update
512 // statement MySQL auto-update it to the current timestamp;
513 // however, things have changed since MySQL 4.1, so
514 // it's better to set a fields_prev in this situation
515 $backup_field = '<input type="hidden" name="fields_prev'
516 . $field_name_appendix . '" value="'
517 . htmlspecialchars($vrow[$field['Field']]) . '" />';
519 // (we are inserting)
520 // display default values
521 if (! isset($field['Default'])) {
522 $field['Default'] = '';
523 $real_null_value = true;
526 $data = $field['Default'];
528 if ($field['True_Type'] == 'bit') {
529 $special_chars = PMA_convert_bit_default_value($field['Default']);
531 $special_chars = htmlspecialchars($field['Default']);
534 $special_chars_encoded = PMA_duplicateFirstNewline($special_chars);
535 // this will select the UNHEX function while inserting
536 if (($field['is_binary'] ||
($field['is_blob'] && ! $cfg['ProtectBinary'])) && $_SESSION['tmp_user_values']['display_binary_as_hex'] && $cfg['ShowFunctionFields']) {
537 $field['display_binary_as_hex'] = true;
541 $idindex = ($o_rows * $fields_cnt) +
$i +
1;
542 $tabindex = $idindex;
544 // Get a list of data types that are not yet supported.
545 $no_support_types = PMA_unsupportedDatatypes();
547 // The function column
548 // -------------------
549 // We don't want binary data to be destroyed
550 // Note: from the MySQL manual: "BINARY doesn't affect how the column is
551 // stored or retrieved" so it does not mean that the contents is
553 if ($cfg['ShowFunctionFields']) {
554 if (($cfg['ProtectBinary'] && $field['is_blob'] && !$is_upload)
555 ||
($cfg['ProtectBinary'] == 'all' && $field['is_binary'])) {
556 echo ' <td align="center">' . __('Binary') . '</td>' . "\n";
557 } elseif (strstr($field['True_Type'], 'enum') ||
strstr($field['True_Type'], 'set') ||
in_array($field['pma_type'], $no_support_types)) {
558 echo ' <td align="center">--</td>' . "\n";
562 <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">
564 echo PMA_getFunctionsForField($field, $insert_mode);
570 } // end if ($cfg['ShowFunctionFields'])
575 $foreignData = PMA_getForeignData($foreigners, $field['Field'], false, '', '');
577 if ($field['Null'] == 'YES') {
578 echo ' <input type="hidden" name="fields_null_prev' . $field_name_appendix . '"';
579 if ($real_null_value && !$field['first_timestamp']) {
584 echo ' <input type="checkbox" class="checkbox_null" tabindex="' . ($tabindex +
$tabindex_for_null) . '"'
585 . ' name="fields_null' . $field_name_appendix . '"';
586 if ($real_null_value && !$field['first_timestamp']) {
587 echo ' checked="checked"';
589 echo ' id="field_' . ($idindex) . '_2" />';
591 // nullify_code is needed by the js nullify() function
592 if (strstr($field['True_Type'], 'enum')) {
593 if (strlen($field['Type']) > 20) {
598 } elseif (strstr($field['True_Type'], 'set')) {
600 } elseif ($foreigners && isset($foreigners[$field['Field']]) && $foreignData['foreign_link'] == false) {
601 // foreign key in a drop-down
603 } elseif ($foreigners && isset($foreigners[$field['Field']]) && $foreignData['foreign_link'] == true) {
604 // foreign key with a browsing icon
609 // to be able to generate calls to nullify() in jQuery
610 echo '<input type="hidden" class="nullify_code" name="nullify_code' . $field_name_appendix . '" value="' . $nullify_code . '" />';
611 echo '<input type="hidden" class="hashed_field" name="hashed_field' . $field_name_appendix . '" value="' . $field['Field_md5'] . '" />';
612 echo '<input type="hidden" class="multi_edit" name="multi_edit' . $field_name_appendix . '" value="' . PMA_escapeJsString($vkey) . '" />';
614 echo ' </td>' . "\n";
616 // The value column (depends on type)
618 // See bug #1667887 for the reason why we don't use the maxlength
622 // Will be used by js/tbl_change.js to set the default value
623 // for the "Continue insertion" feature
624 echo '<span class="default_value hide">' . $special_chars . '</span>';
625 if ($foreignData['foreign_link'] == true) {
626 echo $backup_field . "\n";
628 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>"
630 <input type
="text" name
="fields<?php echo $field_name_appendix; ?>"
631 class="textfield" <?php
echo $unnullify_trigger; ?
>
632 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
633 id
="field_<?php echo ($idindex); ?>_3"
634 value
="<?php echo htmlspecialchars($data); ?>" />
635 <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
>
637 } elseif (is_array($foreignData['disp_row'])) {
638 echo $backup_field . "\n";
640 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>"
642 <select name
="fields<?php echo $field_name_appendix; ?>"
643 <?php
echo $unnullify_trigger; ?
>
645 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
646 id
="field_<?php echo ($idindex); ?>_3">
647 <?php
echo PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $data, $cfg['ForeignKeyMaxLimit']); ?
>
651 unset($foreignData['disp_row']);
652 } elseif ($cfg['LongtextDoubleTextarea'] && strstr($field['pma_type'], 'longtext')) {
656 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
657 <td colspan
="5" align
="right">
658 <?php
echo $backup_field . "\n"; ?
>
659 <textarea name
="fields<?php echo $field_name_appendix; ?>"
660 rows
="<?php echo ($cfg['TextareaRows']*2); ?>"
661 cols
="<?php echo ($cfg['TextareaCols']*2); ?>"
662 dir
="<?php echo $text_dir; ?>"
663 id
="field_<?php echo ($idindex); ?>_3"
664 <?php
echo $unnullify_trigger; ?
>
665 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
666 ><?php
echo $special_chars_encoded; ?
></textarea
>
668 } elseif (strstr($field['pma_type'], 'text')) {
669 echo $backup_field . "\n";
671 <textarea name
="fields<?php echo $field_name_appendix; ?>"
672 rows
="<?php echo $cfg['TextareaRows']; ?>"
673 cols
="<?php echo $cfg['TextareaCols']; ?>"
674 dir
="<?php echo $text_dir; ?>"
675 id
="field_<?php echo ($idindex); ?>_3"
676 <?php
echo $unnullify_trigger; ?
>
677 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
678 ><?php
echo $special_chars_encoded; ?
></textarea
>
681 if (strlen($special_chars) > 32000) {
683 echo ' <td>' . __(' Because of its length,<br /> this column might not be editable ');
685 } elseif ($field['pma_type'] == 'enum') {
686 if (! isset($table_fields[$i]['values'])) {
687 $table_fields[$i]['values'] = array();
688 foreach ($extracted_fieldspec['enum_set_values'] as $val) {
689 // Removes automatic MySQL escape format
690 $val = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $val));
691 $table_fields[$i]['values'][] = array(
693 'html' => htmlspecialchars($val),
697 $field_enum_values = $table_fields[$i]['values'];
699 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="enum" />
700 <input type
="hidden" name
="fields<?php echo $field_name_appendix; ?>" value
="" />
702 echo "\n" . ' ' . $backup_field . "\n";
704 // show dropdown or radio depend on length
705 if (strlen($field['Type']) > 20) {
707 <select name
="fields<?php echo $field_name_appendix; ?>"
708 <?php
echo $unnullify_trigger; ?
>
710 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
711 id
="field_<?php echo ($idindex); ?>_3">
712 <option value
=""> 
;</option
>
716 foreach ($field_enum_values as $enum_value) {
718 echo '<option value="' . $enum_value['html'] . '"';
719 if ($data == $enum_value['plain']
721 && (! isset($where_clause) ||
$field['Null'] != 'YES')
722 && isset($field['Default'])
723 && $enum_value['plain'] == $field['Default'])) {
724 echo ' selected="selected"';
726 echo '>' . $enum_value['html'] . '</option>' . "\n";
734 foreach ($field_enum_values as $enum_value) {
736 echo '<input type="radio" name="fields' . $field_name_appendix . '"';
737 echo ' class="textfield"';
738 echo ' value="' . $enum_value['html'] . '"';
739 echo ' id="field_' . ($idindex) . '_3_' . $j . '"';
740 echo $unnullify_trigger;
741 if ($data == $enum_value['plain']
743 && (! isset($where_clause) ||
$field['Null'] != 'YES')
744 && isset($field['Default'])
745 && $enum_value['plain'] == $field['Default'])) {
746 echo ' checked="checked"';
748 echo ' tabindex="' . ($tabindex +
$tabindex_for_value) . '" />';
749 echo '<label for="field_' . $idindex . '_3_' . $j . '">'
750 . $enum_value['html'] . '</label>' . "\n";
754 } elseif ($field['pma_type'] == 'set') {
755 if (! isset($table_fields[$i]['values'])) {
756 $table_fields[$i]['values'] = array();
757 foreach ($extracted_fieldspec['enum_set_values'] as $val) {
758 $table_fields[$i]['values'][] = array(
760 'html' => htmlspecialchars($val),
763 $table_fields[$i]['select_size'] = min(4, count($table_fields[$i]['values']));
765 $field_set_values = $table_fields[$i]['values'];
766 $select_size = $table_fields[$i]['select_size'];
768 $vset = array_flip(explode(',', $data));
769 echo $backup_field . "\n";
771 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="set" />
772 <select name
="fields<?php echo $field_name_appendix . '[]'; ?>"
774 size
="<?php echo $select_size; ?>"
775 multiple
="multiple" <?php
echo $unnullify_trigger; ?
>
776 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
777 id
="field_<?php echo ($idindex); ?>_3">
779 foreach ($field_set_values as $field_set_value) {
781 echo '<option value="' . $field_set_value['html'] . '"';
782 if (isset($vset[$field_set_value['plain']])) {
783 echo ' selected="selected"';
785 echo '>' . $field_set_value['html'] . '</option>' . "\n";
791 // We don't want binary data destroyed
792 elseif ($field['is_binary'] ||
$field['is_blob']) {
793 if (($cfg['ProtectBinary'] && $field['is_blob'])
794 ||
($cfg['ProtectBinary'] == 'all' && $field['is_binary'])) {
797 if (PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type) && PMA_BS_IsPBMSReference($data, $db))
799 echo '<input type="hidden" name="remove_blob_ref_' . $field['Field_md5'] . $vkey . '" value="' . $data . '" />';
800 echo '<input type="checkbox" name="remove_blob_repo_' . $field['Field_md5'] . $vkey . '" /> ' . __('Remove BLOB Repository Reference') . "<br />";
801 echo PMA_BS_CreateReferenceLink($data, $db);
806 echo __('Binary - do not edit');
808 $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
809 echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
813 } // end if (PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type) && PMA_BS_IsPBMSReference($data, $db))
815 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="protected" />
816 <input type
="hidden" name
="fields<?php echo $field_name_appendix; ?>" value
="" />
818 } elseif ($field['is_blob']) {
820 echo $backup_field . "\n";
822 <textarea name
="fields<?php echo $field_name_appendix; ?>"
823 rows
="<?php echo $cfg['TextareaRows']; ?>"
824 cols
="<?php echo $cfg['TextareaCols']; ?>"
825 dir
="<?php echo $text_dir; ?>"
826 id
="field_<?php echo ($idindex); ?>_3"
827 <?php
echo $unnullify_trigger; ?
>
828 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
829 ><?php
echo $special_chars_encoded; ?
></textarea
>
833 // field size should be at least 4 and max $cfg['LimitChars']
834 $fieldsize = min(max($field['len'], 4), $cfg['LimitChars']);
836 echo $backup_field . "\n";
838 <input type
="text" name
="fields<?php echo $field_name_appendix; ?>"
839 value
="<?php echo $special_chars; ?>" size
="<?php echo $fieldsize; ?>"
840 class="textfield" <?php
echo $unnullify_trigger; ?
>
841 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
842 id
="field_<?php echo ($idindex); ?>_3" />
844 } // end if...elseif...else
846 // Upload choice (only for BLOBs because the binary
847 // attribute does not imply binary contents)
848 // (displayed whatever value the ProtectBinary has)
850 if ($is_upload && $field['is_blob']) {
851 // check if field type is of longblob and if the table is PBMS enabled.
852 if (($field['pma_type'] == "longblob") && PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type)) {
854 echo '<input type="checkbox" name="upload_blob_repo' . $vkey . '[' . $field['Field_md5'] . ']" /> ' . __('Upload to BLOB repository');
858 echo '<input type="file" name="fields_upload' . $vkey . '[' . $field['Field_md5'] . ']" class="textfield" id="field_' . $idindex . '_3" size="10" ' . $unnullify_trigger . '/> ';
860 // find maximum upload size, based on field type
862 * @todo with functions this is not so easy, as you can basically
863 * process any data with function like MD5
865 $max_field_sizes = array(
868 'mediumblob' => '16777216',
869 'longblob' => '4294967296'); // yeah, really
871 $this_field_max_size = $max_upload_size; // from PHP max
872 if ($this_field_max_size > $max_field_sizes[$field['pma_type']]) {
873 $this_field_max_size = $max_field_sizes[$field['pma_type']];
875 echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n";
876 // do not generate here the MAX_FILE_SIZE, because we should
877 // put only one in the form to accommodate the biggest field
878 if ($this_field_max_size > $biggest_max_file_size) {
879 $biggest_max_file_size = $this_field_max_size;
883 if (!empty($cfg['UploadDir'])) {
884 $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']));
885 if ($files === false) {
886 echo ' <font color="red">' . __('Error') . '</font><br />' . "\n";
887 echo ' ' . __('The directory you set for upload work cannot be reached') . "\n";
888 } elseif (!empty($files)) {
890 echo ' <i>' . __('Or') . '</i>' . ' ' . __('web server upload directory') . ':<br />' . "\n";
891 echo ' <select size="1" name="fields_uploadlocal' . $vkey . '[' . $field['Field_md5'] . ']">' . "\n";
892 echo ' <option value="" selected="selected"></option>' . "\n";
894 echo ' </select>' . "\n";
896 } // end if (web-server upload directory)
897 } // end elseif (binary or blob)
899 elseif (in_array($field['pma_type'], $no_support_types)) {
900 // ignore this column to avoid changing it
903 // field size should be at least 4 and max 40
904 $fieldsize = min(max($field['len'], 4), 40);
905 echo $backup_field . "\n";
906 if ($field['is_char'] && ($cfg['CharEditing'] == 'textarea' ||
strpos($data, "\n") !== false)) {
909 <textarea name
="fields<?php echo $field_name_appendix; ?>"
910 rows
="<?php echo $cfg['CharTextareaRows']; ?>"
911 cols
="<?php echo $cfg['CharTextareaCols']; ?>"
912 dir
="<?php echo $text_dir; ?>"
913 id
="field_<?php echo ($idindex); ?>_3"
914 <?php
echo $unnullify_trigger; ?
>
915 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
916 ><?php
echo $special_chars_encoded; ?
></textarea
>
919 $the_class = 'textfield';
920 if ($field['pma_type'] == 'date') {
921 $the_class .= ' datefield';
922 } elseif ($field['pma_type'] == 'datetime' ||
substr($field['pma_type'], 0, 9) == 'timestamp') {
923 $the_class .= ' datetimefield';
926 <input type
="text" name
="fields<?php echo $field_name_appendix; ?>"
927 value
="<?php echo $special_chars; ?>" size
="<?php echo $fieldsize; ?>"
928 class="<?php echo $the_class; ?>" <?php
echo $unnullify_trigger; ?
>
929 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
930 id
="field_<?php echo ($idindex); ?>_3" />
932 if ($field['Extra'] == 'auto_increment') {
934 <input type
="hidden" name
="auto_increment<?php echo $field_name_appendix; ?>" value
="1" />
937 if (substr($field['pma_type'], 0, 9) == 'timestamp') {
939 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="timestamp" />
942 if (substr($field['pma_type'], 0, 8) == 'datetime') {
944 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="datetime" />
947 if ($field['True_Type'] == 'bit') {
949 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="bit" />
952 if ($field['pma_type'] == 'date' ||
$field['pma_type'] == 'datetime' ||
substr($field['pma_type'], 0, 9) == 'timestamp') {
953 // the _3 suffix points to the date field
954 // the _2 suffix points to the corresponding NULL checkbox
955 // in dateFormat, 'yy' means the year with 4 digits
963 $odd_row = !$odd_row;
966 echo ' </tbody></table><br />';
967 } // end foreach on multi-edit
971 <fieldset id
="actions_panel">
972 <table border
="0" cellpadding
="5" cellspacing
="0">
974 <td valign
="middle" nowrap
="nowrap">
975 <select name
="submit_type" class="control_at_footer" tabindex
="<?php echo ($tabindex + $tabindex_for_value + 1); ?>">
977 if (isset($where_clause)) {
979 <option value
="save"><?php
echo __('Save'); ?
></option
>
983 <option value
="insert"><?php
echo __('Insert as new row'); ?
></option
>
984 <option value
="insertignore"><?php
echo __('Insert as new row and ignore errors'); ?
></option
>
985 <option value
="showinsert"><?php
echo __('Show insert query'); ?
></option
>
990 if (! isset($after_insert)) {
991 $after_insert = 'back';
996  
; 
; 
;<strong
><?php
echo __('and then'); ?
></strong
> 
; 
; 
;
998 <td valign
="middle" nowrap
="nowrap">
999 <select name
="after_insert">
1000 <option value
="back" <?php
echo ($after_insert == 'back' ?
'selected="selected"' : ''); ?
>><?php
echo __('Go back to previous page'); ?
></option
>
1001 <option value
="new_insert" <?php
echo ($after_insert == 'new_insert' ?
'selected="selected"' : ''); ?
>><?php
echo __('Insert another new row'); ?
></option
>
1003 if (isset($where_clause)) {
1005 <option value
="same_insert" <?php
echo ($after_insert == 'same_insert' ?
'selected="selected"' : ''); ?
>><?php
echo __('Go back to this page'); ?
></option
>
1007 // If we have just numeric primary key, we can also edit next
1008 // in 2.8.2, we were looking for `field_name` = numeric_value
1009 //if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $where_clause)) {
1010 // in 2.9.0, we are looking for `table_name`.`field_name` = numeric_value
1011 if ($found_unique_key && preg_match('@^[\s]*`[^`]*`[\.]`[^`]*` = [0-9]+@', $where_clause)) {
1013 <option value
="edit_next" <?php
echo ($after_insert == 'edit_next' ?
'selected="selected"' : ''); ?
>><?php
echo __('Edit next row'); ?
></option
>
1024 <?php
echo PMA_showHint(__('Use TAB key to move from value to value, or CTRL+arrows to move anywhere')); ?
>
1026 <td colspan
="3" align
="right" valign
="middle">
1027 <input type
="submit" class="control_at_footer" value
="<?php echo __('Go'); ?>" tabindex
="<?php echo ($tabindex + $tabindex_for_value + 6); ?>" id
="buttonYes" />
1028 <input type
="reset" class="control_at_footer" value
="<?php echo __('Reset'); ?>" tabindex
="<?php echo ($tabindex + $tabindex_for_value + 7); ?>" />
1033 <?php
if ($biggest_max_file_size > 0) {
1034 echo ' ' . PMA_generateHiddenMaxFileSize($biggest_max_file_size) . "\n";
1040 <!-- Continue insertion form
-->
1041 <form id
="continueForm" method
="post" action
="tbl_replace.php" name
="continueForm" >
1042 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
1043 <input type
="hidden" name
="goto" value
="<?php echo htmlspecialchars($GLOBALS['goto']); ?>" />
1044 <input type
="hidden" name
="err_url" value
="<?php echo htmlspecialchars($err_url); ?>" />
1045 <input type
="hidden" name
="sql_query" value
="<?php echo htmlspecialchars($sql_query); ?>" />
1047 if (isset($where_clauses)) {
1048 foreach ($where_clause_array as $key_id => $where_clause) {
1049 echo '<input type="hidden" name="where_clause[' . $key_id . ']" value="' . htmlspecialchars(trim($where_clause)) . '" />'. "\n";
1052 $tmp = '<select name="insert_rows" id="insert_rows">' . "\n";
1053 $option_values = array(1,2,5,10,15,20,30,40);
1054 foreach ($option_values as $value) {
1055 $tmp .= '<option value="' . $value . '"';
1056 if ($value == $cfg['InsertRows']) {
1057 $tmp .= ' selected="selected"';
1059 $tmp .= '>' . $value . '</option>' . "\n";
1061 $tmp .= '</select>' . "\n";
1062 echo "\n" . sprintf(__('Continue insertion with %s rows'), $tmp);
1064 echo '<noscript><input type="submit" value="' . __('Go') . '" /></noscript>' . "\n";
1065 echo '</form>' . "\n";
1069 * Displays the footer
1071 require './libraries/footer.inc.php';