diff --git a/core/includes/theme.inc b/core/includes/theme.inc index dd50e62..32b1e9f 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1482,6 +1482,24 @@ function drupal_pre_render_table(array $element) { * narrow viewports to save horizontal space. * - Any HTML attributes, such as "colspan", to apply to the column header * cell. + * - footer: An array containing the table footers. Each element of the array + * can be either a localized string or an associative array with the + * following keys: + * - "data": The localized summary information of the table column. + * - Any HTML attributes, such as "colspan", to apply to the column footer + * cell. + * Here's an example for $footer: + * @code + * // simple footer + * $footer = array('footer cell1', 'footer cell2', 'footer cell3'); + * // complex footer + * $footer = array( + * 'data' => array( + * array('data' => t('footer cell1'), 'class' => 'footer-cell-1'), + * array('data' => t('footer cell2'), 'colspan' => 2)), + * 'class' => 'footer' + * ); + * @endcode * - rows: 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 @@ -1545,6 +1563,7 @@ function drupal_pre_render_table(array $element) { */ function theme_table($variables) { $header = $variables['header']; + $footer = $variables['footer']; $rows = $variables['rows']; $attributes = $variables['attributes']; $caption = $variables['caption']; @@ -1656,6 +1675,40 @@ function theme_table($variables) { $ts = array(); } + if (count($footer)) { + // Check if we're dealing with a simple or complex row + if (isset($footer['data'])) { + $cells = $footer['data']; + // Set the attributes array and exclude 'data' + $attributes = $footer; + unset($attributes['data']); + } + else { + $cells = $footer; + $attributes = array(); + } + + // HTML requires that the tfoot tag has tr tags in it followed by tbody + // tags. Using ternary operator to check and see if we have any rows. + $output .= (count($rows) ? '