themes: MDL-19077 new $OUTPUT->header/footer to replace print_header/footer.

Also, part of the change from weblib.php functions to $OUTPUT-> methods.

This is part of http://docs.moodle.org/en/Development:Theme_engines_for_Moodle%3F

This is a big change, and the result is not perfect yet. Expect some debugging output
on some pages.

The main part of these changes are that $OUTPUT->header now looks for a file
in the theme called layout.php, rather than header.html and footer.html. Also
you can have special templates for certain pages like layout-home.php. There is
fallback code for Moodle 1.9 themes, so they still work.

A few of the old arguments to print_header are no longer supported. (You get an
exception if you try to use them.) Sam H will be cleaning those up.

All the weblib functions that have been replaced with $OUTPUT-> have version in
deprecatedlib, so existing code will go on working for the foreseeable future.
This commit is contained in:
tjhunt
2009-06-26 09:06:16 +00:00
parent 520cea9216
commit 34a2777ccb
31 changed files with 1728 additions and 862 deletions
+50 -24
View File
@@ -8483,36 +8483,62 @@ function moodle_request_shutdown() {
}
/**
* If new messages are waiting for the current user, then return
* Javascript code to create a popup window
*
* @global object
* @global object
* @return string Javascript code
* This function is called when output is started. This is a chance for Moodle core
* to check things like whether the messages popup should be shown.
*/
function output_starting_hook() {
global $CFG, $PAGE;
// If maintenance mode is on, change the page header.
if (!empty($CFG->maintenance_enabled)) {
$PAGE->set_button('<a href="' . $CFG->wwwroot . '/' . $CFG->admin .
'/settings.php?section=maintenancemode">' . get_string('maintenancemode', 'admin') .
'</a> ' . $PAGE->button);
$title = $PAGE->title;
if ($title) {
$title .= ' - ';
}
$PAGE->set_title($title . get_string('maintenancemode', 'admin'));
}
// Show the messaging popup, if there are messages.
message_popup_window();
}
/**
* If new messages are waiting for the current user, then load the
* JavaScript required to pop up the messaging window.
*/
function message_popup_window() {
global $USER, $DB, $PAGE;
$popuplimit = 30; // Minimum seconds between popups
if (!defined('MESSAGE_WINDOW')) {
if (isset($USER->id) and !isguestuser()) {
if (!isset($USER->message_lastpopup)) {
$USER->message_lastpopup = 0;
}
if ((time() - $USER->message_lastpopup) > $popuplimit) { /// It's been long enough
if (get_user_preferences('message_showmessagewindow', 1) == 1) {
if ($DB->count_records_select('message', 'useridto = ? AND timecreated > ?', array($USER->id, $USER->message_lastpopup))) {
$USER->message_lastpopup = time();
$PAGE->requires->js_function_call('openpopup', array('/message/index.php', 'message',
'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0));
}
}
}
}
if (defined('MESSAGE_WINDOW') || empty($CFG->messaging)) {
return;
}
return '';
if (!isset($USER->id) || isguestuser()) {
return;
}
if (!isset($USER->message_lastpopup)) {
$USER->message_lastpopup = 0;
}
$popuplimit = 30; // Minimum seconds between popups
if ((time() - $USER->message_lastpopup) <= $popuplimit) { /// It's been long enough
return;
}
if (!get_user_preferences('message_showmessagewindow', 1)) {
return;
}
if ($DB->count_records_select('message', 'useridto = ? AND timecreated > ?', array($USER->id, $USER->message_lastpopup))) {
$USER->message_lastpopup = time();
$PAGE->requires->js_function_call('openpopup', array('/message/index.php', 'message',
'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0));
}
}
/**