diff --git a/core/includes/theme.inc b/core/includes/theme.inc index cc60af2..e3bc350 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2013,6 +2013,12 @@ 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 title of the table column. + * - Any HTML attributes, such as "colspan", to apply to the column header + * cell. * - 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 @@ -2076,6 +2082,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']; @@ -2188,6 +2195,19 @@ function theme_table($variables) { $ts = array(); } + if (count($footer)) { + // 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) ? ' ' : ' '); + $i = 0; + foreach ($footer as $cell) { + $cell = tablesort_cell($cell, $header, $ts, $i++); + $output .= _theme_table_cell($cell); + } + // Using ternary operator to close the tags based on whether or not there are rows + $output .= (count($rows) ? " \n" : "\n"); + } + // Format the table rows: if (count($rows)) { $output .= "\n"; @@ -3172,7 +3192,7 @@ function drupal_common_theme() { 'variables' => array(), ), 'table' => array( - 'variables' => array('header' => NULL, 'rows' => NULL, 'attributes' => array(), 'caption' => NULL, 'colgroups' => array(), 'sticky' => TRUE, 'responsive' => TRUE, 'empty' => ''), + 'variables' => array('header' => NULL, 'footer' => NULL, 'rows' => NULL, 'attributes' => array(), 'caption' => NULL, 'colgroups' => array(), 'sticky' => TRUE, 'responsive' => TRUE, 'empty' => ''), ), 'meter' => array( 'variables' => array('display_value' => NULL, 'form' => NULL, 'high' => NULL, 'low' => NULL, 'max' => NULL, 'min' => NULL, 'optimum' => NULL, 'value' => NULL, 'percentage' => NULL, 'attributes' => array()),