Commit 3ffb612a authored by Steven Wittens's avatar Steven Wittens
Browse files

#76741: Allow <th> tags for theme_table cells

parent 8c1560c7
...@@ -663,6 +663,7 @@ function theme_submenu($links) { ...@@ -663,6 +663,7 @@ function theme_submenu($links) {
* *
* Each cell can be either a string or an associative array with the following keys: * Each cell can be either a string or an associative array with the following keys:
* - "data": The string to display in the table cell. * - "data": The string to display in the table cell.
* - "header": Indicates this cell is a header.
* - Any HTML attributes, such as "colspan", to apply to the table cell. * - Any HTML attributes, such as "colspan", to apply to the table cell.
* *
* Here's an example for $rows: * Here's an example for $rows:
...@@ -699,7 +700,7 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) { ...@@ -699,7 +700,7 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) {
$output .= ' <thead><tr>'; $output .= ' <thead><tr>';
foreach ($header as $cell) { foreach ($header as $cell) {
$cell = tablesort_header($cell, $header, $ts); $cell = tablesort_header($cell, $header, $ts);
$output .= _theme_table_cell($cell, 1); $output .= _theme_table_cell($cell, TRUE);
} }
$output .= " </tr></thead>\n"; $output .= " </tr></thead>\n";
} }
...@@ -739,7 +740,7 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) { ...@@ -739,7 +740,7 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) {
$i = 0; $i = 0;
foreach ($cells as $cell) { foreach ($cells as $cell) {
$cell = tablesort_cell($cell, $header, $ts, $i++); $cell = tablesort_cell($cell, $header, $ts, $i++);
$output .= _theme_table_cell($cell, 0); $output .= _theme_table_cell($cell);
} }
$output .= " </tr>\n"; $output .= " </tr>\n";
} }
...@@ -1001,16 +1002,15 @@ function theme_progress_bar($percent, $message) { ...@@ -1001,16 +1002,15 @@ function theme_progress_bar($percent, $message) {
* @} End of "defgroup themeable". * @} End of "defgroup themeable".
*/ */
function _theme_table_cell($cell, $header = 0) { function _theme_table_cell($cell, $header = FALSE) {
$attributes = ''; $attributes = '';
if (is_array($cell)) { if (is_array($cell)) {
$data = $cell['data']; $data = $cell['data'];
foreach ($cell as $key => $value) { $header |= isset($cell['header']);
if ($key != 'data') { unset($cell['data']);
$attributes .= " $key=\"$value\""; unset($cell['header']);
} $attributes = drupal_attributes($cell);
}
} }
else { else {
$data = $cell; $data = $cell;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment