From e08f775b68f7c52f7287974623a7ca42a2ab149b Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 29 Mar 2005 18:09:47 +0000 Subject: [PATCH] Don't offer unavailable collations. --- ChangeLog | 4 ++++ libraries/mysql_charsets.lib.php | 14 +++++++++++--- server_collations.php | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9620b7703..faad4953a 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-03-29 Alexander M. Turek + * server_collations.php, libraries/mysql_charsets.lib.php: Don't offer + unavailable collations (bug #1172517). + 2005-03-28 Alexander M. Turek * left.php: Implemented the forgotten view icon. diff --git a/libraries/mysql_charsets.lib.php b/libraries/mysql_charsets.lib.php index 616ad4522..1bb5f1d21 100644 --- a/libraries/mysql_charsets.lib.php +++ b/libraries/mysql_charsets.lib.php @@ -21,7 +21,7 @@ if (PMA_MYSQL_INT_VERSION >= 40100){ sort($mysql_charsets, SORT_STRING); $mysql_collations = array_flip($mysql_charsets); - $mysql_default_collations = $mysql_collations_flat = array();; + $mysql_default_collations = $mysql_collations_flat = $mysql_charsets_available = $mysql_collations_available = array(); while ($row = PMA_DBI_fetch_assoc($res)) { if (!is_array($mysql_collations[$row['Charset']])) { $mysql_collations[$row['Charset']] = array($row['Collation']); @@ -32,6 +32,8 @@ if (PMA_MYSQL_INT_VERSION >= 40100){ if ((isset($row['D']) && $row['D'] == 'Y') || (isset($row['Default']) && $row['Default'] == 'Yes')) { $mysql_default_collations[$row['Charset']] = $row['Collation']; } + $mysql_collations_available[$row['Collation']] = !isset($row['Compiled']) || $row['Compiled'] == 'Yes'; + $mysql_charsets_available[$row['Charset']] = !empty($mysql_charsets_available[$row['Charset']]) || !empty($mysql_collations_available[$row['Collation']]); } $mysql_collations_count = count($mysql_collations_flat); @@ -304,8 +306,8 @@ if (PMA_MYSQL_INT_VERSION >= 40100){ define('PMA_CSDROPDOWN_COLLATION', 0); define('PMA_CSDROPDOWN_CHARSET', 1); - function PMA_generateCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION, $name = NULL, $id = NULL, $default = NULL, $label = TRUE, $indent = 0, $submitOnChange = FALSE) { - global $mysql_charsets, $mysql_charsets_descriptions, $mysql_collations; + function PMA_generateCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION, $name = NULL, $id = NULL, $default = NULL, $label = TRUE, $indent = 0, $submitOnChange = FALSE, $displayUnavailable = FALSE) { + global $mysql_charsets, $mysql_charsets_descriptions, $mysql_charsets_available, $mysql_collations, $mysql_collations_available; if (empty($name)) { if ($type == PMA_CSDROPDOWN_COLLATION) { @@ -324,10 +326,16 @@ if (PMA_MYSQL_INT_VERSION >= 40100){ } $return_str .= $spacer . ' ' . "\n"; foreach ($mysql_charsets as $current_charset) { + if (!$mysql_charsets_available[$current_charset]) { + continue; + } $current_cs_descr = empty($mysql_charsets_descriptions[$current_charset]) ? $current_charset : $mysql_charsets_descriptions[$current_charset]; if ($type == PMA_CSDROPDOWN_COLLATION) { $return_str .= $spacer . ' ' . "\n"; foreach ($mysql_collations[$current_charset] as $current_collation) { + if (!$mysql_collations_available[$current_collation]) { + continue; + } $return_str .= $spacer . ' ' . "\n"; } $return_str .= $spacer . ' ' . "\n"; diff --git a/server_collations.php b/server_collations.php index ea78d0d0e..15b6ca7ea 100644 --- a/server_collations.php +++ b/server_collations.php @@ -84,7 +84,7 @@ foreach ($mysql_charsets as $current_charset) { $useBgcolorOne = TRUE; foreach ($mysql_collations[$current_charset] as $current_collation) { $i++; - echo ' ' . "\n" + echo ' ' . "\n" . ' ' . "\n" . '  ' . htmlspecialchars($current_collation) . ' ' . "\n" . ' ' . "\n"