From: moodler Date: Mon, 8 Jan 2007 03:06:32 +0000 (+0000) Subject: print_simple_box_* functions deprecated and replaced with clean new functions print_box_* X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2123b644a68d635b17b91561a36e4f0b5b8a7e68;p=moodle.git print_simple_box_* functions deprecated and replaced with clean new functions print_box_* MDL-8101 MDL-4943 --- diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 5db5b4fb07..c084115847 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -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 .= ''; + + 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 = ''; + if ($return) { + return $output; + } else { + echo $output; + } +} + + + ?> diff --git a/lib/weblib.php b/lib/weblib.php index a737e0c23a..c793cd0050 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -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 .= ''; + $output .= ''; 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 = ''; 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. *