Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
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. | |
__set ($name, $value) | |
PHP overloading magic to catch obvious coding errors. | |
add_alternate_version ($title, $url, $mimetype) | |
Sets an alternative version of this page. | |
add_body_class ($class) | |
Adds a CSS class to the body tag of the page. | |
add_body_classes ($classes) | |
Adds an array of body classes to the body tag of this page. | |
add_header_action (string $html) | |
Add some HTML to the list of actions to render in the header actions menu. | |
add_report_nodes ($userid, $nodeinfo) | |
Add a report node and a specific report to the navigation. | |
apply_theme_region_manipulations ($region) | |
Returns the block region having made any required theme manipulations. | |
debug_summary () | |
Get a description of this page. | |
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. | |
force_lock_all_blocks () | |
Remove access to editing/moving on all blocks on a page. | |
force_settings_menu ($forced=true) | |
Force the settings menu to be displayed on this page. | |
force_theme ($themename) | |
Force this page to use a particular theme. | |
get_edited_page_hash () | |
Allows to 'serialize' the edited page information and store it in the session cache. | |
get_header_actions () | |
Get the list of HTML for actions to render in the header actions menu. | |
get_navigation_overflow_state () | |
Gets the navigation overflow state. | |
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. | |
get_primary_activate_tab () | |
The key of the primary nav node to activate. | |
get_renderer ($component, $subtype=null, $target=null) | |
Returns instance of page renderer. | |
get_secondary_active_tab () | |
The key of secondary nav node to activate. | |
get_show_course_index () | |
Get the current status for displaying the course index. | |
get_where_theme_was_initialised () | |
For diagnostic/debugging purposes, find where the theme setup was triggered. | |
has_navbar () | |
Checks to see if there are any items on the navbar object. | |
has_secondary_navigation () | |
Check if the secondary navigation should be rendered. | |
has_set_url () | |
Returns true if the page URL has beem set. | |
has_tablist_secondary_navigation () | |
Check if the secondary navigation should be rendered with a tablist as opposed to a menubar. | |
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. | |
initialise_theme_and_output () | |
Method for use by Moodle core to set up the theme. | |
is_settings_menu_forced () | |
Check to see if the settings menu is forced to display on this activity / resource page. | |
reload_theme () | |
Reload theme settings. | |
reset_theme_and_output () | |
Reset the theme and output for a new context. | |
set_activity_record ($module) | |
Sets the activity record. | |
set_block_actions_done ($setting=true) | |
Gets set when the block actions for the page have been processed. | |
set_blocks_editing_capability ($capability) | |
Set the capability that allows users to edit blocks on this page. | |
set_button ($html) | |
Specify a fragment of HTML that goes where the 'Turn editing on' button normally goes. | |
set_cacheable ($cacheable) | |
Sets whether the browser should cache this page or not. | |
set_category_by_id ($categoryid) | |
Set the course category this page belongs to manually. | |
set_cm ($cm, $course=null, $module=null) | |
The course module that this page belongs to (if it does belong to one). | |
set_context ($context) | |
Set the main context to which this page belongs. | |
set_course ($course) | |
Set the current course. | |
set_docs_path ($path) | |
Set a different path to use for the 'Documentation for this page' link. | |
set_focuscontrol ($controlid) | |
Specify a form control should be focused when the page has loaded. | |
set_heading ($heading, bool $applyformatting=true, bool $clean=true) | |
Sets the heading to use for the page. | |
set_headingmenu ($menu) | |
Sets some HTML to use next to the heading moodle_page::set_heading(). | |
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. | |
set_navigation_overflow_state (bool $state) | |
Sets the navigation overflow state. | |
set_other_editing_capability ($capability) | |
Some pages let you turn editing on for reasons other than editing blocks. | |
set_pagelayout ($pagelayout) | |
Sets the layout to use for this page. | |
set_pagetype ($pagetype) | |
Sets the pagetype to use for this page. | |
set_periodic_refresh_delay ($delay=null) | |
Sets the page to periodically refresh. | |
set_popup_notification_allowed ($allowed) | |
Allow or disallow popup notifications on this page. | |
set_primary_active_tab (string $navkey) | |
Set the key of the primary nav node to be activated. | |
set_secondary_active_tab (string $navkey) | |
Set the key of the secondary nav node to be activated. | |
set_secondary_navigation (bool $hassecondarynavigation, bool $istablist=false) | |
Set the flag to indicate if the secondary navigation should be rendered. | |
set_secondarynav (secondary $nav) | |
Force set secondary_nav. | |
set_show_course_index (bool $state) | |
Set the status for displaying the course index. | |
set_state ($state) | |
Set the state. | |
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. | |
set_title ($title, bool $appendsitename=true) | |
Sets the title for the 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. | |
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. | |
user_allowed_editing () | |
Does the user have permission to see this page in editing mode. | |
user_can_edit_blocks () | |
Does the user have permission to edit blocks on this page. | |
user_is_editing () | |
Should the current user see this page in editing mode. | |
verify_https_required () | |
Static Public Member Functions | |
static | retrieve_edited_page (string $hash, $strictness=IGNORE_MISSING) |
Retrieves a page that is being edited from the session cache. | |
Protected Member Functions | |
all_editing_caps () | |
Combines all of the required editing caps for the page and returns them as an array. | |
ensure_categories_loaded () | |
Ensures that the category the current course is within, as well as all of its parent categories, have been loaded. | |
ensure_category_loaded () | |
This function ensures that the category of the current course has been loaded, and if not, the function loads it now. | |
ensure_theme_not_set () | |
Ensure the theme has not been loaded yet. | |
initialise_default_pagetype ($script=null) | |
Sets ->pagetype from the script name. | |
initialise_standard_body_classes () | |
Initialises the CSS classes that will be added to body tag of the page. | |
load_activity_record () | |
Loads the activity record for the current CM object associated with this page. | |
load_category ($categoryid) | |
Loads the requested category into the pages categories array. | |
magic_get_activityheader () | |
Returns the activity header object. | |
magic_get_activityname () | |
Please do not call this method directly, use the ->activityname syntax. | |
magic_get_activityrecord () | |
Please do not call this method directly, use the ->activityrecord syntax. | |
magic_get_alternateversions () | |
The list of alternate versions of this page. | |
magic_get_blockmanipulations () | |
Returns an array of minipulations or false if there are none to make. | |
magic_get_blocks () | |
Please do not call this method directly, use the ->blocks syntax. | |
magic_get_bodyclasses () | |
Please do not call this method directly, use the ->bodyclasses syntax. | |
magic_get_bodyid () | |
Please do not call this method directly, use the ->pagetype syntax. | |
magic_get_button () | |
Please do not call this method directly, use the ->button syntax. | |
magic_get_cacheable () | |
Please do not call this method directly, use the ->cacheable syntax. | |
magic_get_categories () | |
Please do not call this method directly, use the ->categories syntax. | |
magic_get_category () | |
Please do not call this method directly, use the ->category syntax. | |
magic_get_cm () | |
Please do not call this method directly, use the ->cm syntax. | |
magic_get_context () | |
Please do not call this method directly, use the ->context syntax. | |
magic_get_course () | |
Please do not call this method directly, use the ->course syntax. | |
magic_get_devicetypeinuse () | |
Please do not call this method directly, use the ->devicetypeinuse syntax. | |
magic_get_docspath () | |
Please do not call this method directly, use the ->docspath syntax. | |
magic_get_flatnav () | |
Returns the flat navigation object. | |
magic_get_focuscontrol () | |
Please do not call this method directly, use the ->focuscontrol syntax. | |
magic_get_headerprinted () | |
Please do not call this method directly, use the ->headerprinted syntax. | |
magic_get_heading () | |
Please do not call this method directly, use the ->heading syntax. | |
magic_get_headingmenu () | |
Please do not call this method directly, use the ->heading syntax. | |
magic_get_layout_options () | |
Please do not call this method directly, use the ->layout_options syntax. | |
magic_get_navbar () | |
Return a navbar object. | |
magic_get_navigation () | |
Return the navigation object. | |
magic_get_opencontainers () | |
Please do not call this method directly use the ->opencontainers syntax. | |
magic_get_pagelayout () | |
Please do not call this method directly, use the ->pagelayout syntax. | |
magic_get_pagetype () | |
Please do not call this method directly, use the ->pagetype syntax. | |
magic_get_periodicrefreshdelay () | |
Please do not call this method directly use the ->periodicrefreshdelay syntax moodle_page::__get(). | |
magic_get_primarynav () | |
Returns the primary navigation object. | |
magic_get_primarynavcombined () | |
Returns the primary navigation object. | |
magic_get_requestip () | |
Returns request IP address. | |
magic_get_requestorigin () | |
Returns the origin of current request. | |
magic_get_requires () | |
Please do not call this method directly, use the ->requires syntax. | |
magic_get_secondarynav () | |
Returns the secondary navigation object. | |
magic_get_settingsnav () | |
Returns the settings navigation object. | |
magic_get_state () | |
Please do not call this method directly, use the ->state syntax. | |
magic_get_subpage () | |
Please do not call this method directly, use the ->subpage syntax. | |
magic_get_theme () | |
Please do not call this method directly, use the ->theme syntax. | |
magic_get_title () | |
Please do not call this method directly, use the ->title syntax. | |
magic_get_url () | |
Please do not call this method directly, use the ->url syntax. | |
resolve_theme () | |
Work out the theme this page should use. | |
starting_output () | |
This method is called when the page first moves out of the STATE_BEFORE_HEADER state. | |
url_to_class_name ($url) | |
Converts the provided URL into a CSS class that be used within the page. | |
Protected Attributes | |
string | $_activekeysecondary = null |
the key of the secondary node to be activated. | |
string | $_activenodeprimary = null |
the key of the primary node to be activated. | |
activity_header | $_activityheader |
The activity header for the page. | |
array | $_alternateversions = array() |
An array of links to alternative versions of this page. | |
bool | $_block_actions_done = false |
An internal flag to record when block actions have been processed. | |
block_manager | $_blocks = null |
The blocks manager for this page. | |
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. | |
bool | $_cacheable = true |
Sets whether this page should be cached by the browser or not. | |
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. | |
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. | |
string | $_devicetypeinuse = null |
Is set to the name of the device type in use. | |
string | $_docspath = null |
Set a different path to use for the 'Documentation for this page' link. | |
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 | $_forcelockallblocks = false |
Whether to override/remove all editing capabilities for blocks on the page. | |
bool | $_forcesettingsmenu = false |
Is the settings menu being forced to display on this page (activities / resources only). | |
bool | $_hassecondarynavigation = true |
Should the secondary menu be rendered. | |
bool | $_hastablistsecondarynavigation = false |
Should the secondary menu be rendered as a tablist as opposed to a menubar. | |
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. | |
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. | |
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. | |
navbar | $_navbar = null |
Contains the navbar structure. | |
global_navigation | $_navigation = null |
Contains the global navigation structure. | |
bool | $_navigationoverflow = true |
The value of displaying the navigation overflow. | |
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. | |
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. | |
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. | |
primary | $_primarynav = null |
Contains the nav nodes that will appear in the primary navigation. | |
primaryoutput | $_primarynavcombined = null |
Contains the combined nav nodes that will appear in the primary navigation. | |
bool | $_regionmainsettingsinheader = false |
Should the region main settings menu be rendered in the header. | |
page_requirements_manager | $_requires = null |
Page requirements manager. | |
secondary | $_secondarynav = null |
Contains the nav nodes that will appear in the secondary navigation. | |
settings_navigation | $_settingsnav = null |
Contains the settings navigation structure. | |
bool bool | $_showcourseindex = true |
Indicates whether the course index drawer should be shown. | |
int | $_state = self::STATE_BEFORE_HEADER |
The current state of the page. | |
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. | |
string | $_title = '' |
The title for the page. | |
moodle_url | $_url = null |
The URL for this page. | |
array | $_wherethemewasinitialised = null |
stack trace. | |
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_lock_all_blocks | ( | ) |
Remove access to editing/moving on all blocks on a page.
This overrides any capabilities and is intended only for pages where no user (including admins) should be able to modify blocks on the page (eg My Courses).
void |
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_edited_page_hash | ( | ) |
Allows to 'serialize' the edited page information and store it in the session cache.
Due to Moodle architectural decision and non-SPA approach, a lot of page setup is happening in the actual page php file, for example, setting course/cm/context, setting layout and pagetype, requiring capabilities, setting specific block editing capabilities.
When storing this information in the session cache we can pass the pagehash (cache key) as an argument to web services in AJAX requests and retrieve all data associated with the page without actually executing PHP code on that page.
string|null |
moodle_page::get_header_actions | ( | ) |
Get the list of HTML for actions to render in the header actions menu.
string[] |
moodle_page::get_navigation_overflow_state | ( | ) |
Gets the navigation overflow state.
bool | The navigation overflow state. |
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_primary_activate_tab | ( | ) |
The key of the primary nav node to activate.
string|null | get the key of the primary nav node to activate. |
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_secondary_active_tab | ( | ) |
The key of secondary nav node to activate.
string|null | get the key of the secondary node to activate. |
moodle_page::get_show_course_index | ( | ) |
Get the current status for displaying the course index.
bool |
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_secondary_navigation | ( | ) |
Check if the secondary navigation should be rendered.
bool |
moodle_page::has_set_url | ( | ) |
Returns true if the page URL has beem set.
bool |
moodle_page::has_tablist_secondary_navigation | ( | ) |
Check if the secondary navigation should be rendered with a tablist as opposed to a menubar.
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 |
Returns the activity header object.
activity_header |
|
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|null | 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 Documentation 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 the primary navigation object.
primary |
|
protected |
Returns the primary navigation object.
primaryoutput |
|
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 |
|
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.
|
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. |
|
static |
Retrieves a page that is being edited from the session cache.
{
string | $hash | |
int | $strictness |
self|null |
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 'Documentation 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, | |
bool | $applyformatting = true, | ||
bool | $clean = true ) |
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>. |
bool | $applyformatting | apply format_string() - by default true. |
bool | $clean | whether the heading should be cleaned or not when no formatting is applied - by default true. |
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_navigation_overflow_state | ( | bool | $state | ) |
Sets the navigation overflow state.
This allows developers to turn off the overflow menu if they perhaps are using some other navigation to show settings.
bool | $state | The state of whether to show the navigation overflow. |
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_primary_active_tab | ( | string | $navkey | ) |
Set the key of the primary nav node to be activated.
string | $navkey |
moodle_page::set_secondary_active_tab | ( | string | $navkey | ) |
Set the key of the secondary nav node to be activated.
string | $navkey | the key of the secondary nav node to be activated. |
moodle_page::set_secondary_navigation | ( | bool | $hassecondarynavigation, |
bool | $istablist = false ) |
Set the flag to indicate if the secondary navigation should be rendered.
bool | $hassecondarynavigation | If the secondary navigation should be rendered. |
bool | $istablist | When true, the navigation bar should be rendered and behave with a tablist ARIA role. If false, it's rendered with a menubar ARIA role. Defaults to false. |
moodle_page::set_secondarynav | ( | secondary | $nav | ) |
Force set secondary_nav.
Useful in cases where we dealing with non course modules. e.g. blocks, tools.
secondary | $nav |
moodle_page::set_show_course_index | ( | bool | $state | ) |
Set the status for displaying the course index.
bool | $state |
|
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, | |
bool | $appendsitename = true ) |
Sets the title for the page.
This is normally used within the title tag in the head of the page.
Some tips for providing a meaningful page title:
For more information, see Understanding Success Criterion 2.4.2: Page Titled
string | $title | the title that should go in the <head> section of the HTML of this page. |
bool | $appendsitename | Appends site name at the end of the given title. It is encouraged to append the site name as this especially helps with accessibility. If it's necessary to override this, please keep in mind to ensure that the title provides a concise summary of the page being displayed. |
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.
Can be forced to false by calling the force_lock_all_blocks() method.
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 'Documentation 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 |
Contains the combined nav nodes that will appear in the primary navigation.
Includes - primarynav, langmenu, usermenu
|
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.