]> git.mjollnir.org Git - moodle.git/commitdiff
Added $return=false parameter to close_window_button() and choose_from_radio().
authormoquist <moquist>
Thu, 10 Aug 2006 04:33:55 +0000 (04:33 +0000)
committermoquist <moquist>
Thu, 10 Aug 2006 04:33:55 +0000 (04:33 +0000)
lib/weblib.php

index 2e5ecbe447b75ea37a14b42281a4348846e7496e..9dc6893fe9fc9eb293b3f9257e63caef813013db 100644 (file)
@@ -655,20 +655,27 @@ function button_to_popup_window ($url, $name='popup', $linkname='click here',
 /**
  * Prints a simple button to close a window
  */
-function close_window_button($name='closewindow') {
-
-    echo '<center>' . "\n";
-    echo '<script type="text/javascript">' . "\n";
-    echo '<!--' . "\n";
-    echo "document.write('<form>');\n";
-    echo "document.write('<input type=\"button\" onclick=\"self.close();\" value=\"".get_string("closewindow")."\" />');\n";
-    echo "document.write('<\/form>');\n";
-    echo '-->' . "\n";
-    echo '</script>' . "\n";
-    echo '<noscript>' . "\n";
-    print_string($name);
-    echo '</noscript>' . "\n";
-    echo '</center>' . "\n";
+function close_window_button($name='closewindow', $return=false) {
+    $output = '';
+
+    $output .= '<center>' . "\n";
+    $output .= '<script type="text/javascript">' . "\n";
+    $output .= '<!--' . "\n";
+    $output .= "document.write('<form>');\n";
+    $output .= "document.write('<input type=\"button\" onclick=\"self.close();\" value=\"".get_string("closewindow")."\" />');\n";
+    $output .= "document.write('<\/form>');\n";
+    $output .= '-->' . "\n";
+    $output .= '</script>' . "\n";
+    $output .= '<noscript>' . "\n";
+    $output .= get_string($name);
+    $output .= '</noscript>' . "\n";
+    $output .= '</center>' . "\n";
+
+    if ($return) {
+        return $output;
+    } else {
+        echo $output;
+    }
 }
 
 /*
@@ -802,7 +809,7 @@ function choose_from_menu_nested($options,$name,$selected='',$nothing='choose',$
  * @param string $name     Name of the radiogroup (unique in the form)
  * @param string $checked  The value that is already checked
  */
-function choose_from_radio ($options, $name, $checked='') {
+function choose_from_radio ($options, $name, $checked='', $return=false) {
 
     static $idcounter = 0;
 
@@ -832,7 +839,11 @@ function choose_from_radio ($options, $name, $checked='') {
 
     $output .= '</span>' .  "\n";
 
-    echo $output;
+    if ($return) {
+        return $output;
+    } else {
+        echo $output;
+    }
 }
 
 /** Display an standard html checkbox with an optional label
@@ -884,7 +895,7 @@ function print_checkbox ($name, $value, $checked = true, $label = '', $alt = '',
  * @param string  $label   The label to be showed near the text field
  * @param string  $alt     The info to be inserted in the alt tag
  */
-function print_textfield ($name, $value, $alt = '',$size=50,$maxlength= 0,$return=false) {
+function print_textfield ($name, $value, $alt = '',$size=50,$maxlength=0, $return=false) {
 
     static $idcounter = 0;