From c44889c0887d72c6888da380797cea9daaeace6a Mon Sep 17 00:00:00 2001 From: tjhunt Date: Thu, 19 Jun 2008 18:38:27 +0000 Subject: [PATCH] MDL-15321 - Add a class to the last column and row of the table in print_table to help theming --- lib/weblib.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 48f4c079bf..e2fcaa0f1b 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -4675,6 +4675,7 @@ function print_table($table, $return=false) { if (!empty($table->head)) { $countcols = count($table->head); $output .= ''; + $lastkey = end(array_keys($table->head)); foreach ($table->head as $key => $heading) { if (!isset($size[$key])) { @@ -4683,23 +4684,33 @@ function print_table($table, $return=false) { if (!isset($align[$key])) { $align[$key] = ''; } + if ($key == $lastkey) { + $extraclass = ' lastcol'; + } else { + $extraclass = ''; + } - $output .= ''. $heading .''; + $output .= ''. $heading .''; } $output .= ''."\n"; } if (!empty($table->data)) { $oddeven = 1; + $lastrowkey = end(array_keys($table->data)); foreach ($table->data as $key => $row) { $oddeven = $oddeven ? 0 : 1; if (!isset($table->rowclass[$key])) { $table->rowclass[$key] = ''; } + if ($key == $lastrowkey) { + $table->rowclass[$key] .= ' lastrow'; + } $output .= ''."\n"; if ($row == 'hr' and $countcols) { $output .= '
'; } else { /// it's a normal row of data + $lastkey = end(array_keys($row)); foreach ($row as $key => $item) { if (!isset($size[$key])) { $size[$key] = ''; @@ -4710,7 +4721,12 @@ function print_table($table, $return=false) { if (!isset($wrap[$key])) { $wrap[$key] = ''; } - $output .= ''. $item .''; + if ($key == $lastkey) { + $extraclass = ' lastcol'; + } else { + $extraclass = ''; + } + $output .= ''. $item .''; } } $output .= ''."\n"; -- 2.39.5