Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Public Member Functions | |
__get ($name) | |
PHP overloading magic to make the $PAGE->course syntax work by redirecting it to the corresponding $PAGE->magic_get_course() method if there is one, and throwing an exception if not. More... | |
__set ($name, $value) | |
PHP overloading magic to catch obvious coding errors. More... | |
add_alternate_version ($title, $url, $mimetype) | |
Sets an alternative version of this page. More... | |
add_body_class ($class) | |
Adds a CSS class to the body tag of the page. More... | |
add_body_classes ($classes) | |
Adds an array of body classes to the body tag of this page. More... | |
add_header_action (string $html) | |
Add some HTML to the list of actions to render in the header actions menu. More... | |
add_report_nodes ($userid, $nodeinfo) | |
Add a report node and a specific report to the navigation. More... | |
apply_theme_region_manipulations ($region) | |
Returns the block region having made any required theme manipulations. More... | |
debug_summary () | |
Get a description of this page. More... | |
end_collecting_javascript_requirements () | |
Switches back from collecting fragment JS requirement to the original requirement manager. | |
ensure_param_not_in_url ($param) | |
Make sure page URL does not contain the given URL parameter. More... | |
force_settings_menu ($forced=true) | |
Force the settings menu to be displayed on this page. More... | |
force_theme ($themename) | |
Force this page to use a particular theme. More... | |
get_header_actions () | |
Get the list of HTML for actions to render in the header actions menu. More... | |
get_popup_notification_allowed () | |
Are popup notifications allowed on this page? Popup notifications may be disallowed in situations such as while upgrading or completing a quiz. More... | |
get_renderer ($component, $subtype=null, $target=null) | |
Returns instance of page renderer. More... | |
get_where_theme_was_initialised () | |
For diagnostic/debugging purposes, find where the theme setup was triggered. More... | |
has_navbar () | |
Checks to see if there are any items on the navbar object. More... | |
has_set_url () | |
Returns true if the page URL has beem set. More... | |
https_required () | |
include_region_main_settings_in_header_actions () | |
Check if the region main settings should be rendered as an action in the header actions menu rather than at the top of the content. More... | |
initialise_theme_and_output () | |
Method for use by Moodle core to set up the theme. More... | |
is_settings_menu_forced () | |
Check to see if the settings menu is forced to display on this activity / resource page. More... | |
reload_theme () | |
Reload theme settings. More... | |
reset_theme_and_output () | |
Reset the theme and output for a new context. More... | |
set_activity_record ($module) | |
Sets the activity record. More... | |
set_block_actions_done ($setting=true) | |
Gets set when the block actions for the page have been processed. More... | |
set_blocks_editing_capability ($capability) | |
Set the capability that allows users to edit blocks on this page. More... | |
set_button ($html) | |
Specify a fragment of HTML that goes where the 'Turn editing on' button normally goes. More... | |
set_cacheable ($cacheable) | |
Sets whether the browser should cache this page or not. More... | |
set_category_by_id ($categoryid) | |
Set the course category this page belongs to manually. More... | |
set_cm ($cm, $course=null, $module=null) | |
The course module that this page belongs to (if it does belong to one). More... | |
set_context ($context) | |
Set the main context to which this page belongs. More... | |
set_course ($course) | |
Set the current course. More... | |
set_docs_path ($path) | |
Set a different path to use for the 'Moodle docs for this page' link. More... | |
set_focuscontrol ($controlid) | |
Specify a form control should be focused when the page has loaded. More... | |
set_heading ($heading) | |
Sets the heading to use for the page. More... | |
set_headingmenu ($menu) | |
Sets some HTML to use next to the heading moodle_page::set_heading(). More... | |
set_include_region_main_settings_in_header_actions (bool $value) | |
Set the flag to indicate if the region main settings should be rendered as an action in the header actions menu rather than at the top of the content. More... | |
set_other_editing_capability ($capability) | |
Some pages let you turn editing on for reasons other than editing blocks. More... | |
set_pagelayout ($pagelayout) | |
Sets the layout to use for this page. More... | |
set_pagetype ($pagetype) | |
Sets the pagetype to use for this page. More... | |
set_periodic_refresh_delay ($delay=null) | |
Sets the page to periodically refresh. More... | |
set_popup_notification_allowed ($allowed) | |
Allow or disallow popup notifications on this page. More... | |
set_state ($state) | |
Set the state. More... | |
set_subpage ($subpage) | |
If context->id and pagetype are not enough to uniquely identify this page, then you can set a subpage id as well. More... | |
set_title ($title) | |
Sets the title for the page. More... | |
set_url ($url, array $params=null) | |
You should call this method from every page to set the URL that should be used to return to this page. More... | |
start_collecting_javascript_requirements () | |
Switches from the regular requirements manager to the fragment requirements manager to capture all necessary JavaScript to display a chunk of HTML such as an mform. More... | |
user_allowed_editing () | |
Does the user have permission to see this page in editing mode. More... | |
user_can_edit_blocks () | |
Does the user have permission to edit blocks on this page. More... | |
user_is_editing () | |
Should the current user see this page in editing mode. More... | |
verify_https_required () | |
Protected Member Functions | |
all_editing_caps () | |
Combines all of the required editing caps for the page and returns them as an array. More... | |
ensure_categories_loaded () | |
Ensures that the category the current course is within, as well as all of its parent categories, have been loaded. More... | |
ensure_category_loaded () | |
This function ensures that the category of the current course has been loaded, and if not, the function loads it now. More... | |
ensure_theme_not_set () | |
Ensure the theme has not been loaded yet. More... | |
initialise_default_pagetype ($script=null) | |
Sets ->pagetype from the script name. More... | |
initialise_standard_body_classes () | |
Initialises the CSS classes that will be added to body tag of the page. More... | |
load_activity_record () | |
Loads the activity record for the current CM object associated with this page. More... | |
load_category ($categoryid) | |
Loads the requested category into the pages categories array. More... | |
magic_get_activityname () | |
Please do not call this method directly, use the ->activityname syntax. More... | |
magic_get_activityrecord () | |
Please do not call this method directly, use the ->activityrecord syntax. More... | |
magic_get_alternateversions () | |
The list of alternate versions of this page. More... | |
magic_get_blockmanipulations () | |
Returns an array of minipulations or false if there are none to make. More... | |
magic_get_blocks () | |
Please do not call this method directly, use the ->blocks syntax. More... | |
magic_get_bodyclasses () | |
Please do not call this method directly, use the ->bodyclasses syntax. More... | |
magic_get_bodyid () | |
Please do not call this method directly, use the ->pagetype syntax. More... | |
magic_get_button () | |
Please do not call this method directly, use the ->button syntax. More... | |
magic_get_cacheable () | |
Please do not call this method directly, use the ->cacheable syntax. More... | |
magic_get_categories () | |
Please do not call this method directly, use the ->categories syntax. More... | |
magic_get_category () | |
Please do not call this method directly, use the ->category syntax. More... | |
magic_get_cm () | |
Please do not call this method directly, use the ->cm syntax. More... | |
magic_get_context () | |
Please do not call this method directly, use the ->context syntax. More... | |
magic_get_course () | |
Please do not call this method directly, use the ->course syntax. More... | |
magic_get_devicetypeinuse () | |
Please do not call this method directly, use the ->devicetypeinuse syntax. More... | |
magic_get_docspath () | |
Please do not call this method directly, use the ->docspath syntax. More... | |
magic_get_flatnav () | |
Returns the flat navigation object. More... | |
magic_get_focuscontrol () | |
Please do not call this method directly, use the ->focuscontrol syntax. More... | |
magic_get_headerprinted () | |
Please do not call this method directly, use the ->headerprinted syntax. More... | |
magic_get_heading () | |
Please do not call this method directly, use the ->heading syntax. More... | |
magic_get_headingmenu () | |
Please do not call this method directly, use the ->heading syntax. More... | |
magic_get_layout_options () | |
Please do not call this method directly, use the ->layout_options syntax. More... | |
magic_get_navbar () | |
Return a navbar object. More... | |
magic_get_navigation () | |
Return the navigation object. More... | |
magic_get_opencontainers () | |
Please do not call this method directly use the ->opencontainers syntax. More... | |
magic_get_pagelayout () | |
Please do not call this method directly, use the ->pagelayout syntax. More... | |
magic_get_pagetype () | |
Please do not call this method directly, use the ->pagetype syntax. More... | |
magic_get_periodicrefreshdelay () | |
Please do not call this method directly use the ->periodicrefreshdelay syntax moodle_page::__get(). More... | |
magic_get_requestip () | |
Returns request IP address. More... | |
magic_get_requestorigin () | |
Returns the origin of current request. More... | |
magic_get_requires () | |
Please do not call this method directly, use the ->requires syntax. More... | |
magic_get_settingsnav () | |
Returns the settings navigation object. More... | |
magic_get_state () | |
Please do not call this method directly, use the ->state syntax. More... | |
magic_get_subpage () | |
Please do not call this method directly, use the ->subpage syntax. More... | |
magic_get_theme () | |
Please do not call this method directly, use the ->theme syntax. More... | |
magic_get_title () | |
Please do not call this method directly, use the ->title syntax. More... | |
magic_get_url () | |
Please do not call this method directly, use the ->url syntax. More... | |
resolve_theme () | |
Work out the theme this page should use. More... | |
starting_output () | |
This method is called when the page first moves out of the STATE_BEFORE_HEADER state. More... | |
url_to_class_name ($url) | |
Converts the provided URL into a CSS class that be used within the page. More... | |
Protected Attributes | |
array | $_alternateversions = array() |
An array of links to alternative versions of this page. More... | |
bool | $_block_actions_done = false |
An internal flag to record when block actions have been processed. More... | |
block_manager | $_blocks = null |
The blocks manager for this page. More... | |
string | $_blockseditingcap = 'moodle/site:manageblocks' |
The capability required by the user in order to edit blocks and block settings on this page. | |
array | $_bodyclasses = array() |
An array of CSS classes that should be added to the body tag in HTML. | |
string | $_button = '' |
HTML to go where the turn on editing button is located. More... | |
bool | $_cacheable = true |
Sets whether this page should be cached by the browser or not. More... | |
array | $_categories = null |
This holds any categories that $_course belongs to, starting with the particular category it belongs to, and working out through any parent categories to the top level. More... | |
cm_info | $_cm = null |
If this page belongs to a module, this is the cm_info module description object. | |
context | $_context = null |
The context that this page belongs to. | |
stdClass | $_course = null |
The course currently associated with this page. More... | |
string | $_devicetypeinuse = null |
Is set to the name of the device type in use. More... | |
string | $_docspath = null |
Set a different path to use for the 'Moodle docs for this page' link. More... | |
flat_navigation | $_flatnav = null |
Contains a list of nav nodes, most closely related to the current page. | |
string | $_focuscontrol = '' |
Can be set to the ID of an element on the page, if done that element receives focus when the page loads. | |
bool | $_forcesettingsmenu = false |
Is the settings menu being forced to display on this page (activities / resources only). More... | |
array | $_headeractions = [] |
Array of header actions HTML to add to the page header actions menu. | |
string | $_heading = '' |
The string to use as the heading of the page. More... | |
string | $_headingmenu = null |
The menu (or actions) to display in the heading. | |
bool | $_https_login_required = false |
Used to determine if HTTPS should be required for login. | |
array | $_layout_options = null |
List of theme layout options, these are ignored by core. More... | |
array | $_legacybrowsers = array('MSIE' => 6.0) |
Associative array of browser shortnames (as used by check_browser_version) and their minimum required versions. | |
string | $_legacyclass = null |
A legacy class that will be added to the body tag. | |
stdClass | $_module = null |
If $_cm is not null, then this will hold the corresponding row from the modname table. More... | |
navbar | $_navbar = null |
Contains the navbar structure. | |
global_navigation | $_navigation = null |
Contains the global navigation structure. | |
xhtml_container_stack | $_opencontainers |
Tracks XHTML tags on this page that have been opened but not closed. | |
array | $_othereditingcaps = array() |
An array of any other capabilities the current user must have in order to editing the page and/or its content (not just blocks). | |
string | $_pagelayout = 'base' |
The pagelayout to use when displaying this page. More... | |
string | $_pagetype = null |
The pagetype is used to describe the page and defaults to a representation of the physical path to the page e.g. More... | |
int | $_periodicrefreshdelay = null |
Sets the page to refresh after a given delay (in seconds) using meta refresh in standard_head_html() in outputlib.php If set to null(default) the page is not refreshed. | |
bool | $_popup_notification_allowed = true |
Determines if popup notifications allowed on this page. More... | |
bool | $_regionmainsettingsinheader = false |
Should the region main settings menu be rendered in the header. | |
page_requirements_manager | $_requires = null |
Page requirements manager. More... | |
settings_navigation | $_settingsnav = null |
Contains the settings navigation structure. | |
int | $_state = self::STATE_BEFORE_HEADER |
The current state of the page. More... | |
string | $_subpage = '' |
An optional arbitrary parameter that can be set on pages where the context and pagetype is not enough to identify the page. | |
theme_config | $_theme = null |
The theme to use with this page. More... | |
string | $_title = '' |
The title for the page. More... | |
moodle_url | $_url = null |
The URL for this page. More... | |
array | $_wherethemewasinitialised = null |
stack trace. More... | |
page_requirements_manager | $savedrequires = null |
Saves the requirement manager object used before switching to to fragments one. | |
moodle_page::__get | ( | $name | ) |
PHP overloading magic to make the $PAGE->course syntax work by redirecting it to the corresponding $PAGE->magic_get_course() method if there is one, and throwing an exception if not.
string | $name | property name |
mixed |
coding_exception |
moodle_page::__set | ( | $name, | |
$value | |||
) |
PHP overloading magic to catch obvious coding errors.
This method has been created to catch obvious coding errors where the developer has tried to set a page property using $PAGE->key = $value. In the moodle_page class all properties must be set using the appropriate $PAGE->set_something($value) method.
string | $name | property name |
mixed | $value | Value |
void | Throws exception if field not defined in page class |
coding_exception |
moodle_page::add_alternate_version | ( | $title, | |
$url, | |||
$mimetype | |||
) |
Sets an alternative version of this page.
There can be alternate versions of some pages (for example an RSS feed version). Call this method for each alternative version available. For each alternative version a link will be included in the <head> tag.
string | $title | The title to give the alternate version. |
string | moodle_url | $url | The URL of the alternate version. |
string | $mimetype | The mime-type of the alternate version. |
coding_exception |
moodle_page::add_body_class | ( | $class | ) |
Adds a CSS class to the body tag of the page.
string | $class | add this class name ot the class attribute on the body tag. |
coding_exception |
moodle_page::add_body_classes | ( | $classes | ) |
Adds an array of body classes to the body tag of this page.
array | $classes | this utility method calls add_body_class for each array element. |
moodle_page::add_header_action | ( | string | $html | ) |
Add some HTML to the list of actions to render in the header actions menu.
string | $html | The HTML to add. |
moodle_page::add_report_nodes | ( | $userid, | |
$nodeinfo | |||
) |
Add a report node and a specific report to the navigation.
int | $userid | The user ID that we are looking to add this report node to. |
array | $nodeinfo | Name and url of the final node that we are creating. |
|
protected |
Combines all of the required editing caps for the page and returns them as an array.
array |
moodle_page::apply_theme_region_manipulations | ( | $region | ) |
Returns the block region having made any required theme manipulations.
string | $region |
string |
moodle_page::debug_summary | ( | ) |
Get a description of this page.
Normally displayed in the footer in developer debug mode.
string |
|
protected |
Ensures that the category the current course is within, as well as all of its parent categories, have been loaded.
void |
|
protected |
This function ensures that the category of the current course has been loaded, and if not, the function loads it now.
void |
coding_exception |
moodle_page::ensure_param_not_in_url | ( | $param | ) |
Make sure page URL does not contain the given URL parameter.
This should not be necessary if the script has called set_url properly. However, in some situations like the block editing actions; when the URL has been guessed, it will contain dangerous block-related actions. Therefore, the blocks code calls this function to clean up such parameters before doing any redirect.
string | $param | the name of the parameter to make sure is not in the page URL. |
|
protected |
Ensure the theme has not been loaded yet.
If it has an exception is thrown.
coding_exception |
moodle_page::force_settings_menu | ( | $forced = true | ) |
Force the settings menu to be displayed on this page.
This will only force the settings menu on an activity / resource page that is being displayed on a theme that uses a settings menu.
bool | $forced | default of true, can be sent false to turn off the force. |
moodle_page::force_theme | ( | $themename | ) |
Force this page to use a particular theme.
Please use this cautiously. It is only intended to be used by the themes selector admin page.
string | $themename | the name of the theme to use. |
moodle_page::get_header_actions | ( | ) |
Get the list of HTML for actions to render in the header actions menu.
string[] |
moodle_page::get_popup_notification_allowed | ( | ) |
Are popup notifications allowed on this page? Popup notifications may be disallowed in situations such as while upgrading or completing a quiz.
bool | true if popup notifications may be displayed |
moodle_page::get_renderer | ( | $component, | |
$subtype = null , |
|||
$target = null |
|||
) |
Returns instance of page renderer.
string | $component | name such as 'core', 'mod_forum' or 'qtype_multichoice'. |
string | $subtype | optional subtype such as 'news' resulting to 'mod_forum_news' |
string | $target | one of rendering target constants |
renderer_base |
moodle_page::get_where_theme_was_initialised | ( | ) |
For diagnostic/debugging purposes, find where the theme setup was triggered.
null|array | null if theme not yet setup. Stacktrace if it was. |
moodle_page::has_navbar | ( | ) |
Checks to see if there are any items on the navbar object.
bool | true if there are, false if not |
moodle_page::has_set_url | ( | ) |
Returns true if the page URL has beem set.
bool |
moodle_page::https_required | ( | ) |
moodle_page::include_region_main_settings_in_header_actions | ( | ) |
Check if the region main settings should be rendered as an action in the header actions menu rather than at the top of the content.
bool |
|
protected |
Sets ->pagetype from the script name.
For example, if the script that was run is mod/quiz/view.php, ->pagetype will be set to 'mod-quiz-view'.
string | $script | the path to the script that should be used to initialise ->pagetype. If not passed the $SCRIPT global will be used. If legacy code has set $CFG->pagepath that will be used instead, and a developer warning issued. |
|
protected |
Initialises the CSS classes that will be added to body tag of the page.
The function is responsible for adding all of the critical CSS classes that describe the current page, and its state. This includes classes that describe the following for example:
moodle_page::initialise_theme_and_output | ( | ) |
Method for use by Moodle core to set up the theme.
Do not use this in your own code.
Make sure the right theme for this page is loaded. Tell our blocks_manager about the theme block regions, and then, if we are $PAGE, set up the global $OUTPUT.
void |
moodle_page::is_settings_menu_forced | ( | ) |
Check to see if the settings menu is forced to display on this activity / resource page.
This only applies to themes that use the settings menu.
bool | True if the settings menu is forced to display. |
|
protected |
Loads the activity record for the current CM object associated with this page.
This will load moodle_page::$_module with a row from the related module table in the database. For instance if moodle_page::$_cm is a forum then a row from the forum table will be loaded.
|
protected |
Loads the requested category into the pages categories array.
int | $categoryid |
moodle_exception |
|
protected |
Please do not call this method directly, use the ->activityname syntax.
string | the The type of activity we are in, for example 'forum' or 'quiz'. Will be null if this page is not within a module. |
|
protected |
Please do not call this method directly, use the ->activityrecord syntax.
stdClass | the row from the activities own database table (for example the forum or quiz table) that this page belongs to. Will be null if this page is not within a module. |
|
protected |
The list of alternate versions of this page.
array | mime type => object with ->url and ->title. |
|
protected |
Returns an array of minipulations or false if there are none to make.
bool|array |
|
protected |
Please do not call this method directly, use the ->blocks syntax.
block_manager | the blocks manager object for this page. |
|
protected |
Please do not call this method directly, use the ->bodyclasses syntax.
string | the class names to put on the body element in the HTML. |
|
protected |
Please do not call this method directly, use the ->pagetype syntax.
string | The id to use on the body tag, uses magic_get_pagetype(). |
|
protected |
Please do not call this method directly, use the ->button syntax.
string | the HTML to go where the Turn editing on button normally goes. |
|
protected |
Please do not call this method directly, use the ->cacheable syntax.
bool | can this page be cached by the user's browser. |
|
protected |
Please do not call this method directly, use the ->categories syntax.
array | an array of all the categories the page course belongs to, starting with the immediately containing category, and working out to the top-level category. This may be the empty array if we are in the front page course. |
|
protected |
Please do not call this method directly, use the ->category syntax.
stdClass | the category that the page course belongs to. If there isn't one (that is, if this is the front page course) returns null. |
|
protected |
Please do not call this method directly, use the ->cm syntax.
cm_info | the course_module that this page belongs to. Will be null if this page is not within a module. This is a full cm object, as loaded by get_coursemodule_from_id or get_coursemodule_from_instance, so the extra modname and name fields are present. |
|
protected |
Please do not call this method directly, use the ->context syntax.
context | the main context to which this page belongs. |
|
protected |
Please do not call this method directly, use the ->course syntax.
stdClass | the current course that we are inside - a row from the course table. (Also available as $COURSE global.) If we are not inside an actual course, this will be the site course. |
|
protected |
Please do not call this method directly, use the ->devicetypeinuse syntax.
string | The device type being used. |
|
protected |
Please do not call this method directly, use the ->docspath syntax.
string | the path to the Moodle docs for this page. |
|
protected |
Returns the flat navigation object.
flat_navigation |
|
protected |
Please do not call this method directly, use the ->focuscontrol syntax.
string | the id of the HTML element to be focused when the page has loaded. |
|
protected |
Please do not call this method directly, use the ->headerprinted syntax.
bool | has the header already been printed? |
|
protected |
Please do not call this method directly, use the ->heading syntax.
string | the main heading that should be displayed at the top of the <body>. |
|
protected |
Please do not call this method directly, use the ->heading syntax.
string | The menu (or actions) to display in the heading |
|
protected |
Please do not call this method directly, use the ->layout_options syntax.
array | returns arrays with options for layout file |
|
protected |
Return a navbar object.
navbar |
|
protected |
Return the navigation object.
global_navigation |
|
protected |
Please do not call this method directly use the ->opencontainers syntax.
xhtml_container_stack | tracks XHTML tags on this page that have been opened but not closed. mainly for internal use by the rendering code. |
|
protected |
Please do not call this method directly, use the ->pagelayout syntax.
string | the general type of page this is. For example 'standard', 'popup', 'home'. Allows the theme to display things differently, if it wishes to. |
|
protected |
Please do not call this method directly, use the ->pagetype syntax.
string | e.g. 'my-index' or 'mod-quiz-attempt'. |
|
protected |
Please do not call this method directly use the ->periodicrefreshdelay syntax moodle_page::__get().
int | The periodic refresh delay to use with meta refresh |
|
protected |
Returns request IP address.
string | IP address or null if unknown |
|
protected |
Returns the origin of current request.
Note: constants are not required because we need to use these values in logging and reports.
string | 'web', 'ws', 'cli', 'restore', etc. |
|
protected |
Please do not call this method directly, use the ->requires syntax.
page_requirements_manager | tracks the JavaScript, CSS files, etc. required by this page. |
|
protected |
Returns the settings navigation object.
settings_navigation |
|
protected |
Please do not call this method directly, use the ->state syntax.
integer | one of the STATE_XXX constants. You should not normally need to use this in your code. It is intended for internal use by this class and its friends like print_header, to check that everything is working as expected. Also accessible as $PAGE->state. |
|
protected |
Please do not call this method directly, use the ->subpage syntax.
string | The subpage identifier, if any. |
|
protected |
Please do not call this method directly, use the ->theme syntax.
theme_config | the initialised theme for this page. |
|
protected |
Please do not call this method directly, use the ->title syntax.
string | the title that should go in the <head> section of the HTML of this page. |
|
protected |
Please do not call this method directly, use the ->url syntax.
moodle_url | the clean URL required to load the current page. (You should normally use this in preference to $ME or $FULLME.) |
moodle_page::reload_theme | ( | ) |
Reload theme settings.
This is used when we need to reset settings because they are now double cached in theme.
moodle_page::reset_theme_and_output | ( | ) |
Reset the theme and output for a new context.
This only makes sense from external::validate_context(). Do not cheat.
string | the name of the theme that should be used on this page. |
|
protected |
Work out the theme this page should use.
This depends on numerous $CFG settings, and the properties of this page.
string | the name of the theme that should be used on this page. |
moodle_page::set_activity_record | ( | $module | ) |
Sets the activity record.
This could be a row from the main table for a module. For instance if the current module (cm) is a forum this should be a row from the forum table.
stdClass | $module | A row from the main database table for the module that this page belongs to. |
coding_exception |
moodle_page::set_block_actions_done | ( | $setting = true | ) |
Gets set when the block actions for the page have been processed.
bool | $setting |
moodle_page::set_blocks_editing_capability | ( | $capability | ) |
Set the capability that allows users to edit blocks on this page.
Normally the default of 'moodle/site:manageblocks' is used, but a few pages like the My Moodle page need to use a different capability like 'moodle/my:manageblocks'.
string | $capability | a capability. |
moodle_page::set_button | ( | $html | ) |
Specify a fragment of HTML that goes where the 'Turn editing on' button normally goes.
string | $html | the HTML to display there. |
moodle_page::set_cacheable | ( | $cacheable | ) |
Sets whether the browser should cache this page or not.
bool | $cacheable | can this page be cached by the user's browser. |
moodle_page::set_category_by_id | ( | $categoryid | ) |
Set the course category this page belongs to manually.
This automatically sets $PAGE->course to be the site course. You cannot use this method if you have already set $PAGE->course - in that case, the category must be the one that the course belongs to. This also automatically sets the page context to the category context.
int | $categoryid | The id of the category to set. |
coding_exception |
moodle_page::set_cm | ( | $cm, | |
$course = null , |
|||
$module = null |
|||
) |
The course module that this page belongs to (if it does belong to one).
stdClass | cm_info | $cm | a record from course_modules table or cm_info from get_fast_modinfo(). |
stdClass | $course | |
stdClass | $module |
void |
coding_exception |
moodle_page::set_context | ( | $context | ) |
Set the main context to which this page belongs.
context | $context | a context object. You normally get this with context_xxxx::instance(). |
moodle_page::set_course | ( | $course | ) |
Set the current course.
This sets both $PAGE->course and $COURSE. It also sets the right theme and locale.
Normally you don't need to call this function yourself, require_login will call it for you if you pass a $course to it. You can use this function on pages that do need to call require_login().
Sets $PAGE->context to the course context, if it is not already set.
stdClass | $course | the course to set as the global course. |
coding_exception |
moodle_page::set_docs_path | ( | $path | ) |
Set a different path to use for the 'Moodle docs for this page' link.
By default, it uses the pagetype, which is normally the same as the script name. So, for example, for mod/quiz/attempt.php, pagetype is mod-quiz-attempt, and so docspath is mod/quiz/attempt.
string | $path | the path to use at the end of the moodle docs URL. |
moodle_page::set_focuscontrol | ( | $controlid | ) |
Specify a form control should be focused when the page has loaded.
string | $controlid | the id of the HTML element to be focused. |
moodle_page::set_heading | ( | $heading | ) |
Sets the heading to use for the page.
This is normally used as the main heading at the top of the content.
string | $heading | the main heading that should be displayed at the top of the <body>. |
moodle_page::set_headingmenu | ( | $menu | ) |
Sets some HTML to use next to the heading moodle_page::set_heading().
string | $menu | The menu/content to show in the heading |
moodle_page::set_include_region_main_settings_in_header_actions | ( | bool | $value | ) |
Set the flag to indicate if the region main settings should be rendered as an action in the header actions menu rather than at the top of the content.
bool | $value | If the settings should be in the header. |
moodle_page::set_other_editing_capability | ( | $capability | ) |
Some pages let you turn editing on for reasons other than editing blocks.
If that is the case, you can pass other capabilities that let the user edit this page here.
string | array | $capability | either a capability, or an array of capabilities. |
moodle_page::set_pagelayout | ( | $pagelayout | ) |
Sets the layout to use for this page.
The page layout determines how the page will be displayed, things such as block regions, content areas, etc are controlled by the layout. The theme in use for the page will determine that the layout contains.
This properly defaults to 'base', so you only need to call this function if you want something different. The exact range of supported layouts is specified in the standard theme.
For an idea of the common page layouts see But please keep in mind that it may be (and normally is) out of date. The only place to find an accurate up-to-date list of the page layouts available for your version of Moodle is theme/base/config.php
string | $pagelayout | the page layout this is. For example 'popup', 'home'. |
moodle_page::set_pagetype | ( | $pagetype | ) |
Sets the pagetype to use for this page.
Normally you do not need to set this manually, it is automatically created from the script name. However, on some pages this is overridden. For example the page type for course/view.php includes the course format, for example 'course-view-weeks'. This gets used as the id attribute on <body> and also for determining which blocks are displayed.
string | $pagetype | e.g. 'my-index' or 'mod-quiz-attempt'. |
moodle_page::set_periodic_refresh_delay | ( | $delay = null | ) |
Sets the page to periodically refresh.
This function must be called before $OUTPUT->header has been called or a coding exception will be thrown.
int | $delay | Sets the delay before refreshing the page, if set to null refresh is cancelled. |
coding_exception |
moodle_page::set_popup_notification_allowed | ( | $allowed | ) |
Allow or disallow popup notifications on this page.
Popups are allowed by default.
bool | $allowed | true if notifications are allowed. False if not allowed. They are allowed by default. |
moodle_page::set_state | ( | $state | ) |
Set the state.
The state must be one of that STATE_... constants, and the state is only allowed to advance one step at a time.
int | $state | The new state. |
coding_exception |
moodle_page::set_subpage | ( | $subpage | ) |
If context->id and pagetype are not enough to uniquely identify this page, then you can set a subpage id as well.
For example, the tags page sets
string | $subpage | an arbitrary identifier that, along with context->id and pagetype, uniquely identifies this page. |
moodle_page::set_title | ( | $title | ) |
Sets the title for the page.
This is normally used within the title tag in the head of the page.
string | $title | the title that should go in the <head> section of the HTML of this page. |
moodle_page::set_url | ( | $url, | |
array | $params = null |
||
) |
You should call this method from every page to set the URL that should be used to return to this page.
Used, for example, by the blocks editing UI to know where to return the user after an action. For example, course/view.php does: $id = optional_param('id', 0, PARAM_INT); $PAGE->set_url('/course/view.php', array('id' => $id));
moodle_url | string | $url | URL relative to $CFG->wwwroot or moodle_url instance |
array | $params | parameters to add to the URL |
coding_exception |
moodle_page::start_collecting_javascript_requirements | ( | ) |
Switches from the regular requirements manager to the fragment requirements manager to capture all necessary JavaScript to display a chunk of HTML such as an mform.
This is for use by the get_fragment() web service and not for use elsewhere.
|
protected |
This method is called when the page first moves out of the STATE_BEFORE_HEADER state.
This is our last change to initialise things.
|
protected |
Converts the provided URL into a CSS class that be used within the page.
This is primarily used to add the wwwroot to the body tag as a CSS class.
string | $url |
string |
moodle_page::user_allowed_editing | ( | ) |
Does the user have permission to see this page in editing mode.
bool |
moodle_page::user_can_edit_blocks | ( | ) |
Does the user have permission to edit blocks on this page.
bool |
moodle_page::user_is_editing | ( | ) |
Should the current user see this page in editing mode.
That is, are they allowed to edit this page, and are they currently in editing mode.
bool |
moodle_page::verify_https_required | ( | ) |
|
protected |
An array of links to alternative versions of this page.
Primarily used for RSS versions of the current page.
|
protected |
An internal flag to record when block actions have been processed.
Remember block actions occur on the current URL and it is important that even they are never executed more than once.
|
protected |
The blocks manager for this page.
It is responsible for the blocks and there content on this page.
|
protected |
HTML to go where the turn on editing button is located.
This is nearly a legacy item and not used very often any more.
|
protected |
Sets whether this page should be cached by the browser or not.
If it is set to true (default) the page is served with caching headers.
|
protected |
This holds any categories that $_course belongs to, starting with the particular category it belongs to, and working out through any parent categories to the top level.
These are loaded progressively, if needed. There are three states. $_categories = null initially when nothing is loaded; $_categories = array($id => $cat, $parentid => null) when we have loaded $_course->category, but not any parents; and a complete array once everything is loaded.
|
protected |
The course currently associated with this page.
If not has been provided the front page course is used.
|
protected |
Is set to the name of the device type in use.
This will we worked out when it is first used.
|
protected |
Set a different path to use for the 'Moodle docs for this page' link.
By default, it uses the path of the file for instance mod/quiz/attempt.
|
protected |
Is the settings menu being forced to display on this page (activities / resources only).
This is only used by themes that use the settings menu.
|
protected |
The string to use as the heading of the page.
Shown near the top of the page within most themes.
|
protected |
List of theme layout options, these are ignored by core.
To be used in individual theme layout files only.
|
protected |
If $_cm is not null, then this will hold the corresponding row from the modname table.
For example, if $_cm->modname is 'quiz', this will be a row from the quiz table.
|
protected |
The pagelayout to use when displaying this page.
The pagelayout needs to have been defined by the theme in use, or one of its parents. By default base is used however standard is the more common layout. Note that this gets automatically set by core during operations like require_login.
|
protected |
The pagetype is used to describe the page and defaults to a representation of the physical path to the page e.g.
my-index, mod-quiz-attempt
|
protected |
Determines if popup notifications allowed on this page.
Code such as the quiz module disables popup notifications in situations such as upgrading or completing a quiz.
|
protected |
Page requirements manager.
It is responsible for all JavaScript and CSS resources required by this page.
|
protected |
The current state of the page.
The state a page is within determines what actions are possible for it.
|
protected |
The theme to use with this page.
This has to be properly initialised via moodle_page::initialise_theme_and_output() which happens magically before any operation that requires it.
|
protected |
The title for the page.
Used within the title tag in the HTML head.
|
protected |
The URL for this page.
This is mandatory and must be set before output is started.
|
protected |
stack trace.
Then the theme is initialised, we save the stack trace, for use in error messages.