3 // vim: expandtab sw=4 ts=4 sts=4:
7 <?php
if ($cfg['CtrlArrowsMoving']) { ?
>
8 <!-- Set on key handler
for moving using by Ctrl+arrows
-->
9 <script type
="text/javascript" language
="javascript">
11 document
.onkeydown
= onKeyDownArrowsHandler
;
16 <form method
="post" action
="<?php echo $action; ?>">
18 echo PMA_generate_common_hidden_inputs($db, $table);
19 if ($action == 'tbl_create.php3') {
21 <input type
="hidden" name
="reload" value
="1" />
24 else if ($action == 'tbl_addfield.php3') {
27 <input type
="hidden" name
="after_field" value
="<?php echo $after_field; ?>" />
32 if (isset($num_fields)) {
34 <input type
="hidden" name
="orig_num_fields" value
="<?php echo $num_fields; ?>" />
38 if (isset($after_field)) {
40 <input type
="hidden" name
="orig_after_field" value
="<?php echo $after_field; ?>" />
44 if (isset($selected) && is_array($selected)) {
46 while(list($o_fld_nr, $o_fld_val) = each($selected)) {
48 <input type
="hidden" name
="selected[<?php echo $o_fld_nr; ?>]" value
="<?php echo urlencode($o_fld_val); ?>" />
50 if (!isset($true_selected)) {
52 <input type
="hidden" name
="true_selected[<?php echo $o_fld_nr; ?>]" value
="<?php echo urlencode($o_fld_val); ?>" />
58 if (isset($true_selected) && is_array($true_selected)) {
59 @reset
($true_selected);
60 while(list($o_fld_nr, $o_fld_val) = each($true_selected)) {
62 <input type
="hidden" name
="true_selected[<?php echo $o_fld_nr; ?>]" value
="<?php echo urlencode($o_fld_val); ?>" />
67 } elseif (isset($field)) {
69 <input type
="hidden" name
="orig_field" value
="<?php echo urlencode($field); ?>" />
70 <input type
="hidden" name
="true_selected[] value="<?php
echo (isset($orig_field) ?
$orig_field : urlencode($field)); ?
>" />
74 $is_backup = ($action != 'tbl_create.php3' && $action != 'tbl_addfield.php3');
76 $header_cells = array();
77 $content_cells = array();
79 $header_cells[] = $strField;
80 $header_cells[] = $strType . '<br /><span style="font
-weight
: normal
">' . PMA_showMySQLDocu('Reference', 'Column_types') . '</span>';
81 $header_cells[] = $strLengthSet;
82 $header_cells[] = $strAttr;
83 $header_cells[] = $strNull;
84 $header_cells[] = $strDefault . '**';
85 $header_cells[] = $strExtra;
87 require('./libraries/relation.lib.php3');
88 require('./libraries/transformations.lib.php3');
89 $cfgRelation = PMA_getRelationsParam();
91 $comments_map = array();
93 $available_mime = array();
95 if ($cfgRelation['commwork']) {
96 $comments_map = PMA_getComments($db, $table);
97 $header_cells[] = $strComments;
99 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
100 $mime_map = PMA_getMIME($db, $table);
101 $available_mime = PMA_getAvailableMIMEtypes();
103 $header_cells[] = $strMIME_MIMEtype;
104 $header_cells[] = $strMIME_transformation;
105 $header_cells[] = $strMIME_transformation_options . '***';
110 // lem9: We could remove this 'if' and let the key information be shown and
111 // editable. However, for this to work, tbl_alter must be modified to use the
112 // key fields, as tbl_addfield does.
115 $header_cells[] = $strPrimary;
116 $header_cells[] = $strIndex;
117 $header_cells[] = $strUnique;
118 $header_cells[] = '---';
119 $header_cells[] = $strIdxFulltext;
122 // garvin: workaround for field_fulltext, because its submitted indizes contain
123 // the index as a value, not a key. Inserted here for easier maintaineance
124 // and less code to change in existing files.
125 if (isset($field_fulltext) && is_array($field_fulltext)) {
126 @reset($field_fulltext);
127 while(list($fulltext_nr, $fulltext_indexkey) = each($field_fulltext)) {
128 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
132 for ($i = 0 ; $i < $num_fields; $i++) {
133 $submit_null = FALSE;
134 if (isset($regenerate) && $regenerate == TRUE) {
135 // An error happened with previous inputs, so we will restore the data
136 // to embed it once again in this form.
138 $row['Field'] = (isset($field_name) && isset($field_name[$i]) ? $field_name[$i] : FALSE);
139 $row['Type'] = (isset($field_type) && isset($field_type[$i]) ? $field_type[$i] : FALSE);
140 $row['Null'] = (isset($field_null) && isset($field_null[$i]) ? $field_null[$i] : '');
141 if ($row['Null'] == '') {
145 if (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'primary_' . $i) {
147 } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'index_' . $i) {
149 } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'unique_' . $i) {
155 $row['Default'] = (isset($field_default) && isset($field_default[$i]) ? $field_default[$i] : FALSE);
156 $row['Extra'] = (isset($field_extra) && isset($field_extra[$i]) ? $field_extra[$i] : FALSE);
157 $row['Comment'] = (isset($submit_fulltext) && isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : FALSE);
159 $submit_length = (isset($field_length) && isset($field_length[$i]) ? $field_length[$i] : FALSE);
160 $submit_attribute = (isset($field_attribute) && isset($field_attribute[$i]) ? $field_attribute[$i] : FALSE);
162 if (isset($field_comments) && isset($field_comments[$i])) {
163 $comments_map[$row['Field']] = $field_comments[$i];
166 if (isset($field_mimetype) && isset($field_mimetype[$i])) {
167 $mime_map[$row['Field']]['mimetype'] = $field_mimetype[$i];
170 if (isset($field_transformation) && isset($field_transformation[$i])) {
171 $mime_map[$row['Field']]['transformation'] = $field_transformation[$i];
174 if (isset($field_transformation_options) && isset($field_transformation_options[$i])) {
175 $mime_map[$row['Field']]['transformation_options'] = $field_transformation_options[$i];
178 } elseif (isset($fields_meta)) {
179 $row = $fields_meta[$i];
182 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
184 // Cell index: If certain fields get left out, the counter shouldn't chage.
188 $backup_field = (isset($true_selected) && $true_selected[$i] ? $true_selected[$i] : (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : ''));
189 $content_cells[$i][$ci] = "\n
" . '<input type="hidden
" name="field_orig
[]" value="' . $backup_field . '" />' . "\n
";
191 $content_cells[$i][$ci] = '';
194 $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" />';
196 $content_cells[$i][$ci] = '<select name
="field_type[]" id
="field_' . $i . '_2">' . "\n";
198 if (empty($row['Type
'])) {
203 $type = $row['Type
'];
205 // set or enum types: slashes single quotes inside options
206 if (eregi('^
(set|enum
)\
((.+
)\
)$
', $type, $tmp)) {
208 $length = substr(ereg_replace('([^
,])\'\'', '\\
1\\\'', ',' . $tmp[2]), 1);
210 $type = eregi_replace('BINARY
', '', $type);
211 $type = eregi_replace('ZEROFILL
', '', $type);
212 $type = eregi_replace('UNSIGNED
', '', $type);
215 $type = chop(eregi_replace('\\
(.*\\)', '', $type));
217 $length = eregi_replace("^$type\(", '', $length);
218 $length = eregi_replace('\
)$
', '', trim($length));
220 if ($length == $type) {
225 if (isset($submit_length) && $submit_length != FALSE) {
226 $length = $submit_length;
229 for ($j = 0; $j < count($cfg['ColumnTypes
']); $j++) {
230 $content_cells[$i][$ci] .= ' <option value
="'. $cfg['ColumnTypes'][$j] . '"';
231 if (strtoupper($type) == strtoupper($cfg['ColumnTypes
'][$j])) {
232 $content_cells[$i][$ci] .= ' selected
="selected"';
234 $content_cells[$i][$ci] .= '>' . $cfg['ColumnTypes
'][$j] . '</option
>' . "\n";
237 $content_cells[$i][$ci] .= ' </select
>';
241 $content_cells[$i][$ci] = "\n" . '<input type
="hidden" name
="field_length_orig[]" value
="' . urlencode($length) . '" />';
243 $content_cells[$i][$ci] = '';
246 $content_cells[$i][$ci] .= "\n" . '<input id
="field_' . $i . '_3" type
="text" name
="field_length[]" size
="8" value
="' . str_replace('"', '"
;', $length) . '" class="textfield
" />' . "\n
";
249 $content_cells[$i][$ci] = '<select name="field_attribute
[]" id="field_
' . $i . '_4
">' . "\n
";
251 if (eregi('^(set|enum)$', $type)) {
256 $binary = eregi('BINARY', $row['Type'], $test_attribute1);
257 $unsigned = eregi('UNSIGNED', $row['Type'], $test_attribute2);
258 $zerofill = eregi('ZEROFILL', $row['Type'], $test_attribute3);
262 $strAttribute = 'BINARY';
265 $strAttribute = 'UNSIGNED';
268 $strAttribute = 'UNSIGNED ZEROFILL';
271 if (isset($submit_attribute) && $submit_attribute != FALSE) {
272 $strAttribute = $submit_attribute;
275 for ($j = 0;$j < count($cfg['AttributeTypes']); $j++) {
276 $content_cells[$i][3] .= ' <option value="'. $cfg['AttributeTypes
'][$j] . '"';
277 if (strtoupper($strAttribute) == strtoupper($cfg['AttributeTypes'][$j])) {
278 $content_cells[$i][3] .= ' selected="selected
"';
280 $content_cells[$i][3] .= '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n
";
283 $content_cells[$i][$ci] .= '</select>';
286 $content_cells[$i][$ci] = '<select name="field_null
[]" id="field_
' . $i . '_5
">';
288 if ((!isset($row) || empty($row['Null']) || $row['Null'] == 'NOT NULL') && $submit_null == FALSE) {
289 $content_cells[$i][$ci] .= "\n
";
290 $content_cells[$i][$ci] .= ' <option value="NOT
NULL">not null</option>' . "\n
";
291 $content_cells[$i][$ci] .= ' <option value="">null</option>' . "\n
";
293 $content_cells[$i][$ci] .= "\n
";
294 $content_cells[$i][$ci] .= ' <option value="">null</option>' . "\n
";
295 $content_cells[$i][$ci] .= ' <option value="NOT
NULL">not null</option>' . "\n
";
298 $content_cells[$i][$ci] .= "\n
" . '</select>';
302 && !isset($row['Default']) && !empty($row['Null'])) {
303 $row['Default'] = 'NULL';
307 $content_cells[$i][5] = "\n
" . '<input type="hidden
" name="field_default_orig
[]" size="8" value="' . (isset($row) && isset($row['Default']) ? urlencode($row['Default']) : '') . '" />';
309 $content_cells[$i][5] = "\n
";
312 $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" />';
315 $content_cells[$i][$ci] = '<select name
="field_extra[]" id
="field_' . $i . '_7">';
317 if(!isset($row) || empty($row['Extra
'])) {
318 $content_cells[$i][$ci] .= "\n";
319 $content_cells[$i][$ci] .= '<option value
=""></option
>' . "\n";
320 $content_cells[$i][$ci] .= '<option value
="AUTO_INCREMENT">auto_increment
</option
>' . "\n";
322 $content_cells[$i][$ci] .= "\n";
323 $content_cells[$i][$ci] .= '<option value
="AUTO_INCREMENT">auto_increment
</option
>' . "\n";
324 $content_cells[$i][$ci] .= '<option value
=""></option
>' . "\n";
327 $content_cells[$i][$ci] .= "\n" . '</select
>';
331 if ($cfgRelation['commwork
']) {
332 $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" />';
336 // garvin: MIME-types
337 if ($cfgRelation['mimework
'] && $cfg['BrowseMIME
'] && $cfgRelation['commwork
']) {
338 $content_cells[$i][$ci] = '<select id
="field_' . $i . '_8" size
="1" name
="field_mimetype[]">' . "\n";
339 $content_cells[$i][$ci] .= ' <option value
=""></option
>' . "\n";
340 $content_cells[$i][$ci] .= ' <option value
="auto">auto
-detect
</option
>' . "\n";
342 if (is_array($available_mime['mimetype
'])) {
343 @reset($available_mime['mimetype
']);
344 while(list($mimekey, $mimetype) = each($available_mime['mimetype
'])) {
345 $checked = (isset($row) && isset($row['Field
']) && isset($mime_map[$row['Field
']]['mimetype
']) && ($mime_map[$row['Field
']]['mimetype
'] == str_replace('/', '_
', $mimetype)) ? 'selected
' : '');
346 $content_cells[$i][$ci] .= ' <option value
="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option
>';
350 $content_cells[$i][$ci] .= '</select
>';
353 $content_cells[$i][$ci] = '<select id
="field_' . $i . '_9" size
="1" name
="field_transformation[]">' . "\n";
354 $content_cells[$i][$ci] .= ' <option value
="" title
="' . $strNone . '"></option
>' . "\n";
355 if (is_array($available_mime['transformation
'])) {
356 @reset($available_mime['transformation
']);
357 while(list($mimekey, $transform) = each($available_mime['transformation
'])) {
358 $checked = (isset($row) && isset($row['Field
']) && isset($mime_map[$row['Field
']]['transformation
']) && ($mime_map[$row['Field
']]['transformation
'] == $available_mime['transformation_file
'][$mimekey]) ? 'selected
' : '');
359 $tooltip = 'strTransformation_
' . strtolower(str_replace('.inc
.php3
', '', $available_mime['transformation_file
'][$mimekey]));
360 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br
/>', ' ', $strMIME_nodescription), 'PMA_transformation_
' . $tooltip . '()');
361 $content_cells[$i][$ci] .= '<option value
="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title
="' . $tooltip . '">' . htmlspecialchars($transform) . '</option
>' . "\n";
365 $content_cells[$i][$ci] .= '</select
>';
368 $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" />';
372 // lem9: See my other comment about removing this 'if'.
374 if (isset($row) && isset($row['Key
']) && $row['Key
'] == 'PRI
') {
375 $checked_primary = ' checked
="checked"';
377 $checked_primary = '';
379 if (isset($row) && isset($row['Key
']) && $row['Key
'] == 'MUL
') {
380 $checked_index = ' checked
="checked"';
384 if (isset($row) && isset($row['Key
']) && $row['Key
'] == 'UNI
') {
385 $checked_unique = ' checked
="checked"';
387 $checked_unique = '';
389 if (empty($checked_primary)
390 && empty($checked_index)
391 && empty($checked_unique)) {
392 $checked_none = ' checked
="checked"';
397 if (PMA_MYSQL_INT_VERSION >= 32323
398 &&(isset($row) && isset($row['Comment
']) && $row['Comment
'] == 'FULLTEXT
')) {
399 $checked_fulltext = ' checked
="checked"';
401 $checked_fulltext = '';
404 $content_cells[$i][$ci] = "\n" . '<input type
="radio" name
="field_key_' . $i . '" value
="primary_' . $i . '"' . $checked_primary . ' />';
407 $content_cells[$i][$ci] = "\n" . '<input type
="radio" name
="field_key_' . $i . '" value
="index_' . $i . '"' . $checked_index . ' />';
410 $content_cells[$i][$ci] = "\n" . '<input type
="radio" name
="field_key_' . $i . '" value
="unique_' . $i . '"' . $checked_unique . ' />';
413 $content_cells[$i][$ci] = "\n" . '<input type
="radio" name
="field_key_' . $i . '" value
="none_' . $i . '"' . $checked_none . ' />';
416 if (PMA_MYSQL_INT_VERSION >= 32323) {
417 $content_cells[$i][$ci] = '<input type
="checkbox" name
="field_fulltext[]" value
="' . $i . '"' . $checked_fulltext . ' />';
418 } // end if (PMA_MYSQL_INT_VERSION >= 32323)
419 } // end if ($action ==...)
422 if ($cfg['DefaultPropDisplay
'] == 'horizontal
') {
424 <table border="<?php echo $cfg['Border
']; ?>">
427 @reset($header_cells);
428 while(@list($header_nr, $header_val) = @each($header_cells)) {
430 <th><?php echo $header_val; ?></th>
436 @reset($content_cells);
438 while(@list($content_nr, $content_row) = @each($content_cells)) {
440 echo "\n" . '<tr
>' . "\n";
442 $bgcolor = ($i % 2) ? $cfg['BgcolorOne
'] : $cfg['BgcolorTwo
'];
444 while(list($content_row_nr, $content_row_val) = @each($content_row)) {
446 <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $content_row_val; ?></td>
449 echo "\n" . '</tr
>' . "\n";
457 <table border="<?php echo $cfg['Border
']; ?>">
459 @reset($header_cells);
461 while(@list($header_nr, $header_val) = @each($header_cells)) {
462 echo "\n" . '<tr
>' . "\n";
464 <th align="right"><?php echo $header_val; ?></th>
466 for ($j = 0; $j < count($content_cells); $j++) {
467 if (isset($content_cells[$j][$i]) && $content_cells[$j][$i] != '') {
468 $bgcolor = ($j % 2) ? $cfg['BgcolorOne
'] : $cfg['BgcolorTwo
'];
470 <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $content_cells[$j][$i]; ?></td>
475 echo "\n" . '</tr
>' . "\n";
484 if ($action == 'tbl_create
.php3
' && PMA_MYSQL_INT_VERSION >= 32300) {
489 <td><?php echo $strTableComments; ?> :</td>
491 if ($action == 'tbl_create
.php3
') {
494 <td width="25"> </td>
495 <td><?php echo $strTableType; ?> :</td>
503 <input type="text" name="comment" size="40" maxlength="80" value="<?php echo (isset($comment) ? $comment : ''); ?>" class="textfield" />
506 // BEGIN - Table Type - 2 May 2001 - Robbat2
507 // change by staybyte - 11 June 2001
508 if ($action == 'tbl_create
.php3
') {
509 // find mysql capability - staybyte - 11. June 2001
510 $query = 'SHOW VARIABLES LIKE \'have_%\'
';
511 $result = PMA_mysql_query($query);
512 if ($result != FALSE && mysql_num_rows($result) > 0) {
513 while ($tmp = PMA_mysql_fetch_array($result)) {
514 if (isset($tmp['Variable_name
'])) {
515 switch ($tmp['Variable_name
']) {
517 if (isset($tmp['Variable_name
']) && $tmp['Value
'] == 'YES
') {
522 if (isset($tmp['Variable_name
']) && $tmp['Value
'] == 'YES
') {
527 if (isset($tmp['Variable_name
']) && $tmp['Value
'] == 'YES
') {
532 if (isset($tmp['Variable_name
']) && $tmp['Value
'] == 'YES
') {
540 mysql_free_result($result);
544 <td width="25"> </td>
546 <select name="tbl_type">
547 <option <?php echo (isset($tbl_type) && $tbl_type == 'Default' ? 'selected
="checked"' : ''); ?> value="Default"><?php echo $strDefault; ?></option>
548 <option <?php echo (isset($tbl_type) && $tbl_type == 'MYISAM
' ? 'selected
="checked"' : ''); ?> value="MYISAM">MyISAM</option>
549 <option <?php echo (isset($tbl_type) && $tbl_type == 'HEAP
' ? 'selected
="checked"' : ''); ?> value="HEAP">Heap</option>
550 <option <?php echo (isset($tbl_type) && $tbl_type == 'MERGE
' ? 'selected
="checked"' : ''); ?> value="MERGE">Merge</option>
551 <?php if (isset($tbl_bdb)) { ?><option <?php echo (isset($tbl_type) && $tbl_type == 'BDB
' ? 'selected
="checked"' : ''); ?> value="BDB">Berkeley DB</option><?php } ?>
552 <?php if (isset($tbl_gemini)) { ?><option <?php echo (isset($tbl_type) && $tbl_type == 'GEMINI
' ? 'selected
="checked"' : ''); ?> value="GEMINI">Gemini</option><?php } ?>
553 <?php if (isset($tbl_innodb)) { ?><option <?php echo (isset($tbl_type) && $tbl_type == 'INNO DB
' ? 'selected
="checked"' : ''); ?> value="InnoDB">INNO DB</option><?php } ?>
554 <?php if (isset($tbl_isam)) { ?><option <?php echo (isset($tbl_type) && $tbl_type == 'ISAM
' ? 'selected
="checked"' : ''); ?> value="ISAM">ISAM</option><?php } ?>
567 // END - Table Type - 2 May 2001 - Robbat2
570 <input type="submit" name="submit" value="<?php echo $strSave; ?>" />
575 <td valign="top">* </td>
577 <?php echo $strSetEnumVal . "\n"; ?>
581 <td valign="top">** </td>
583 <?php echo $strDefaultValueHelp . "\n"; ?>
588 if ($cfgRelation['commwork
'] && $cfgRelation['mimework
'] && $cfg['BrowseMIME
']) {
591 <td valign="top" rowspan="2">*** </td>
593 <?php echo $strMIME_transformation_options_note . "\n"; ?>
599 <?php echo sprintf($strMIME_transformation_note, '<a href
="libraries/transformations/overview.php3?' . PMA_generate_common_url($db, $table) . '" target
="_new">', '</a
>') . "\n"; ?>
609 <center><?php echo PMA_showMySQLDocu('Reference
', 'CREATE_TABLE
'); ?></center>