summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-03-18 19:03:29 +0000
committerDries Buytaert <dries@buytaert.net>2010-03-18 19:03:29 +0000
commitcb009a324e86e1bd4ab4d421881ab96f9077906a (patch)
tree9952a9895f070eac45a79f9a6f3114ab8f6a4141
parent224243b8173b9a75b45072ee81f97601fba83d3c (diff)
downloadbrdo-cb009a324e86e1bd4ab4d421881ab96f9077906a.tar.gz
brdo-cb009a324e86e1bd4ab4d421881ab96f9077906a.tar.bz2
- Patch #720202 by naxoc, kkaefer: theme_table() doesn't use thead with empty cells.
-rw-r--r--includes/theme.inc10
-rw-r--r--modules/simpletest/tests/theme.test11
2 files changed, 16 insertions, 5 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index f8ebbffb7..6f436df02 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -1663,6 +1663,11 @@ function theme_table($variables) {
}
}
+ // Add the 'empty' row message if available.
+ if (!count($rows) && $empty) {
+ $rows[] = array(array('data' => $empty, 'colspan' => count($header), 'class' => array('empty', 'message')));
+ }
+
// Format the table header:
if (count($header)) {
$ts = tablesort_init($header);
@@ -1680,11 +1685,6 @@ function theme_table($variables) {
$ts = array();
}
- // Add the 'empty' row message if available.
- if (!count($rows) && $empty) {
- $rows[] = array(array('data' => $empty, 'colspan' => count($header), 'class' => array('empty', 'message')));
- }
-
// Format the table rows:
if (count($rows)) {
$output .= "<tbody>\n";
diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test
index c46dc9d93..d3ba6f9bb 100644
--- a/modules/simpletest/tests/theme.test
+++ b/modules/simpletest/tests/theme.test
@@ -95,6 +95,17 @@ class ThemeTableUnitTest extends DrupalWebTestCase {
$this->assertNoRaw('sticky-enabled', t('Table does not have a class of sticky-enabled because $sticky = FALSE.'));
drupal_static_reset('drupal_add_js');
}
+
+ /**
+ * Tests that the table header is printed even if there are no rows. And that
+ * the empty text is displayed correctly.
+ */
+ function testThemeTableWithEmptyMessage() {
+ $header = array(t('Header 1'), t('Header 2'));
+ $this->content = theme('table', array('header' => $header, 'rows' => array(), 'empty' => t('No strings available.')));
+ $this->assertRaw('<tr class="odd"><td colspan="2" class="empty message">No strings available.</td>', t('Correct colspan was set on empty message.'));
+ $this->assertRaw('<thead><tr><th>Header 1</th>', t('Table header was printed.'));
+ }
}
/**