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/grab_globals.lib.php');
9 $js_to_run = 'tbl_change.js';
10 require_once('./header.inc.php');
11 require_once('./libraries/relation.lib.php'); // foreign keys
15 * Displays the query submitted and its result
17 if (!empty($disp_message)) {
20 $goto = 'tbl_properties.php?'
21 . PMA_generate_common_url($db, $table)
22 . '&$show_query=1'
23 . '&sql_query=' . (isset($disp_query) ?
urlencode($disp_query) : '');
27 if (isset($sql_query)) {
28 $sql_query_cpy = $sql_query;
31 if (isset($disp_query)) {
32 $sql_query = $disp_query;
34 PMA_showMessage($disp_message);
35 if (isset($goto_cpy)) {
39 if (isset($sql_query_cpy)) {
40 $sql_query = $sql_query_cpy;
41 unset($sql_query_cpy);
47 * Defines the url to return to in case of error in a sql statement
50 $goto = 'db_details.php';
52 if (!preg_match('@^(db_details|tbl_properties|tbl_select|ldi_table)@', $goto)) {
53 $err_url = $goto . "?" . PMA_generate_common_url($db) . "&sql_query=" . urlencode($sql_query);
55 $err_url = $goto . '?'
56 . PMA_generate_common_url($db)
57 . ((preg_match('@^(tbl_properties|tbl_select)@', $goto)) ?
'&table=' . urlencode($table) : '');
62 * Ensures db and table are valid, else moves to the "parent" script
64 require('./libraries/db_table_exists.lib.php');
68 * Sets parameters for links
70 $url_query = PMA_generate_common_url($db, $table)
71 . '&goto=tbl_properties.php';
73 require('./tbl_properties_table_info.php');
77 $comments_map = array();
79 if ($GLOBALS['cfg']['ShowPropertyComments']) {
80 require_once('./libraries/relation.lib.php');
81 require_once('./libraries/transformations.lib.php');
83 $cfgRelation = PMA_getRelationsParam();
85 if ($cfgRelation['commwork']) {
86 $comments_map = PMA_getComments($db, $table);
91 * Displays top menu links
93 require('./tbl_properties_links.php');
96 * Get the list of the fields of the current table
98 PMA_DBI_select_db($db);
99 $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE
);
100 if (isset($primary_key)) {
101 if (is_array($primary_key)) {
102 $primary_key_array = $primary_key;
104 $primary_key_array = array(0 => $primary_key);
109 foreach ($primary_key_array AS $rowcount => $primary_key) {
110 $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';';
111 $result[$rowcount] = PMA_DBI_query($local_query, NULL, PMA_DBI_QUERY_STORE
);
112 $row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]);
113 $primary_keys[$rowcount] = $primary_key;
116 if (!$row[$rowcount]) {
117 unset($row[$rowcount]);
118 unset($primary_key_array[$rowcount]);
120 $goto = 'tbl_properties.php?'
121 . PMA_generate_common_url($db, $table)
122 . '&$show_query=1'
123 . '&sql_query=' . urlencode($local_query);
124 if (isset($sql_query)) {
125 $sql_query_cpy = $sql_query;
128 $sql_query = $local_query;
129 PMA_showMessage($strEmptyResultSet);
132 if (isset($sql_query_cpy)) {
133 $sql_query = $sql_query_cpy;
134 unset($sql_query_cpy);
137 require_once('./footer.inc.php');
138 } // end if (no record returned)
141 $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;', NULL, PMA_DBI_QUERY_STORE
);
146 // retrieve keys into foreign fields, if any
147 $cfgRelation = PMA_getRelationsParam();
148 $foreigners = ($cfgRelation['relwork'] ?
PMA_getForeigners($db, $table) : FALSE);
154 // loic1: autocomplete feature of IE kills the "onchange" event handler and it
155 // must be replaced by the "onpropertychange" one in this case
156 $chg_evt_handler = (PMA_USR_BROWSER_AGENT
== 'IE' && PMA_USR_BROWSER_VER
>= 5)
159 // Had to put the URI because when hosted on an https server,
160 // some browsers send wrongly this form to the http server.
163 <?php
if ($cfg['CtrlArrowsMoving']) { ?
>
164 <!-- Set on key handler
for moving using by Ctrl+arrows
-->
165 <script src
="libraries/keyhandler.js" type
="text/javascript" language
="javascript"></script
>
166 <script type
="text/javascript" language
="javascript">
168 var switch_movement
= 0;
169 document
.onkeydown
= onKeyDownArrowsHandler
;
174 <!-- Change table properties form
-->
175 <form method
="post" action
="tbl_replace.php" name
="insertForm" <?php
if ($is_upload) echo ' enctype="multipart/form-data"'; ?
>>
176 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
177 <input type
="hidden" name
="goto" value
="<?php echo urlencode($goto); ?>" />
178 <input type
="hidden" name
="pos" value
="<?php echo isset($pos) ? $pos : 0; ?>" />
179 <input type
="hidden" name
="session_max_rows" value
="<?php echo isset($session_max_rows) ? $session_max_rows : ''; ?>" />
180 <input type
="hidden" name
="disp_direction" value
="<?php echo isset($disp_direction) ? $disp_direction : ''; ?>" />
181 <input type
="hidden" name
="repeat_cells" value
="<?php echo isset($repeat_cells) ? $repeat_cells : ''; ?>" />
182 <input type
="hidden" name
="dontlimitchars" value
="<?php echo (isset($dontlimitchars) ? $dontlimitchars : 0); ?>" />
183 <input type
="hidden" name
="err_url" value
="<?php echo urlencode($err_url); ?>" />
184 <input type
="hidden" name
="sql_query" value
="<?php echo isset($sql_query) ? urlencode($sql_query) : ''; ?>" />
185 <input type
="hidden" name
="reload" value
="1" />
187 if (isset($primary_key_array)) {
188 foreach ($primary_key_array AS $primary_key) {
190 <input type
="hidden" name
="primary_key[]" value
="<?php echo urlencode($primary_key); ?>" />
196 if ($cfg['PropertiesIconic'] == true) {
197 // We need to copy the value or else the == 'both' check will always return true
198 $propicon = (string)$cfg['PropertiesIconic'];
200 if ($propicon == 'both') {
201 $iconic_spacer = '<div class="nowrap">';
206 $titles['Browse'] = $iconic_spacer . '<img width="16" height="16" src="' . $pmaThemeImage . 'b_browse.png" alt="' . $strBrowseForeignValues . '" title="' . $strBrowseForeignValues . '" border="0" />';
208 if ($propicon == 'both') {
209 $titles['Browse'] .= ' ' . $strBrowseForeignValues . '</div>';
212 $titles['Browse'] = $strBrowseForeignValues;
215 // Set if we passed the first timestamp field
217 $fields_cnt = PMA_DBI_num_rows($table_def);
219 // Set a flag here because the 'if' would not be valid in the loop
220 // if we set a value in some field
221 $insert_mode = (!isset($row) ?
TRUE : FALSE);
223 $loop_array = array();
224 for ($i = 0; $i < $cfg['InsertRows']; $i++
) $loop_array[] = FALSE;
229 while ($trow = PMA_DBI_fetch_assoc($table_def)) {
230 $trow_table_def[] = $trow;
234 $tabindex_for_function = +
1000;
235 $tabindex_for_null = +
2000;
236 $tabindex_for_value = 0;
238 foreach ($loop_array AS $vrowcount => $vrow) {
239 if ($vrow === FALSE) {
244 $jsvkey = $vrowcount;
245 $browse_foreigners_uri = '&pk=' . $vrowcount;
247 $jsvkey = urlencode($primary_keys[$vrowcount]);
248 $browse_foreigners_uri = '&pk=' . urlencode($primary_keys[$vrowcount]);
250 $vkey = '[multi_edit][' . $jsvkey . ']';
252 $vresult = (isset($result) && is_array($result) && isset($result[$vrowcount]) ?
$result[$vrowcount] : $result);
253 if ($insert_mode && $vrowcount > 0) {
254 echo '<input type="checkbox" checked="checked" name="insert_ignore_' . $vrowcount . '" id="insert_ignore_check_' . $vrowcount . '" />';
255 echo '<label for="insert_ignore_check_' . $vrowcount . '">' . $strIgnore . '</label><br />' . "\n";
258 <table border
="<?php echo $cfg['Border']; ?>" cellpadding
="2" cellspacing
="1">
260 <th
><?php
echo $strField; ?
></th
>
261 <th
><?php
echo $strType; ?
></th
>
263 if ($cfg['ShowFunctionFields']) {
264 echo ' <th>' . $strFunction . '</th>' . "\n";
267 <th
><?php
echo $strNull; ?
></th
>
268 <th
><?php
echo $strValue; ?
></th
>
272 // garvin: For looping on multiple rows, we need to reset any variable used inside the loop to indicate sth.
274 unset($first_timestamp);
276 // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one)
277 $m_rows = $o_rows +
1;
279 for ($i = 0; $i < $fields_cnt; $i++
) {
280 // Display the submit button after every 15 lines --swix
281 // (wanted to use an <a href="#bottom"> and <a name> instead,
282 // but it didn't worked because of the <base href>)
284 if ((($o_rows * $fields_cnt +
$i) %
15 == 0) && ($i +
$o_rows != 0)) {
287 <th colspan
="5" align
="right" class="tblFooters">
288 <input type
="submit" value
="<?php echo $strGo; ?>" /> 
;
295 $row_table_def = $trow_table_def[$i];
296 $row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']);
298 $field = $row_table_def['Field'];
300 // removed previous PHP3-workaround that caused a problem with
301 // field names like '000'
306 // loic1: current date should not be set as default if the field is NULL
307 // for the current row
308 // lem9: but do not put here the current datetime if there is a default
309 // value (the real default value will be set in the
310 // Default value logic below)
312 // Note: (tested in MySQL 4.0.16): when lang is some UTF-8,
313 // $row_table_def['Default'] is not set if it contains NULL:
314 // Array ( [Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime )
315 // but, look what we get if we switch to iso: (Default is NULL)
316 // Array ( [Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime )
317 // so I force a NULL into it (I don't think it's possible
318 // to have an empty default value for DATETIME)
319 // then, the "if" after this one will work
320 if ($row_table_def['Type'] == 'datetime'
321 && !isset($row_table_def['Default'])
322 && isset($row_table_def['Null'])
323 && $row_table_def['Null'] == 'YES') {
324 $row_table_def['Default'] = NULL;
327 if ($row_table_def['Type'] == 'datetime'
328 && (!isset($row_table_def['Default']))
329 && (!is_null($row_table_def['Default']))) {
333 $vrow[$rowfield] = date('Y-m-d H:i:s', time());
335 $vrow = array($rowfield => date('Y-m-d H:i:s', time()));
338 // UPDATE case with an empty and not NULL value under PHP4
339 else if (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) {
340 $vrow[$rowfield] = date('Y-m-d H:i:s', time());
341 } // end if... else if...
343 $len = (preg_match('@float|double@', $row_table_def['Type']))
345 : PMA_DBI_field_len($vresult, $i);
346 $first_timestamp = 0;
348 $field_name = htmlspecialchars($field);
349 if (isset($comments_map[$field])) {
350 $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$field]) . '">' . $field_name . '</span>';
353 $bgcolor = ($i %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
356 <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
>
361 $is_binary = stristr($row_table_def['Type'], ' binary');
362 $is_blob = stristr($row_table_def['Type'], 'blob');
363 $is_char = stristr($row_table_def['Type'], 'char');
364 switch ($row_table_def['True_Type']) {
374 if (!$timestamp_seen) { // can only occur once per table
376 $first_timestamp = 1;
378 $type = $row_table_def['Type'];
379 $type_nowrap = ' nowrap="nowrap"';
383 $type = $row_table_def['Type'];
384 $type_nowrap = ' nowrap="nowrap"';
388 <td align
="center" bgcolor
="<?php echo $bgcolor; ?>"<?php
echo $type_nowrap; ?
>>
394 // Prepares the field value
395 $real_null_value = FALSE;
397 if (!isset($vrow[$rowfield])
398 ||
(function_exists('is_null') && is_null($vrow[$rowfield]))) {
399 $real_null_value = TRUE;
400 $vrow[$rowfield] = '';
402 $data = $vrow[$rowfield];
404 // loic1: special binary "characters"
405 if ($is_binary ||
$is_blob) {
406 $vrow[$rowfield] = str_replace("\x00", '\0', $vrow[$rowfield]);
407 $vrow[$rowfield] = str_replace("\x08", '\b', $vrow[$rowfield]);
408 $vrow[$rowfield] = str_replace("\x0a", '\n', $vrow[$rowfield]);
409 $vrow[$rowfield] = str_replace("\x0d", '\r', $vrow[$rowfield]);
410 $vrow[$rowfield] = str_replace("\x1a", '\Z', $vrow[$rowfield]);
412 $special_chars = htmlspecialchars($vrow[$rowfield]);
413 $data = $vrow[$rowfield];
414 } // end if... else...
415 // loic1: if a timestamp field value is not included in an update
416 // statement MySQL auto-update it to the current timestamp
417 $backup_field = ($row_table_def['True_Type'] == 'timestamp')
419 : '<input type="hidden" name="fields_prev' . $vkey . '[' . urlencode($field) . ']" value="' . urlencode($vrow[$rowfield]) . '" />';
421 // loic1: display default values
422 if (!isset($row_table_def['Default'])) {
423 $row_table_def['Default'] = '';
424 $real_null_value = TRUE;
427 $data = $row_table_def['Default'];
429 $special_chars = htmlspecialchars($row_table_def['Default']);
433 $idindex = ($o_rows * $fields_cnt) +
$i +
1;
434 $tabindex = (($idindex - 1) * 3) +
1;
436 // The function column
437 // -------------------
438 // Change by Bernard M. Piller <bernard@bmpsystems.com>
439 // We don't want binary data to be destroyed
440 // Note: from the MySQL manual: "BINARY doesn't affect how the column is
441 // stored or retrieved" so it does not mean that the contents is
443 if ($cfg['ShowFunctionFields']) {
444 if (($cfg['ProtectBinary'] && $is_blob)
445 ||
($cfg['ProtectBinary'] == 'all' && $is_binary)) {
446 echo ' <td align="center" bgcolor="'. $bgcolor . '">' . $strBinary . '</td>' . "\n";
447 } else if (strstr($row_table_def['True_Type'], 'enum') ||
strstr($row_table_def['True_Type'], 'set')) {
448 echo ' <td align="center" bgcolor="'. $bgcolor . '">--</td>' . "\n";
451 <td bgcolor
="<?php echo $bgcolor; ?>">
452 <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">
458 // garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR'
459 // or something similar. Then directly look up the entry in the RestrictFunctions array,
460 // which will then reveal the available dropdown options
461 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'])]])) {
462 $current_func_type = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])];
463 $dropdown = $cfg['RestrictFunctions'][$current_func_type];
464 $default_function = $cfg['DefaultFunctions'][$current_func_type];
467 $default_function = '';
470 $dropdown_built = array();
471 $op_spacing_needed = FALSE;
473 // garvin: loop on the dropdown array and print all available options for that field.
474 $cnt_dropdown = count($dropdown);
475 for ($j = 0; $j < $cnt_dropdown; $j++
) {
476 // Is current function defined as default?
477 $selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp'])
478 ||
(!$first_timestamp && $dropdown[$j] == $default_function)
479 ?
' selected="selected"'
482 echo '<option' . $selected . '>' . $dropdown[$j] . '</option>' . "\n";
483 $dropdown_built[$dropdown[$j]] = 'TRUE';
484 $op_spacing_needed = TRUE;
487 // garvin: For compatibility's sake, do not let out all other functions. Instead
488 // print a seperator (blank) and then show ALL functions which weren't shown
490 $cnt_functions = count($cfg['Functions']);
491 for ($j = 0; $j < $cnt_functions; $j++
) {
492 if (!isset($dropdown_built[$cfg['Functions'][$j]]) ||
$dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
493 // Is current function defined as default?
494 $selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp'])
495 ||
(!$first_timestamp && $cfg['Functions'][$j] == $default_function)
496 ?
' selected="selected"'
498 if ($op_spacing_needed == TRUE) {
500 echo '<option value="">--------</option>' . "\n";
501 $op_spacing_needed = FALSE;
505 echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";
514 } // end if ($cfg['ShowFunctionFields'])
519 echo ' <td bgcolor="' . $bgcolor . '">' . "\n";
520 if (!(($cfg['ProtectBinary'] && $is_blob) ||
($cfg['ProtectBinary'] == 'all' && $is_binary))
521 && $row_table_def['Null'] == 'YES') {
522 echo ' <input type="checkbox" tabindex="' . ($tabindex +
$tabindex_for_null) . '"'
523 . ' name="fields_null' . $vkey . '[' . urlencode($field) . ']"';
524 if ($real_null_value && !$first_timestamp) {
525 echo ' checked="checked"';
527 echo ' id="field_' . ($idindex) . '_2"';
528 $onclick = ' onclick="if (this.checked) {nullify(';
529 if (strstr($row_table_def['True_Type'], 'enum')) {
530 if (strlen($row_table_def['Type']) > 20) {
535 } else if (strstr($row_table_def['True_Type'], 'set')) {
537 } else if ($foreigners && isset($foreigners[$field])) {
542 $onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\', \'' . $vkey . '\'); this.checked = true}; return true" />' . "\n";
545 echo ' ' . "\n";
547 echo ' </td>' . "\n";
549 // The value column (depends on type)
552 require('./libraries/get_foreign.lib.php');
554 if (isset($foreign_link) && $foreign_link == true) {
556 <td bgcolor
="<?php echo $bgcolor; ?>">
557 <?php
echo $backup_field . "\n"; ?
>
558 <input type
="hidden" name
="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value
="foreign" />
559 <input type
="hidden" name
="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value
="" id
="field_<?php echo ($idindex); ?>_1" />
560 <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); ?>" />
561 <script type
="text/javascript" language
="javascript">
562 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>');
566 } else if (isset($disp_row) && is_array($disp_row)) {
568 <td bgcolor="<?php
echo $bgcolor; ?
>">
569 <?php echo $backup_field . "\n
"; ?>
570 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="foreign
" />
571 <input type="hidden
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="" id="field_
<?php
echo $idindex; ?
>_1
" />
572 <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
">
573 <?php echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data, $cfg['ForeignKeyMaxLimit']); ?>
579 else if ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
581 <td bgcolor="<?php
echo $bgcolor; ?
>"> </td>
584 <td colspan="4" align="right
" bgcolor="<?php
echo $bgcolor; ?
>">
585 <?php echo $backup_field . "\n
"; ?>
586 <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
"
587 <?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>
591 else if (strstr($type, 'text')) {
593 <td bgcolor="<?php
echo $bgcolor; ?
>">
594 <?php echo $backup_field . "\n
"; ?>
595 <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
"
596 <?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>
600 if (strlen($special_chars) > 32000) {
601 echo ' <td bgcolor="' . $bgcolor . '">' . $strTextAreaLength . '</td>' . "\n
";
604 else if ($type == 'enum') {
605 $enum = PMA_getEnumSetOptions($row_table_def['Type']);
606 $enum_cnt = count($enum);
608 <td bgcolor="<?php
echo $bgcolor; ?
>">
609 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="enum
" />
610 <input type="hidden
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="" />
612 echo "\n
" . ' ' . $backup_field;
614 // show dropdown or radio depend on length
615 if (strlen($row_table_def['Type']) > 20) {
618 <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
">
619 <option value=""></option>
623 for ($j = 0; $j < $enum_cnt; $j++) {
624 // Removes automatic MySQL escape format
625 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
627 //echo '<option value="' . htmlspecialchars($enum_atom) . '"';
628 echo '<option value="' . urlencode($enum_atom) . '"';
629 if ($data == $enum_atom
630 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
631 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
632 echo ' selected="selected
"';
634 echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n
";
643 for ($j = 0; $j < $enum_cnt; $j++) {
644 // Removes automatic MySQL escape format
645 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
647 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}"';
648 if ($data == $enum_atom
649 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
650 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
651 echo ' checked="checked
"';
653 echo 'tabindex="' . ($tabindex + $tabindex_for_value) . '" />';
654 echo '<label for="field_
' . $idindex . '_3_
' . $j . '">' . htmlspecialchars($enum_atom) . '</label>' . "\n
";
664 else if ($type == 'set') {
665 $set = PMA_getEnumSetOptions($row_table_def['Type']);
670 for ($vals = explode(',', $data); list($t, $k) = each($vals);) {
673 $countset = count($set);
674 $size = min(4, $countset);
676 <td bgcolor="<?php
echo $bgcolor; ?
>">
677 <?php echo $backup_field . "\n
"; ?>
678 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="set
" />
679 <input type="hidden
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="" />
680 <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
">
683 for ($j = 0; $j < $countset; $j++) {
685 //echo '<option value="'. htmlspecialchars($set[$j]) . '"';
686 echo '<option value="'. urlencode($set[$j]) . '"';
687 if (isset($vset[$set[$j]]) && $vset[$set[$j]]) {
688 echo ' selected="selected
"';
690 echo '>' . htmlspecialchars($set[$j]) . '</option>' . "\n
";
697 // Change by Bernard M. Piller <bernard@bmpsystems.com>
698 // We don't want binary data destroyed
699 else if ($is_binary || $is_blob) {
700 if (($cfg['ProtectBinary'] && $is_blob)
701 || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
704 <td bgcolor="<?php
echo $bgcolor; ?
>">
706 echo $strBinaryDoNotEdit;
708 $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
709 echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
714 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="protected" />
715 <input type="hidden
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="" />
717 } else if ($is_blob) {
720 <td bgcolor="<?php
echo $bgcolor; ?
>">
721 <?php echo $backup_field . "\n
"; ?>
722 <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
"
723 <?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>
728 $fieldsize = $maxlength = 4;
730 $fieldsize = (($len > 40) ? 40 : $len);
735 <td bgcolor="<?php
echo $bgcolor; ?
>">
736 <?php echo $backup_field . "\n
"; ?>
737 <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
" />
739 } // end if...elseif...else
741 // Upload choice (only for BLOBs because the binary
742 // attribute does not imply binary contents)
743 // (displayed whatever value the ProtectBinary has)
745 if ($is_upload && $is_blob) {
746 echo '<input type="file
" name="fields_upload_
' . urlencode($field) . $vkey . '" class="textfield
" id="field_
' . ($idindex) . '_3
" size="10" /> ';
748 // find maximum upload size, based on field type
749 $max_field_sizes = array(
752 'mediumblob' => '16777216',
753 'longblob' => '4294967296'); // yeah, really
755 $this_field_max_size = $max_upload_size; // from PHP max
756 if ($this_field_max_size > $max_field_sizes[$type]) {
757 $this_field_max_size = $max_field_sizes[$type];
759 echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n
";
760 echo ' ' . PMA_generateHiddenMaxFileSize($this_field_max_size) . "\n
";
763 if (!empty($cfg['UploadDir'])) {
764 if (substr($cfg['UploadDir'], -1) != '/') {
765 $cfg['UploadDir'] .= '/';
767 if ($handle = @opendir($cfg['UploadDir'])) {
769 while ($file = @readdir($handle)) {
770 if (is_file($cfg['UploadDir'] . $file) && !PMA_checkFileExtensions($file, '.sql')) {
771 if ($is_first == 0) {
773 echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . ':<br />' . "\n
";
774 echo ' <select size="1" name="fields_uploadlocal_
' . urlencode($field) . $vkey . '">' . "\n
";
775 echo ' <option value="" selected="selected
"></option>' . "\n
";
776 } // end if (is_first)
777 echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n
";
779 } // end if (is_file)
782 echo ' </select>' . "\n
";
783 } // end if (isfirst > 0)
786 echo ' <font color="red
">' . $strError . '</font><br />' . "\n
";
787 echo ' ' . $strWebServerUploadDirectoryError . "\n
";
789 } // end if (web-server upload directory)
793 } // end else if ( binary or blob)
795 // For char or varchar, respect the maximum length (M); for other
796 // types (int or float), the length is not a limit on the values that
797 // can be entered, so let's be generous (20) (we could also use the
798 // real limits for each numeric type)
799 // 2004-04-07, it turned out that 20 was not generous enough
802 $fieldsize = (($len > 40) ? 40 : $len);
808 } // end if... else...
811 <td bgcolor="<?php
echo $bgcolor; ?
>">
812 <?php echo $backup_field . "\n
"; ?>
814 if ($is_char && isset($cfg['CharEditing']) && ($cfg['CharEditing'] == 'textarea')) {
817 <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
"
818 <?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>
823 <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
" />
825 if ($type == 'date' || $type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
827 <script type="text
/javascript
">
829 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>');
847 echo ' </table><br />';
848 } // end foreach on multi-edit
852 <table border="0" cellpadding="5" cellspacing="0">
854 <td valign="middle
" nowrap="nowrap
">
855 <select name="submit_type
">
857 if (isset($primary_key)) {
859 <option value="<?php
echo $strSave; ?
>" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
1); ?
>"><?php echo $strSave; ?></option>
863 <option value="<?php
echo $strInsertAsNewRow; ?
>" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
2); ?
>"><?php echo $strInsertAsNewRow; ?></option>
868 // Defines whether "insert another
new row
" should be
869 // selected or not (keep this choice sticky)
870 if (!empty($disp_message)) {
871 $selected_after_insert_new_insert = ' selected="selected
"';
872 $selected_after_insert_back = '';
874 $selected_after_insert_back = ' selected="selected
"';
875 $selected_after_insert_new_insert = '';
880 <b><?php echo $strAndThen; ?></b>
882 <td valign="middle
" nowrap="nowrap
">
883 <select name="after_insert
">
884 <option value="back
" <?php echo $selected_after_insert_back; ?>><?php echo $strAfterInsertBack; ?></option>
885 <option value="new_insert
" <?php echo $selected_after_insert_new_insert; ?>><?php echo $strAfterInsertNewInsert; ?></option>
887 if (isset($primary_key))
889 <option value="same_insert
"><?php echo $strAfterInsertSame; ?></option>
891 // If we have just numeric primary key, we can also edit next
892 if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $primary_key)) {
894 <option value="edit_next
"><?php echo $strAfterInsertNext; ?></option>
905 <?php echo PMA_showHint($strUseTabKey); ?>
907 <td colspan="3" align="right
" valign="middle
">
908 <input type="submit
" value="<?php
echo $strGo; ?
>" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
6); ?
>" id="buttonYes
" />
909 <input type="reset
" value="<?php
echo $strReset; ?
>" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
7); ?
>" />
919 * Displays the footer
922 require_once('./footer.inc.php');