output MDL-19077 Implemented periodic refresh to meta refresh by delay

Also created layout-popup.php for standardwhite theme to provide a simpler template
This commit is contained in:
samhemelryk 2009-06-30 07:57:41 +00:00
parent cadf365256
commit 17a6649b95
3 changed files with 79 additions and 0 deletions

View File

@ -787,6 +787,14 @@ class moodle_core_renderer extends moodle_renderer_base {
}
// This is only set by the {@link redirect()} method
$output .= $this->metarefreshtag;
// Check if a periodic refresh delay has been set and make sure we arn't
// already meta refreshing
if ($this->metarefreshtag=='' && $this->page->periodicrefreshdelay!==null) {
$metarefesh = '<meta http-equiv="refresh" content="%d;url=%s" />';
$output .= sprintf($metarefesh, $this->page->periodicrefreshdelay, $this->page->url->out());
}
ob_start();
include($CFG->javascript);
$output .= ob_get_contents();
@ -912,6 +920,8 @@ class moodle_core_renderer extends moodle_renderer_base {
$this->metarefreshtag = '<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />'."\n";
$this->page->requires->js_function_call('document.location.replace', array($url))->after_delay($delay+3);
}
$this->page->set_generaltype('popup');
$this->page->set_title('redirect');
$output = $this->header();
$output .= $this->notification($message, $messageclass);
$output .= $this->footer();

View File

@ -124,6 +124,14 @@ class moodle_page {
protected $_button = '';
/**
* Sets the page to refresh after a given delay (in seconds) using meta refresh
* in {@link standard_head_html()} in outputlib.php
* If set to null(default) the page is not refreshed
* @var int|null
*/
protected $_periodicrefreshdelay = null;
/**
* This is simply to improve backwards compatability. If old code relies on
* a page class that implements print_header, or complex logic in
@ -386,6 +394,13 @@ class moodle_page {
return $this->_button;
}
/**
*
*/
public function get_periodicrefreshdelay() {
return $this->_periodicrefreshdelay;
}
/**
* PHP overloading magic to make the $PAGE->course syntax work by redirecting
* it to the corresponding $PAGE->get_course() method if there is one, and
@ -731,6 +746,26 @@ class moodle_page {
$this->_cacheable = $cacheable;
}
/**
* Sets the page to periodically refresh
*
* This function must be called before $OUTPUT->header has been called or
* a coding exception will be thrown.
*
* @param int $delay Sets the delay before refreshing the page, if set to null
* refresh is cancelled
*/
public function set_periodic_refresh_delay($delay=null) {
if ($this->_state > self::STATE_BEFORE_HEADER) {
throw new coding_exception('You cannot set a periodic refresh delay after the header has been printed');
}
if ($delay===null) {
$this->_periodicrefreshdelay = null;
} else if (is_int($delay)) {
$this->_periodicrefreshdelay = $delay;
}
}
/// Initialisation methods =====================================================
/// These set various things up in a default way.

View File

@ -0,0 +1,34 @@
<?php echo $OUTPUT->doctype() ?>
<html <?php echo $OUTPUT->htmlattributes() ?>>
<head>
<title><?php echo $PAGE->title ?></title>
<link rel="shortcut icon" href="<?php echo $CFG->themewww .'/'. current_theme() ?>/favicon.ico" />
<?php echo $OUTPUT->standard_head_html() ?>
</head>
<body id="<?php echo $PAGE->pagetype ?>" class="<?php echo $PAGE->bodyclasses ?>">
<?php echo $OUTPUT->standard_top_of_body_html() ?>
<div id="page">
<?php if ($navigation) { // This is the navigation bar with breadcrumbs ?>
<div class="navbar clearfix">
<div class="breadcrumb"><?php print_navigation($navigation); ?></div>
<div class="navbutton"><?php echo $PAGE->button; ?></div>
</div>
<?php } else if ($PAGE->heading) { // If no navigation, but a heading, then print a line ?>
<hr />
<?php } ?>
<!-- END OF HEADER -->
<div id="content" class="clearfix">
[MAIN CONTENT GOES HERE]
</div>
<!-- START OF FOOTER -->
<div id="footer" class="clearfix">
</div>
</div>
<?php echo $OUTPUT->standard_end_of_body_html() ?>
</body>
</html>