|
static | early_error ($message, $moreinfourl, $link, $backtrace, $debuginfo=null, $errorcode=null) |
| This function should only be called by this class, or from exception handlers.
|
|
static | early_error_content ($message, $moreinfourl, $link, $backtrace, $debuginfo=null) |
| Returns nicely formatted error message in a div box.
|
|
static | early_notification ($message, $classes='notifyproblem') |
| Early notification message.
|
|
static | early_redirect_message ($encodedurl, $message, $delay) |
| Early redirection page, used before full init of $PAGE global.
|
|
static | plain_page ($title, $content, $meta='') |
| Output basic html page.
|
|
static | plain_redirect_message ($encodedurl) |
| Page should redirect message.
|
|
This class solves the problem of how to initialise $OUTPUT.
The problem is caused be two factors
-
On the one hand, we cannot be sure when output will start. In particular, an error, which needs to be displayed, could be thrown at any time.
-
On the other hand, we cannot be sure when we will have all the information necessary to correctly initialise $OUTPUT. $OUTPUT depends on the theme, which (potentially) depends on the current course, course categories, and logged in user. It also depends on whether the current page requires HTTPS.
So, it is hard to find a single natural place during Moodle script execution, which we can guarantee is the right time to initialise $OUTPUT. Instead we adopt the following strategy
-
We will initialise $OUTPUT the first time it is used.
-
If, after $OUTPUT has been initialised, the script tries to change something that $OUTPUT depends on, we throw an exception making it clear that the script did something wrong.
The only problem with that is, how do we initialise $OUTPUT on first use if, it is going to be used like $OUTPUT->somthing(...)? Well that is where this class comes in. Initially, we set up $OUTPUT = new bootstrap_renderer(). Then, when any method is called on that object, we initialise $OUTPUT, and pass the call on.
Note that this class is used before lib/outputlib.php has been loaded, so we must be careful referring to classes/functions from there, they may not be defined yet, and we must avoid fatal errors.
- Copyright
- 2009 Tim Hunt
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- Since
- Moodle 2.0