]> git.mjollnir.org Git - moodle.git/commitdiff
Small improvement to print_table. Lets you apply a class attribute to particular...
authortjhunt <tjhunt>
Fri, 6 Jul 2007 11:29:25 +0000 (11:29 +0000)
committertjhunt <tjhunt>
Fri, 6 Jul 2007 11:29:25 +0000 (11:29 +0000)
lib/weblib.php

index 6ca90a4e73298fa7e333c5ceb67a2c1070818ac8..bd45ca10dd71c1aa03126d736303fdd5af14fa6f 100644 (file)
@@ -3879,7 +3879,8 @@ function print_png($url, $sizex, $sizey, $return, $parameters='alt=""') {
  * Print a nicely formatted table.
  *
  * @param array $table is an object with several properties.
- *     <ul<li>$table->head - An array of heading names.
+ * <ul>
+ *     <li>$table->head - An array of heading names.
  *     <li>$table->align - An array of column alignments
  *     <li>$table->size  - An array of column sizes
  *     <li>$table->wrap - An array of "nowrap"s or nothing
@@ -3888,6 +3889,9 @@ function print_png($url, $sizex, $sizey, $return, $parameters='alt=""') {
  *     <li>$table->tablealign  - Align the whole table
  *     <li>$table->cellpadding  - Padding on each cell
  *     <li>$table->cellspacing  - Spacing between cells
+ *     <li>$table->class - class attribute to put on the table
+ *     <li>$table->id - id attribute to put on the table.
+ *     <li>$table->rowclass[] - classes to add to particular rows.
  * </ul>
  * @param bool $return whether to return an output string or echo now
  * @return boolean or $string
@@ -3974,7 +3978,10 @@ function print_table($table, $return=false) {
         $oddeven = 1;
         foreach ($table->data as $key => $row) {
             $oddeven = $oddeven ? 0 : 1;
-            $output .= '<tr class="r'.$oddeven.'">'."\n";
+            if (!isset($table->rowclass[$key])) {
+                $table->rowclass[$key] = '';
+            }
+            $output .= '<tr class="r'.$oddeven.' '.$table->rowclass[$key].'">'."\n";
             if ($row == 'hr' and $countcols) {
                 $output .= '<td colspan="'. $countcols .'"><div class="tabledivider"></div></td>';
             } else {  /// it's a normal row of data