]> git.mjollnir.org Git - moodle.git/commitdiff
Fix 2, bug 4943: "print_simple_box behaviour changed". Centred is now default alignme...
authornfreear <nfreear>
Thu, 6 Apr 2006 17:21:04 +0000 (17:21 +0000)
committernfreear <nfreear>
Thu, 6 Apr 2006 17:21:04 +0000 (17:21 +0000)
lib/weblib.php

index d56b70d6c691047fce6a9b05ff89335977477680..56fab917882fc0f632e51e68e8f96d5511ca5e48 100644 (file)
@@ -2499,13 +2499,13 @@ function print_continue($link) {
 
 /**
  * Print a message in a standard themed box.
+ * See, {@link print_simple_box_start}.
  *
- * @param string $message ?
- * @param string $align ?
- * @param string $width ?
- * @param string $color ?
- * @param int $padding ?
- * @param string $class ?
+ * @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
  */
 function print_simple_box($message, $align='', $width='', $color='', $padding=5, $class='generalbox', $id='') {
@@ -2516,9 +2516,16 @@ function print_simple_box($message, $align='', $width='', $color='', $padding=5,
 
 /**
  * Print the top portion of a standard themed box.
+ *   To improve accessibility, the box is now a DIV, not a TABLE.
+ * If the box is left aligned and width is not specified the box will shrink 
+ *   to fit - as per the 1.5 table behaviour.
+ * If alignment and width are not specified, the box will be centred and given
+ *   a width of 30em, based on usability studies 
+ * {@link http://www.maxdesign.com.au/presentation/em/ Ideal line length for content}.
+ *   Text will be left aligned - the behaviour has changed, but will hopefully look OK.
  *
- * @param string $align string, alignment of the box, not the text (default left, center, right).
- * @param string $width string, width of the box, including units, for example '100%'. 
+ * @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.
@@ -2536,10 +2543,13 @@ function print_simple_box_start($align='', $width='', $color='', $padding=5, $cl
     if ($color) {
         $style_out .= 'background-color:'. $color .'; ';
     }
-    if ($align && 'center' == $align) {
+    if (!$align || 'center' == $align) {
+       if (! $width) {
+         $style_out .= 'width:30em; '; 
+       }
        $style_out .= 'margin-left:auto; margin-right:auto; ';
     }
-    elseif (!$align || 'left' == $align) {
+    elseif ($align && 'left' == $align) {
         $style_out .= 'float:left; ';
     }
     else {
@@ -2552,7 +2562,11 @@ function print_simple_box_start($align='', $width='', $color='', $padding=5, $cl
     if ($id) {
         $id = 'id="'. $id .'"';
     } 
-    echo "<div $id class=\"$class\" style=\"$style_out\"><div class=\"$class"."content\" style=\"$style_in\">\n"; 
+    echo "\n<div $id class=\"$class\" style=\"$style_out\"><div class=\"$class"."content\" style=\"$style_in\">\n";
+    global $CFG;
+    if ($CFG->debug > 7) {
+      echo "<!--PARAMS, a:$align, w:$width, c:$color, p:$padding, cl:$class, id:$id -->\n";    
+    } 
 }
 
 /**