3 // vim: expandtab sw=4 ts=4 sts=4:
6 * Get the variables sent or posted to this script and displays the header
8 require_once('./libraries/common.lib.php');
10 $js_to_run = 'tbl_change.js';
11 require_once('./header.inc.php');
12 require_once('./libraries/relation.lib.php'); // foreign keys
13 require_once('./libraries/file_listing.php'); // file listing
17 * Displays the query submitted and its result
19 if (!empty($disp_message)) {
22 $goto = 'tbl_properties.php?'
23 . PMA_generate_common_url($db, $table)
24 . '&$show_query=1'
25 . '&sql_query=' . (isset($disp_query) ?
urlencode($disp_query) : '');
29 if (isset($sql_query)) {
30 $sql_query_cpy = $sql_query;
33 if (isset($disp_query)) {
34 $sql_query = $disp_query;
36 PMA_showMessage($disp_message);
37 if (isset($goto_cpy)) {
41 if (isset($sql_query_cpy)) {
42 $sql_query = $sql_query_cpy;
43 unset($sql_query_cpy);
49 * Defines the url to return to in case of error in a sql statement
52 $goto = 'db_details.php';
54 if (!preg_match('@^(db_details|tbl_properties|tbl_select)@', $goto)) {
55 $err_url = $goto . "?" . PMA_generate_common_url($db) . "&sql_query=" . urlencode($sql_query);
57 $err_url = $goto . '?'
58 . PMA_generate_common_url($db)
59 . ((preg_match('@^(tbl_properties|tbl_select)@', $goto)) ?
'&table=' . urlencode($table) : '');
64 * Ensures db and table are valid, else moves to the "parent" script
66 require_once('./libraries/db_table_exists.lib.php');
70 * Sets parameters for links
72 $url_query = PMA_generate_common_url($db, $table)
73 . '&goto=tbl_properties.php';
75 require_once('./tbl_properties_table_info.php');
79 $comments_map = array();
81 if ($GLOBALS['cfg']['ShowPropertyComments']) {
82 require_once('./libraries/relation.lib.php');
83 require_once('./libraries/transformations.lib.php');
85 $cfgRelation = PMA_getRelationsParam();
87 if ($cfgRelation['commwork']) {
88 $comments_map = PMA_getComments($db, $table);
93 * Displays top menu links
95 require_once('./tbl_properties_links.php');
99 * Get the analysis of SHOW CREATE TABLE for this table
101 $show_create_table = PMA_DBI_fetch_value(
102 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
104 $analyzed_sql = PMA_SQP_analyze( PMA_SQP_parse( $show_create_table ) );
105 unset($show_create_table);
108 * Get the list of the fields of the current table
110 PMA_DBI_select_db($db);
111 $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE
);
112 if (isset($primary_key)) {
113 if (is_array($primary_key)) {
114 $primary_key_array = $primary_key;
116 $primary_key_array = array(0 => $primary_key);
121 foreach ($primary_key_array AS $rowcount => $primary_key) {
122 $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';';
123 $result[$rowcount] = PMA_DBI_query($local_query, NULL, PMA_DBI_QUERY_STORE
);
124 $row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]);
125 $primary_keys[$rowcount] = $primary_key;
128 if (!$row[$rowcount]) {
129 unset($row[$rowcount]);
130 unset($primary_key_array[$rowcount]);
132 $goto = 'tbl_properties.php?'
133 . PMA_generate_common_url($db, $table)
134 . '&$show_query=1'
135 . '&sql_query=' . urlencode($local_query);
136 if (isset($sql_query)) {
137 $sql_query_cpy = $sql_query;
140 $sql_query = $local_query;
141 PMA_showMessage($strEmptyResultSet);
144 if (isset($sql_query_cpy)) {
145 $sql_query = $sql_query_cpy;
146 unset($sql_query_cpy);
149 require_once('./footer.inc.php');
150 } // end if (no record returned)
153 $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;', NULL, PMA_DBI_QUERY_STORE
);
158 // retrieve keys into foreign fields, if any
159 $cfgRelation = PMA_getRelationsParam();
160 $foreigners = ($cfgRelation['relwork'] ?
PMA_getForeigners($db, $table) : FALSE);
166 // loic1: autocomplete feature of IE kills the "onchange" event handler and it
167 // must be replaced by the "onpropertychange" one in this case
168 $chg_evt_handler = (PMA_USR_BROWSER_AGENT
== 'IE' && PMA_USR_BROWSER_VER
>= 5)
171 // Had to put the URI because when hosted on an https server,
172 // some browsers send wrongly this form to the http server.
175 <?php
if ($cfg['CtrlArrowsMoving']) { ?
>
176 <!-- Set on key handler
for moving using by Ctrl+arrows
-->
177 <script src
="libraries/keyhandler.js" type
="text/javascript" language
="javascript"></script
>
178 <script type
="text/javascript" language
="javascript">
180 var switch_movement
= 0;
181 document
.onkeydown
= onKeyDownArrowsHandler
;
186 <!-- Change table properties form
-->
187 <form method
="post" action
="tbl_replace.php" name
="insertForm" <?php
if ($is_upload) echo ' enctype="multipart/form-data"'; ?
>>
188 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
189 <input type
="hidden" name
="goto" value
="<?php echo urlencode($goto); ?>" />
190 <input type
="hidden" name
="pos" value
="<?php echo isset($pos) ? $pos : 0; ?>" />
191 <input type
="hidden" name
="session_max_rows" value
="<?php echo isset($session_max_rows) ? $session_max_rows : ''; ?>" />
192 <input type
="hidden" name
="disp_direction" value
="<?php echo isset($disp_direction) ? $disp_direction : ''; ?>" />
193 <input type
="hidden" name
="repeat_cells" value
="<?php echo isset($repeat_cells) ? $repeat_cells : ''; ?>" />
194 <input type
="hidden" name
="dontlimitchars" value
="<?php echo (isset($dontlimitchars) ? $dontlimitchars : 0); ?>" />
195 <input type
="hidden" name
="err_url" value
="<?php echo urlencode($err_url); ?>" />
196 <input type
="hidden" name
="sql_query" value
="<?php echo isset($sql_query) ? urlencode($sql_query) : ''; ?>" />
198 if (isset($primary_key_array)) {
199 foreach ($primary_key_array AS $primary_key) {
201 <input type
="hidden" name
="primary_key[]" value
="<?php echo urlencode($primary_key); ?>" />
207 if ($cfg['PropertiesIconic'] == true) {
208 // We need to copy the value or else the == 'both' check will always return true
209 $propicon = (string)$cfg['PropertiesIconic'];
211 if ($propicon == 'both') {
212 $iconic_spacer = '<div class="nowrap">';
217 $titles['Browse'] = $iconic_spacer . '<img width="16" height="16" src="' . $pmaThemeImage . 'b_browse.png" alt="' . $strBrowseForeignValues . '" title="' . $strBrowseForeignValues . '" border="0" />';
219 if ($propicon == 'both') {
220 $titles['Browse'] .= ' ' . $strBrowseForeignValues . '</div>';
223 $titles['Browse'] = $strBrowseForeignValues;
226 // Set if we passed the first timestamp field
228 $fields_cnt = PMA_DBI_num_rows($table_def);
230 // Set a flag here because the 'if' would not be valid in the loop
231 // if we set a value in some field
232 $insert_mode = (!isset($row) ?
TRUE : FALSE);
234 $loop_array = array();
235 for ($i = 0; $i < $cfg['InsertRows']; $i++
) $loop_array[] = FALSE;
240 while ($trow = PMA_DBI_fetch_assoc($table_def)) {
241 $trow_table_def[] = $trow;
245 $tabindex_for_function = +
1000;
246 $tabindex_for_null = +
2000;
247 $tabindex_for_value = 0;
249 $biggest_max_file_size = 0;
250 foreach ($loop_array AS $vrowcount => $vrow) {
251 if ($vrow === FALSE) {
256 $jsvkey = $vrowcount;
257 $browse_foreigners_uri = '&pk=' . $vrowcount;
259 $jsvkey = urlencode($primary_keys[$vrowcount]);
260 $browse_foreigners_uri = '&pk=' . urlencode($primary_keys[$vrowcount]);
262 $vkey = '[multi_edit][' . $jsvkey . ']';
264 $vresult = (isset($result) && is_array($result) && isset($result[$vrowcount]) ?
$result[$vrowcount] : $result);
265 if ($insert_mode && $vrowcount > 0) {
266 echo '<input type="checkbox" checked="checked" name="insert_ignore_' . $vrowcount . '" id="insert_ignore_check_' . $vrowcount . '" />';
267 echo '<label for="insert_ignore_check_' . $vrowcount . '">' . $strIgnore . '</label><br />' . "\n";
270 <table border
="<?php echo $cfg['Border']; ?>" cellpadding
="2" cellspacing
="1">
272 <th
><?php
echo $strField; ?
></th
>
273 <th
><?php
echo $strType; ?
></th
>
275 if ($cfg['ShowFunctionFields']) {
276 echo ' <th>' . $strFunction . '</th>' . "\n";
279 <th
><?php
echo $strNull; ?
></th
>
280 <th
><?php
echo $strValue; ?
></th
>
284 // garvin: For looping on multiple rows, we need to reset any variable used inside the loop to indicate sth.
286 unset($first_timestamp);
288 // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one)
289 $m_rows = $o_rows +
1;
291 for ($i = 0; $i < $fields_cnt; $i++
) {
292 // Display the submit button after every 15 lines --swix
293 // (wanted to use an <a href="#bottom"> and <a name> instead,
294 // but it didn't worked because of the <base href>)
296 if ((($o_rows * $fields_cnt +
$i) %
15 == 0) && ($i +
$o_rows != 0)) {
299 <th colspan
="5" align
="right" class="tblFooters">
300 <input type
="submit" value
="<?php echo $strGo; ?>" /> 
;
307 $row_table_def = $trow_table_def[$i];
308 $row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']);
310 $field = $row_table_def['Field'];
312 // removed previous PHP3-workaround that caused a problem with
313 // field names like '000'
318 // loic1: current date should not be set as default if the field is NULL
319 // for the current row
320 // lem9: but do not put here the current datetime if there is a default
321 // value (the real default value will be set in the
322 // Default value logic below)
324 // Note: (tested in MySQL 4.0.16): when lang is some UTF-8,
325 // $row_table_def['Default'] is not set if it contains NULL:
326 // Array ( [Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime )
327 // but, look what we get if we switch to iso: (Default is NULL)
328 // Array ( [Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime )
329 // so I force a NULL into it (I don't think it's possible
330 // to have an empty default value for DATETIME)
331 // then, the "if" after this one will work
332 if ($row_table_def['Type'] == 'datetime'
333 && !isset($row_table_def['Default'])
334 && isset($row_table_def['Null'])
335 && $row_table_def['Null'] == 'YES') {
336 $row_table_def['Default'] = NULL;
339 if ($row_table_def['Type'] == 'datetime'
340 && (!isset($row_table_def['Default']))
341 && (!is_null($row_table_def['Default']))) {
345 $vrow[$rowfield] = date('Y-m-d H:i:s', time());
347 $vrow = array($rowfield => date('Y-m-d H:i:s', time()));
350 // UPDATE case with an empty and not NULL value under PHP4
351 else if (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) {
352 $vrow[$rowfield] = date('Y-m-d H:i:s', time());
353 } // end if... else if...
355 $len = (preg_match('@float|double@', $row_table_def['Type']))
357 : PMA_DBI_field_len($vresult, $i);
358 $first_timestamp = 0;
360 $field_name = htmlspecialchars($field);
361 if (isset($comments_map[$field])) {
362 $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$field]) . '">' . $field_name . '</span>';
365 $bgcolor = ($i %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
368 <td
<?php
echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ?
'rowspan="2"' : ''); ?
> align
="center" bgcolor
="<?php echo $bgcolor; ?>"><?php
echo $field_name; ?
></td
>
373 $is_binary = stristr($row_table_def['Type'], ' binary');
374 $is_blob = stristr($row_table_def['Type'], 'blob');
375 $is_char = stristr($row_table_def['Type'], 'char');
376 switch ($row_table_def['True_Type']) {
386 if (!$timestamp_seen) { // can only occur once per table
388 $first_timestamp = 1;
390 $type = $row_table_def['Type'];
391 $type_nowrap = ' nowrap="nowrap"';
395 $type = $row_table_def['Type'];
396 $type_nowrap = ' nowrap="nowrap"';
400 <td align
="center" bgcolor
="<?php echo $bgcolor; ?>"<?php
echo $type_nowrap; ?
>>
406 // Prepares the field value
407 $real_null_value = FALSE;
409 if (!isset($vrow[$rowfield])
410 ||
(function_exists('is_null') && is_null($vrow[$rowfield]))) {
411 $real_null_value = TRUE;
412 $vrow[$rowfield] = '';
414 $data = $vrow[$rowfield];
416 // loic1: special binary "characters"
417 if ($is_binary ||
$is_blob) {
418 $vrow[$rowfield] = str_replace("\x00", '\0', $vrow[$rowfield]);
419 $vrow[$rowfield] = str_replace("\x08", '\b', $vrow[$rowfield]);
420 $vrow[$rowfield] = str_replace("\x0a", '\n', $vrow[$rowfield]);
421 $vrow[$rowfield] = str_replace("\x0d", '\r', $vrow[$rowfield]);
422 $vrow[$rowfield] = str_replace("\x1a", '\Z', $vrow[$rowfield]);
424 $special_chars = htmlspecialchars($vrow[$rowfield]);
425 $data = $vrow[$rowfield];
426 } // end if... else...
427 // loic1: if a timestamp field value is not included in an update
428 // statement MySQL auto-update it to the current timestamp
429 $backup_field = ($row_table_def['True_Type'] == 'timestamp')
431 : '<input type="hidden" name="fields_prev' . $vkey . '[' . urlencode($field) . ']" value="' . urlencode($vrow[$rowfield]) . '" />';
433 // loic1: display default values
434 if (!isset($row_table_def['Default'])) {
435 $row_table_def['Default'] = '';
436 $real_null_value = TRUE;
439 $data = $row_table_def['Default'];
441 $special_chars = htmlspecialchars($row_table_def['Default']);
445 $idindex = ($o_rows * $fields_cnt) +
$i +
1;
446 $tabindex = (($idindex - 1) * 3) +
1;
448 // The function column
449 // -------------------
450 // Change by Bernard M. Piller <bernard@bmpsystems.com>
451 // We don't want binary data to be destroyed
452 // Note: from the MySQL manual: "BINARY doesn't affect how the column is
453 // stored or retrieved" so it does not mean that the contents is
455 if ($cfg['ShowFunctionFields']) {
456 if (($cfg['ProtectBinary'] && $is_blob && !$is_upload)
457 ||
($cfg['ProtectBinary'] == 'all' && $is_binary)) {
458 echo ' <td align="center" bgcolor="'. $bgcolor . '">' . $strBinary . '</td>' . "\n";
459 } else if (strstr($row_table_def['True_Type'], 'enum') ||
strstr($row_table_def['True_Type'], 'set')) {
460 echo ' <td align="center" bgcolor="'. $bgcolor . '">--</td>' . "\n";
463 <td bgcolor
="<?php echo $bgcolor; ?>">
464 <select name
="funcs<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" <?php
echo $chg_evt_handler; ?
>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex
="<?php echo ($tabindex + $tabindex_for_function); ?>" id
="field_<?php echo $idindex; ?>_1">
470 // garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR'
471 // or something similar. Then directly look up the entry in the RestrictFunctions array,
472 // which will then reveal the available dropdown options
473 if (isset($cfg['RestrictFunctions']) && isset($cfg['RestrictColumnTypes']) && isset($cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]) && isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]])) {
474 $current_func_type = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])];
475 $dropdown = $cfg['RestrictFunctions'][$current_func_type];
476 $default_function = $cfg['DefaultFunctions'][$current_func_type];
479 $default_function = '';
482 $dropdown_built = array();
483 $op_spacing_needed = FALSE;
484 // garvin: loop on the dropdown array and print all available options for that field.
485 $cnt_dropdown = count($dropdown);
486 for ($j = 0; $j < $cnt_dropdown; $j++
) {
487 // Is current function defined as default?
488 // For MySQL < 4.1.2, for the first timestamp we set as
489 // default function the one defined in config (which
490 // should be NOW() ).
491 // For MySQL >= 4.1.2, we don't set the default function
492 // if there is a default value for the timestamp
493 // (not including CURRENT_TIMESTAMP)
494 // and the column does not have the
495 // ON UPDATE DEFAULT TIMESTAMP attribute.
497 if (PMA_MYSQL_INT_VERSION
< 40102
498 ||
(PMA_MYSQL_INT_VERSION
>= 40102
499 && !($row_table_def['True_Type'] == 'timestamp' && !empty($row_table_def['Default']) && !isset($analyzed_sql[0]['create_table_fields'][$field]['on_update_current_timestamp'])))) {
500 $selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp'])
501 ||
(!$first_timestamp && $dropdown[$j] == $default_function)
502 ?
' selected="selected"'
506 echo '<option' . $selected . '>' . $dropdown[$j] . '</option>' . "\n";
507 $dropdown_built[$dropdown[$j]] = 'TRUE';
508 $op_spacing_needed = TRUE;
511 // garvin: For compatibility's sake, do not let out all other functions. Instead
512 // print a separator (blank) and then show ALL functions which weren't shown
514 $cnt_functions = count($cfg['Functions']);
515 for ($j = 0; $j < $cnt_functions; $j++
) {
516 if (!isset($dropdown_built[$cfg['Functions'][$j]]) ||
$dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
517 // Is current function defined as default?
518 $selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp'])
519 ||
(!$first_timestamp && $cfg['Functions'][$j] == $default_function)
520 ?
' selected="selected"'
522 if ($op_spacing_needed == TRUE) {
524 echo '<option value="">--------</option>' . "\n";
525 $op_spacing_needed = FALSE;
529 echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";
538 } // end if ($cfg['ShowFunctionFields'])
543 echo ' <td bgcolor="' . $bgcolor . '">' . "\n";
544 if (!(($cfg['ProtectBinary'] && $is_blob) ||
($cfg['ProtectBinary'] == 'all' && $is_binary))
545 && $row_table_def['Null'] == 'YES') {
546 echo ' <input type="checkbox" tabindex="' . ($tabindex +
$tabindex_for_null) . '"'
547 . ' name="fields_null' . $vkey . '[' . urlencode($field) . ']"';
548 if ($real_null_value && !$first_timestamp) {
549 echo ' checked="checked"';
551 echo ' id="field_' . ($idindex) . '_2"';
552 $onclick = ' onclick="if (this.checked) {nullify(';
553 if (strstr($row_table_def['True_Type'], 'enum')) {
554 if (strlen($row_table_def['Type']) > 20) {
559 } else if (strstr($row_table_def['True_Type'], 'set')) {
561 } else if ($foreigners && isset($foreigners[$field])) {
566 $onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\', \'' . $vkey . '\'); this.checked = true}; return true" />' . "\n";
569 echo ' ' . "\n";
571 echo ' </td>' . "\n";
573 // The value column (depends on type)
576 require('./libraries/get_foreign.lib.php');
578 if (isset($foreign_link) && $foreign_link == true) {
580 <td bgcolor
="<?php echo $bgcolor; ?>">
581 <?php
echo $backup_field . "\n"; ?
>
582 <input type
="hidden" name
="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value
="foreign" />
583 <input type
="hidden" name
="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value
="" id
="field_<?php echo ($idindex); ?>_1" />
584 <input type
="text" name
="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" class="textfield" <?php
echo $chg_evt_handler; ?
>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>" id
="field_<?php echo ($idindex); ?>_3" value
="<?php echo htmlspecialchars($data); ?>" />
585 <script type
="text/javascript" language
="javascript">
586 document
.writeln('<a 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 urlencode($field) . $browse_foreigners_uri; ?>"><?php echo str_replace("'", "\'
", $titles['Browse']); ?></a>');
590 } else if (isset($disp_row) && is_array($disp_row)) {
592 <td bgcolor="<?php
echo $bgcolor; ?
>">
593 <?php echo $backup_field . "\n
"; ?>
594 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="foreign
" />
595 <input type="hidden
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="" id="field_
<?php
echo $idindex; ?
>_1
" />
596 <select name="field_
<?php
echo md5($field); ?
><?php
echo $vkey; ?
>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>" id="field_
<?php
echo ($idindex); ?
>_3
">
597 <?php echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data, $cfg['ForeignKeyMaxLimit']); ?>
603 else if ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
605 <td bgcolor="<?php
echo $bgcolor; ?
>"> </td>
608 <td colspan="4" align="right
" bgcolor="<?php
echo $bgcolor; ?
>">
609 <?php echo $backup_field . "\n
"; ?>
610 <textarea name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" rows="<?php
echo ($cfg['TextareaRows']*2); ?
>" cols="<?php
echo ($cfg['TextareaCols']*2); ?
>" dir="<?php
echo $text_dir; ?
>" id="field_
<?php
echo ($idindex); ?
>_3
"
611 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>"><?php echo $special_chars; ?></textarea>
615 else if (strstr($type, 'text')) {
617 <td bgcolor="<?php
echo $bgcolor; ?
>">
618 <?php echo $backup_field . "\n
"; ?>
619 <textarea name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" rows="<?php
echo $cfg['TextareaRows']; ?
>" cols="<?php
echo $cfg['TextareaCols']; ?
>" dir="<?php
echo $text_dir; ?
>" id="field_
<?php
echo ($idindex); ?
>_3
"
620 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>"><?php echo $special_chars; ?></textarea>
624 if (strlen($special_chars) > 32000) {
625 echo ' <td bgcolor="' . $bgcolor . '">' . $strTextAreaLength . '</td>' . "\n
";
628 else if ($type == 'enum') {
629 $enum = PMA_getEnumSetOptions($row_table_def['Type']);
630 $enum_cnt = count($enum);
632 <td bgcolor="<?php
echo $bgcolor; ?
>">
633 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="enum
" />
634 <input type="hidden
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="" />
636 echo "\n
" . ' ' . $backup_field;
638 // show dropdown or radio depend on length
639 if (strlen($row_table_def['Type']) > 20) {
642 <select name="field_
<?php
echo md5($field); ?
><?php
echo $vkey; ?
>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>" id="field_
<?php
echo ($idindex); ?
>_3
">
643 <option value=""></option>
647 for ($j = 0; $j < $enum_cnt; $j++) {
648 // Removes automatic MySQL escape format
649 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
651 //echo '<option value="' . htmlspecialchars($enum_atom) . '"';
652 echo '<option value="' . urlencode($enum_atom) . '"';
653 if ($data == $enum_atom
654 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
655 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
656 echo ' selected="selected
"';
658 echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n
";
667 for ($j = 0; $j < $enum_cnt; $j++) {
668 // Removes automatic MySQL escape format
669 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
671 echo '<input type="radio
" name="field_
' . md5($field) . $vkey . '[]" value="' . urlencode($enum_atom) . '" id="field_
' . ($idindex) . '_3_
' . $j . '" onclick="if (typeof(document
.forms
[\'insertForm\'
].elements
[\'fields_null
' . str_replace('"', '\"', $vkey) . '[' . urlencode($field) . ']\']) != \'undefined\') {document.forms[\'insertForm\'].elements[\'fields_null' . str_replace('"', '\"
', $vkey) . '[' . urlencode($field) .']\'].checked
= false}"';
672 if ($data == $enum_atom
673 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
674 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
675 echo ' checked="checked
"';
677 echo 'tabindex="' . ($tabindex + $tabindex_for_value) . '" />';
678 echo '<label for="field_
' . $idindex . '_3_
' . $j . '">' . htmlspecialchars($enum_atom) . '</label>' . "\n
";
688 else if ($type == 'set') {
689 $set = PMA_getEnumSetOptions($row_table_def['Type']);
694 for ($vals = explode(',', $data); list($t, $k) = each($vals);) {
697 $countset = count($set);
698 $size = min(4, $countset);
700 <td bgcolor="<?php
echo $bgcolor; ?
>">
701 <?php echo $backup_field . "\n
"; ?>
702 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="set
" />
703 <input type="hidden
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="" />
704 <select name="field_
<?php
echo md5($field); ?
><?php
echo $vkey; ?
>[]" size="<?php
echo $size; ?
>" multiple="multiple
" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>" id="field_
<?php
echo ($idindex); ?
>_3
">
707 for ($j = 0; $j < $countset; $j++) {
709 //echo '<option value="'. htmlspecialchars($set[$j]) . '"';
710 echo '<option value="'. urlencode($set[$j]) . '"';
711 if (isset($vset[$set[$j]]) && $vset[$set[$j]]) {
712 echo ' selected="selected
"';
714 echo '>' . htmlspecialchars($set[$j]) . '</option>' . "\n
";
721 // Change by Bernard M. Piller <bernard@bmpsystems.com>
722 // We don't want binary data destroyed
723 else if ($is_binary || $is_blob) {
724 if (($cfg['ProtectBinary'] && $is_blob)
725 || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
728 <td bgcolor="<?php
echo $bgcolor; ?
>">
730 echo $strBinaryDoNotEdit;
732 $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
733 echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
738 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="protected" />
739 <input type="hidden
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="" />
741 } else if ($is_blob) {
744 <td bgcolor="<?php
echo $bgcolor; ?
>">
745 <?php echo $backup_field . "\n
"; ?>
746 <textarea name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" rows="<?php
echo $cfg['TextareaRows']; ?
>" cols="<?php
echo $cfg['TextareaCols']; ?
>" dir="<?php
echo $text_dir; ?
>" id="field_
<?php
echo ($idindex); ?
>_3
"
747 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>" ><?php echo $special_chars; ?></textarea>
752 $fieldsize = $maxlength = 4;
754 $fieldsize = (($len > 40) ? 40 : $len);
759 <td bgcolor="<?php
echo $bgcolor; ?
>">
760 <?php echo $backup_field . "\n
"; ?>
761 <input type="text
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="<?php
echo $special_chars; ?
>" size="<?php
echo $fieldsize; ?
>" maxlength="<?php
echo $maxlength; ?
>" class="textfield
" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>" id="field_
<?php
echo ($idindex); ?
>_3
" />
763 } // end if...elseif...else
765 // Upload choice (only for BLOBs because the binary
766 // attribute does not imply binary contents)
767 // (displayed whatever value the ProtectBinary has)
769 if ($is_upload && $is_blob) {
771 echo '<input type="file
" name="fields_upload_
' . urlencode($field) . $vkey . '" class="textfield
" id="field_
' . ($idindex) . '_3
" size="10" /> ';
773 // find maximum upload size, based on field type
774 // FIXME: with functions this is not so easy, as you can basically process any data with function like MD5
775 $max_field_sizes = array(
778 'mediumblob' => '16777216',
779 'longblob' => '4294967296'); // yeah, really
781 $this_field_max_size = $max_upload_size; // from PHP max
782 if ($this_field_max_size > $max_field_sizes[$type]) {
783 $this_field_max_size = $max_field_sizes[$type];
785 echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n
";
786 // do not generate here the MAX_FILE_SIZE, because we should
787 // put only one in the form to accommodate the biggest field
788 if ($this_field_max_size > $biggest_max_file_size) {
789 $biggest_max_file_size = $this_field_max_size;
793 if (!empty($cfg['UploadDir'])) {
794 $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']));
795 if ($files === FALSE) {
796 echo ' <font color="red
">' . $strError . '</font><br />' . "\n
";
797 echo ' ' . $strWebServerUploadDirectoryError . "\n
";
798 } elseif (!empty($files)) {
800 echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . ':<br />' . "\n
";
801 echo ' <select size="1" name="fields_uploadlocal_
' . urlencode($field) . $vkey . '">' . "\n
";
802 echo ' <option value="" selected="selected
"></option>' . "\n
";
804 echo ' </select>' . "\n
";
806 } // end if (web-server upload directory)
810 } // end else if ( binary or blob)
812 // For char or varchar, respect the maximum length (M); for other
813 // types (int or float), the length is not a limit on the values that
814 // can be entered, so let's be generous (20) (we could also use the
815 // real limits for each numeric type)
816 // 2004-04-07, it turned out that 20 was not generous enough
819 $fieldsize = (($len > 40) ? 40 : $len);
825 } // end if... else...
828 <td bgcolor="<?php
echo $bgcolor; ?
>">
829 <?php echo $backup_field . "\n
"; ?>
831 if ($is_char && isset($cfg['CharEditing']) && ($cfg['CharEditing'] == 'textarea')) {
834 <textarea name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" rows="<?php
echo $cfg['CharTextareaRows']; ?
>" cols="<?php
echo $cfg['CharTextareaCols']; ?
>" dir="<?php
echo $text_dir; ?
>" id="field_
<?php
echo ($idindex); ?
>_3
"
835 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>" ><?php echo $special_chars; ?></textarea>
840 <input type="text
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="<?php
echo $special_chars; ?
>" size="<?php
echo $fieldsize; ?
>" maxlength="<?php
echo $maxlength; ?
>" class="textfield
" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>" id="field_
<?php
echo ($idindex); ?
>_3
" />
842 if ($row_table_def['Extra'] == 'auto_increment') {
844 <input type="hidden
" name="auto_increment
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="1" />
847 if ($type == 'date' || $type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
849 <script type="text
/javascript
">
851 document.write('<a title="<?php
echo $strCalendar;?
>" href="javascript
:openCalendar(\'<?php
echo PMA_generate_common_url();?
>\', \'insertForm\'
, \'field_
<?php
echo ($idindex); ?
>_3\'
, \'<?php
echo (PMA_MYSQL_INT_VERSION
>= 40100 && substr($type, 0, 9) == 'timestamp') ?
'datetime' : substr($type, 0, 9); ?
>\')"><img class="calendar
" src="<?php
echo $pmaThemeImage; ?
>b_calendar
.png
" alt="<?php
echo $strCalendar; ?
>"/></a>');
869 echo ' </table><br />';
870 } // end foreach on multi-edit
874 <table border="0" cellpadding="5" cellspacing="0">
876 <td valign="middle
" nowrap="nowrap
">
877 <select name="submit_type
">
879 if (isset($primary_key)) {
881 <option value="<?php
echo $strSave; ?
>" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
1); ?
>"><?php echo $strSave; ?></option>
885 <option value="<?php
echo $strInsertAsNewRow; ?
>" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
2); ?
>"><?php echo $strInsertAsNewRow; ?></option>
890 // Defines whether "insert another
new row
" should be
891 // selected or not (keep this choice sticky)
892 if (!empty($disp_message)) {
893 $selected_after_insert_new_insert = ' selected="selected
"';
894 $selected_after_insert_back = '';
896 $selected_after_insert_back = ' selected="selected
"';
897 $selected_after_insert_new_insert = '';
902 <b><?php echo $strAndThen; ?></b>
904 <td valign="middle
" nowrap="nowrap
">
905 <select name="after_insert
">
906 <option value="back
" <?php echo $selected_after_insert_back; ?>><?php echo $strAfterInsertBack; ?></option>
907 <option value="new_insert
" <?php echo $selected_after_insert_new_insert; ?>><?php echo $strAfterInsertNewInsert; ?></option>
909 if (isset($primary_key))
911 <option value="same_insert
"><?php echo $strAfterInsertSame; ?></option>
913 // If we have just numeric primary key, we can also edit next
914 if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $primary_key)) {
916 <option value="edit_next
"><?php echo $strAfterInsertNext; ?></option>
927 <?php echo PMA_showHint($strUseTabKey); ?>
929 <td colspan="3" align="right
" valign="middle
">
930 <input type="submit
" value="<?php
echo $strGo; ?
>" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
6); ?
>" id="buttonYes
" />
931 <input type="reset
" value="<?php
echo $strReset; ?
>" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
7); ?
>" />
935 <?php if ($biggest_max_file_size > 0) {
936 echo ' ' . PMA_generateHiddenMaxFileSize($biggest_max_file_size) . "\n
";
944 * Displays the footer
947 require_once('./footer.inc.php');