From cd4958f72c249b9254f7038432cbe7a390dd93bf Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Dec 2011 14:44:09 +0200 Subject: [PATCH 1/2] [ticket/10507] Sort styles in acp Sort styles by name in admin control panel PHPBB3-10507 --- phpBB/includes/acp/acp_styles.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 3bc8c86500..38f4c57bd8 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -540,6 +540,7 @@ parse_css_file = {PARSE_CSS_FILE} global $user, $template, $db, $config, $phpbb_root_path, $phpEx; $sql_from = ''; + $sql_sort = 'LOWER(' . $mode . '_name)'; $style_count = array(); switch ($mode) @@ -571,6 +572,9 @@ parse_css_file = {PARSE_CSS_FILE} case 'imageset': $sql_from = STYLES_IMAGESET_TABLE; break; + + default: + trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING); } $l_prefix = strtoupper($mode); @@ -594,7 +598,8 @@ parse_css_file = {PARSE_CSS_FILE} ); $sql = "SELECT * - FROM $sql_from"; + FROM $sql_from + ORDER BY $sql_sort ASC"; $result = $db->sql_query($sql); $installed = array(); From 80149d0c872292cf7cf7be8aa1eca5641f7cd708 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Dec 2011 16:18:52 +0200 Subject: [PATCH 2/2] [ticket/10507] DBAL unit test Unit test for ORDER BY LOWER(style_name) PHPBB3-10507 --- tests/dbal/fixtures/styles.xml | 39 +++++++++++++++++++++ tests/dbal/order_lower_test.php | 62 +++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 tests/dbal/fixtures/styles.xml create mode 100644 tests/dbal/order_lower_test.php diff --git a/tests/dbal/fixtures/styles.xml b/tests/dbal/fixtures/styles.xml new file mode 100644 index 0000000000..47b384c47f --- /dev/null +++ b/tests/dbal/fixtures/styles.xml @@ -0,0 +1,39 @@ + + + + style_id + style_name + style_copyright + style_active + template_id + theme_id + imageset_id + + 1 + prosilver + © phpBB Group + 1 + 1 + 1 + 1 + + + 2 + prosilver2 + © phpBB Group + 0 + 2 + 2 + 2 + + + 3 + Prosilver1 + © phpBB Group + 0 + 3 + 3 + 3 + +
+
diff --git a/tests/dbal/order_lower_test.php b/tests/dbal/order_lower_test.php new file mode 100644 index 0000000000..fd1c950252 --- /dev/null +++ b/tests/dbal/order_lower_test.php @@ -0,0 +1,62 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/styles.xml'); + } + + public function test_cross_join() + { + $db = $this->new_dbal(); + + // http://tracker.phpbb.com/browse/PHPBB3-10507 + // Test ORDER BY LOWER(style_name) + $db->sql_return_on_error(true); + + $sql = 'SELECT * FROM phpbb_styles ORDER BY LOWER(style_name)'; + $result = $db->sql_query($sql); + + $db->sql_return_on_error(false); + + $this->assertEquals(array( + array( + 'style_id' => 1, + 'style_name' => 'prosilver', + 'style_copyright' => '© phpBB Group', + 'style_active' => 1, + 'template_id' => 1, + 'theme_id' => 1, + 'imageset_id' => 1 + ), + array( + 'style_id' => 3, + 'style_name' => 'Prosilver1', + 'style_copyright' => '© phpBB Group', + 'style_active' => 0, + 'template_id' => 3, + 'theme_id' => 3, + 'imageset_id' => 3 + ), + array( + 'style_id' => 2, + 'style_name' => 'prosilver2', + 'style_copyright' => '© phpBB Group', + 'style_active' => 0, + 'template_id' => 2, + 'theme_id' => 2, + 'imageset_id' => 2 + ) + ), + $db->sql_fetchrowset($result) + ); + } +}