Documentation TYPO3 par Ameos |
00001 <?php 00002 /* $Id: tbl_change.php,v 2.10 2004/01/05 16:56:46 garvinhicking Exp $ */ 00003 // vim: expandtab sw=4 ts=4 sts=4: 00004 00005 00009 require_once('./libraries/grab_globals.lib.php'); 00010 $js_to_run = 'tbl_change.js'; 00011 require_once('./header.inc.php'); 00012 require_once('./libraries/relation.lib.php'); // foreign keys 00013 00014 00018 if (!empty($disp_message)) { 00019 if (isset($goto)) { 00020 $goto_cpy = $goto; 00021 $goto = 'tbl_properties.php?' 00022 . PMA_generate_common_url($db, $table) 00023 . '&$show_query=1' 00024 . '&sql_query=' . (isset($disp_query) ? urlencode($disp_query) : ''); 00025 } else { 00026 $show_query = '1'; 00027 } 00028 if (isset($sql_query)) { 00029 $sql_query_cpy = $sql_query; 00030 unset($sql_query); 00031 } 00032 if (isset($disp_query)) { 00033 $sql_query = $disp_query; 00034 } 00035 PMA_showMessage($disp_message); 00036 if (isset($goto_cpy)) { 00037 $goto = $goto_cpy; 00038 unset($goto_cpy); 00039 } 00040 if (isset($sql_query_cpy)) { 00041 $sql_query = $sql_query_cpy; 00042 unset($sql_query_cpy); 00043 } 00044 } 00045 00046 00050 if (!isset($goto)) { 00051 $goto = 'db_details.php'; 00052 } 00053 if (!preg_match('@^(db_details|tbl_properties|tbl_select)@', $goto)) { 00054 $err_url = $goto . "?" . PMA_generate_common_url($db) . "&sql_query=" . urlencode($sql_query); 00055 } else { 00056 $err_url = $goto . '?' 00057 . PMA_generate_common_url($db) 00058 . ((preg_match('@^(tbl_properties|tbl_select)@', $goto)) ? '&table=' . urlencode($table) : ''); 00059 } 00060 00061 00065 require('./libraries/db_table_exists.lib.php'); 00066 00067 00071 $url_query = PMA_generate_common_url($db, $table) 00072 . '&goto=tbl_properties.php'; 00073 00074 require('./tbl_properties_table_info.php'); 00075 echo '<br />'; 00076 00077 00081 PMA_mysql_select_db($db); 00082 $table_def = PMA_mysql_query('SHOW FIELDS FROM ' . PMA_backquote($table)); 00083 if (isset($primary_key)) { 00084 if (is_array($primary_key)) { 00085 $primary_key_array = $primary_key; 00086 } else { 00087 $primary_key_array = array(0 => $primary_key); 00088 } 00089 00090 $row = array(); 00091 $result = array(); 00092 foreach($primary_key_array AS $rowcount => $primary_key) { 00093 $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key; 00094 $result[$rowcount] = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); 00095 $row[$rowcount] = PMA_mysql_fetch_array($result[$rowcount]); 00096 $primary_keys[$rowcount] = $primary_key; 00097 00098 // No row returned 00099 if (!$row[$rowcount]) { 00100 unset($row[$rowcount]); 00101 unset($primary_key_array[$rowcount]); 00102 $goto_cpy = $goto; 00103 $goto = 'tbl_properties.php?' 00104 . PMA_generate_common_url($db, $table) 00105 . '&$show_query=1' 00106 . '&sql_query=' . urlencode($local_query); 00107 if (isset($sql_query)) { 00108 $sql_query_cpy = $sql_query; 00109 unset($sql_query); 00110 } 00111 $sql_query = $local_query; 00112 PMA_showMessage($strEmptyResultSet); 00113 $goto = $goto_cpy; 00114 unset($goto_cpy); 00115 if (isset($sql_query_cpy)) { 00116 $sql_query = $sql_query_cpy; 00117 unset($sql_query_cpy); 00118 } 00119 } // end if (no record returned) 00120 } 00121 } else { 00122 $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1'; 00123 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); 00124 unset($row); 00125 } 00126 00127 // <markus@noga.de> 00128 // retrieve keys into foreign fields, if any 00129 $cfgRelation = PMA_getRelationsParam(); 00130 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE); 00131 00132 00136 // loic1: autocomplete feature of IE kills the "onchange" event handler and it 00137 // must be replaced by the "onpropertychange" one in this case 00138 $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5) 00139 ? 'onpropertychange' 00140 : 'onchange'; 00141 // Had to put the URI because when hosted on an https server, 00142 // some browsers send wrongly this form to the http server. 00143 ?> 00144 00145 <?php if ($cfg['CtrlArrowsMoving']) { ?> 00146 <!-- Set on key handler for moving using by Ctrl+arrows --> 00147 <script type="text/javascript" language="javascript"> 00148 <!-- 00149 document.onkeydown = onKeyDownArrowsHandler; 00150 // --> 00151 </script> 00152 <?php } ?> 00153 00154 <!-- Change table properties form --> 00155 <form method="post" action="tbl_replace.php" name="insertForm" <?php if ($is_upload) echo ' enctype="multipart/form-data"'; ?>> 00156 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?> 00157 <input type="hidden" name="goto" value="<?php echo $goto; ?>" /> 00158 <input type="hidden" name="pos" value="<?php echo isset($pos) ? $pos : 0; ?>" /> 00159 <input type="hidden" name="session_max_rows" value="<?php echo isset($session_max_rows) ? $session_max_rows : ''; ?>" /> 00160 <input type="hidden" name="disp_direction" value="<?php echo isset($disp_direction) ? $disp_direction : ''; ?>" /> 00161 <input type="hidden" name="repeat_cells" value="<?php echo isset($repeat_cells) ? $repeat_cells : ''; ?>" /> 00162 <input type="hidden" name="dontlimitchars" value="<?php echo (isset($dontlimitchars) ? $dontlimitchars : 0); ?>" /> 00163 <input type="hidden" name="err_url" value="<?php echo urlencode($err_url); ?>" /> 00164 <input type="hidden" name="sql_query" value="<?php echo isset($sql_query) ? urlencode($sql_query) : ''; ?>" /> 00165 <?php 00166 if (isset($primary_key_array)) { 00167 foreach($primary_key_array AS $primary_key) { 00168 ?> 00169 <input type="hidden" name="primary_key[]" value="<?php echo urlencode($primary_key); ?>" /> 00170 <?php 00171 } 00172 } 00173 echo "\n"; 00174 00175 if ($cfg['PropertiesIconic'] == true) { 00176 // We need to copy the value or else the == 'both' check will always return true 00177 $propicon = (string)$cfg['PropertiesIconic']; 00178 00179 if ($propicon == 'both') { 00180 $iconic_spacer = '<nobr>'; 00181 } else { 00182 $iconic_spacer = ''; 00183 } 00184 00185 $titles['Browse'] = $iconic_spacer . '<img width="12" height="13" src="images/button_browse.png" alt="' . $strBrowseForeignValues . '" title="' . $strBrowseForeignValues . '" border="0" />'; 00186 00187 if ($propicon == 'both') { 00188 $titles['Browse'] .= ' ' . $strBrowseForeignValues . '</nobr>'; 00189 } 00190 } else { 00191 $titles['Browse'] = $strBrowseForeignValues; 00192 } 00193 00194 // Set if we passed the first timestamp field 00195 $timestamp_seen = 0; 00196 $fields_cnt = mysql_num_rows($table_def); 00197 00198 // Set a flag here because the 'if' would not be valid in the loop 00199 // if we set a value in some field 00200 $insert_mode = (!isset($row) ? TRUE : FALSE); 00201 $loop_array = (isset($row) ? $row : array(0 => FALSE)); 00202 00203 while ($trow = PMA_mysql_fetch_array($table_def)) { 00204 $trow_table_def[] = $trow; 00205 } 00206 00207 $o_rows = 0; 00208 foreach($loop_array AS $vrowcount => $vrow) { 00209 if ($vrow === FALSE) { 00210 unset($vrow); 00211 } 00212 00213 $vresult = (isset($result) && is_array($result) && isset($result[$vrowcount]) ? $result[$vrowcount] : $result); 00214 ?> 00215 <table border="<?php echo $cfg['Border']; ?>"> 00216 <tr> 00217 <th><?php echo $strField; ?></th> 00218 <th><?php echo $strType; ?></th> 00219 <?php 00220 if ($cfg['ShowFunctionFields']) { 00221 echo ' <th>' . $strFunction . '</th>' . "\n"; 00222 } 00223 ?> 00224 <th><?php echo $strNull; ?></th> 00225 <th><?php echo $strValue; ?></th> 00226 </tr> 00227 <?php 00228 00229 if ($insert_mode) { 00230 $vkey = ''; 00231 $browse_foreigners_uri = ''; 00232 } else { 00233 $vkey = '[multi_edit][' . urlencode($primary_keys[$vrowcount]) . ']'; 00234 $browse_foreigners_uri = '&pk=' . urlencode($primary_keys[$vrowcount]); 00235 } 00236 00237 // garvin: For looping on multiple rows, we need to reset any variable used inside the loop to indicate sth. 00238 $timestamp_seen = 0; 00239 unset($first_timestamp); 00240 00241 // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one) 00242 $m_rows = $o_rows + 1; 00243 00244 for ($i = 0; $i < $fields_cnt; $i++) { 00245 // Display the submit button after every 15 lines --swix 00246 // (wanted to use an <a href="#bottom"> and <a name> instead, 00247 // but it didn't worked because of the <base href>) 00248 00249 if ((($i % 15) == 0) && ($i != 0)) { 00250 ?> 00251 <tr> 00252 <th colspan="5" align="right"> 00253 <input type="submit" value="<?php echo $strGo; ?>" /> 00254 </th> 00255 </tr> 00256 <?php 00257 } // end if 00258 echo "\n"; 00259 00260 $row_table_def = $trow_table_def[$i]; 00261 $row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']); 00262 00263 $field = $row_table_def['Field']; 00264 00265 // garvin: possible workaround. If current field is numerical, do not try to 00266 // access the result-array with its 'associative' key but with its numerical 00267 // represantation. 00268 if (is_numeric($field)) { 00269 $rowfield = $i; 00270 } else { 00271 $rowfield = $field; 00272 } 00273 00274 // d a t e t i m e 00275 // 00276 // loic1: current date should not be set as default if the field is NULL 00277 // for the current row 00278 // lem9: but do not put here the current datetime if there is a default 00279 // value (the real default value will be set in the 00280 // Default value logic below) 00281 if ($row_table_def['Type'] == 'datetime' 00282 && (!isset($row_table_def['Default']))) { 00283 // INSERT case 00284 if ($insert_mode) { 00285 if (isset($vrow)) { 00286 $vrow[$rowfield] = date('Y-m-d H:i:s', time()); 00287 } else { 00288 $vrow = array($rowfield => date('Y-m-d H:i:s', time())); 00289 } 00290 } 00291 // UPDATE case with an empty and not NULL value under PHP4 00292 else if (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) { 00293 $vrow[$rowfield] = date('Y-m-d H:i:s', time()); 00294 } // end if... else if... 00295 } 00296 $len = (preg_match('@float|double@', $row_table_def['Type'])) 00297 ? 100 00298 : @mysql_field_len($vresult, $i); 00299 $first_timestamp = 0; 00300 00301 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; 00302 ?> 00303 <tr> 00304 <td <?php echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ? 'rowspan="2"' : ''); ?> align="center" bgcolor="<?php echo $bgcolor; ?>"><?php echo htmlspecialchars($field); ?></td> 00305 <?php 00306 echo "\n"; 00307 00308 // The type column 00309 $is_binary = stristr($row_table_def['Type'], ' binary'); 00310 $is_blob = stristr($row_table_def['Type'], 'blob'); 00311 $is_char = stristr($row_table_def['Type'], 'char'); 00312 switch ($row_table_def['True_Type']) { 00313 case 'set': 00314 $type = 'set'; 00315 $type_nowrap = ''; 00316 break; 00317 case 'enum': 00318 $type = 'enum'; 00319 $type_nowrap = ''; 00320 break; 00321 case 'timestamp': 00322 if (!$timestamp_seen) { // can only occur once per table 00323 $timestamp_seen = 1; 00324 $first_timestamp = 1; 00325 } 00326 $type = $row_table_def['Type']; 00327 $type_nowrap = ' nowrap="nowrap"'; 00328 break; 00329 00330 default: 00331 $type = $row_table_def['Type']; 00332 $type_nowrap = ' nowrap="nowrap"'; 00333 break; 00334 } 00335 ?> 00336 <td align="center" bgcolor="<?php echo $bgcolor; ?>"<?php echo $type_nowrap; ?>> 00337 <?php echo $type; ?> 00338 </td> 00339 <?php 00340 echo "\n"; 00341 00342 // Prepares the field value 00343 $real_null_value = FALSE; 00344 if (isset($vrow)) { 00345 if (!isset($vrow[$rowfield]) 00346 || (function_exists('is_null') && is_null($vrow[$rowfield]))) { 00347 $real_null_value = TRUE; 00348 $vrow[$rowfield] = ''; 00349 $special_chars = ''; 00350 $data = $vrow[$rowfield]; 00351 } else { 00352 // loic1: special binary "characters" 00353 if ($is_binary || $is_blob) { 00354 $vrow[$rowfield] = str_replace("\x00", '\0', $vrow[$rowfield]); 00355 $vrow[$rowfield] = str_replace("\x08", '\b', $vrow[$rowfield]); 00356 $vrow[$rowfield] = str_replace("\x0a", '\n', $vrow[$rowfield]); 00357 $vrow[$rowfield] = str_replace("\x0d", '\r', $vrow[$rowfield]); 00358 $vrow[$rowfield] = str_replace("\x1a", '\Z', $vrow[$rowfield]); 00359 } // end if 00360 $special_chars = htmlspecialchars($vrow[$rowfield]); 00361 $data = $vrow[$rowfield]; 00362 } // end if... else... 00363 // loic1: if a timestamp field value is not included in an update 00364 // statement MySQL auto-update it to the current timestamp 00365 $backup_field = ($row_table_def['True_Type'] == 'timestamp') 00366 ? '' 00367 : '<input type="hidden" name="fields_prev' . $vkey . '[' . urlencode($field) . ']" value="' . urlencode($vrow[$rowfield]) . '" />'; 00368 } else { 00369 // loic1: display default values 00370 if (!isset($row_table_def['Default'])) { 00371 $row_table_def['Default'] = ''; 00372 $real_null_value = TRUE; 00373 $data = ''; 00374 //$data = 'NULL'; 00375 } else { 00376 $data = $row_table_def['Default']; 00377 } 00378 $special_chars = htmlspecialchars($row_table_def['Default']); 00379 $backup_field = ''; 00380 } 00381 00382 // The function column 00383 // ------------------- 00384 // Change by Bernard M. Piller <bernard@bmpsystems.com> 00385 // We don't want binary data to be destroyed 00386 // Note: from the MySQL manual: "BINARY doesn't affect how the column is 00387 // stored or retrieved" so it does not mean that the contents is 00388 // binary 00389 if ($cfg['ShowFunctionFields']) { 00390 if (($cfg['ProtectBinary'] && $is_blob) 00391 || ($cfg['ProtectBinary'] == 'all' && $is_binary)) { 00392 echo ' <td align="center" bgcolor="'. $bgcolor . '">' . $strBinary . '</td>' . "\n"; 00393 } else if (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) { 00394 echo ' <td align="center" bgcolor="'. $bgcolor . '">--</td>' . "\n"; 00395 } else { 00396 ?> 00397 <td bgcolor="<?php echo $bgcolor; ?>"> 00398 <select name="funcs<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $vkey; ?>')" tabindex="<?php echo ($fields_cnt + ($i * $m_rows) + 1); ?>" id="field_<?php echo $i * $m_rows; ?>_1"> 00399 <option></option> 00400 <?php 00401 echo "\n"; 00402 $selected = ''; 00403 00404 // garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR' 00405 // or something similar. Then directly look up the entry in the RestrictFunctions array, 00406 // which will then reveal the available dropdown options 00407 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'])]])) { 00408 $current_func_type = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]; 00409 $dropdown = $cfg['RestrictFunctions'][$current_func_type]; 00410 $default_function = $cfg['DefaultFunctions'][$current_func_type]; 00411 } else { 00412 $dropdown = array(); 00413 } 00414 00415 $dropdown_built = array(); 00416 $op_spacing_needed = FALSE; 00417 00418 // garvin: loop on the dropdown array and print all available options for that field. 00419 $cnt_dropdown = count($dropdown); 00420 for ($j = 0; $j < $cnt_dropdown; $j++) { 00421 // Is current function defined as default? 00422 $selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp']) 00423 || (!$first_timestamp && $dropdown[$j] == $default_function) 00424 ? ' selected="selected"' 00425 : ''; 00426 echo ' '; 00427 echo '<option' . $selected . '>' . $dropdown[$j] . '</option>' . "\n"; 00428 $dropdown_built[$dropdown[$j]] = 'TRUE'; 00429 $op_spacing_needed = TRUE; 00430 } 00431 00432 // garvin: For compatibility's sake, do not let out all other functions. Instead 00433 // print a seperator (blank) and then show ALL functions which weren't shown 00434 // yet. 00435 $cnt_functions = count($cfg['Functions']); 00436 for ($j = 0; $j < $cnt_functions; $j++) { 00437 if (!isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'TRUE') { 00438 // Is current function defined as default? 00439 $selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp']) 00440 || (!$first_timestamp && $cfg['Functions'][$j] == $default_function) 00441 ? ' selected="selected"' 00442 : ''; 00443 if ($op_spacing_needed == TRUE) { 00444 echo ' '; 00445 echo '<option value="">--------</option>' . "\n"; 00446 $op_spacing_needed = FALSE; 00447 } 00448 00449 echo ' '; 00450 echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n"; 00451 } 00452 } // end for 00453 unset($selected); 00454 ?> 00455 </select> 00456 </td> 00457 <?php 00458 } 00459 } // end if ($cfg['ShowFunctionFields']) 00460 echo "\n"; 00461 00462 // The null column 00463 // --------------- 00464 echo ' <td bgcolor="' . $bgcolor . '">' . "\n"; 00465 if (!(($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary)) 00466 && $row_table_def['Null'] == 'YES') { 00467 echo ' <input type="checkbox" tabindex="' . ((2 * $fields_cnt) + ($i * $m_rows) + 1) . '"' 00468 . ' name="fields_null' . $vkey . '[' . urlencode($field) . ']"'; 00469 //if ($data == 'NULL' && !$first_timestamp) { 00470 if ($real_null_value && !$first_timestamp) { 00471 echo ' checked="checked"'; 00472 } 00473 echo ' id="field_' . ($i * $m_rows) . '_2"'; 00474 $onclick = ' onclick="if (this.checked) {nullify('; 00475 if (strstr($row_table_def['True_Type'], 'enum')) { 00476 if (strlen($row_table_def['Type']) > 20) { 00477 $onclick .= '1, '; 00478 } else { 00479 $onclick .= '2, '; 00480 } 00481 } else if (strstr($row_table_def['True_Type'], 'set')) { 00482 $onclick .= '3, '; 00483 } else if ($foreigners && isset($foreigners[$field])) { 00484 $onclick .= '4, '; 00485 } else { 00486 $onclick .= '5, '; 00487 } 00488 $onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\', \'' . $vkey . '\'); this.checked = true}; return true" />' . "\n"; 00489 echo $onclick; 00490 } else { 00491 echo ' ' . "\n"; 00492 } 00493 echo ' </td>' . "\n"; 00494 00495 // The value column (depends on type) 00496 // ---------------- 00497 00498 require('./libraries/get_foreign.lib.php'); 00499 00500 if (isset($foreign_link) && $foreign_link == true) { 00501 ?> 00502 <td bgcolor="<?php echo $bgcolor; ?>"> 00503 <?php echo $backup_field . "\n"; ?> 00504 <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="foreign" /> 00505 <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo ($i * $m_rows); ?>_1" /> 00506 <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 $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $mrows); ?>_3" value="<?php echo htmlspecialchars($data); ?>" /> 00507 <script type="text/javascript" language="javascript"> 00508 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>'); 00509 </script> 00510 </td> 00511 <?php 00512 } else if (isset($disp) && $disp) { 00513 ?> 00514 <td bgcolor="<?php echo $bgcolor; ?>"> 00515 <?php echo $backup_field . "\n"; ?> 00516 <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="foreign" /> 00517 <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $i; ?>_1" /> 00518 <select name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $m_rows); ?>_3"> 00519 <?php echo PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, 100); ?> 00520 </select> 00521 </td> 00522 <?php 00523 unset($disp); 00524 } 00525 else if ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) { 00526 ?> 00527 <td bgcolor="<?php echo $bgcolor; ?>"> </td> 00528 </tr> 00529 <tr> 00530 <td colspan="4" align="right" bgcolor="<?php echo $bgcolor; ?>"> 00531 <?php echo $backup_field . "\n"; ?> 00532 <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo ($cfg['TextareaRows']*2); ?>" cols="<?php echo ($cfg['TextareaCols']*2); ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($i * $m_rows); ?>_3" 00533 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>"><?php echo $special_chars; ?></textarea> 00534 </td> 00535 <?php 00536 } 00537 else if (strstr($type, 'text')) { 00538 ?> 00539 <td bgcolor="<?php echo $bgcolor; ?>"> 00540 <?php echo $backup_field . "\n"; ?> 00541 <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($i * $m_rows); ?>_3" 00542 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>"><?php echo $special_chars; ?></textarea> 00543 </td> 00544 <?php 00545 echo "\n"; 00546 if (strlen($special_chars) > 32000) { 00547 echo ' <td bgcolor="' . $bgcolor . '">' . $strTextAreaLength . '</td>' . "\n"; 00548 } 00549 } 00550 else if ($type == 'enum') { 00551 $enum = PMA_getEnumSetOptions($row_table_def['Type']); 00552 $enum_cnt = count($enum); 00553 ?> 00554 <td bgcolor="<?php echo $bgcolor; ?>"> 00555 <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="enum" /> 00556 <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" /> 00557 <?php 00558 echo "\n" . ' ' . $backup_field; 00559 00560 // show dropdown or radio depend on length 00561 if (strlen($row_table_def['Type']) > 20) { 00562 echo "\n"; 00563 ?> 00564 <select name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $m_rows); ?>_3"> 00565 <option value=""></option> 00566 <?php 00567 echo "\n"; 00568 00569 for ($j = 0; $j < $enum_cnt; $j++) { 00570 // Removes automatic MySQL escape format 00571 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j])); 00572 echo ' '; 00573 echo '<option value="' . htmlspecialchars($enum_atom) . '"'; 00574 if ($data == $enum_atom 00575 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES') 00576 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) { 00577 echo ' selected="selected"'; 00578 } 00579 echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n"; 00580 } // end for 00581 00582 ?> 00583 </select> 00584 <?php 00585 } // end if 00586 else { 00587 echo "\n"; 00588 for ($j = 0; $j < $enum_cnt; $j++) { 00589 // Removes automatic MySQL escape format 00590 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j])); 00591 echo ' '; 00592 echo '<input type="radio" name="field_' . md5($field) . $vkey . '[]" value="' . urlencode($enum_atom) . '" id="field_' . ($i*$m_rows) . '_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}"'; 00593 if ($data == $enum_atom 00594 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES') 00595 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) { 00596 echo ' checked="checked"'; 00597 } 00598 echo 'tabindex="' . (($i * $m_rows) + 1) . '" />' . "\n"; 00599 echo ' <label for="field_' . ($i * $m_rows) . '_3_' . $j . '">' . htmlspecialchars($enum_atom) . '</label>' . "\n"; 00600 } // end for 00601 00602 } // end else 00603 echo "\n"; 00604 ?> 00605 </td> 00606 <?php 00607 echo "\n"; 00608 } 00609 else if ($type == 'set') { 00610 $set = PMA_getEnumSetOptions($row_table_def['Type']); 00611 00612 if (isset($vset)) { 00613 unset($vset); 00614 } 00615 for ($vals = explode(',', $data); list($t, $k) = each($vals);) { 00616 $vset[$k] = 1; 00617 } 00618 $countset = count($set); 00619 $size = min(4, $countset); 00620 ?> 00621 <td bgcolor="<?php echo $bgcolor; ?>"> 00622 <?php echo $backup_field . "\n"; ?> 00623 <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="set" /> 00624 <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" /> 00625 <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 $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $m_rows); ?>_3"> 00626 <?php 00627 echo "\n"; 00628 for ($j = 0; $j < $countset; $j++) { 00629 echo ' '; 00630 echo '<option value="'. htmlspecialchars($set[$j]) . '"'; 00631 if (isset($vset[$set[$j]]) && $vset[$set[$j]]) { 00632 echo ' selected="selected"'; 00633 } 00634 echo '>' . htmlspecialchars($set[$j]) . '</option>' . "\n"; 00635 } // end for 00636 ?> 00637 </select> 00638 </td> 00639 <?php 00640 } 00641 // Change by Bernard M. Piller <bernard@bmpsystems.com> 00642 // We don't want binary data destroyed 00643 else if ($is_binary || $is_blob) { 00644 if (($cfg['ProtectBinary'] && $is_blob) 00645 || ($cfg['ProtectBinary'] == 'all' && $is_binary)) { 00646 echo "\n"; 00647 ?> 00648 <td bgcolor="<?php echo $bgcolor; ?>"> 00649 <?php 00650 echo $strBinaryDoNotEdit; 00651 if (isset($data)) { 00652 $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1); 00653 echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')'; 00654 unset($data_size); 00655 } 00656 echo "\n"; 00657 ?> 00658 <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="protected" /> 00659 <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" /> 00660 <?php 00661 } else if ($is_blob) { 00662 echo "\n"; 00663 ?> 00664 <td bgcolor="<?php echo $bgcolor; ?>"> 00665 <?php echo $backup_field . "\n"; ?> 00666 <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($i*$m_rows); ?>_3" 00667 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" ><?php echo $special_chars; ?></textarea> 00668 <?php 00669 00670 } else { 00671 if ($len < 4) { 00672 $fieldsize = $maxlength = 4; 00673 } else { 00674 $fieldsize = (($len > 40) ? 40 : $len); 00675 $maxlength = $len; 00676 } 00677 echo "\n"; 00678 ?> 00679 <td bgcolor="<?php echo $bgcolor; ?>"> 00680 <?php echo $backup_field . "\n"; ?> 00681 <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 $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $m_rows); ?>_3" /> 00682 <?php 00683 } // end if...elseif...else 00684 00685 // Upload choice (only for BLOBs because the binary 00686 // attribute does not imply binary contents) 00687 // (displayed whatever value the ProtectBinary has) 00688 00689 if ($is_upload && $is_blob) { 00690 echo '<input type="file" name="fields_upload_' . urlencode($field) . $vkey . '" class="textfield" id="field_' . ($i * $m_rows) . '_3" size="10" /> '; 00691 00692 // find maximum upload size, based on field type 00693 $max_field_sizes = array( 00694 'tinyblob' => '256', 00695 'blob' => '65536', 00696 'mediumblob' => '16777216', 00697 'longblob' => '4294967296'); // yeah, really 00698 00699 $this_field_max_size = $max_upload_size; // from PHP max 00700 if ($this_field_max_size > $max_field_sizes[$type]) { 00701 $this_field_max_size = $max_field_sizes[$type]; 00702 } 00703 echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n"; 00704 echo ' ' . PMA_generateHiddenMaxFileSize($this_field_max_size) . "\n"; 00705 } 00706 00707 if (!empty($cfg['UploadDir'])) { 00708 if (substr($cfg['UploadDir'], -1) != '/') { 00709 $cfg['UploadDir'] .= '/'; 00710 } 00711 if ($handle = @opendir($cfg['UploadDir'])) { 00712 $is_first = 0; 00713 while ($file = @readdir($handle)) { 00714 if (is_file($cfg['UploadDir'] . $file) && !PMA_checkFileExtensions($file, '.sql')) { 00715 if ($is_first == 0) { 00716 echo "<br />\n"; 00717 echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . ' :<br />' . "\n"; 00718 echo ' <select size="1" name="fields_uploadlocal_' . urlencode($field) . $vkey . '">' . "\n"; 00719 echo ' <option value="" selected="selected"></option>' . "\n"; 00720 } // end if (is_first) 00721 echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n"; 00722 $is_first++; 00723 } // end if (is_file) 00724 } // end while 00725 if ($is_first > 0) { 00726 echo ' </select>' . "\n"; 00727 } // end if (isfirst > 0) 00728 @closedir($handle); 00729 } else { 00730 echo ' <font color="red">' . $strError . '</font><br />' . "\n"; 00731 echo ' ' . $strWebServerUploadDirectoryError . "\n"; 00732 } 00733 } // end if (web-server upload directory) 00734 00735 echo '</td>'; 00736 00737 } // end else if ( binary or blob) 00738 else { 00739 // For char or varchar, respect the maximum length (M); for other 00740 // types (int or float), the length is not a limit on the values that 00741 // can be entered, so let's be generous (20) (we could also use the 00742 // real limits for each numeric type) 00743 if ($is_char) { 00744 $fieldsize = (($len > 40) ? 40 : $len); 00745 $maxlength = $len; 00746 } 00747 else { 00748 $fieldsize = $maxlength = 20; 00749 } // end if... else... 00750 echo "\n"; 00751 ?> 00752 <td bgcolor="<?php echo $bgcolor; ?>"> 00753 <?php echo $backup_field . "\n"; ?> 00754 <?php 00755 if ($is_char && isset($cfg['CharEditing']) && ($cfg['CharEditing'] == 'textarea')) { 00756 echo "\n"; 00757 ?> 00758 <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['CharTextareaRows']; ?>" cols="<?php echo $cfg['CharTextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($i * $m_rows); ?>_3" 00759 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" ><?php echo $special_chars; ?></textarea> 00760 <?php 00761 } else { 00762 echo "\n"; 00763 ?> 00764 <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 $vkey; ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $m_rows); ?>_3" /> 00765 <?php 00766 } 00767 echo "\n"; 00768 ?> 00769 </td> 00770 <?php 00771 } 00772 echo "\n"; 00773 ?> 00774 </tr> 00775 <?php 00776 echo "\n"; 00777 } // end for 00778 $o_rows++; 00779 echo ' </table><br />'; 00780 } // end foreach on multi-edit 00781 ?> 00782 <br /> 00783 00784 <table cellpadding="5"> 00785 <tr> 00786 <td valign="middle" nowrap="nowrap"> 00787 <?php 00788 if (isset($primary_key)) { 00789 ?> 00790 <input type="radio" name="submit_type" value="<?php echo $strSave; ?>" id="radio_submit_type_save" checked="checked" tabindex="<?php echo ((3 * $fields_cnt) + 1); ?>" /><label for="radio_submit_type_save"><?php echo $strSave; ?></label><br /> 00791 <?php echo $strOr; ?><br /> 00792 <input type="radio" name="submit_type" value="<?php echo $strInsertAsNewRow; ?>" id="radio_submit_type_insert_as_new_row" tabindex="<?php echo ((3 * $fields_cnt) + 2); ?>" /><label for="radio_submit_type_insert_as_new_row"><?php echo $strInsertAsNewRow; ?></label> 00793 <?php 00794 } else { 00795 echo "\n"; 00796 ?> 00797 <input type="hidden" name="submit_type" value="<?php echo $strInsertAsNewRow; ?>" /> 00798 <?php 00799 echo ' ' . $strInsertAsNewRow . "\n"; 00800 } 00801 echo "\n"; 00802 00803 // Defines whether "insert a new row after the current insert" should be 00804 // checked or not (keep this choice sticky) 00805 // but do not check both radios, because Netscape 4.8 would display both checked 00806 if (!empty($disp_message)) { 00807 $checked_after_insert_new_insert = ' checked="checked"'; 00808 $checked_after_insert_back = ''; 00809 } else { 00810 $checked_after_insert_back = ' checked="checked"'; 00811 $checked_after_insert_new_insert = ''; 00812 } 00813 ?> 00814 </td> 00815 <td valign="middle"> 00816 <b>-- <?php echo $strAnd; ?> --</b> 00817 </td> 00818 <td valign="middle" nowrap="nowrap"> 00819 <input type="radio" name="after_insert" value="back" id="radio_after_insert_back" <?php echo $checked_after_insert_back; ?> tabindex="<?php echo ((3 * $fields_cnt) + 3); ?>" /><label for="radio_after_insert_back"><?php echo $strAfterInsertBack; ?></label><br /> 00820 <?php echo $strOr; ?><br /> 00821 <input type="radio" name="after_insert" value="new_insert" id="radio_after_insert_new_insert"<?php echo $checked_after_insert_new_insert; ?> tabindex="<?php echo ((3 * $fields_cnt) + 4); ?>" /><label for="radio_after_insert_new_insert"><?php echo $strAfterInsertNewInsert; ?></label> 00822 </td> 00823 </tr> 00824 00825 <tr> 00826 <td colspan="3" align="right" valign="middle"> 00827 <input type="submit" value="<?php echo $strGo; ?>" tabindex="<?php echo ((3 * $fields_cnt) + 5); ?>" /> 00828 <input type="reset" value="<?php echo $strReset; ?>" tabindex="<?php echo ((3 * $fields_cnt) + 6); ?>" /> 00829 </td> 00830 </tr> 00831 </table> 00832 00833 </form> 00834 00835 00836 <?php 00840 echo "\n"; 00841 require_once('./footer.inc.php'); 00842 ?>