]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13020 : deprecates make_table
authorscyrma <scyrma>
Wed, 16 Jan 2008 08:17:25 +0000 (08:17 +0000)
committerscyrma <scyrma>
Wed, 16 Jan 2008 08:17:25 +0000 (08:17 +0000)
lib/deprecatedlib.php
lib/weblib.php
question/type/questiontype.php

index b723804519c236f00e4251a85081fbc038243ece..89679a90f9c8eab574a0ad409d7c75a3202713a3 100644 (file)
@@ -853,6 +853,29 @@ function get_group_teachers($courseid, $groupid) {
 
 ########### FROM weblib.php ##########################################################################
 
+/**
+ * Creates a nicely formatted table and returns it.
+ *
+ * @param array $table is an object with several properties.
+ *     <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
+ *     <li>$table->data[] - An array of arrays containing the data.
+ *     <li>$table->class -  A css class name
+ *     <li>$table->fontsize - Is the size of all the text
+ *     <li>$table->tablealign  - Align the whole table
+ *     <li>$table->width  - A percentage of the page
+ *     <li>$table->cellpadding  - Padding on each cell
+ *     <li>$table->cellspacing  - Spacing between cells
+ * </ul>
+ * @return string
+ * @todo Finish documenting this function
+ */
+function make_table($table) {
+    return print_table($table, true);
+}
+
 
 /**
  * Print a message in a standard themed box.
index b6ec9f7c79baa594b20d4e3e0322d287136b636a..997bdb3e3e5d8cf8b97043a728bf56e21d3c9caf 100644 (file)
@@ -4756,119 +4756,6 @@ function print_table($table, $return=false) {
     return true;
 }
 
-/**
- * Creates a nicely formatted table and returns it.
- *
- * @param array $table is an object with several properties.
- *     <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
- *     <li>$table->data[] - An array of arrays containing the data.
- *     <li>$table->class -  A css class name
- *     <li>$table->fontsize - Is the size of all the text
- *     <li>$table->tablealign  - Align the whole table
- *     <li>$table->width  - A percentage of the page
- *     <li>$table->cellpadding  - Padding on each cell
- *     <li>$table->cellspacing  - Spacing between cells
- * </ul>
- * @return string
- * @todo Finish documenting this function
- */
-function make_table($table) {
-
-    if (isset($table->align)) {
-        foreach ($table->align as $key => $aa) {
-            if ($aa) {
-                $align[$key] = ' align="'. $aa .'"';
-            } else {
-                $align[$key] = '';
-            }
-        }
-    }
-    if (isset($table->size)) {
-        foreach ($table->size as $key => $ss) {
-            if ($ss) {
-                $size[$key] = ' width="'. $ss .'"';
-            } else {
-                $size[$key] = '';
-            }
-        }
-    }
-    if (isset($table->wrap)) {
-        foreach ($table->wrap as $key => $ww) {
-            if ($ww) {
-                $wrap[$key] = ' style="white-space:nowrap;" ';
-            } else {
-                $wrap[$key] = '';
-            }
-        }
-    }
-
-    if (empty($table->width)) {
-        $table->width = '80%';
-    }
-
-    if (empty($table->tablealign)) {
-        $table->tablealign = 'center';
-    }
-
-    if (empty($table->cellpadding)) {
-        $table->cellpadding = '5';
-    }
-
-    if (empty($table->cellspacing)) {
-        $table->cellspacing = '1';
-    }
-
-    if (empty($table->class)) {
-        $table->class = 'generaltable';
-    }
-
-    if (empty($table->fontsize)) {
-        $fontsize = '';
-    } else {
-        $fontsize = '<font size="'. $table->fontsize .'">';
-    }
-
-    $output =  '<table width="'. $table->width .'" align="'. $table->tablealign .'" ';
-    $output .= ' cellpadding="'. $table->cellpadding .'" cellspacing="'. $table->cellspacing .'" class="'. $table->class .'">'."\n";
-
-    if (!empty($table->head)) {
-        $output .= '<tr valign="top">';
-        foreach ($table->head as $key => $heading) {
-            if (!isset($size[$key])) {
-                $size[$key] = '';
-            }
-            if (!isset($align[$key])) {
-                $align[$key] = '';
-            }
-            $output .= '<th valign="top" '. $align[$key].$size[$key] .' style="white-space:nowrap;" class="'. $table->class .'header" scope="col">'.$fontsize.$heading.'</th>';
-        }
-        $output .= '</tr>'."\n";
-    }
-
-    foreach ($table->data as $row) {
-        $output .= '<tr valign="top">';
-        foreach ($row as $key => $item) {
-            if (!isset($size[$key])) {
-                $size[$key] = '';
-            }
-            if (!isset($align[$key])) {
-                $align[$key] = '';
-            }
-            if (!isset($wrap[$key])) {
-                $wrap[$key] = '';
-            }
-            $output .= '<td '. $align[$key].$size[$key].$wrap[$key] .' class="'. $table->class .'cell">'. $fontsize . $item .'</td>';
-        }
-        $output .= '</tr>'."\n";
-    }
-    $output .= '</table>'."\n";
-
-    return $output;
-}
-
 function print_recent_activity_note($time, $user, $text, $link, $return=false) {
     static $strftimerecent;
     $output = '';
index 9807d7351f09113165f80ef415a828569b056768..079a6226967ece2b8e57ab266670921ed59d28eb 100644 (file)
@@ -933,7 +933,7 @@ class default_questiontype {
                                                 );
                     }
                 }
-                $history = make_table($table);
+                $history = print_table($table, true);
             }
         }
         return $history;