diff --git a/includes/theme.inc b/includes/theme.inc
index 57c2b1724eb..c59a7f11f61 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -581,10 +581,29 @@ function theme_submenu($links) {
* - "sort": A default sort order for this column ("asc" or "desc").
* - Any HTML attributes, such as "colspan", to apply to the column header cell.
* @param $rows
- * An array of arrays containing the table cells. Each cell can be either a
- * string or and associative array with the following keys:
+ * An array of table rows. Every row is an array of cells, or an associative
+ * array with the following keys:
+ * - "data": an array of cells
+ * - Any HTML attributes, such as "class", to apply to the table row.
+ *
+ * Each cell can be either a string or an associative array with the following keys:
* - "data": The string to display in the table cell.
* - Any HTML attributes, such as "colspan", to apply to the table cell.
+ *
+ * Here's an example for $rows:
+ * @verbatim
+ * $rows = array(
+ * // Simple row
+ * array(
+ * 'Cell 1', 'Cell 2', 'Cell 3'
+ * ),
+ * // Row with attributes on the row and some of its cells.
+ * array(
+ * 'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => 'funky'
+ * )
+ * );
+ * @endverbatim
+ *
* @param $attributes
* An array of HTML attributes to apply to the table tag.
* @return
@@ -608,18 +627,38 @@ function theme_table($header, $rows, $attributes = NULL) {
// Format the table rows:
if (is_array($rows)) {
foreach ($rows as $number => $row) {
- if ($number % 2 == 1) {
- $output .= '
';
+ $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;
+ }
+ }
}
else {
- $output .= '
';
+ $cells = $row;
}
+ // Add light/dark class
+ $class = ($number % 2 == 1) ? 'light': 'dark';
+ if (isset($attributes['class'])) {
+ $attributes['class'] .= ' '. $class;
+ }
+ else {
+ $attributes['class'] = $class;
+ }
+
+ // Build row
+ $output .= '
';
$i = 0;
- foreach ($row as $cell) {
- $cell = tablesort_cell($cell, $header, $ts, $i);
+ foreach ($cells as $cell) {
+ $cell = tablesort_cell($cell, $header, $ts, $i++);
$output .= _theme_table_cell($cell, 0);
- $i++;
}
$output .= "
\n";
}
diff --git a/misc/drupal.css b/misc/drupal.css
index 0c341eaa4ef..bcc8b1156ba 100644
--- a/misc/drupal.css
+++ b/misc/drupal.css
@@ -37,14 +37,14 @@ th {
th.active img {
display: inline;
}
-tr.dark td, tr.light td {
+tr.dark, tr.light {
background-color: #eee;
border-bottom: 1px solid #ccc;
}
-tr.dark td, tr.light td {
+tr.dark, tr.light {
padding: 0.1em 0.6em;
}
-tr td.active {
+td.active {
background-color: #ddd;
}
@@ -390,34 +390,34 @@ img.screenshot {
font-size: 0.85em;
text-align: right;
}
-tr td.watchdog-user {
+tr.watchdog-user {
background: #ffd;
}
-tr td.watchdog-user.active {
+tr.watchdog-user .active {
background: #eed;
}
-tr td.watchdog-special {
+tr.watchdog-special {
background: #ddf;
}
-tr td.watchdog-special.active {
+tr.watchdog-special .active {
background: #cce;
}
-tr td.watchdog-warning {
+tr.watchdog-warning {
background: #fda;
}
-tr td.watchdog-warning.active {
+tr.watchdog-warning .active {
background: #ec9;
}
-tr td.watchdog-httpd {
+tr.watchdog-httpd {
background: #dfd;
}
-tr td.watchdog-httpd.active {
+tr.watchdog-httpd .active {
background: #cec;
}
-tr td.watchdog-error {
+tr.watchdog-error {
background: #ffc9c9;
}
-tr td.watchdog-error.active {
+tr.watchdog-error .active {
background: #eeb9b9;
}
diff --git a/modules/watchdog.module b/modules/watchdog.module
index c37ff3b2b6f..9be7a45f72e 100644
--- a/modules/watchdog.module
+++ b/modules/watchdog.module
@@ -95,12 +95,17 @@ function watchdog_overview($type = '') {
$result = pager_query($sql, 50);
while ($watchdog = db_fetch_object($result)) {
- $rows[] = array(
- array('data' => format_date($watchdog->timestamp, 'small'), 'class' => "watchdog-$watchdog->type"),
- array('data' => truncate_utf8(strip_tags($watchdog->message), 64), 'class' => "watchdog-$watchdog->type"),
- array('data' => format_name($watchdog), 'class' => "watchdog-$watchdog->type"),
- array('data' => $watchdog->link, 'class' => "watchdog-$watchdog->type"),
- array('data' => l(t('details'), "admin/logs/view/$watchdog->wid"), 'class' => "watchdog-$watchdog->type")
+ $rows[] = array('data' =>
+ array(
+ // Cells
+ format_date($watchdog->timestamp, 'small'),
+ truncate_utf8(strip_tags($watchdog->message), 64),
+ format_name($watchdog),
+ $watchdog->link,
+ l(t('details'), "admin/logs/view/$watchdog->wid")
+ ),
+ // Attributes for tr
+ 'class' => "watchdog-$watchdog->type"
);
}
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module
index c37ff3b2b6f..9be7a45f72e 100644
--- a/modules/watchdog/watchdog.module
+++ b/modules/watchdog/watchdog.module
@@ -95,12 +95,17 @@ function watchdog_overview($type = '') {
$result = pager_query($sql, 50);
while ($watchdog = db_fetch_object($result)) {
- $rows[] = array(
- array('data' => format_date($watchdog->timestamp, 'small'), 'class' => "watchdog-$watchdog->type"),
- array('data' => truncate_utf8(strip_tags($watchdog->message), 64), 'class' => "watchdog-$watchdog->type"),
- array('data' => format_name($watchdog), 'class' => "watchdog-$watchdog->type"),
- array('data' => $watchdog->link, 'class' => "watchdog-$watchdog->type"),
- array('data' => l(t('details'), "admin/logs/view/$watchdog->wid"), 'class' => "watchdog-$watchdog->type")
+ $rows[] = array('data' =>
+ array(
+ // Cells
+ format_date($watchdog->timestamp, 'small'),
+ truncate_utf8(strip_tags($watchdog->message), 64),
+ format_name($watchdog),
+ $watchdog->link,
+ l(t('details'), "admin/logs/view/$watchdog->wid")
+ ),
+ // Attributes for tr
+ 'class' => "watchdog-$watchdog->type"
);
}