Documentation TYPO3 par Ameos

tbl_change.php

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


Généré par TYPO3 Ameos avec  doxygen 1.4.6