Bug #3141327 (Foreign key input options)

This commit is contained in:
Marc Delisle
2010-12-27 08:29:31 -05:00
parent 0bc06b2a1a
commit ab393d3f82
2 changed files with 33 additions and 23 deletions

View File

@@ -127,6 +127,7 @@
- [interface] Use less noisy message and remove disable link on server charts and database statistics. - [interface] Use less noisy message and remove disable link on server charts and database statistics.
+ rfe #3141330 [relation] When displaying results, show a link to the foreign + rfe #3141330 [relation] When displaying results, show a link to the foreign
table even when phpMyAdmin configuration storage is not active table even when phpMyAdmin configuration storage is not active
- bug #3141327 [relation] Foreign key input options
3.3.10.0 (not yet released) 3.3.10.0 (not yet released)

View File

@@ -840,7 +840,9 @@ function PMA__foreignDropdownBuild($foreign, $data, $mode)
{ {
$reloptions = array(); $reloptions = array();
if ($mode == 'id-content') { // id-only is a special mode used when no foreign display column
// is available
if ($mode == 'id-content' || $mode == 'id-only') {
// sort for id-content // sort for id-content
if ($GLOBALS['cfg']['NaturalOrder']) { if ($GLOBALS['cfg']['NaturalOrder']) {
uksort($foreign, 'strnatcasecmp'); uksort($foreign, 'strnatcasecmp');
@@ -857,7 +859,6 @@ function PMA__foreignDropdownBuild($foreign, $data, $mode)
} }
foreach ($foreign as $key => $value) { foreach ($foreign as $key => $value) {
if (PMA_strlen($value) <= $GLOBALS['cfg']['LimitChars']) { if (PMA_strlen($value) <= $GLOBALS['cfg']['LimitChars']) {
$vtitle = ''; $vtitle = '';
$value = htmlspecialchars($value); $value = htmlspecialchars($value);
@@ -866,7 +867,7 @@ function PMA__foreignDropdownBuild($foreign, $data, $mode)
$value = htmlspecialchars(substr($value, 0, $GLOBALS['cfg']['LimitChars']) . '...'); $value = htmlspecialchars(substr($value, 0, $GLOBALS['cfg']['LimitChars']) . '...');
} }
$reloption = ' <option value="' . htmlspecialchars($key) . '"'; $reloption = '<option value="' . htmlspecialchars($key) . '"';
if ($vtitle != '') { if ($vtitle != '') {
$reloption .= ' title="' . $vtitle . '"'; $reloption .= ' title="' . $vtitle . '"';
} }
@@ -876,9 +877,11 @@ function PMA__foreignDropdownBuild($foreign, $data, $mode)
} }
if ($mode == 'content-id') { if ($mode == 'content-id') {
$reloptions[] = $reloption . '>' . $value . '&nbsp;-&nbsp;' . htmlspecialchars($key) . '</option>' . "\n"; $reloptions[] = $reloption . '>' . $value . '&nbsp;-&nbsp;' . htmlspecialchars($key) . '</option>';
} else { } elseif ($mode == 'id-content') {
$reloptions[] = $reloption . '>' . htmlspecialchars($key) . '&nbsp;-&nbsp;' . $value . '</option>' . "\n"; $reloptions[] = $reloption . '>' . htmlspecialchars($key) . '&nbsp;-&nbsp;' . $value . '</option>';
} elseif ($mode == 'id-only') {
$reloptions[] = $reloption . '>' . htmlspecialchars($key) . '</option>';
} }
} // end foreach } // end foreach
@@ -925,33 +928,39 @@ function PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data,
// put the dropdown sections in correct order // put the dropdown sections in correct order
$top = array(); $top = array();
$bot = array(); $bottom = array();
if (PMA_isValid($GLOBALS['cfg']['ForeignKeyDropdownOrder'], 'array')) { if ($foreign_display) {
if (PMA_isValid($GLOBALS['cfg']['ForeignKeyDropdownOrder'][0])) { if (PMA_isValid($GLOBALS['cfg']['ForeignKeyDropdownOrder'], 'array')) {
$top = PMA__foreignDropdownBuild($foreign, $data, if (PMA_isValid($GLOBALS['cfg']['ForeignKeyDropdownOrder'][0])) {
$GLOBALS['cfg']['ForeignKeyDropdownOrder'][0]); $top = PMA__foreignDropdownBuild($foreign, $data,
} $GLOBALS['cfg']['ForeignKeyDropdownOrder'][0]);
if (PMA_isValid($GLOBALS['cfg']['ForeignKeyDropdownOrder'][1])) { }
$bot = PMA__foreignDropdownBuild($foreign, $data, if (PMA_isValid($GLOBALS['cfg']['ForeignKeyDropdownOrder'][1])) {
$GLOBALS['cfg']['ForeignKeyDropdownOrder'][1]); $bottom = PMA__foreignDropdownBuild($foreign, $data,
$GLOBALS['cfg']['ForeignKeyDropdownOrder'][1]);
}
} else {
$top = PMA__foreignDropdownBuild($foreign, $data, 'id-content');
$bottom = PMA__foreignDropdownBuild($foreign, $data, 'content-id');
} }
} else { } else {
$top = PMA__foreignDropdownBuild($foreign, $data, 'id-content'); $top = PMA__foreignDropdownBuild($foreign, $data, 'id-only');
$bot = PMA__foreignDropdownBuild($foreign, $data, 'content-id');
} }
// beginning of dropdown // beginning of dropdown
$ret = '<option value="">&nbsp;</option>' . "\n"; $ret = '<option value="">&nbsp;</option>';
$top_count = count($top); $top_count = count($top);
if ($max == -1 || $top_count < $max) { if ($max == -1 || $top_count < $max) {
$ret .= implode('', $top); $ret .= implode('', $top);
if ($top_count > 0) { if ($foreign_display && $top_count > 0) {
$ret .= ' <option value="">&nbsp;</option>' . "\n"; // this empty option is to visually mark the beginning of the
$ret .= ' <option value="">&nbsp;</option>' . "\n"; // second series of values (bottom)
$ret .= '<option value="">&nbsp;</option>';
} }
} }
$ret .= implode('', $bot); if ($foreign_display) {
$ret .= implode('', $bottom);
}
return $ret; return $ret;
} // end of 'PMA_foreignDropdown()' function } // end of 'PMA_foreignDropdown()' function