diff --git a/ChangeLog b/ChangeLog index f094e4277..c9d5f2fe0 100755 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ $Id$ $Source$ 2004-01-05 Garvin Hicking + * browse_foreigners.php, tbl_change.php: Sort key/value pairs + as discussed in RFE #868369. Made foreigner window resizable. * libraries/functions.js: Reverted row marker patch. See RFE #867284 for details. * libraries/display_tbl.lib.php, libraries/display_tbl_links.lib.php, diff --git a/browse_foreigners.php b/browse_foreigners.php index f18ce72f9..5461bc39f 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -139,30 +139,75 @@ $header = ' echo $header; if (isset($disp) && $disp) { + function dimsort($arrayA, $arrayB) { + $keyA = key($arrayA); + $keyB = key($arrayB); + + if ($arrayA[$keyA] == $arrayB[$keyB]) { + return 0; + } + + return ($arrayA[$keyA] < $arrayB[$keyB]) ? -1 : 1; + } + + $mysql_key_relrow = array(); + $mysql_val_relrow = array(); $count = 0; while ($relrow = @PMA_mysql_fetch_array($disp)) { + if ($foreign_display != FALSE) { + $val = $relrow[$foreign_display]; + } else { + $val = ''; + } + + $mysql_key_relrow[$count] = array($relrow[$foreign_field] => $val); + $mysql_val_relrow[$count] = array($val => $relrow[$foreign_field]); $count++; - $bgcolor = ($count % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; + } + + usort($mysql_val_relrow, 'dimsort'); + + $hcount = 0; + for ($i = 0; $i < $count; $i++) { + $hcount++; + $bgcolor = ($hcount % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; - $key = $relrow[$foreign_field]; - if (strlen($relrow[$foreign_display]) <= $cfg['LimitChars']) { - $value = (($foreign_display != FALSE) ? htmlspecialchars($relrow[$foreign_display]) : ''); + if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) { + echo $header; + $hcount = -1; + } + + + $val = key($mysql_val_relrow[$i]); + $key = $mysql_val_relrow[$i][$val]; + + if (strlen($val) <= $cfg['LimitChars']) { + $value = htmlspecialchars($val); $vtitle = ''; } else { - $vtitle = htmlspecialchars($relrow[$foreign_display]); - $value = (($foreign_display != FALSE) ? htmlspecialchars(substr($vtitle, 0, $cfg['LimitChars']) . '...') : ''); + $vtitle = htmlspecialchars($val); + $value = htmlspecialchars(substr($val, 0, $cfg['LimitChars']) . '...'); } - if ($cfg['RepeatCells'] > 0 && $count > $cfg['RepeatCells']) { - echo $header; - $count = -1; - } $key_equals_data = isset($data) && $key == $data; ?> ' : '') . '' . htmlspecialchars($key) . '' . ($key_equals_data ? '' : ''); ?> ' : '') . '' . $value . '' . ($key_equals_data ? '' : ''); ?> + ' : '') . '' . $value . '' . ($key_equals_data ? '' : ''); ?> ' : '') . '' . htmlspecialchars($key) . '' . ($key_equals_data ? '' : ''); ?> diff --git a/tbl_change.php b/tbl_change.php index 61729a724..76e201b8a 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -505,7 +505,7 @@ foreach($loop_array AS $vrowcount => $vrow) { ="return unNullify('', '')" tabindex="" id="field__3" value="" />