]> git.mjollnir.org Git - moodle.git/commitdiff
print_simple_box_* functions deprecated and replaced with clean new functions print_box_*
authormoodler <moodler>
Mon, 8 Jan 2007 03:06:32 +0000 (03:06 +0000)
committermoodler <moodler>
Mon, 8 Jan 2007 03:06:32 +0000 (03:06 +0000)
MDL-8101 MDL-4943

lib/deprecatedlib.php
lib/weblib.php

index 5db5b4fb070ffdf4ed88047932e43e3736f20869..c084115847597dfc192f4d46e0f6ff83c3916575 100644 (file)
@@ -786,4 +786,99 @@ function get_group_teachers($courseid, $groupid) {
 }
 
 
+
+########### FROM weblib.php ##########################################################################
+
+
+/**
+ * Print a message in a standard themed box.
+ * This old function used to implement boxes using tables.  Now it uses a DIV, but the old 
+ * parameters remain.  If possible, $align, $width and $color should not be defined at all.
+ * Preferably just use print_box() in weblib.php
+ *
+ * @param string $align, alignment of the box, not the text (default center, left, right).
+ * @param string $width, width of the box, including units %, for example '100%'.
+ * @param string $color, background colour of the box, for example '#eee'.
+ * @param int $padding, padding in pixels, specified without units.
+ * @param string $class, space-separated class names.
+ * @param string $id, space-separated id names.
+ * @param boolean $return, return as string or just print it
+ */
+function print_simple_box($message, $align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) {
+    $output = '';
+    $output .= print_simple_box_start($align, $width, $color, $padding, $class, $id, true);
+    $output .= stripslashes_safe($message);
+    $output .= print_simple_box_end(true);
+
+    if ($return) {
+        return $output;
+    } else {
+        echo $output;
+    }
+}
+
+
+
+/**
+ * This old function used to implement boxes using tables.  Now it uses a DIV, but the old 
+ * parameters remain.  If possible, $align, $width and $color should not be defined at all.
+ * Even better, please use print_box_start() in weblib.php
+ *
+ * @param string $align, alignment of the box, not the text (default center, left, right).   DEPRECATED
+ * @param string $width, width of the box, including % units, for example '100%'.            DEPRECATED
+ * @param string $color, background colour of the box, for example '#eee'.                   DEPRECATED
+ * @param int $padding, padding in pixels, specified without units.                          OBSOLETE
+ * @param string $class, space-separated class names.
+ * @param string $id, space-separated id names.
+ * @param boolean $return, return as string or just print it
+ */
+function print_simple_box_start($align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) {
+
+    $output = '';
+
+    $divclasses = $class.' '.$class.'content';
+    $divstyles  = '';
+
+    if ($align) {
+        $divclasses .= ' boxalign'.$align;    // Implement alignment using a class
+    }
+    if ($width) {    // Hopefully we can eliminate these in calls to this function (inline styles are bad)
+        $divstyles  .= ' width:'.$width.';';
+    }
+    if ($color) {    // Hopefully we can eliminate these in calls to this function (inline styles are bad)
+        $divstyles  .= ' background:'.$color.';';
+    }
+    if ($divstyles) {
+        $divstyles = ' style="'.$divstyles.'"';
+    }
+
+    if ($id) {
+        $id = ' id="'.$id.'"';
+    }
+
+    $output .= '<div'.$id.$divstyles.' class="'.$divclasses.'">';
+
+    if ($return) {
+        return $output;
+    } else {
+        echo $output;
+    }
+}
+
+
+/**
+ * Print the end portion of a standard themed box.
+ * Preferably just use print_box_end() in weblib.php
+ */
+function print_simple_box_end($return=false) {
+    $output = '</div>';
+    if ($return) {
+        return $output;
+    } else {
+        echo $output;
+    }
+}
+
+
+
 ?>
index a737e0c23a7985833c57838761d5deae32059404..c793cd005029354aa973493e0da26008d0344fa7 100644 (file)
@@ -2892,22 +2892,21 @@ function print_continue($link, $return=false) {
     }
 }
 
+
 /**
  * Print a message in a standard themed box.
- * See, {@link print_simple_box_start}.
+ * Replaces print_simple_box (see deprecatedlib.php)
  *
- * @param string $align string, alignment of the box, not the text (default center, left, right).
- * @param string $width string, width of the box, including units %, for example '100%'.
- * @param string $color string, background colour of the box, for example '#eee'.
- * @param int $padding integer, padding in pixels, specified without units.
- * @param string $class string, space-separated class names.
- * @todo Finish documenting this function
+ * @param string $message, the content of the box
+ * @param string $class, space-separated class names.
+ * @param string $id, space-separated id names.
+ * @param boolean $return, return as string or just print it
  */
-function print_simple_box($message, $align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) {
-    $output = '';
-    $output .= print_simple_box_start($align, $width, $color, $padding, $class, $id, true);
+function print_box($message, $class='generalbox', $id='', $return=false) {
+
+    $output  = print_box_start($class, $id, true);
     $output .= stripslashes_safe($message);
-    $output .= print_simple_box_end(true);
+    $output .= print_box_end(true);
 
     if ($return) {
         return $output;
@@ -2916,40 +2915,24 @@ function print_simple_box($message, $align='', $width='', $color='', $padding=5,
     }
 }
 
-/**
- * Print the top portion of a standard themed box using a TABLE.  Yes, we know.
- * See bug 4943 for details on some accessibility work regarding this that didn't make it into 1.6.
+/* 
+ * Starts a box using divs
+ * Replaces print_simple_box_start (see deprecatedlib.php)
  *
- * @param string $align string, alignment of the box, not the text (default center, left, right).
- * @param string $width string, width of the box, including % units, for example '100%'.
- * @param string $color string, background colour of the box, for example '#eee'.
- * @param int $padding integer, padding in pixels, specified without units.
- * @param string $class string, space-separated class names.
+ * @param string $class, space-separated class names.
+ * @param string $id, space-separated id names.
+ * @param boolean $return, return as string or just print it
  */
-function print_simple_box_start($align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) {
-
+function print_box_start($class='generalbox', $id='', $return=false) {
     $output = '';
 
     $divclasses = $class.' '.$class.'content';
-    $divstyles  = '';
 
-    if ($align) {
-        $divclasses .= ' boxalign'.$align;    // Implement alignment using a class
-    }
-    if ($width) {
-        $divstyles  .= ' width:'.$width.';';
-    }
     if ($id) {
         $id = ' id="'.$id.'"';
     }
-    if ($color) {
-        $divstyles  .= ' background:'.$color.';';
-    }
-    if ($divstyles) {
-        $divstyles = ' style="'.$divstyles.'"';
-    }
 
-    $output .= '<div'.$id.$divstyles.' class="'.$divclasses.'">';
+    $output .= '<div'.$id.' class="'.$divclasses.'">';
 
     if ($return) {
         return $output;
@@ -2958,10 +2941,14 @@ function print_simple_box_start($align='', $width='', $color='', $padding=5, $cl
     }
 }
 
-/**
- * Print the end portion of a standard themed box.
+
+/* 
+ * Simple function to end a box (see above)
+ * Replaces print_simple_box_end (see deprecatedlib.php)
+ *
+ * @param boolean $return, return as string or just print it
  */
-function print_simple_box_end($return=false) {
+function print_box_end($return=false) {
     $output = '</div>';
     if ($return) {
         return $output;
@@ -3000,6 +2987,7 @@ function print_single_button($link, $options, $label='OK', $method='get', $targe
     }
 }
 
+
 /**
  * Print a spacer image with the option of including a line break.
  *