}
}
+/**
+ * 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;
+ }
+}
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) {
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.
*