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 include_once './libraries/data_drizzle.inc.php';
26 include_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.16.custom.js';
124 $GLOBALS['js_include'][] = 'jquery/timepicker.js';
125 $GLOBALS['js_include'][] = 'gis_data_editor.js';
128 * HTTP and HTML headers
130 require_once './libraries/header.inc.php';
133 * Displays the query submitted and its result
135 * @todo where does $disp_message and $disp_query come from???
137 if (! empty($disp_message)) {
138 if (! isset($disp_query)) {
141 PMA_showMessage($disp_message, $disp_query);
145 * Displays top menu links
147 require_once './libraries/tbl_links.inc.php';
151 * Get the analysis of SHOW CREATE TABLE for this table
152 * @todo should be handled by class Table
154 $show_create_table = PMA_DBI_fetch_value(
155 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
157 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
158 unset($show_create_table);
161 * Get the list of the fields of the current table
163 PMA_DBI_select_db($db);
164 $table_fields = array_values(PMA_DBI_get_columns($db, $table));
166 if (isset($where_clause)) {
167 // when in edit mode load all selected rows from table
168 $insert_mode = false;
169 if (is_array($where_clause)) {
170 $where_clause_array = $where_clause;
172 $where_clause_array = array(0 => $where_clause);
176 $found_unique_key = false;
177 $where_clauses = array();
179 foreach ($where_clause_array as $key_id => $where_clause) {
180 $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';';
181 $result[$key_id] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE
);
182 $rows[$key_id] = PMA_DBI_fetch_assoc($result[$key_id]);
183 $where_clauses[$key_id] = str_replace('\\', '\\\\', $where_clause);
186 if (! $rows[$key_id]) {
187 unset($rows[$key_id], $where_clause_array[$key_id]);
188 PMA_showMessage(__('MySQL returned an empty result set (i.e. zero rows).'), $local_query);
190 include './libraries/footer.inc.php';
191 } else { // end if (no row returned)
192 $meta = PMA_DBI_get_fields_meta($result[$key_id]);
193 list($unique_condition, $tmp_clause_is_unique) = PMA_getUniqueCondition($result[$key_id], count($meta), $meta, $rows[$key_id], true);
194 if (! empty($unique_condition)) {
195 $found_unique_key = true;
197 unset($unique_condition, $tmp_clause_is_unique);
202 // no primary key given, just load first row - but what happens if table is empty?
204 $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE
);
205 $rows = array_fill(0, $cfg['InsertRows'], false);
208 // Copying a row - fetched data will be inserted as a new row, therefore the where clause is needless.
209 if (isset($default_action) && $default_action === 'insert') {
210 unset($where_clause, $where_clauses);
213 // retrieve keys into foreign fields, if any
214 $foreigners = PMA_getForeigners($db, $table);
220 // autocomplete feature of IE kills the "onchange" event handler and it
221 // must be replaced by the "onpropertychange" one in this case
222 $chg_evt_handler = (PMA_USR_BROWSER_AGENT
== 'IE' && PMA_USR_BROWSER_VER
>= 5 && PMA_USR_BROWSER_VER
< 7)
225 // Had to put the URI because when hosted on an https server,
226 // some browsers send wrongly this form to the http server.
229 <!-- Set on key handler
for moving using by Ctrl+arrows
-->
230 <script src
="./js/keyhandler.js" type
="text/javascript"></script
>
231 <script type
="text/javascript">
233 var switch_movement
= 0;
234 document
.onkeydown
= onKeyDownArrowsHandler
;
239 $_form_params = array(
242 'goto' => $GLOBALS['goto'],
243 'err_url' => $err_url,
244 'sql_query' => $sql_query,
246 if (isset($where_clauses)) {
247 foreach ($where_clause_array as $key_id => $where_clause) {
248 $_form_params['where_clause[' . $key_id . ']'] = trim($where_clause);
251 if (isset($clause_is_unique)) {
252 $_form_params['clause_is_unique'] = $clause_is_unique;
257 <!-- Insert
/Edit form
-->
258 <form id
="insertForm" method
="post" action
="tbl_replace.php" name
="insertForm" <?php
if ($is_upload) { echo ' enctype="multipart/form-data"'; } ?
>>
260 echo PMA_generate_common_hidden_inputs($_form_params);
262 $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
264 // Set if we passed the first timestamp field
266 $fields_cnt = count($table_fields);
269 $tabindex_for_function = +
3000;
270 $tabindex_for_null = +
6000;
271 $tabindex_for_value = 0;
273 $biggest_max_file_size = 0;
275 // user can toggle the display of Function column
276 // (currently does not work for multi-edits)
277 $url_params['db'] = $db;
278 $url_params['table'] = $table;
279 if (isset($where_clause)) {
280 $url_params['where_clause'] = trim($where_clause);
282 if (! empty($sql_query)) {
283 $url_params['sql_query'] = $sql_query;
286 if (! $cfg['ShowFunctionFields'] ||
! $cfg['ShowFieldTypesInDataEditView']) {
289 if (! $cfg['ShowFunctionFields']) {
290 $this_url_params = array_merge($url_params,
291 array('ShowFunctionFields' => 1, 'ShowFieldTypesInDataEditView' => $cfg['ShowFieldTypesInDataEditView'], 'goto' => 'sql.php'));
292 echo ' : <a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '">' . __('Function') . '</a>' . "\n";
294 if (! $cfg['ShowFieldTypesInDataEditView']) {
295 $this_other_url_params = array_merge($url_params,
296 array('ShowFieldTypesInDataEditView' => 1, 'ShowFunctionFields' => $cfg['ShowFunctionFields'], 'goto' => 'sql.php'));
297 echo ' : <a href="tbl_change.php' . PMA_generate_common_url($this_other_url_params) . '">' . __('Type') . '</a>' . "\n";
300 foreach ($rows as $row_id => $vrow) {
301 if ($vrow === false) {
306 $rownumber_param = '&rownumber=' . $row_id;
307 $vkey = '[multi_edit][' . $jsvkey . ']';
309 $vresult = (isset($result) && is_array($result) && isset($result[$row_id]) ?
$result[$row_id] : $result);
310 if ($insert_mode && $row_id > 0) {
311 echo '<input type="checkbox" checked="checked" name="insert_ignore_' . $row_id . '" id="insert_ignore_' . $row_id . '" />';
312 echo '<label for="insert_ignore_' . $row_id . '">' . __('Ignore') . '</label><br />' . "\n";
315 <table
class="insertRowTable">
318 <th
><?php
echo __('Column'); ?
></th
>
321 if ($cfg['ShowFieldTypesInDataEditView']) {
322 $this_url_params = array_merge($url_params,
323 array('ShowFieldTypesInDataEditView' => 0, 'ShowFunctionFields' => $cfg['ShowFunctionFields'], 'goto' => 'sql.php'));
324 echo ' <th><a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '" title="' . __('Hide') . '">' . __('Type') . '</a></th>' . "\n";
327 if ($cfg['ShowFunctionFields']) {
328 $this_url_params = array_merge($url_params,
329 array('ShowFunctionFields' => 0, 'ShowFieldTypesInDataEditView' => $cfg['ShowFieldTypesInDataEditView'], 'goto' => 'sql.php'));
330 echo ' <th><a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '" title="' . __('Hide') . '">' . __('Function') . '</a></th>' . "\n";
333 <th
><?php
echo __('Null'); ?
></th
>
334 <th
><?php
echo __('Value'); ?
></th
>
339 <th colspan
="5" align
="right" class="tblFooters">
340 <input type
="submit" value
="<?php echo __('Go'); ?>" />
346 // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one)
347 $m_rows = $o_rows +
1;
350 for ($i = 0; $i < $fields_cnt; $i++
) {
351 if (! isset($table_fields[$i]['processed'])) {
352 $table_fields[$i]['Field_html'] = htmlspecialchars($table_fields[$i]['Field']);
353 $table_fields[$i]['Field_md5'] = md5($table_fields[$i]['Field']);
354 // True_Type contains only the type (stops at first bracket)
355 $table_fields[$i]['True_Type'] = preg_replace('@\(.*@s', '', $table_fields[$i]['Type']);
359 // Current date should not be set as default if the field is NULL
360 // for the current row, but do not put here the current datetime
361 // if there is a default value (the real default value will be set
362 // in the Default value logic below)
364 // Note: (tested in MySQL 4.0.16): when lang is some UTF-8,
365 // $field['Default'] is not set if it contains NULL:
366 // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime)
367 // but, look what we get if we switch to iso: (Default is NULL)
368 // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime)
369 // so I force a NULL into it (I don't think it's possible
370 // to have an empty default value for DATETIME)
371 // then, the "if" after this one will work
372 if ($table_fields[$i]['Type'] == 'datetime'
373 && ! isset($table_fields[$i]['Default'])
374 && isset($table_fields[$i]['Null'])
375 && $table_fields[$i]['Null'] == 'YES') {
376 $table_fields[$i]['Default'] = null;
379 $table_fields[$i]['len'] =
380 preg_match('@float|double@', $table_fields[$i]['Type']) ?
100 : -1;
383 if (isset($comments_map[$table_fields[$i]['Field']])) {
384 $table_fields[$i]['Field_title'] = '<span style="border-bottom: 1px dashed black;" title="'
385 . htmlspecialchars($comments_map[$table_fields[$i]['Field']]) . '">'
386 . $table_fields[$i]['Field_html'] . '</span>';
388 $table_fields[$i]['Field_title'] = $table_fields[$i]['Field_html'];
392 // Fix for bug #3152931 'ENUM and SET cannot have "Binary" option'
393 // If check to ensure types such as "enum('one','two','binary',..)" or
394 // "enum('one','two','varbinary',..)" are not categorized as binary.
395 if (stripos($table_fields[$i]['Type'], 'binary') === 0
396 ||
stripos($table_fields[$i]['Type'], 'varbinary') === 0) {
397 $table_fields[$i]['is_binary'] = stristr($table_fields[$i]['Type'], 'binary');
399 $table_fields[$i]['is_binary'] = false;
402 // If check to ensure types such as "enum('one','two','blob',..)" or
403 // "enum('one','two','tinyblob',..)" etc. are not categorized as blob.
404 if (stripos($table_fields[$i]['Type'], 'blob') === 0
405 ||
stripos($table_fields[$i]['Type'], 'tinyblob') === 0
406 ||
stripos($table_fields[$i]['Type'], 'mediumblob') === 0
407 ||
stripos($table_fields[$i]['Type'], 'longblob') === 0) {
408 $table_fields[$i]['is_blob'] = stristr($table_fields[$i]['Type'], 'blob');
410 $table_fields[$i]['is_blob'] = false;
413 // If check to ensure types such as "enum('one','two','char',..)" or
414 // "enum('one','two','varchar',..)" are not categorized as char.
415 if (stripos($table_fields[$i]['Type'], 'char') === 0
416 ||
stripos($table_fields[$i]['Type'], 'varchar') === 0) {
417 $table_fields[$i]['is_char'] = stristr($table_fields[$i]['Type'], 'char');
419 $table_fields[$i]['is_char'] = false;
422 $table_fields[$i]['first_timestamp'] = false;
423 switch ($table_fields[$i]['True_Type']) {
425 $table_fields[$i]['pma_type'] = 'set';
426 $table_fields[$i]['wrap'] = '';
429 $table_fields[$i]['pma_type'] = 'enum';
430 $table_fields[$i]['wrap'] = '';
433 if (!$timestamp_seen) { // can only occur once per table
435 $table_fields[$i]['first_timestamp'] = true;
437 $table_fields[$i]['pma_type'] = $table_fields[$i]['Type'];
438 $table_fields[$i]['wrap'] = ' nowrap="nowrap"';
442 $table_fields[$i]['pma_type'] = $table_fields[$i]['Type'];
443 $table_fields[$i]['wrap'] = ' nowrap="nowrap"';
447 $field = $table_fields[$i];
448 $extracted_fieldspec = PMA_extractFieldSpec($field['Type']);
450 if (-1 === $field['len']) {
451 $field['len'] = PMA_DBI_field_len($vresult, $i);
452 // length is unknown for geometry fields, make enough space to edit very simple WKTs
453 if (-1 === $field['len']) {
457 //Call validation when the form submited...
458 $unnullify_trigger = $chg_evt_handler . "=\"return verificationsAfterFieldChange('". PMA_escapeJsString($field['Field_md5']) . "', '"
459 . PMA_escapeJsString($jsvkey) . "','".$field['pma_type']."')\"";
461 // Use an MD5 as an array index to avoid having special characters in the name atttibute (see bug #1746964 )
462 $field_name_appendix = $vkey . '[' . $field['Field_md5'] . ']';
464 if ($field['Type'] == 'datetime'
465 && ! isset($field['Default'])
466 && ! is_null($field['Default'])
467 && ($insert_mode ||
! isset($vrow[$field['Field']]))) {
469 // UPDATE case with an NULL value
470 $vrow[$field['Field']] = date('Y-m-d H:i:s', time());
473 <tr
class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
474 <td
<?php
echo ($cfg['LongtextDoubleTextarea'] && strstr($field['True_Type'], 'longtext') ?
'rowspan="2"' : ''); ?
> align
="center">
475 <?php
echo $field['Field_title']; ?
>
476 <input type
="hidden" name
="fields_name<?php echo $field_name_appendix; ?>" value
="<?php echo $field['Field_html']; ?>"/>
478 <?php
if ($cfg['ShowFieldTypesInDataEditView']) { ?
>
479 <td align
="center"<?php
echo $field['wrap']; ?
>><span
class="column_type"><?php
echo $field['pma_type']; ?
></span
>
484 // Get a list of GIS data types.
485 $gis_data_types = PMA_getGISDatatypes();
487 // Prepares the field value
488 $real_null_value = false;
489 $special_chars_encoded = '';
492 if (is_null($vrow[$field['Field']])) {
493 $real_null_value = true;
494 $vrow[$field['Field']] = '';
496 $data = $vrow[$field['Field']];
497 } elseif ($field['True_Type'] == 'bit') {
498 $special_chars = PMA_printable_bit_value($vrow[$field['Field']], $extracted_fieldspec['spec_in_brackets']);
499 } elseif (in_array($field['True_Type'], $gis_data_types)) {
500 // Convert gis data to Well Know Text format
501 $vrow[$field['Field']] = PMA_asWKT($vrow[$field['Field']], true);
502 $special_chars = htmlspecialchars($vrow[$field['Field']]);
504 // special binary "characters"
505 if ($field['is_binary'] ||
($field['is_blob'] && ! $cfg['ProtectBinary'])) {
506 if ($_SESSION['tmp_user_values']['display_binary_as_hex'] && $cfg['ShowFunctionFields']) {
507 $vrow[$field['Field']] = bin2hex($vrow[$field['Field']]);
508 $field['display_binary_as_hex'] = true;
510 $vrow[$field['Field']] = PMA_replace_binary_contents($vrow[$field['Field']]);
513 $special_chars = htmlspecialchars($vrow[$field['Field']]);
515 //We need to duplicate the first \n or otherwise we will lose the first newline entered in a VARCHAR or TEXT column
516 $special_chars_encoded = PMA_duplicateFirstNewline($special_chars);
518 $data = $vrow[$field['Field']];
519 } // end if... else...
521 //when copying row, it is useful to empty auto-increment column to prevent duplicate key error
522 if (isset($default_action) && $default_action === 'insert') {
523 if ($field['Key'] === 'PRI' && strpos($field['Extra'], 'auto_increment') !== false) {
524 $data = $special_chars_encoded = $special_chars = null;
527 // If a timestamp field value is not included in an update
528 // statement MySQL auto-update it to the current timestamp;
529 // however, things have changed since MySQL 4.1, so
530 // it's better to set a fields_prev in this situation
531 $backup_field = '<input type="hidden" name="fields_prev'
532 . $field_name_appendix . '" value="'
533 . htmlspecialchars($vrow[$field['Field']]) . '" />';
535 // (we are inserting)
536 // display default values
537 if (! isset($field['Default'])) {
538 $field['Default'] = '';
539 $real_null_value = true;
542 $data = $field['Default'];
544 if ($field['True_Type'] == 'bit') {
545 $special_chars = PMA_convert_bit_default_value($field['Default']);
547 $special_chars = htmlspecialchars($field['Default']);
550 $special_chars_encoded = PMA_duplicateFirstNewline($special_chars);
551 // this will select the UNHEX function while inserting
552 if (($field['is_binary'] ||
($field['is_blob'] && ! $cfg['ProtectBinary'])) && $_SESSION['tmp_user_values']['display_binary_as_hex'] && $cfg['ShowFunctionFields']) {
553 $field['display_binary_as_hex'] = true;
557 $idindex = ($o_rows * $fields_cnt) +
$i +
1;
558 $tabindex = $idindex;
560 // Get a list of data types that are not yet supported.
561 $no_support_types = PMA_unsupportedDatatypes();
563 // The function column
564 // -------------------
565 // We don't want binary data to be destroyed
566 // Note: from the MySQL manual: "BINARY doesn't affect how the column is
567 // stored or retrieved" so it does not mean that the contents is
569 if ($cfg['ShowFunctionFields']) {
570 if (($cfg['ProtectBinary'] && $field['is_blob'] && !$is_upload)
571 ||
($cfg['ProtectBinary'] == 'all' && $field['is_binary'])) {
572 echo ' <td align="center">' . __('Binary') . '</td>' . "\n";
573 } elseif (strstr($field['True_Type'], 'enum') ||
strstr($field['True_Type'], 'set') ||
in_array($field['pma_type'], $no_support_types)) {
574 echo ' <td align="center">--</td>' . "\n";
578 <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">
580 echo PMA_getFunctionsForField($field, $insert_mode);
586 } // end if ($cfg['ShowFunctionFields'])
591 $foreignData = PMA_getForeignData($foreigners, $field['Field'], false, '', '');
593 if ($field['Null'] == 'YES') {
594 echo ' <input type="hidden" name="fields_null_prev' . $field_name_appendix . '"';
595 if ($real_null_value && !$field['first_timestamp']) {
600 echo ' <input type="checkbox" class="checkbox_null" tabindex="' . ($tabindex +
$tabindex_for_null) . '"'
601 . ' name="fields_null' . $field_name_appendix . '"';
602 if ($real_null_value && !$field['first_timestamp']) {
603 echo ' checked="checked"';
605 echo ' id="field_' . ($idindex) . '_2" />';
607 // nullify_code is needed by the js nullify() function
608 if (strstr($field['True_Type'], 'enum')) {
609 if (strlen($field['Type']) > 20) {
614 } elseif (strstr($field['True_Type'], 'set')) {
616 } elseif ($foreigners && isset($foreigners[$field['Field']]) && $foreignData['foreign_link'] == false) {
617 // foreign key in a drop-down
619 } elseif ($foreigners && isset($foreigners[$field['Field']]) && $foreignData['foreign_link'] == true) {
620 // foreign key with a browsing icon
625 // to be able to generate calls to nullify() in jQuery
626 echo '<input type="hidden" class="nullify_code" name="nullify_code' . $field_name_appendix . '" value="' . $nullify_code . '" />';
627 echo '<input type="hidden" class="hashed_field" name="hashed_field' . $field_name_appendix . '" value="' . $field['Field_md5'] . '" />';
628 echo '<input type="hidden" class="multi_edit" name="multi_edit' . $field_name_appendix . '" value="' . PMA_escapeJsString($vkey) . '" />';
630 echo ' </td>' . "\n";
632 // The value column (depends on type)
634 // See bug #1667887 for the reason why we don't use the maxlength
638 // Will be used by js/tbl_change.js to set the default value
639 // for the "Continue insertion" feature
640 echo '<span class="default_value hide">' . $special_chars . '</span>';
641 if ($foreignData['foreign_link'] == true) {
642 echo $backup_field . "\n";
644 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>"
646 <input type
="text" name
="fields<?php echo $field_name_appendix; ?>"
647 class="textfield" <?php
echo $unnullify_trigger; ?
>
648 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
649 id
="field_<?php echo ($idindex); ?>_3"
650 value
="<?php echo htmlspecialchars($data); ?>" />
651 <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
>
653 } elseif (is_array($foreignData['disp_row'])) {
654 echo $backup_field . "\n";
656 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>"
658 <select name
="fields<?php echo $field_name_appendix; ?>"
659 <?php
echo $unnullify_trigger; ?
>
661 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
662 id
="field_<?php echo ($idindex); ?>_3">
663 <?php
echo PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $data, $cfg['ForeignKeyMaxLimit']); ?
>
667 unset($foreignData['disp_row']);
668 } elseif ($cfg['LongtextDoubleTextarea'] && strstr($field['pma_type'], 'longtext')) {
672 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
673 <td colspan
="5" align
="right">
674 <?php
echo $backup_field . "\n"; ?
>
675 <textarea name
="fields<?php echo $field_name_appendix; ?>"
676 rows
="<?php echo ($cfg['TextareaRows']*2); ?>"
677 cols
="<?php echo ($cfg['TextareaCols']*2); ?>"
678 dir
="<?php echo $text_dir; ?>"
679 id
="field_<?php echo ($idindex); ?>_3"
680 <?php
echo $unnullify_trigger; ?
>
681 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
682 ><?php
echo $special_chars_encoded; ?
></textarea
>
684 } elseif (strstr($field['pma_type'], 'text')) {
685 echo $backup_field . "\n";
687 <textarea name
="fields<?php echo $field_name_appendix; ?>"
688 rows
="<?php echo $cfg['TextareaRows']; ?>"
689 cols
="<?php echo $cfg['TextareaCols']; ?>"
690 dir
="<?php echo $text_dir; ?>"
691 id
="field_<?php echo ($idindex); ?>_3"
692 <?php
echo $unnullify_trigger; ?
>
693 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
694 ><?php
echo $special_chars_encoded; ?
></textarea
>
697 if (strlen($special_chars) > 32000) {
699 echo ' <td>' . __('Because of its length,<br /> this column might not be editable');
701 } elseif ($field['pma_type'] == 'enum') {
702 if (! isset($table_fields[$i]['values'])) {
703 $table_fields[$i]['values'] = array();
704 foreach ($extracted_fieldspec['enum_set_values'] as $val) {
705 // Removes automatic MySQL escape format
706 $val = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $val));
707 $table_fields[$i]['values'][] = array(
709 'html' => htmlspecialchars($val),
713 $field_enum_values = $table_fields[$i]['values'];
715 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="enum" />
716 <input type
="hidden" name
="fields<?php echo $field_name_appendix; ?>" value
="" />
718 echo "\n" . ' ' . $backup_field . "\n";
720 // show dropdown or radio depend on length
721 if (strlen($field['Type']) > 20) {
723 <select name
="fields<?php echo $field_name_appendix; ?>"
724 <?php
echo $unnullify_trigger; ?
>
726 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
727 id
="field_<?php echo ($idindex); ?>_3">
728 <option value
=""> 
;</option
>
732 foreach ($field_enum_values as $enum_value) {
734 echo '<option value="' . $enum_value['html'] . '"';
735 if ($data == $enum_value['plain']
737 && (! isset($where_clause) ||
$field['Null'] != 'YES')
738 && isset($field['Default'])
739 && $enum_value['plain'] == $field['Default'])) {
740 echo ' selected="selected"';
742 echo '>' . $enum_value['html'] . '</option>' . "\n";
750 foreach ($field_enum_values as $enum_value) {
752 echo '<input type="radio" name="fields' . $field_name_appendix . '"';
753 echo ' class="textfield"';
754 echo ' value="' . $enum_value['html'] . '"';
755 echo ' id="field_' . ($idindex) . '_3_' . $j . '"';
756 echo $unnullify_trigger;
757 if ($data == $enum_value['plain']
759 && (! isset($where_clause) ||
$field['Null'] != 'YES')
760 && isset($field['Default'])
761 && $enum_value['plain'] == $field['Default'])) {
762 echo ' checked="checked"';
764 echo ' tabindex="' . ($tabindex +
$tabindex_for_value) . '" />';
765 echo '<label for="field_' . $idindex . '_3_' . $j . '">'
766 . $enum_value['html'] . '</label>' . "\n";
770 } elseif ($field['pma_type'] == 'set') {
771 if (! isset($table_fields[$i]['values'])) {
772 $table_fields[$i]['values'] = array();
773 foreach ($extracted_fieldspec['enum_set_values'] as $val) {
774 $table_fields[$i]['values'][] = array(
776 'html' => htmlspecialchars($val),
779 $table_fields[$i]['select_size'] = min(4, count($table_fields[$i]['values']));
781 $field_set_values = $table_fields[$i]['values'];
782 $select_size = $table_fields[$i]['select_size'];
784 $vset = array_flip(explode(',', $data));
785 echo $backup_field . "\n";
787 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="set" />
788 <select name
="fields<?php echo $field_name_appendix . '[]'; ?>"
790 size
="<?php echo $select_size; ?>"
791 multiple
="multiple" <?php
echo $unnullify_trigger; ?
>
792 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
793 id
="field_<?php echo ($idindex); ?>_3">
795 foreach ($field_set_values as $field_set_value) {
797 echo '<option value="' . $field_set_value['html'] . '"';
798 if (isset($vset[$field_set_value['plain']])) {
799 echo ' selected="selected"';
801 echo '>' . $field_set_value['html'] . '</option>' . "\n";
806 // We don't want binary data destroyed
807 } elseif ($field['is_binary'] ||
$field['is_blob']) {
808 if (($cfg['ProtectBinary'] && $field['is_blob'])
809 ||
($cfg['ProtectBinary'] == 'all' && $field['is_binary'])
813 if (PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type)
814 && PMA_BS_IsPBMSReference($data, $db)
816 echo '<input type="hidden" name="remove_blob_ref_' . $field['Field_md5'] . $vkey . '" value="' . $data . '" />';
817 echo '<input type="checkbox" name="remove_blob_repo_' . $field['Field_md5'] . $vkey . '" /> ' . __('Remove BLOB Repository Reference') . "<br />";
818 echo PMA_BS_CreateReferenceLink($data, $db);
821 echo __('Binary - do not edit');
823 $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
824 echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
828 } // end if (PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type) && PMA_BS_IsPBMSReference($data, $db))
830 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="protected" />
831 <input type
="hidden" name
="fields<?php echo $field_name_appendix; ?>" value
="" />
833 } elseif ($field['is_blob']) {
835 echo $backup_field . "\n";
837 <textarea name
="fields<?php echo $field_name_appendix; ?>"
838 rows
="<?php echo $cfg['TextareaRows']; ?>"
839 cols
="<?php echo $cfg['TextareaCols']; ?>"
840 dir
="<?php echo $text_dir; ?>"
841 id
="field_<?php echo ($idindex); ?>_3"
842 <?php
echo $unnullify_trigger; ?
>
843 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
844 ><?php
echo $special_chars_encoded; ?
></textarea
>
848 // field size should be at least 4 and max $cfg['LimitChars']
849 $fieldsize = min(max($field['len'], 4), $cfg['LimitChars']);
851 echo $backup_field . "\n";
853 <input type
="text" name
="fields<?php echo $field_name_appendix; ?>"
854 value
="<?php echo $special_chars; ?>" size
="<?php echo $fieldsize; ?>"
855 class="textfield" <?php
echo $unnullify_trigger; ?
>
856 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
857 id
="field_<?php echo ($idindex); ?>_3" />
859 } // end if...elseif...else
861 // Upload choice (only for BLOBs because the binary
862 // attribute does not imply binary contents)
863 // (displayed whatever value the ProtectBinary has)
865 if ($is_upload && $field['is_blob']) {
866 // check if field type is of longblob and if the table is PBMS enabled.
867 if (($field['pma_type'] == "longblob")
868 && PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type)
871 echo '<input type="checkbox" name="upload_blob_repo' . $vkey . '[' . $field['Field_md5'] . ']" /> ' . __('Upload to BLOB repository');
875 echo '<input type="file" name="fields_upload' . $vkey . '[' . $field['Field_md5'] . ']" class="textfield" id="field_' . $idindex . '_3" size="10" ' . $unnullify_trigger . '/> ';
877 // find maximum upload size, based on field type
879 * @todo with functions this is not so easy, as you can basically
880 * process any data with function like MD5
882 $max_field_sizes = array(
885 'mediumblob' => '16777216',
886 'longblob' => '4294967296'); // yeah, really
888 $this_field_max_size = $max_upload_size; // from PHP max
889 if ($this_field_max_size > $max_field_sizes[$field['pma_type']]) {
890 $this_field_max_size = $max_field_sizes[$field['pma_type']];
892 echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n";
893 // do not generate here the MAX_FILE_SIZE, because we should
894 // put only one in the form to accommodate the biggest field
895 if ($this_field_max_size > $biggest_max_file_size) {
896 $biggest_max_file_size = $this_field_max_size;
900 if (!empty($cfg['UploadDir'])) {
901 $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']));
902 if ($files === false) {
903 echo ' <font color="red">' . __('Error') . '</font><br />' . "\n";
904 echo ' ' . __('The directory you set for upload work cannot be reached') . "\n";
905 } elseif (!empty($files)) {
907 echo ' <i>' . __('Or') . '</i>' . ' ' . __('web server upload directory') . ':<br />' . "\n";
908 echo ' <select size="1" name="fields_uploadlocal' . $vkey . '[' . $field['Field_md5'] . ']">' . "\n";
909 echo ' <option value="" selected="selected"></option>' . "\n";
911 echo ' </select>' . "\n";
913 } // end if (web-server upload directory)
914 // end elseif (binary or blob)
915 } elseif (! in_array($field['pma_type'], $no_support_types)) {
916 // ignore this column to avoid changing it
917 if ($field['is_char']) {
918 $fieldsize = $extracted_fieldspec['spec_in_brackets'];
921 * This case happens for example for INT or DATE columns;
922 * in these situations, the value returned in $field['len']
925 $fieldsize = $field['len'];
927 $fieldsize = min(max($fieldsize, $cfg['MinSizeForInputField']), $cfg['MaxSizeForInputField']);
928 echo $backup_field . "\n";
929 if ($field['is_char']
930 && ($cfg['CharEditing'] == 'textarea'
931 ||
strpos($data, "\n") !== false)
935 <textarea
class="char" name
="fields<?php echo $field_name_appendix; ?>"
936 rows
="<?php echo $cfg['CharTextareaRows']; ?>"
937 cols
="<?php echo $cfg['CharTextareaCols']; ?>"
938 dir
="<?php echo $text_dir; ?>"
939 id
="field_<?php echo ($idindex); ?>_3"
940 <?php
echo $unnullify_trigger; ?
>
941 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
942 ><?php
echo $special_chars_encoded; ?
></textarea
>
945 $the_class = 'textfield';
946 if ($field['pma_type'] == 'date') {
947 $the_class .= ' datefield';
948 } elseif ($field['pma_type'] == 'datetime'
949 ||
substr($field['pma_type'], 0, 9) == 'timestamp'
951 $the_class .= ' datetimefield';
954 <input type
="text" name
="fields<?php echo $field_name_appendix; ?>"
955 value
="<?php echo $special_chars; ?>" size
="<?php echo $fieldsize; ?>"
956 class="<?php echo $the_class; ?>" <?php
echo $unnullify_trigger; ?
>
957 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
958 id
="field_<?php echo ($idindex); ?>_3" />
960 if ($field['Extra'] == 'auto_increment') {
962 <input type
="hidden" name
="auto_increment<?php echo $field_name_appendix; ?>" value
="1" />
965 if (substr($field['pma_type'], 0, 9) == 'timestamp') {
967 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="timestamp" />
970 if (substr($field['pma_type'], 0, 8) == 'datetime') {
972 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="datetime" />
975 if ($field['True_Type'] == 'bit') {
977 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>" value
="bit" />
980 if ($field['pma_type'] == 'date'
981 ||
$field['pma_type'] == 'datetime'
982 ||
substr($field['pma_type'], 0, 9) == 'timestamp'
984 // the _3 suffix points to the date field
985 // the _2 suffix points to the corresponding NULL checkbox
986 // in dateFormat, 'yy' means the year with 4 digits
990 if (in_array($field['pma_type'], $gis_data_types)) {
991 $data_val = isset($vrow[$field['Field']]) ?
$vrow[$field['Field']] : '';
992 $_url_params = array(
993 'field' => $field['Field_title'],
994 'value' => $data_val,
996 if ($field['pma_type'] != 'geometry') {
997 $_url_params = $_url_params +
array('gis_data[gis_type]' => strtoupper($field['pma_type']));
999 $edit_url = 'gis_data_editor.php' . PMA_generate_common_url($_url_params);
1000 $edit_str = PMA_getIcon('b_edit.png', __('Edit/Insert'));
1001 echo('<span class="open_gis_editor">');
1002 echo(PMA_linkOrButton($edit_url, $edit_str, array(), false, false, '_blank'));
1009 $odd_row = !$odd_row;
1012 echo ' </tbody></table><br />';
1013 } // end foreach on multi-edit
1015 <div id
="gis_editor"></div
><div id
="popup_background"></div
>
1017 <fieldset id
="actions_panel">
1018 <table border
="0" cellpadding
="5" cellspacing
="0">
1020 <td valign
="middle" nowrap
="nowrap">
1021 <select name
="submit_type" class="control_at_footer" tabindex
="<?php echo ($tabindex + $tabindex_for_value + 1); ?>">
1023 if (isset($where_clause)) {
1025 <option value
="save"><?php
echo __('Save'); ?
></option
>
1029 <option value
="insert"><?php
echo __('Insert as new row'); ?
></option
>
1030 <option value
="insertignore"><?php
echo __('Insert as new row and ignore errors'); ?
></option
>
1031 <option value
="showinsert"><?php
echo __('Show insert query'); ?
></option
>
1036 if (! isset($after_insert)) {
1037 $after_insert = 'back';
1041 <td valign
="middle">
1042  
; 
; 
;<strong
><?php
echo __('and then'); ?
></strong
> 
; 
; 
;
1044 <td valign
="middle" nowrap
="nowrap">
1045 <select name
="after_insert">
1046 <option value
="back" <?php
echo ($after_insert == 'back' ?
'selected="selected"' : ''); ?
>><?php
echo __('Go back to previous page'); ?
></option
>
1047 <option value
="new_insert" <?php
echo ($after_insert == 'new_insert' ?
'selected="selected"' : ''); ?
>><?php
echo __('Insert another new row'); ?
></option
>
1049 if (isset($where_clause)) {
1051 <option value
="same_insert" <?php
echo ($after_insert == 'same_insert' ?
'selected="selected"' : ''); ?
>><?php
echo __('Go back to this page'); ?
></option
>
1053 // If we have just numeric primary key, we can also edit next
1054 // in 2.8.2, we were looking for `field_name` = numeric_value
1055 //if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $where_clause)) {
1056 // in 2.9.0, we are looking for `table_name`.`field_name` = numeric_value
1057 if ($found_unique_key && preg_match('@^[\s]*`[^`]*`[\.]`[^`]*` = [0-9]+@', $where_clause)) {
1059 <option value
="edit_next" <?php
echo ($after_insert == 'edit_next' ?
'selected="selected"' : ''); ?
>><?php
echo __('Edit next row'); ?
></option
>
1070 <?php
echo PMA_showHint(__('Use TAB key to move from value to value, or CTRL+arrows to move anywhere')); ?
>
1072 <td colspan
="3" align
="right" valign
="middle">
1073 <input type
="submit" class="control_at_footer" value
="<?php echo __('Go'); ?>" tabindex
="<?php echo ($tabindex + $tabindex_for_value + 6); ?>" id
="buttonYes" />
1074 <input type
="reset" class="control_at_footer" value
="<?php echo __('Reset'); ?>" tabindex
="<?php echo ($tabindex + $tabindex_for_value + 7); ?>" />
1079 <?php
if ($biggest_max_file_size > 0) {
1080 echo ' ' . PMA_generateHiddenMaxFileSize($biggest_max_file_size) . "\n";
1086 <!-- Continue insertion form
-->
1087 <form id
="continueForm" method
="post" action
="tbl_replace.php" name
="continueForm" >
1088 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
1089 <input type
="hidden" name
="goto" value
="<?php echo htmlspecialchars($GLOBALS['goto']); ?>" />
1090 <input type
="hidden" name
="err_url" value
="<?php echo htmlspecialchars($err_url); ?>" />
1091 <input type
="hidden" name
="sql_query" value
="<?php echo htmlspecialchars($sql_query); ?>" />
1093 if (isset($where_clauses)) {
1094 foreach ($where_clause_array as $key_id => $where_clause) {
1095 echo '<input type="hidden" name="where_clause[' . $key_id . ']" value="' . htmlspecialchars(trim($where_clause)) . '" />'. "\n";
1098 $tmp = '<select name="insert_rows" id="insert_rows">' . "\n";
1099 $option_values = array(1,2,5,10,15,20,30,40);
1100 foreach ($option_values as $value) {
1101 $tmp .= '<option value="' . $value . '"';
1102 if ($value == $cfg['InsertRows']) {
1103 $tmp .= ' selected="selected"';
1105 $tmp .= '>' . $value . '</option>' . "\n";
1107 $tmp .= '</select>' . "\n";
1108 echo "\n" . sprintf(__('Continue insertion with %s rows'), $tmp);
1110 echo '<noscript><input type="submit" value="' . __('Go') . '" /></noscript>' . "\n";
1111 echo '</form>' . "\n";
1115 * Displays the footer
1117 require './libraries/footer.inc.php';