3 // vim: expandtab sw=4 ts=4 sts=4:
7 <!-- Set on key handler
for moving using by Ctrl+arrows
-->
8 <script type
="text/javascript" language
="javascript">
10 document
.onkeydown
= onKeyDownArrowsHandler
;
14 <form method
="post" action
="<?php echo $action; ?>">
16 echo PMA_generate_common_hidden_inputs($db, $table);
17 if ($action == 'tbl_create.php3') {
19 <input type
="hidden" name
="reload" value
="1" />
22 else if ($action == 'tbl_addfield.php3') {
25 <input type
="hidden" name
="after_field" value
="<?php echo $after_field; ?>" />
30 if (isset($num_fields)) {
32 <input type
="hidden" name
="orig_num_fields" value
="<?php echo $num_fields; ?>" />
36 if (isset($after_field)) {
38 <input type
="hidden" name
="orig_after_field" value
="<?php echo $after_field; ?>" />
42 if (isset($selected) && is_array($selected)) {
44 while(list($o_fld_nr, $o_fld_val) = each($selected)) {
46 <input type
="hidden" name
="selected[<?php echo $o_fld_nr; ?>]" value
="<?php echo urlencode($o_fld_val); ?>" />
48 if (!isset($true_selected)) {
50 <input type
="hidden" name
="true_selected[<?php echo $o_fld_nr; ?>]" value
="<?php echo urlencode($o_fld_val); ?>" />
56 if (isset($true_selected) && is_array($true_selected)) {
57 @reset
($true_selected);
58 while(list($o_fld_nr, $o_fld_val) = each($true_selected)) {
60 <input type
="hidden" name
="true_selected[<?php echo $o_fld_nr; ?>]" value
="<?php echo urlencode($o_fld_val); ?>" />
65 } elseif (isset($field)) {
67 <input type
="hidden" name
="orig_field" value
="<?php echo urlencode($field); ?>" />
68 <input type
="hidden" name
="true_selected[] value="<?php
echo (isset($orig_field) ?
$orig_field : urlencode($field)); ?
>" />
72 $is_backup = ($action != 'tbl_create.php3' && $action != 'tbl_addfield.php3');
74 $header_cells = array();
75 $content_cells = array();
77 $header_cells[] = $strField;
78 $header_cells[] = $strType . '<br /><span style="font
-weight
: normal
">' . PMA_showMySQLDocu('Reference', 'Column_types') . '</span>';
79 $header_cells[] = $strLengthSet;
80 $header_cells[] = $strAttr;
81 $header_cells[] = $strNull;
82 $header_cells[] = $strDefault . '**';
83 $header_cells[] = $strExtra;
85 require('./libraries/relation.lib.php3');
86 require('./libraries/transformations.lib.php3');
87 $cfgRelation = PMA_getRelationsParam();
89 $comments_map = array();
91 $available_mime = array();
93 if ($cfgRelation['commwork']) {
94 $comments_map = PMA_getComments($db, $table);
95 $header_cells[] = $strComments;
97 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
98 $mime_map = PMA_getMIME($db, $table);
99 $available_mime = PMA_getAvailableMIMEtypes();
101 $header_cells[] = $strMIME_MIMEtype;
102 $header_cells[] = $strMIME_transformation;
103 $header_cells[] = $strMIME_transformation_options . '***';
108 // lem9: We could remove this 'if' and let the key information be shown and
109 // editable. However, for this to work, tbl_alter must be modified to use the
110 // key fields, as tbl_addfield does.
113 $header_cells[] = $strPrimary;
114 $header_cells[] = $strIndex;
115 $header_cells[] = $strUnique;
116 $header_cells[] = '---';
117 $header_cells[] = $strIdxFulltext;
120 // garvin: workaround for field_fulltext, because its submitted indizes contain
121 // the index as a value, not a key. Inserted here for easier maintaineance
122 // and less code to change in existing files.
123 if (isset($field_fulltext) && is_array($field_fulltext)) {
124 @reset($field_fulltext);
125 while(list($fulltext_nr, $fulltext_indexkey) = each($field_fulltext)) {
126 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
130 for ($i = 0 ; $i < $num_fields; $i++) {
131 $submit_null = FALSE;
132 if (isset($regenerate) && $regenerate == TRUE) {
133 // An error happened with previous inputs, so we will restore the data
134 // to embed it once again in this form.
136 $row['Field'] = (isset($field_name) && isset($field_name[$i]) ? $field_name[$i] : FALSE);
137 $row['Type'] = (isset($field_type) && isset($field_type[$i]) ? $field_type[$i] : FALSE);
138 $row['Null'] = (isset($field_null) && isset($field_null[$i]) ? $field_null[$i] : '');
139 if ($row['Null'] == '') {
143 if (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'primary_' . $i) {
145 } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'index_' . $i) {
147 } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'unique_' . $i) {
153 $row['Default'] = (isset($field_default) && isset($field_default[$i]) ? $field_default[$i] : FALSE);
154 $row['Extra'] = (isset($field_extra) && isset($field_extra[$i]) ? $field_extra[$i] : FALSE);
155 $row['Comment'] = (isset($submit_fulltext) && isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : FALSE);
157 $submit_length = (isset($field_length) && isset($field_length[$i]) ? $field_length[$i] : FALSE);
158 $submit_attribute = (isset($field_attribute) && isset($field_attribute[$i]) ? $field_attribute[$i] : FALSE);
160 if (isset($field_comments) && isset($field_comments[$i])) {
161 $comments_map[$row['Field']] = $field_comments[$i];
164 if (isset($field_mimetype) && isset($field_mimetype[$i])) {
165 $mime_map[$row['Field']]['mimetype'] = $field_mimetype[$i];
168 if (isset($field_transformation) && isset($field_transformation[$i])) {
169 $mime_map[$row['Field']]['transformation'] = $field_transformation[$i];
172 if (isset($field_transformation_options) && isset($field_transformation_options[$i])) {
173 $mime_map[$row['Field']]['transformation_options'] = $field_transformation_options[$i];
176 } elseif (isset($fields_meta)) {
177 $row = $fields_meta[$i];
180 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
182 // Cell index: If certain fields get left out, the counter shouldn't chage.
186 $backup_field = (isset($true_selected) && $true_selected[$i] ? $true_selected[$i] : (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : ''));
187 $content_cells[$i][$ci] = "\n
" . '<input type="hidden
" name="field_orig
[]" value="' . $backup_field . '" />' . "\n
";
189 $content_cells[$i][$ci] = '';
192 $content_cells[$i][$ci] .= "\n
" . '<input id="field_
' . $i . '_1
" type="text
" name="field_name
[]" size="10" maxlength="64" value="' . (isset($row) && isset($row['Field
']) ? str_replace('"', '"', $row['Field']) : '') . '" class="textfield" />';
194 $content_cells[$i][$ci] = '<select name
="field_type[]" id
="field_' . $i . '_2">' . "\n";
196 if (empty($row['Type
'])) {
201 $type = $row['Type
'];
203 // set or enum types: slashes single quotes inside options
204 if (eregi('^
(set|enum
)\
((.+
)\
)$
', $type, $tmp)) {
206 $length = substr(ereg_replace('([^
,])\'\'', '\\
1\\\'', ',' . $tmp[2]), 1);
208 $type = eregi_replace('BINARY
', '', $type);
209 $type = eregi_replace('ZEROFILL
', '', $type);
210 $type = eregi_replace('UNSIGNED
', '', $type);
213 $type = chop(eregi_replace('\\
(.*\\)', '', $type));
215 $length = eregi_replace("^$type\(", '', $length);
216 $length = eregi_replace('\
)$
', '', trim($length));
218 if ($length == $type) {
223 if (isset($submit_length) && $submit_length != FALSE) {
224 $length = $submit_length;
227 for ($j = 0; $j < count($cfg['ColumnTypes
']); $j++) {
228 $content_cells[$i][$ci] .= ' <option value
="'. $cfg['ColumnTypes'][$j] . '"';
229 if (strtoupper($type) == strtoupper($cfg['ColumnTypes
'][$j])) {
230 $content_cells[$i][$ci] .= ' selected
="selected"';
232 $content_cells[$i][$ci] .= '>' . $cfg['ColumnTypes
'][$j] . '</option
>' . "\n";
235 $content_cells[$i][$ci] .= ' </select
>';
239 $content_cells[$i][$ci] = "\n" . '<input type
="hidden" name
="field_length_orig[]" value
="' . urlencode($length) . '" />';
241 $content_cells[$i][$ci] = '';
244 $content_cells[$i][$ci] .= "\n" . '<input id
="field_' . $i . '_3" type
="text" name
="field_length[]" size
="8" value
="' . str_replace('"', '"
;', $length) . '" class="textfield
" />' . "\n
";
247 $content_cells[$i][$ci] = '<select name="field_attribute
[]" id="field_
' . $i . '_4
">' . "\n
";
249 if (eregi('^(set|enum)$', $type)) {
254 $binary = eregi('BINARY', $row['Type'], $test_attribute1);
255 $unsigned = eregi('UNSIGNED', $row['Type'], $test_attribute2);
256 $zerofill = eregi('ZEROFILL', $row['Type'], $test_attribute3);
260 $strAttribute = 'BINARY';
263 $strAttribute = 'UNSIGNED';
266 $strAttribute = 'UNSIGNED ZEROFILL';
269 if (isset($submit_attribute) && $submit_attribute != FALSE) {
270 $strAttribute = $submit_attribute;
273 for ($j = 0;$j < count($cfg['AttributeTypes']); $j++) {
274 $content_cells[$i][3] .= ' <option value="'. $cfg['AttributeTypes
'][$j] . '"';
275 if (strtoupper($strAttribute) == strtoupper($cfg['AttributeTypes'][$j])) {
276 $content_cells[$i][3] .= ' selected="selected
"';
278 $content_cells[$i][3] .= '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n
";
281 $content_cells[$i][$ci] .= '</select>';
284 $content_cells[$i][$ci] = '<select name="field_null
[]" id="field_
' . $i . '_5
">';
286 if ((!isset($row) || empty($row['Null']) || $row['Null'] == 'NOT NULL') && $submit_null == FALSE) {
287 $content_cells[$i][$ci] .= "\n
";
288 $content_cells[$i][$ci] .= ' <option value="NOT
NULL">not null</option>' . "\n
";
289 $content_cells[$i][$ci] .= ' <option value="">null</option>' . "\n
";
291 $content_cells[$i][$ci] .= "\n
";
292 $content_cells[$i][$ci] .= ' <option value="">null</option>' . "\n
";
293 $content_cells[$i][$ci] .= ' <option value="NOT
NULL">not null</option>' . "\n
";
296 $content_cells[$i][$ci] .= "\n
" . '</select>';
300 && !isset($row['Default']) && !empty($row['Null'])) {
301 $row['Default'] = 'NULL';
305 $content_cells[$i][5] = "\n
" . '<input type="hidden
" name="field_default_orig
[]" size="8" value="' . (isset($row) && isset($row['Default']) ? urlencode($row['Default']) : '') . '" />';
307 $content_cells[$i][5] = "\n
";
310 $content_cells[$i][$ci] .= '<input id="field_
' . $i . '_6
" type="text
" name="field_default
[]" size="8" value="' . (isset($row) && isset($row['Default']) ? str_replace('"', '"', $row['Default']) : '') . '" class="textfield" />';
313 $content_cells[$i][$ci] = '<select name
="field_extra[]" id
="field_' . $i . '_7">';
315 if(!isset($row) || empty($row['Extra
'])) {
316 $content_cells[$i][$ci] .= "\n";
317 $content_cells[$i][$ci] .= '<option value
=""></option
>' . "\n";
318 $content_cells[$i][$ci] .= '<option value
="AUTO_INCREMENT">auto_increment
</option
>' . "\n";
320 $content_cells[$i][$ci] .= "\n";
321 $content_cells[$i][$ci] .= '<option value
="AUTO_INCREMENT">auto_increment
</option
>' . "\n";
322 $content_cells[$i][$ci] .= '<option value
=""></option
>' . "\n";
325 $content_cells[$i][$ci] .= "\n" . '</select
>';
329 if ($cfgRelation['commwork
']) {
330 $content_cells[$i][$ci] = '<input id
="field_' . $i . '_7" type
="text" name
="field_comments[]" size
="8" value
="' . (isset($row) && isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '" class="textfield" />';
334 // garvin: MIME-types
335 if ($cfgRelation['mimework
'] && $cfg['BrowseMIME
'] && $cfgRelation['commwork
']) {
336 $content_cells[$i][$ci] = '<select id
="field_' . $i . '_8" size
="1" name
="field_mimetype[]">' . "\n";
337 $content_cells[$i][$ci] .= ' <option value
=""></option
>' . "\n";
338 $content_cells[$i][$ci] .= ' <option value
="auto">auto
-detect
</option
>' . "\n";
340 if (is_array($available_mime['mimetype
'])) {
341 @reset($available_mime['mimetype
']);
342 while(list($mimekey, $mimetype) = each($available_mime['mimetype
'])) {
343 $checked = (isset($row) && isset($row['Field
']) && isset($mime_map[$row['Field
']]['mimetype
']) && ($mime_map[$row['Field
']]['mimetype
'] == str_replace('/', '_
', $mimetype)) ? 'selected
' : '');
344 $content_cells[$i][$ci] .= ' <option value
="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option
>';
348 $content_cells[$i][$ci] .= '</select
>';
351 $content_cells[$i][$ci] = '<select id
="field_' . $i . '_9" size
="1" name
="field_transformation[]">' . "\n";
352 $content_cells[$i][$ci] .= ' <option value
="" title
="' . $strNone . '"></option
>' . "\n";
353 if (is_array($available_mime['transformation
'])) {
354 @reset($available_mime['transformation
']);
355 while(list($mimekey, $transform) = each($available_mime['transformation
'])) {
356 $checked = (isset($row) && isset($row['Field
']) && isset($mime_map[$row['Field
']]['transformation
']) && ($mime_map[$row['Field
']]['transformation
'] == $available_mime['transformation_file
'][$mimekey]) ? 'selected
' : '');
357 $tooltip = 'strTransformation_
' . strtolower(str_replace('.inc
.php3
', '', $available_mime['transformation_file
'][$mimekey]));
358 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br
/>', ' ', $strMIME_nodescription), 'PMA_transformation_
' . $tooltip . '()');
359 $content_cells[$i][$ci] .= '<option value
="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title
="' . $tooltip . '">' . htmlspecialchars($transform) . '</option
>' . "\n";
363 $content_cells[$i][$ci] .= '</select
>';
366 $content_cells[$i][$ci] = '<input id
="field_' . $i . '_10" type
="text" name
="field_transformation_options[]" size
="8" value
="' . (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '" class="textfield" />';
370 // lem9: See my other comment about removing this 'if'.
372 if (isset($row) && isset($row['Key
']) && $row['Key
'] == 'PRI
') {
373 $checked_primary = ' checked
="checked"';
375 $checked_primary = '';
377 if (isset($row) && isset($row['Key
']) && $row['Key
'] == 'MUL
') {
378 $checked_index = ' checked
="checked"';
382 if (isset($row) && isset($row['Key
']) && $row['Key
'] == 'UNI
') {
383 $checked_unique = ' checked
="checked"';
385 $checked_unique = '';
387 if (empty($checked_primary)
388 && empty($checked_index)
389 && empty($checked_unique)) {
390 $checked_none = ' checked
="checked"';
395 if (PMA_MYSQL_INT_VERSION >= 32323
396 &&(isset($row) && isset($row['Comment
']) && $row['Comment
'] == 'FULLTEXT
')) {
397 $checked_fulltext = ' checked
="checked"';
399 $checked_fulltext = '';
402 $content_cells[$i][$ci] = "\n" . '<input type
="radio" name
="field_key_' . $i . '" value
="primary_' . $i . '"' . $checked_primary . ' />';
405 $content_cells[$i][$ci] = "\n" . '<input type
="radio" name
="field_key_' . $i . '" value
="index_' . $i . '"' . $checked_index . ' />';
408 $content_cells[$i][$ci] = "\n" . '<input type
="radio" name
="field_key_' . $i . '" value
="unique_' . $i . '"' . $checked_unique . ' />';
411 $content_cells[$i][$ci] = "\n" . '<input type
="radio" name
="field_key_' . $i . '" value
="none_' . $i . '"' . $checked_none . ' />';
414 if (PMA_MYSQL_INT_VERSION >= 32323) {
415 $content_cells[$i][$ci] = '<input type
="checkbox" name
="field_fulltext[]" value
="' . $i . '"' . $checked_fulltext . ' />';
416 } // end if (PMA_MYSQL_INT_VERSION >= 32323)
417 } // end if ($action ==...)
420 if ($cfg['DefaultPropDisplay
'] == 'horizontal
') {
422 <table border="<?php echo $cfg['Border
']; ?>">
425 @reset($header_cells);
426 while(@list($header_nr, $header_val) = @each($header_cells)) {
428 <th><?php echo $header_val; ?></th>
434 @reset($content_cells);
436 while(@list($content_nr, $content_row) = @each($content_cells)) {
438 echo "\n" . '<tr
>' . "\n";
440 $bgcolor = ($i % 2) ? $cfg['BgcolorOne
'] : $cfg['BgcolorTwo
'];
442 while(list($content_row_nr, $content_row_val) = @each($content_row)) {
444 <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $content_row_val; ?></td>
447 echo "\n" . '</tr
>' . "\n";
455 <table border="<?php echo $cfg['Border
']; ?>">
457 @reset($header_cells);
459 while(@list($header_nr, $header_val) = @each($header_cells)) {
460 echo "\n" . '<tr
>' . "\n";
462 <th align="right"><?php echo $header_val; ?></th>
464 for ($j = 0; $j < count($content_cells); $j++) {
465 if (isset($content_cells[$j][$i]) && $content_cells[$j][$i] != '') {
466 $bgcolor = ($j % 2) ? $cfg['BgcolorOne
'] : $cfg['BgcolorTwo
'];
468 <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $content_cells[$j][$i]; ?></td>
473 echo "\n" . '</tr
>' . "\n";
482 if ($action == 'tbl_create
.php3
' && PMA_MYSQL_INT_VERSION >= 32300) {
487 <td><?php echo $strTableComments; ?> :</td>
489 if ($action == 'tbl_create
.php3
') {
492 <td width="25"> </td>
493 <td><?php echo $strTableType; ?> :</td>
501 <input type="text" name="comment" size="40" maxlength="80" value="<?php echo (isset($comment) ? $comment : ''); ?>" class="textfield" />
504 // BEGIN - Table Type - 2 May 2001 - Robbat2
505 // change by staybyte - 11 June 2001
506 if ($action == 'tbl_create
.php3
') {
507 // find mysql capability - staybyte - 11. June 2001
508 $query = 'SHOW VARIABLES LIKE \'have_%\'
';
509 $result = PMA_mysql_query($query);
510 if ($result != FALSE && mysql_num_rows($result) > 0) {
511 while ($tmp = PMA_mysql_fetch_array($result)) {
512 if (isset($tmp['Variable_name
'])) {
513 switch ($tmp['Variable_name
']) {
515 if (isset($tmp['Variable_name
']) && $tmp['Value
'] == 'YES
') {
520 if (isset($tmp['Variable_name
']) && $tmp['Value
'] == 'YES
') {
525 if (isset($tmp['Variable_name
']) && $tmp['Value
'] == 'YES
') {
530 if (isset($tmp['Variable_name
']) && $tmp['Value
'] == 'YES
') {
538 mysql_free_result($result);
542 <td width="25"> </td>
544 <select name="tbl_type">
545 <option <?php echo (isset($tbl_type) && $tbl_type == 'Default' ? 'selected
="checked"' : ''); ?> value="Default"><?php echo $strDefault; ?></option>
546 <option <?php echo (isset($tbl_type) && $tbl_type == 'MYISAM
' ? 'selected
="checked"' : ''); ?> value="MYISAM">MyISAM</option>
547 <option <?php echo (isset($tbl_type) && $tbl_type == 'HEAP
' ? 'selected
="checked"' : ''); ?> value="HEAP">Heap</option>
548 <option <?php echo (isset($tbl_type) && $tbl_type == 'MERGE
' ? 'selected
="checked"' : ''); ?> value="MERGE">Merge</option>
549 <?php if (isset($tbl_bdb)) { ?><option <?php echo (isset($tbl_type) && $tbl_type == 'BDB
' ? 'selected
="checked"' : ''); ?> value="BDB">Berkeley DB</option><?php } ?>
550 <?php if (isset($tbl_gemini)) { ?><option <?php echo (isset($tbl_type) && $tbl_type == 'GEMINI
' ? 'selected
="checked"' : ''); ?> value="GEMINI">Gemini</option><?php } ?>
551 <?php if (isset($tbl_innodb)) { ?><option <?php echo (isset($tbl_type) && $tbl_type == 'INNO DB
' ? 'selected
="checked"' : ''); ?> value="InnoDB">INNO DB</option><?php } ?>
552 <?php if (isset($tbl_isam)) { ?><option <?php echo (isset($tbl_type) && $tbl_type == 'ISAM
' ? 'selected
="checked"' : ''); ?> value="ISAM">ISAM</option><?php } ?>
565 // END - Table Type - 2 May 2001 - Robbat2
568 <input type="submit" name="submit" value="<?php echo $strSave; ?>" />
573 <td valign="top">* </td>
575 <?php echo $strSetEnumVal . "\n"; ?>
579 <td valign="top">** </td>
581 <?php echo $strDefaultValueHelp . "\n"; ?>
586 if ($cfgRelation['commwork
'] && $cfgRelation['mimework
'] && $cfg['BrowseMIME
']) {
589 <td valign="top" rowspan="2">*** </td>
591 <?php echo $strMIME_transformation_options_note . "\n"; ?>
597 <?php echo sprintf($strMIME_transformation_note, '<a href
="libraries/transformations/overview.php3?' . PMA_generate_common_url($db, $table) . '" target
="_new">', '</a
>') . "\n"; ?>
607 <center><?php echo PMA_showMySQLDocu('Reference
', 'CREATE_TABLE
'); ?></center>