]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19756 Migrated print_close_window to $OUTPUT->print_close_window($text)
authornicolasconnault <nicolasconnault>
Mon, 3 Aug 2009 11:03:16 +0000 (11:03 +0000)
committernicolasconnault <nicolasconnault>
Mon, 3 Aug 2009 11:03:16 +0000 (11:03 +0000)
lib/deprecatedlib.php
lib/outputlib.php
lib/weblib.php

index bf5dc87fb8460ad13a2ace4e94a1a3017656ff69..9735870e4b62a1178516c41958ba9f69ea259100 100644 (file)
@@ -3373,3 +3373,27 @@ function popup_form($baseurl, $options, $formid, $selected='', $nothing='choose'
     }
 }
 
+/**
+ * Prints a simple button to close a window
+ *
+ * @deprecated since Moodle 2.0
+ *
+ * @global object
+ * @param string $name Name of the window to close
+ * @param boolean $return whether this function should return a string or output it.
+ * @param boolean $reloadopener if true, clicking the button will also reload
+ *      the page that opend this popup window.
+ * @return string|void if $return is true, void otherwise
+ */
+function close_window_button($name='closewindow', $return=false, $reloadopener = false) {
+    global $OUTPUT;
+    
+    // debugging('close_window_button() has been deprecated. Please change your code to use $OUTPUT->close_window_button().');
+    $output = $OUTPUT->close_window_button(get_string($name));
+    
+    if ($return) {
+        return $output;
+    } else {
+        echo $output;
+    }
+}
index 53c14cb14e234cda9a9c83c78c39ae52cec00533..d5189fe25de8be2e81b4ef740fd131b3196c9ffd 100644 (file)
@@ -2782,12 +2782,21 @@ class moodle_core_renderer extends moodle_renderer_base {
 
         return $output . $this->output_end_tag($tag);
     }
-
-    public function close_window_button($buttontext = null, $reloadopener = false) {
-        if (empty($buttontext)) {
-            $buttontext = get_string('closewindow');
-        }
-        // TODO
+    
+    /**
+     * Prints a simple button to close a window
+     *
+     * @global objec)t
+     * @param string $text The lang string for the button's label (already output from get_string())
+     * @return string|void if $return is true, void otherwise
+     */
+    public function close_window_button($text) {
+        $closeform = new html_form();
+        $closeform->url = '#';
+        $closeform->button->text = $text;
+        $closeform->button->add_action('click', 'close_window');
+        $closeform->button->prepare();
+        return $this->container($this->button($closeform), 'closewindow');
     }
 
     public function close_window($delay = 0, $reloadopener = false) {
index 5b0d574855d2378658dc29c8ded700a94e68cbc5..cda5465550839573fc0a8461e114d138d9655dac 100644 (file)
@@ -587,40 +587,6 @@ function break_up_long_words($string, $maxsize=20, $cutchar=' ') {
     return $output;
 }
 
-
-/**
- * Prints a simple button to close a window
- *
- * @global object
- * @param string $name Name of the window to close
- * @param boolean $return whether this function should return a string or output it.
- * @param boolean $reloadopener if true, clicking the button will also reload
- *      the page that opend this popup window.
- * @return string|void if $return is true, void otherwise
- */
-function close_window_button($name='closewindow', $return=false, $reloadopener = false) {
-    global $CFG;
-
-    $js = 'self.close();';
-    if ($reloadopener) {
-        $js = 'window.opener.location.reload(1);' . $js;
-    }
-
-    $output = '';
-
-    $output .= '<div class="closewindow">' . "\n";
-    $output .= '<form action="#"><div>';
-    $output .= '<input type="button" onclick="' . $js . '" value="'.get_string($name).'" />';
-    $output .= '</div></form>';
-    $output .= '</div>' . "\n";
-
-    if ($return) {
-        return $output;
-    } else {
-        echo $output;
-    }
-}
-
 /*
  * Try and close the current window using JavaScript, either immediately, or after a delay.
  *