Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
moodle_page Class Reference

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 ()
 

Public Attributes

const STATE_BEFORE_HEADER = 0
 The state of the page before it has printed the header.
 
const STATE_DONE = 3
 The state the page is when the footer has been printed and its function is complete.
 
const STATE_IN_BODY = 2
 The state the page is in while content is presumably being printed.
 
const STATE_PRINTING_HEADER = 1
 The state the page is in temporarily while the header is being printed.
 

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.
 

Member Function Documentation

◆ __get()

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.

Parameters
string$nameproperty name
Return values
mixed
Exceptions
coding_exception

◆ __set()

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.

Parameters
string$nameproperty name
mixed$valueValue
Return values
voidThrows exception if field not defined in page class
Exceptions
coding_exception

◆ add_alternate_version()

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.

Parameters
string$titleThe title to give the alternate version.
string | moodle_url$urlThe URL of the alternate version.
string$mimetypeThe mime-type of the alternate version.
Exceptions
coding_exception

◆ add_body_class()

moodle_page::add_body_class (   $class)

Adds a CSS class to the body tag of the page.

Parameters
string$classadd this class name ot the class attribute on the body tag.
Exceptions
coding_exception

◆ add_body_classes()

moodle_page::add_body_classes (   $classes)

Adds an array of body classes to the body tag of this page.

Parameters
array$classesthis utility method calls add_body_class for each array element.

◆ add_header_action()

moodle_page::add_header_action ( string  $html)

Add some HTML to the list of actions to render in the header actions menu.

Parameters
string$htmlThe HTML to add.

◆ add_report_nodes()

moodle_page::add_report_nodes (   $userid,
  $nodeinfo 
)

Add a report node and a specific report to the navigation.

Parameters
int$useridThe user ID that we are looking to add this report node to.
array$nodeinfoName and url of the final node that we are creating.

◆ all_editing_caps()

moodle_page::all_editing_caps ( )
protected

Combines all of the required editing caps for the page and returns them as an array.

Return values
array

◆ apply_theme_region_manipulations()

moodle_page::apply_theme_region_manipulations (   $region)

Returns the block region having made any required theme manipulations.

Since
Moodle 2.5.1 2.6
Parameters
string$region
Return values
string

◆ debug_summary()

moodle_page::debug_summary ( )

Get a description of this page.

Normally displayed in the footer in developer debug mode.

Return values
string

◆ ensure_categories_loaded()

moodle_page::ensure_categories_loaded ( )
protected

Ensures that the category the current course is within, as well as all of its parent categories, have been loaded.

Return values
void

◆ ensure_category_loaded()

moodle_page::ensure_category_loaded ( )
protected

This function ensures that the category of the current course has been loaded, and if not, the function loads it now.

Return values
void
Exceptions
coding_exception

◆ ensure_param_not_in_url()

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.

Parameters
string$paramthe name of the parameter to make sure is not in the page URL.

◆ ensure_theme_not_set()

moodle_page::ensure_theme_not_set ( )
protected

Ensure the theme has not been loaded yet.

If it has an exception is thrown.

Exceptions
coding_exception

◆ force_settings_menu()

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.

Parameters
bool$forceddefault of true, can be sent false to turn off the force.

◆ force_theme()

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.

Parameters
string$themenamethe name of the theme to use.

◆ get_header_actions()

moodle_page::get_header_actions ( )

Get the list of HTML for actions to render in the header actions menu.

Return values
string[]

◆ get_popup_notification_allowed()

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.

Return values
booltrue if popup notifications may be displayed

◆ get_renderer()

moodle_page::get_renderer (   $component,
  $subtype = null,
  $target = null 
)

Returns instance of page renderer.

Parameters
string$componentname such as 'core', 'mod_forum' or 'qtype_multichoice'.
string$subtypeoptional subtype such as 'news' resulting to 'mod_forum_news'
string$targetone of rendering target constants
Return values
renderer_base

◆ get_where_theme_was_initialised()

moodle_page::get_where_theme_was_initialised ( )

For diagnostic/debugging purposes, find where the theme setup was triggered.

Return values
null|arraynull if theme not yet setup. Stacktrace if it was.

◆ has_navbar()

moodle_page::has_navbar ( )

Checks to see if there are any items on the navbar object.

Return values
booltrue if there are, false if not

◆ has_set_url()

moodle_page::has_set_url ( )

Returns true if the page URL has beem set.

Return values
bool

◆ https_required()

moodle_page::https_required ( )
Deprecated:
since Moodle 3.4

◆ include_region_main_settings_in_header_actions()

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.

Return values
bool

◆ initialise_default_pagetype()

moodle_page::initialise_default_pagetype (   $script = null)
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'.

Parameters
string$scriptthe 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.

◆ initialise_standard_body_classes()

moodle_page::initialise_standard_body_classes ( )
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:

  • Current language
  • Language direction
  • YUI CSS initialisation
  • Pagelayout These are commonly used in CSS to target specific types of pages.

◆ initialise_theme_and_output()

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.

Return values
void

◆ is_settings_menu_forced()

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.

Return values
boolTrue if the settings menu is forced to display.

◆ load_activity_record()

moodle_page::load_activity_record ( )
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.

◆ load_category()

moodle_page::load_category (   $categoryid)
protected

Loads the requested category into the pages categories array.

Parameters
int$categoryid
Exceptions
moodle_exception

◆ magic_get_activityname()

moodle_page::magic_get_activityname ( )
protected

Please do not call this method directly, use the ->activityname syntax.

moodle_page::__get().

Return values
stringthe The type of activity we are in, for example 'forum' or 'quiz'. Will be null if this page is not within a module.

◆ magic_get_activityrecord()

moodle_page::magic_get_activityrecord ( )
protected

Please do not call this method directly, use the ->activityrecord syntax.

moodle_page::__get().

Return values
stdClassthe 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.

◆ magic_get_alternateversions()

moodle_page::magic_get_alternateversions ( )
protected

The list of alternate versions of this page.

Return values
arraymime type => object with ->url and ->title.

◆ magic_get_blockmanipulations()

moodle_page::magic_get_blockmanipulations ( )
protected

Returns an array of minipulations or false if there are none to make.

Since
Moodle 2.5.1 2.6
Return values
bool|array

◆ magic_get_blocks()

moodle_page::magic_get_blocks ( )
protected

Please do not call this method directly, use the ->blocks syntax.

moodle_page::__get().

Return values
block_managerthe blocks manager object for this page.

◆ magic_get_bodyclasses()

moodle_page::magic_get_bodyclasses ( )
protected

Please do not call this method directly, use the ->bodyclasses syntax.

moodle_page::__get().

Return values
stringthe class names to put on the body element in the HTML.

◆ magic_get_bodyid()

moodle_page::magic_get_bodyid ( )
protected

Please do not call this method directly, use the ->pagetype syntax.

moodle_page::__get().

Return values
stringThe id to use on the body tag, uses magic_get_pagetype().

◆ magic_get_button()

moodle_page::magic_get_button ( )
protected

Please do not call this method directly, use the ->button syntax.

moodle_page::__get().

Return values
stringthe HTML to go where the Turn editing on button normally goes.

◆ magic_get_cacheable()

moodle_page::magic_get_cacheable ( )
protected

Please do not call this method directly, use the ->cacheable syntax.

moodle_page::__get().

Return values
boolcan this page be cached by the user's browser.

◆ magic_get_categories()

moodle_page::magic_get_categories ( )
protected

Please do not call this method directly, use the ->categories syntax.

moodle_page::__get().

Return values
arrayan 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.

◆ magic_get_category()

moodle_page::magic_get_category ( )
protected

Please do not call this method directly, use the ->category syntax.

moodle_page::__get().

Return values
stdClassthe category that the page course belongs to. If there isn't one (that is, if this is the front page course) returns null.

◆ magic_get_cm()

moodle_page::magic_get_cm ( )
protected

Please do not call this method directly, use the ->cm syntax.

moodle_page::__get().

Return values
cm_infothe 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.

◆ magic_get_context()

moodle_page::magic_get_context ( )
protected

Please do not call this method directly, use the ->context syntax.

moodle_page::__get().

Return values
contextthe main context to which this page belongs.

◆ magic_get_course()

moodle_page::magic_get_course ( )
protected

Please do not call this method directly, use the ->course syntax.

moodle_page::__get().

Return values
stdClassthe 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.

◆ magic_get_devicetypeinuse()

moodle_page::magic_get_devicetypeinuse ( )
protected

Please do not call this method directly, use the ->devicetypeinuse syntax.

moodle_page::__get().

Return values
stringThe device type being used.

◆ magic_get_docspath()

moodle_page::magic_get_docspath ( )
protected

Please do not call this method directly, use the ->docspath syntax.

moodle_page::__get().

Return values
stringthe path to the Moodle docs for this page.

◆ magic_get_flatnav()

moodle_page::magic_get_flatnav ( )
protected

Returns the flat navigation object.

Return values
flat_navigation

◆ magic_get_focuscontrol()

moodle_page::magic_get_focuscontrol ( )
protected

Please do not call this method directly, use the ->focuscontrol syntax.

moodle_page::__get().

Return values
stringthe id of the HTML element to be focused when the page has loaded.

◆ magic_get_headerprinted()

moodle_page::magic_get_headerprinted ( )
protected

Please do not call this method directly, use the ->headerprinted syntax.

moodle_page::__get().

Return values
boolhas the header already been printed?

◆ magic_get_heading()

moodle_page::magic_get_heading ( )
protected

Please do not call this method directly, use the ->heading syntax.

moodle_page::__get().

Return values
stringthe main heading that should be displayed at the top of the <body>.

◆ magic_get_headingmenu()

moodle_page::magic_get_headingmenu ( )
protected

Please do not call this method directly, use the ->heading syntax.

moodle_page::__get().

Return values
stringThe menu (or actions) to display in the heading

◆ magic_get_layout_options()

moodle_page::magic_get_layout_options ( )
protected

Please do not call this method directly, use the ->layout_options syntax.

moodle_page::__get().

Return values
arrayreturns arrays with options for layout file

◆ magic_get_navbar()

moodle_page::magic_get_navbar ( )
protected

Return a navbar object.

Return values
navbar

◆ magic_get_navigation()

moodle_page::magic_get_navigation ( )
protected

Return the navigation object.

Return values
global_navigation

◆ magic_get_opencontainers()

moodle_page::magic_get_opencontainers ( )
protected

Please do not call this method directly use the ->opencontainers syntax.

moodle_page::__get()

Return values
xhtml_container_stacktracks XHTML tags on this page that have been opened but not closed. mainly for internal use by the rendering code.

◆ magic_get_pagelayout()

moodle_page::magic_get_pagelayout ( )
protected

Please do not call this method directly, use the ->pagelayout syntax.

moodle_page::__get().

Return values
stringthe general type of page this is. For example 'standard', 'popup', 'home'. Allows the theme to display things differently, if it wishes to.

◆ magic_get_pagetype()

moodle_page::magic_get_pagetype ( )
protected

Please do not call this method directly, use the ->pagetype syntax.

moodle_page::__get().

Return values
stringe.g. 'my-index' or 'mod-quiz-attempt'.

◆ magic_get_periodicrefreshdelay()

moodle_page::magic_get_periodicrefreshdelay ( )
protected

Please do not call this method directly use the ->periodicrefreshdelay syntax moodle_page::__get().

Return values
intThe periodic refresh delay to use with meta refresh

◆ magic_get_requestip()

moodle_page::magic_get_requestip ( )
protected

Returns request IP address.

Return values
stringIP address or null if unknown

◆ magic_get_requestorigin()

moodle_page::magic_get_requestorigin ( )
protected

Returns the origin of current request.

Note: constants are not required because we need to use these values in logging and reports.

Return values
string'web', 'ws', 'cli', 'restore', etc.

◆ magic_get_requires()

moodle_page::magic_get_requires ( )
protected

Please do not call this method directly, use the ->requires syntax.

moodle_page::__get().

Return values
page_requirements_managertracks the JavaScript, CSS files, etc. required by this page.

◆ magic_get_settingsnav()

moodle_page::magic_get_settingsnav ( )
protected

Returns the settings navigation object.

Return values
settings_navigation

◆ magic_get_state()

moodle_page::magic_get_state ( )
protected

Please do not call this method directly, use the ->state syntax.

moodle_page::__get().

Return values
integerone 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.

◆ magic_get_subpage()

moodle_page::magic_get_subpage ( )
protected

Please do not call this method directly, use the ->subpage syntax.

moodle_page::__get().

Return values
stringThe subpage identifier, if any.

◆ magic_get_theme()

moodle_page::magic_get_theme ( )
protected

Please do not call this method directly, use the ->theme syntax.

moodle_page::__get().

Return values
theme_configthe initialised theme for this page.

◆ magic_get_title()

moodle_page::magic_get_title ( )
protected

Please do not call this method directly, use the ->title syntax.

moodle_page::__get().

Return values
stringthe title that should go in the <head> section of the HTML of this page.

◆ magic_get_url()

moodle_page::magic_get_url ( )
protected

Please do not call this method directly, use the ->url syntax.

moodle_page::__get().

Return values
moodle_urlthe clean URL required to load the current page. (You should normally use this in preference to $ME or $FULLME.)

◆ reload_theme()

moodle_page::reload_theme ( )

Reload theme settings.

This is used when we need to reset settings because they are now double cached in theme.

◆ reset_theme_and_output()

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.

Return values
stringthe name of the theme that should be used on this page.

◆ resolve_theme()

moodle_page::resolve_theme ( )
protected

Work out the theme this page should use.

This depends on numerous $CFG settings, and the properties of this page.

Return values
stringthe name of the theme that should be used on this page.

◆ set_activity_record()

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.

Parameters
stdClass$moduleA row from the main database table for the module that this page belongs to.
Exceptions
coding_exception

◆ set_block_actions_done()

moodle_page::set_block_actions_done (   $setting = true)

Gets set when the block actions for the page have been processed.

Parameters
bool$setting

◆ set_blocks_editing_capability()

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'.

Parameters
string$capabilitya capability.

◆ set_button()

moodle_page::set_button (   $html)

Specify a fragment of HTML that goes where the 'Turn editing on' button normally goes.

Parameters
string$htmlthe HTML to display there.

◆ set_cacheable()

moodle_page::set_cacheable (   $cacheable)

Sets whether the browser should cache this page or not.

Parameters
bool$cacheablecan this page be cached by the user's browser.

◆ set_category_by_id()

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.

Parameters
int$categoryidThe id of the category to set.
Exceptions
coding_exception

◆ set_cm()

moodle_page::set_cm (   $cm,
  $course = null,
  $module = null 
)

The course module that this page belongs to (if it does belong to one).

Parameters
stdClass | cm_info$cma record from course_modules table or cm_info from get_fast_modinfo().
stdClass$course
stdClass$module
Return values
void
Exceptions
coding_exception

◆ set_context()

moodle_page::set_context (   $context)

Set the main context to which this page belongs.

Parameters
context$contexta context object. You normally get this with context_xxxx::instance().

◆ set_course()

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.

Parameters
stdClass$coursethe course to set as the global course.
Exceptions
coding_exception

◆ set_docs_path()

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.

Parameters
string$paththe path to use at the end of the moodle docs URL.

◆ set_focuscontrol()

moodle_page::set_focuscontrol (   $controlid)

Specify a form control should be focused when the page has loaded.

Parameters
string$controlidthe id of the HTML element to be focused.

◆ set_heading()

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.

Parameters
string$headingthe main heading that should be displayed at the top of the <body>.

◆ set_headingmenu()

moodle_page::set_headingmenu (   $menu)

Sets some HTML to use next to the heading moodle_page::set_heading().

Parameters
string$menuThe menu/content to show in the heading

◆ set_include_region_main_settings_in_header_actions()

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.

Parameters
bool$valueIf the settings should be in the header.

◆ set_other_editing_capability()

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.

Parameters
string | array$capabilityeither a capability, or an array of capabilities.

◆ set_pagelayout()

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

Parameters
string$pagelayoutthe page layout this is. For example 'popup', 'home'.

◆ set_pagetype()

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.

Parameters
string$pagetypee.g. 'my-index' or 'mod-quiz-attempt'.

◆ set_periodic_refresh_delay()

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.

Parameters
int$delaySets the delay before refreshing the page, if set to null refresh is cancelled.
Exceptions
coding_exception

◆ set_popup_notification_allowed()

moodle_page::set_popup_notification_allowed (   $allowed)

Allow or disallow popup notifications on this page.

Popups are allowed by default.

Parameters
bool$allowedtrue if notifications are allowed. False if not allowed. They are allowed by default.

◆ set_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.

Parameters
int$stateThe new state.
Exceptions
coding_exception

◆ set_subpage()

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

Parameters
string$subpagean arbitrary identifier that, along with context->id and pagetype, uniquely identifies this page.

◆ set_title()

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.

Parameters
string$titlethe title that should go in the <head> section of the HTML of this page.

◆ set_url()

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));

Parameters
moodle_url | string$urlURL relative to $CFG->wwwroot or moodle_url instance
array$paramsparameters to add to the URL
Exceptions
coding_exception

◆ start_collecting_javascript_requirements()

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.

◆ starting_output()

moodle_page::starting_output ( )
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.

◆ url_to_class_name()

moodle_page::url_to_class_name (   $url)
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.

Parameters
string$url
Return values
string

◆ user_allowed_editing()

moodle_page::user_allowed_editing ( )

Does the user have permission to see this page in editing mode.

Return values
bool

◆ user_can_edit_blocks()

moodle_page::user_can_edit_blocks ( )

Does the user have permission to edit blocks on this page.

Return values
bool

◆ user_is_editing()

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.

Return values
bool

◆ verify_https_required()

moodle_page::verify_https_required ( )
Deprecated:
since Moodle 3.4

Member Data Documentation

◆ $_alternateversions

array moodle_page::$_alternateversions = array()
protected

An array of links to alternative versions of this page.

Primarily used for RSS versions of the current page.

◆ $_block_actions_done

bool moodle_page::$_block_actions_done = false
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.

◆ $_blocks

block_manager moodle_page::$_blocks = null
protected

The blocks manager for this page.

It is responsible for the blocks and there content on this page.

◆ $_button

string moodle_page::$_button = ''
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.

◆ $_cacheable

bool moodle_page::$_cacheable = true
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.

◆ $_categories

array moodle_page::$_categories = null
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.

◆ $_course

stdClass moodle_page::$_course = null
protected

The course currently associated with this page.

If not has been provided the front page course is used.

◆ $_devicetypeinuse

string moodle_page::$_devicetypeinuse = null
protected

Is set to the name of the device type in use.

This will we worked out when it is first used.

◆ $_docspath

string moodle_page::$_docspath = null
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.

◆ $_forcesettingsmenu

bool moodle_page::$_forcesettingsmenu = false
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.

◆ $_heading

string moodle_page::$_heading = ''
protected

The string to use as the heading of the page.

Shown near the top of the page within most themes.

◆ $_layout_options

array moodle_page::$_layout_options = null
protected

List of theme layout options, these are ignored by core.

To be used in individual theme layout files only.

◆ $_module

stdClass moodle_page::$_module = null
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.

◆ $_pagelayout

string moodle_page::$_pagelayout = 'base'
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.

◆ $_pagetype

string moodle_page::$_pagetype = null
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

◆ $_popup_notification_allowed

bool moodle_page::$_popup_notification_allowed = true
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.

◆ $_requires

page_requirements_manager moodle_page::$_requires = null
protected

Page requirements manager.

It is responsible for all JavaScript and CSS resources required by this page.

◆ $_state

int moodle_page::$_state = self::STATE_BEFORE_HEADER
protected

The current state of the page.

The state a page is within determines what actions are possible for it.

◆ $_theme

theme_config moodle_page::$_theme = null
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.

◆ $_title

string moodle_page::$_title = ''
protected

The title for the page.

Used within the title tag in the HTML head.

◆ $_url

moodle_url moodle_page::$_url = null
protected

The URL for this page.

This is mandatory and must be set before output is started.

◆ $_wherethemewasinitialised

array moodle_page::$_wherethemewasinitialised = null
protected

stack trace.

Then the theme is initialised, we save the stack trace, for use in error messages.


The documentation for this class was generated from the following file: