summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-04-10 17:15:48 (GMT)
committerAlex Pott2013-04-10 17:15:48 (GMT)
commitc7916f055102f457e8d31422e0fdec7a05a4dae0 (patch)
tree554f457b5a8ae9ac594ab3f930c749a6ee218053
parent681a26068bb45cb94af0e95a166b9346e7a46ea4 (diff)
Issue #1959110 by a.ross: Fixed theme_table() outputs the no_striping() option as an HTML attribute.
-rw-r--r--core/includes/theme.inc21
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php15
2 files changed, 25 insertions, 11 deletions
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 8e6b8e9..9a4f2ee 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2203,25 +2203,24 @@ function theme_table($variables) {
$flip = array('even' => 'odd', 'odd' => 'even');
$class = 'even';
foreach ($rows as $number => $row) {
- $attributes = array();
-
// Check if we're dealing with a simple or complex row
if (isset($row['data'])) {
- foreach ($row as $key => $value) {
- if ($key == 'data') {
- $cells = $value;
- }
- else {
- $attributes[$key] = $value;
- }
- }
+ $cells = $row['data'];
+ $no_striping = isset($row['no_striping']) ? $row['no_striping'] : FALSE;
+
+ // Set the attributes array and exclude 'data' and 'no_striping'.
+ $attributes = $row;
+ unset($attributes['data']);
+ unset($attributes['no_striping']);
}
else {
$cells = $row;
+ $attributes = array();
+ $no_striping = FALSE;
}
if (count($cells)) {
// Add odd/even class
- if (empty($row['no_striping'])) {
+ if (!$no_striping) {
$class = $flip[$class];
$attributes['class'][] = $class;
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php
index 392959d..0dbedd7 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php
@@ -66,4 +66,19 @@ class TableTest extends WebTestBase {
$this->assertRaw('<tr class="odd"><td colspan="3" class="empty message">No strings available.</td>', 'Correct colspan was set on empty message.');
$this->assertRaw('<thead><tr><th>Header 1</th>', 'Table header was printed.');
}
+
+ /**
+ * Tests that the 'no_striping' option works correctly.
+ */
+ function testThemeTableWithNoStriping() {
+ $rows = array(
+ array(
+ 'data' => array(1),
+ 'no_striping' => TRUE,
+ ),
+ );
+ $this->content = theme('table', array('rows' => $rows));
+ $this->assertNoRaw('class="odd"', 'Odd/even classes were not added because $no_striping = TRUE.');
+ $this->assertNoRaw('no_striping', 'No invalid no_striping HTML attribute was printed.');
+ }
}