mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-19756 Migrated print_close_window to $OUTPUT->print_close_window($text)
This commit is contained in:
parent
29afd52b10
commit
ce60cbc8ff
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user