Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

Classes for rendering HTML output for Moodle. Please see {@link http://docs.moodle.org/en/Developement:How_Moodle_outputs_HTML} for an overview.

Copyright: 2009 Tim Hunt
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 5661 lines (224 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 6 classes

renderer_base:: (13 methods):
  get_mustache()
  __construct()
  render_from_template()
  render()
  add_action_handler()
  has_started()
  prepare_classes()
  pix_url()
  image_url()
  get_logo_url()
  get_compact_logo_url()
  should_display_navbar_logo()
  should_display_main_logo()

plugin_renderer_base:: (3 methods):
  __construct()
  render()
  __call()

core_renderer:: (156 methods):
  __construct()
  doctype()
  htmlattributes()
  standard_head_html()
  standard_top_of_body_html()
  maintenance_warning()
  standard_footer_html()
  debug_footer_html()
  main_content()
  activity_information()
  activity_navigation()
  standard_end_of_body_html()
  standard_after_main_region_html()
  login_info()
  is_login_page()
  home_link()
  redirect_message()
  header()
  render_page_layout()
  footer()
  container_end_all()
  course_content_header()
  course_content_footer()
  course_header()
  course_footer()
  get_generated_image_for_id()
  get_generated_color_for_id()
  lang_menu()
  block_controls()
  print_textarea()
  render_action_menu()
  render_check_result()
  check_result()
  render_action_menu_link()
  render_action_menu_filler()
  render_action_menu_link_primary()
  render_action_menu_link_secondary()
  block()
  list_block_contents()
  blocks_for_region()
  block_move_target()
  action_link()
  render_action_link()
  action_icon()
  confirm()
  single_button()
  render_single_button()
  single_select()
  download_dataformat_selector()
  render_single_select()
  url_select()
  render_url_select()
  doc_link()
  image_icon()
  render_image_icon()
  pix_icon()
  render_pix_icon()
  render_pix_emoticon()
  render_rating()
  heading_with_help()
  old_help_icon()
  help_icon()
  render_help_icon()
  help_icon_scale()
  spacer()
  user_picture()
  render_user_picture()
  htmllize_file_tree()
  file_picker()
  render_file_picker()
  update_module_button()
  edit_button()
  edit_switch()
  close_window_button()
  error_text()
  fatal_error()
  notification()
  notify_problem()
  notify_success()
  notify_message()
  notify_redirect()
  render_notification()
  continue_button()
  paging_bar()
  render_paging_bar()
  initials_bar()
  render_initials_bar()
  skip_link_target()
  heading()
  box()
  box_start()
  box_end()
  container()
  container_start()
  container_end()
  tree_block_contents()
  search_box()
  navbar_plugin_output()
  user_menu()
  secure_layout_login_info()
  secure_layout_language_menu()
  navbar()
  render_breadcrumb_navigation_node()
  render_navigation_node()
  rarrow()
  larrow()
  uarrow()
  darrow()
  custom_menu()
  custom_menu_flat()
  render_custom_menu()
  render_custom_menu_item()
  theme_switch_links()
  tabtree()
  render_tabtree()
  render_tabobject()
  blocks()
  custom_block_region()
  body_css_classes()
  body_id()
  body_attributes()
  page_heading()
  page_heading_button()
  page_doc_link()
  supportemail()
  services_support_link()
  has_popover_links()
  page_heading_menu()
  page_title()
  favicon()
  render_preferences_groups()
  render_preferences_group()
  context_header()
  render_skip_links()
  render_context_header()
  full_header()
  context_header_settings_menu()
  build_action_menu_from_navigation()
  region_main_settings_menu()
  tag_list()
  render_inplace_editable()
  render_chart_bar()
  render_chart_line()
  render_chart_pie()
  render_chart()
  render_login()
  mform_element()
  render_login_signup_form()
  render_verify_age_location_page()
  render_digital_minor_page()
  render_progress_bar()
  render_progress_bar_update()
  render_checkbox_toggleall()
  render_participants_tertiary_nav()
  moodle_release()
  addblockbutton()

core_renderer_cli:: (10 methods):
  header()
  render_check_result()
  check_result()
  render_progress_bar()
  render_progress_bar_update()
  heading()
  fatal_error()
  notification()
  footer()
  render_notification()

core_renderer_ajax:: (6 methods):
  fatal_error()
  notification()
  redirect_message()
  header()
  footer()
  heading()

core_renderer_maintenance:: (17 methods):
  __construct()
  block()
  blocks()
  blocks_for_region()
  course_content_header()
  course_content_footer()
  course_header()
  course_footer()
  custom_menu()
  file_picker()
  htmllize_file_tree()
  confirm()
  init_block_hider_js()
  lang_menu()
  login_info()
  secure_login_info()
  user_picture()


Class: renderer_base  - X-Ref

Simple base class for Moodle renderers.

Tracks the xhtml_container_stack to use, which is passed in in the constructor.

Also has methods to facilitate generating HTML output.

get_mustache()   X-Ref
Return an instance of the mustache class.

return: Mustache_Engine

__construct(moodle_page $page, $target)   X-Ref
Constructor

The constructor takes two arguments. The first is the page that the renderer
has been created to assist with, and the second is the target.
The target is an additional identifier that can be used to load different
renderers for different options.

param: moodle_page $page the page we are doing output for.
param: string $target one of rendering target constants

render_from_template($templatename, $context)   X-Ref
Renders a template by name with the given context.

The provided data needs to be array/stdClass made up of only simple types.
Simple types are array,stdClass,bool,int,float,string

param: array|stdClass $context Context containing data for the template.
return: string|boolean

render(renderable $widget)   X-Ref
Returns rendered widget.

The provided widget needs to be an object that extends the renderable
interface.
If will then be rendered by a method based upon the classname for the widget.
For instance a widget of class `crazywidget` will be rendered by a protected
render_crazywidget method of this renderer.
If no render_crazywidget method exists and crazywidget implements templatable,
look for the 'crazywidget' template in the same component and render that.

param: renderable $widget instance with renderable interface
return: string

add_action_handler(component_action $action, $id = null)   X-Ref
Adds a JS action for the element with the provided id.

This method adds a JS event for the provided component action to the page
and then returns the id that the event has been attached to.
If no id has been provided then a new ID is generated by {@link html_writer::random_id()}

param: component_action $action
param: string $id
return: string id of element, either original submitted or random new if not supplied

has_started()   X-Ref
Returns true is output has already started, and false if not.

return: boolean true if the header has been printed.

prepare_classes($classes)   X-Ref
Given an array or space-separated list of classes, prepares and returns the HTML class attribute value

param: mixed $classes Space-separated string or array of classes
return: string HTML class attribute value

pix_url($imagename, $component = 'moodle')   X-Ref
Return the direct URL for an image from the pix folder.

Use this function sparingly and never for icons. For icons use pix_icon or the pix helper in a mustache template.

param: string $imagename the name of the icon.
param: string $component specification of one plugin like in get_string()
return: moodle_url

image_url($imagename, $component = 'moodle')   X-Ref
Return the moodle_url for an image.

The exact image location and extension is determined
automatically by searching for gif|png|jpg|jpeg, please
note there can not be diferent images with the different
extension. The imagename is for historical reasons
a relative path name, it may be changed later for core
images. It is recommended to not use subdirectories
in plugin and theme pix directories.

There are three types of images:
1/ theme images  - stored in theme/mytheme/pix/,
use component 'theme'
2/ core images   - stored in /pix/,
overridden via theme/mytheme/pix_core/
3/ plugin images - stored in mod/mymodule/pix,
overridden via theme/mytheme/pix_plugins/mod/mymodule/,
example: image_url('comment', 'mod_glossary')

param: string $imagename the pathname of the image
param: string $component full plugin name (aka component) or 'theme'
return: moodle_url

get_logo_url($maxwidth = null, $maxheight = 200)   X-Ref
Return the site's logo URL, if any.

param: int $maxwidth The maximum width, or null when the maximum width does not matter.
param: int $maxheight The maximum height, or null when the maximum height does not matter.
return: moodle_url|false

get_compact_logo_url($maxwidth = 300, $maxheight = 300)   X-Ref
Return the site's compact logo URL, if any.

param: int $maxwidth The maximum width, or null when the maximum width does not matter.
param: int $maxheight The maximum height, or null when the maximum height does not matter.
return: moodle_url|false

should_display_navbar_logo()   X-Ref
Whether we should display the logo in the navbar.

We will when there are no main logos, and we have compact logo.

return: bool

should_display_main_logo($headinglevel = 1)   X-Ref
Whether we should display the main logo.

param: int $headinglevel The heading level we want to check against.
return: bool

Class: plugin_renderer_base  - X-Ref

Basis for all plugin renderers.

__construct(moodle_page $page, $target)   X-Ref
Constructor method, calls the parent constructor

param: moodle_page $page
param: string $target one of rendering target constants

render(renderable $widget)   X-Ref
Renders the provided widget and returns the HTML to display it.

param: renderable $widget instance with renderable interface
return: string

__call($method, $arguments)   X-Ref
Magic method used to pass calls otherwise meant for the standard renderer
to it to ensure we don't go causing unnecessary grief.

param: string $method
param: array $arguments
return: mixed

Class: core_renderer  - X-Ref

The standard implementation of the core_renderer interface.

__construct(moodle_page $page, $target)   X-Ref
Constructor

param: moodle_page $page the page we are doing output for.
param: string $target one of rendering target constants

doctype()   X-Ref
Get the DOCTYPE declaration that should be used with this page. Designed to
be called in theme layout.php files.

return: string the DOCTYPE declaration that should be used.

htmlattributes()   X-Ref
The attributes that should be added to the <html> tag. Designed to
be called in theme layout.php files.

return: string HTML fragment.

standard_head_html()   X-Ref
The standard tags (meta tags, links to stylesheets and JavaScript, etc.)
that should be included in the <head> tag. Designed to be called in theme
layout.php files.

return: string HTML fragment.

standard_top_of_body_html()   X-Ref
The standard tags (typically skip links) that should be output just inside
the start of the <body> tag. Designed to be called in theme layout.php files.

return: string HTML fragment.

maintenance_warning()   X-Ref
Scheduled maintenance warning message.

Note: This is a nasty hack to display maintenance notice, this should be moved
to some general notification area once we have it.

return: string

standard_footer_html()   X-Ref
content that should be output in the footer area
of the page. Designed to be called in theme layout.php files.

return: string HTML fragment.

debug_footer_html()   X-Ref
Performance information and validation links for debugging.

return: string HTML fragment.

main_content()   X-Ref
Returns standard main content placeholder.
Designed to be called in theme layout.php files.

return: string HTML fragment.

activity_information(cm_info $cminfo, cm_completion_details $completiondetails, array $activitydates)   X-Ref
Returns information about an activity.

param: cm_info $cminfo The course module information.
param: cm_completion_details $completiondetails The completion details for this activity module.
param: array $activitydates The dates for this activity module.
return: string the activity information HTML.

activity_navigation()   X-Ref
Returns standard navigation between activities in a course.

return: string the navigation HTML.

standard_end_of_body_html()   X-Ref
The standard tags (typically script tags that are not needed earlier) that
should be output after everything else. Designed to be called in theme layout.php files.

return: string HTML fragment.

standard_after_main_region_html()   X-Ref
The standard HTML that should be output just before the <footer> tag.
Designed to be called in theme layout.php files.

return: string HTML fragment.

login_info($withlinks = null)   X-Ref
Return the standard string that says whether you are logged in (and switched
roles/logged in as another user).

param: bool $withlinks if false, then don't include any links in the HTML produced.
return: string HTML fragment.

is_login_page()   X-Ref
Check whether the current page is a login page.

return: bool

home_link()   X-Ref
Return the 'back' link that normally appears in the footer.

return: string HTML fragment.

redirect_message($encodedurl, $message, $delay, $debugdisableredirect,$messagetype = \core\output\notification::NOTIFY_INFO)   X-Ref
Redirects the user by any means possible given the current state

This function should not be called directly, it should always be called using
the redirect function in lib/weblib.php

The redirect function should really only be called before page output has started
however it will allow itself to be called during the state STATE_IN_BODY

param: string $encodedurl The URL to send to encoded if required
param: string $message The message to display to the user if any
param: int $delay The delay before redirecting a user, if $message has been
param: boolean $debugdisableredirect this redirect has been disabled for
param: string $messagetype The type of notification to show the message in.
return: string The HTML to display to the user before dying, may contain

header()   X-Ref
Start output by sending the HTTP headers, and printing the HTML <head>
and the start of the <body>.

To control what is printed, you should set properties on $PAGE.

return: string HTML that you must output this, preferably immediately.

render_page_layout($layoutfile)   X-Ref
Renders and outputs the page layout file.

This is done by preparing the normal globals available to a script, and
then including the layout file provided by the current theme for the
requested layout.

param: string $layoutfile The name of the layout file
return: string HTML code

footer()   X-Ref
Outputs the page's footer

return: string HTML fragment

container_end_all($shouldbenone = false)   X-Ref
Close all but the last open container. This is useful in places like error
handling, where you want to close all the open containers (apart from <body>)
before outputting the error message.

param: bool $shouldbenone assert that the stack should be empty now - causes a
return: string the HTML required to close any open containers inside <body>.

course_content_header($onlyifnotcalledbefore = false)   X-Ref
Returns course-specific information to be output immediately above content on any course page
(for the current course)

param: bool $onlyifnotcalledbefore output content only if it has not been output before
return: string

course_content_footer($onlyifnotcalledbefore = false)   X-Ref
Returns course-specific information to be output immediately below content on any course page
(for the current course)

param: bool $onlyifnotcalledbefore output content only if it has not been output before
return: string

course_header()   X-Ref
Returns course-specific information to be output on any course page in the header area
(for the current course)

return: string

course_footer()   X-Ref
Returns course-specific information to be output on any course page in the footer area
(for the current course)

return: string

get_generated_image_for_id($id)   X-Ref
Get the course pattern datauri to show on a course card.

The datauri is an encoded svg that can be passed as a url.
param: int $id Id to use when generating the pattern
return: string datauri

get_generated_color_for_id($id)   X-Ref
Get the course color to show on a course card.

param: int $id Id to use when generating the color.
return: string hex color code.

lang_menu()   X-Ref
Returns lang menu or '', this method also checks forcing of languages in courses.

This function calls {@link core_renderer::render_single_select()} to actually display the language menu.

return: string The lang menu HTML or empty string

block_controls($actions, $blockid = null)   X-Ref
Output the row of editing icons for a block, as defined by the controls array.

param: array $controls an array like {@link block_contents::$controls}.
param: string $blockid The ID given to the block.
return: string HTML fragment.

print_textarea($name, $id, $value, $rows, $cols)   X-Ref
Returns the HTML for a basic textarea field.

param: string $name Name to use for the textarea element
param: string $id The id to use fort he textarea element
param: string $value Initial content to display in the textarea
param: int $rows Number of rows to display
param: int $cols Number of columns to display
return: string the HTML to display

render_action_menu(action_menu $menu)   X-Ref
Renders an action menu component.

param: action_menu $menu
return: string HTML

render_check_result(core\check\result $result)   X-Ref
Renders a Check API result

param: result $result
return: string HTML fragment

check_result(core\check\result $result)   X-Ref
Renders a Check API result

param: result $result
return: string HTML fragment

render_action_menu_link(action_menu_link $action)   X-Ref
Renders an action_menu_link item.

param: action_menu_link $action
return: string HTML fragment

render_action_menu_filler(action_menu_filler $action)   X-Ref
Renders a primary action_menu_filler item.

param: action_menu_link_filler $action
return: string HTML fragment

render_action_menu_link_primary(action_menu_link_primary $action)   X-Ref
Renders a primary action_menu_link item.

param: action_menu_link_primary $action
return: string HTML fragment

render_action_menu_link_secondary(action_menu_link_secondary $action)   X-Ref
Renders a secondary action_menu_link item.

param: action_menu_link_secondary $action
return: string HTML fragment

block(block_contents $bc, $region)   X-Ref
Prints a nice side block with an optional header.

param: block_contents $bc HTML for the content
param: string $region the region the block is appearing in.
return: string the HTML to be output.

list_block_contents($icons, $items)   X-Ref
Render the contents of a block_list.

param: array $icons the icon for each item.
param: array $items the content of each item.
return: string HTML

blocks_for_region($region, $fakeblocksonly = false)   X-Ref
Output all the blocks in a particular region.

param: string $region the name of a region on this page.
param: boolean $fakeblocksonly Output fake block only.
return: string the HTML to be output.

block_move_target($target, $zones, $previous, $region)   X-Ref
Output a place where the block that is currently being moved can be dropped.

param: block_move_target $target with the necessary details.
param: array $zones array of areas where the block can be moved to
param: string $previous the block located before the area currently being rendered.
param: string $region the name of the region
return: string the HTML to be output.

action_link($url, $text, component_action $action = null, array $attributes = null, $icon = null)   X-Ref
Renders a special html link with attached action

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_action_link()} instead.

param: string|moodle_url $url
param: string $text HTML fragment
param: component_action $action
param: array $attributes associative array of html link attributes + disabled
param: pix_icon optional pix icon to render with the link
return: string HTML fragment

render_action_link(action_link $link)   X-Ref
Renders an action_link object.

The provided link is renderer and the HTML returned. At the same time the
associated actions are setup in JS by {@link core_renderer::add_action_handler()}

param: action_link $link
return: string HTML fragment

action_icon($url, pix_icon $pixicon, component_action $action = null, array $attributes = null, $linktext=false)   X-Ref
Renders an action_icon.

This function uses the {@link core_renderer::action_link()} method for the
most part. What it does different is prepare the icon as HTML and use it
as the link text.

Theme developers: If you want to change how action links and/or icons are rendered,
consider overriding function {@link core_renderer::render_action_link()} and
{@link core_renderer::render_pix_icon()}.

param: string|moodle_url $url A string URL or moodel_url
param: pix_icon $pixicon
param: component_action $action
param: array $attributes associative array of html link attributes + disabled
param: bool $linktext show title next to image in link
return: string HTML fragment

confirm($message, $continue, $cancel, array $displayoptions = [])   X-Ref
Print a message along with button choices for Continue/Cancel

If a string or moodle_url is given instead of a single_button, method defaults to post.

param: string $message The question to ask the user
param: single_button|moodle_url|string $continue The single_button component representing the Continue answer. Can also be a moodle_url or string URL
param: single_button|moodle_url|string $cancel The single_button component representing the Cancel answer. Can also be a moodle_url or string URL
param: array $displayoptions optional extra display options
return: string HTML fragment

single_button($url, $label, $method='post', array $options=null)   X-Ref
Returns a form with a single button.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_single_button()} instead.

param: string|moodle_url $url
param: string $label button text
param: string $method get or post submit method
param: array $options associative array {disabled, title, etc.}
return: string HTML fragment

render_single_button(single_button $button)   X-Ref
Renders a single button widget.

This will return HTML to display a form containing a single button.

param: single_button $button
return: string HTML fragment

single_select($url, $name, array $options, $selected = '',$nothing = array('' => 'choosedots')   X-Ref
Returns a form with a single select widget.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_single_select()} instead.

param: moodle_url $url form action target, includes hidden fields
param: string $name name of selection field - the changing parameter in url
param: array $options list of options
param: string $selected selected element
param: array $nothing
param: string $formid
param: array $attributes other attributes for the single select
return: string HTML fragment

download_dataformat_selector($label, $base, $name = 'dataformat', $params = array()   X-Ref
Returns a dataformat selection and download form

param: string $label A text label
param: moodle_url|string $base The download page url
param: string $name The query param which will hold the type of the download
param: array $params Extra params sent to the download page
return: string HTML fragment

render_single_select(single_select $select)   X-Ref
Internal implementation of single_select rendering

param: single_select $select
return: string HTML fragment

url_select(array $urls, $selected, $nothing = array('' => 'choosedots')   X-Ref
Returns a form with a url select widget.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_url_select()} instead.

param: array $urls list of urls - array('/course/view.php?id=1'=>'Frontpage', ....)
param: string $selected selected element
param: array $nothing
param: string $formid
return: string HTML fragment

render_url_select(url_select $select)   X-Ref
Internal implementation of url_select rendering

param: url_select $select
return: string HTML fragment

doc_link($path, $text = '', $forcepopup = false, array $attributes = [])   X-Ref
Returns a string containing a link to the user documentation.
Also contains an icon by default. Shown to teachers and admin only.

param: string $path The page link after doc root and language, no leading slash.
param: string $text The text to be displayed for the link
param: boolean $forcepopup Whether to force a popup regardless of the value of $CFG->doctonewwindow
param: array $attributes htm attributes
return: string

image_icon($pix, $alt, $component='moodle', array $attributes = null)   X-Ref
Return HTML for an image_icon.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_image_icon()} instead.

param: string $pix short pix name
param: string $alt mandatory alt attribute
param: string $component standard compoennt name like 'moodle', 'mod_forum', etc.
param: array $attributes htm attributes
return: string HTML fragment

render_image_icon(image_icon $icon)   X-Ref
Renders a pix_icon widget and returns the HTML to display it.

param: image_icon $icon
return: string HTML fragment

pix_icon($pix, $alt, $component='moodle', array $attributes = null)   X-Ref
Return HTML for a pix_icon.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_pix_icon()} instead.

param: string $pix short pix name
param: string $alt mandatory alt attribute
param: string $component standard compoennt name like 'moodle', 'mod_forum', etc.
param: array $attributes htm lattributes
return: string HTML fragment

render_pix_icon(pix_icon $icon)   X-Ref
Renders a pix_icon widget and returns the HTML to display it.

param: pix_icon $icon
return: string HTML fragment

render_pix_emoticon(pix_emoticon $emoticon)   X-Ref
Return HTML to display an emoticon icon.

param: pix_emoticon $emoticon
return: string HTML fragment

render_rating(rating $rating)   X-Ref
Produces the html that represents this rating in the UI

param: rating $rating the page object on which this rating will appear
return: string

heading_with_help($text, $helpidentifier, $component = 'moodle', $icon = '', $iconalt = '', $level = 2, $classnames = null)   X-Ref
Centered heading with attached help button (same title text)
and optional icon attached.

param: string $text A heading text
param: string $helpidentifier The keyword that defines a help page
param: string $component component name
param: string|moodle_url $icon
param: string $iconalt icon alt text
param: int $level The level of importance of the heading. Defaulting to 2
param: string $classnames A space-separated list of CSS classes. Defaulting to null
return: string HTML fragment

old_help_icon($helpidentifier, $title, $component = 'moodle', $linktext = '')   X-Ref
Returns HTML to display a help icon.


help_icon($identifier, $component = 'moodle', $linktext = '')   X-Ref
Returns HTML to display a help icon.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_help_icon()} instead.

param: string $identifier The keyword that defines a help page
param: string $component component name
param: string|bool $linktext true means use $title as link text, string means link text value
return: string HTML fragment

render_help_icon(help_icon $helpicon)   X-Ref
Implementation of user image rendering.

param: help_icon $helpicon A help icon instance
return: string HTML fragment

help_icon_scale($courseid, stdClass $scale)   X-Ref
Returns HTML to display a scale help icon.

param: int $courseid
param: stdClass $scale instance
return: string HTML fragment

spacer(array $attributes = null, $br = false)   X-Ref
Creates and returns a spacer image with optional line break.

param: array $attributes Any HTML attributes to add to the spaced.
param: bool $br Include a BR after the spacer.... DON'T USE THIS. Don't be
return: string HTML fragment

user_picture(stdClass $user, array $options = null)   X-Ref
Returns HTML to display the specified user's avatar.

User avatar may be obtained in two ways:
<pre>
// Option 1: (shortcut for simple cases, preferred way)
// $user has come from the DB and has fields id, picture, imagealt, firstname and lastname
$OUTPUT->user_picture($user, array('popup'=>true));

// Option 2:
$userpic = new user_picture($user);
// Set properties of $userpic
$userpic->popup = true;
$OUTPUT->render($userpic);
</pre>

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_user_picture()} instead.

param: stdClass $user Object with at least fields id, picture, imagealt, firstname, lastname
param: array $options associative array with user picture options, used only if not a user_picture object,
return: string HTML fragment

render_user_picture(user_picture $userpicture)   X-Ref
Internal implementation of user image rendering.

param: user_picture $userpicture
return: string

htmllize_file_tree($dir)   X-Ref
Internal implementation of file tree viewer items rendering.

param: array $dir
return: string

file_picker($options)   X-Ref
Returns HTML to display the file picker

<pre>
$OUTPUT->file_picker($options);
</pre>

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_file_picker()} instead.

param: array $options associative array with file manager options
return: string HTML fragment

render_file_picker(file_picker $fp)   X-Ref
Internal implementation of file picker rendering.

param: file_picker $fp
return: string

update_module_button()   X-Ref


edit_button(moodle_url $url, string $method = 'post')   X-Ref
Returns HTML to display a "Turn editing on/off" button in a form.

param: moodle_url $url The URL + params to send through when clicking the button
param: string $method
return: string HTML the button

edit_switch()   X-Ref
Create a navbar switch for toggling editing mode.

return: string Html containing the edit switch

close_window_button($text='')   X-Ref
Returns HTML to display a simple button to close a window

param: string $text The lang string for the button's label (already output from get_string())
return: string html fragment

error_text($message)   X-Ref
Output an error message. By default wraps the error message in <span class="error">.
If the error message is blank, nothing is output.

param: string $message the error message.
return: string the HTML to output.

fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = "")   X-Ref
Do not call this function directly.

To terminate the current script with a fatal error, throw an exception.
Doing this will then call this function to display the error, before terminating the execution.

param: string $message The message to output
param: string $moreinfourl URL where more info can be found about the error
param: string $link Link for the Continue button
param: array $backtrace The execution backtrace
param: string $debuginfo Debugging information
return: string the HTML to output.

notification($message, $type = null, $closebutton = true)   X-Ref
Output a notification (that is, a status message about something that has just happened).

Note: \core\notification::add() may be more suitable for your usage.

param: string $message The message to print out.
param: ?string $type   The type of notification. See constants on \core\output\notification.
param: bool $closebutton Whether to show a close icon to remove the notification (default true).
return: string the HTML to output.

notify_problem()   X-Ref


notify_success()   X-Ref


notify_message()   X-Ref


notify_redirect()   X-Ref


render_notification(\core\output\notification $notification)   X-Ref
Render a notification (that is, a status message about something that has
just happened).

param: \core\output\notification $notification the notification to print out
return: string the HTML to output.

continue_button($url)   X-Ref
Returns HTML to display a continue button that goes to a particular URL.

param: string|moodle_url $url The url the button goes to.
return: string the HTML to output.

paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar = 'page')   X-Ref
Returns HTML to display a single paging bar to provide access to other pages  (usually in a search)

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_paging_bar()} instead.

param: int $totalcount The total number of entries available to be paged through
param: int $page The page you are currently viewing
param: int $perpage The number of entries that should be shown per page
param: string|moodle_url $baseurl url of the current page, the $pagevar parameter is added
param: string $pagevar name of page parameter that holds the page number
return: string the HTML to output.

render_paging_bar(paging_bar $pagingbar)   X-Ref
Returns HTML to display the paging bar.

param: paging_bar $pagingbar
return: string the HTML to output.

initials_bar($current, $class, $title, $urlvar, $url, $alpha = null)   X-Ref
Returns HTML to display initials bar to provide access to other pages  (usually in a search)

param: string $current the currently selected letter.
param: string $class class name to add to this initial bar.
param: string $title the name to put in front of this initial bar.
param: string $urlvar URL parameter name for this initial.
param: string $url URL object.
param: array $alpha of letters in the alphabet.
return: string the HTML to output.

render_initials_bar(initials_bar $initialsbar)   X-Ref
Internal implementation of initials bar rendering.

param: initials_bar $initialsbar
return: string

skip_link_target($id = null)   X-Ref
Output the place a skip link goes to.

param: string $id The target name from the corresponding $PAGE->requires->skip_link_to($target) call.
return: string the HTML to output.

heading($text, $level = 2, $classes = null, $id = null)   X-Ref
Outputs a heading

param: string $text The text of the heading
param: int $level The level of importance of the heading. Defaulting to 2
param: string $classes A space-separated list of CSS classes. Defaulting to null
param: string $id An optional ID
return: string the HTML to output.

box($contents, $classes = 'generalbox', $id = null, $attributes = array()   X-Ref
Outputs a box.

param: string $contents The contents of the box
param: string $classes A space-separated list of CSS classes
param: string $id An optional ID
param: array $attributes An array of other attributes to give the box.
return: string the HTML to output.

box_start($classes = 'generalbox', $id = null, $attributes = array()   X-Ref
Outputs the opening section of a box.

param: string $classes A space-separated list of CSS classes
param: string $id An optional ID
param: array $attributes An array of other attributes to give the box.
return: string the HTML to output.

box_end()   X-Ref
Outputs the closing section of a box.

return: string the HTML to output.

container($contents, $classes = null, $id = null)   X-Ref
Outputs a container.

param: string $contents The contents of the box
param: string $classes A space-separated list of CSS classes
param: string $id An optional ID
return: string the HTML to output.

container_start($classes = null, $id = null)   X-Ref
Outputs the opening section of a container.

param: string $classes A space-separated list of CSS classes
param: string $id An optional ID
return: string the HTML to output.

container_end()   X-Ref
Outputs the closing section of a container.

return: string the HTML to output.

tree_block_contents($items, $attrs = array()   X-Ref
Make nested HTML lists out of the items

The resulting list will look something like this:

<pre>
<<ul>>
<<li>><div class='tree_item parent'>(item contents)</div>
<<ul>
<<li>><div class='tree_item'>(item contents)</div><</li>>
<</ul>>
<</li>>
<</ul>>
</pre>

param: array $items
param: array $attrs html attributes passed to the top ofs the list
return: string HTML

search_box($id = false)   X-Ref
Returns a search box.

param: string $id     The search box wrapper div id, defaults to an autogenerated one.
return: string         HTML with the search form hidden by default.

navbar_plugin_output()   X-Ref
Allow plugins to provide some content to be rendered in the navbar.
The plugin must define a PLUGIN_render_navbar_output function that returns
the HTML they wish to add to the navbar.

return: string HTML for the navbar

user_menu($user = null, $withlinks = null)   X-Ref
Construct a user menu, returning HTML that can be echoed out by a
layout file.

param: stdClass $user A user object, usually $USER.
param: bool $withlinks true if a dropdown should be built.
return: string HTML fragment.

secure_layout_login_info()   X-Ref
Secure layout login info.

return: string

secure_layout_language_menu()   X-Ref
Returns the language menu in the secure layout.

No custom menu items are passed though, such that it will render only the language selection.

return: string

navbar()   X-Ref
This renders the navbar.
Uses bootstrap compatible html.


render_breadcrumb_navigation_node(breadcrumb_navigation_node $item)   X-Ref
Renders a breadcrumb navigation node object.

param: breadcrumb_navigation_node $item The navigation node to render.
return: string HTML fragment

render_navigation_node(navigation_node $item)   X-Ref
Renders a navigation node object.

param: navigation_node $item The navigation node to render.
return: string HTML fragment

rarrow()   X-Ref
Accessibility: Right arrow-like character is
used in the breadcrumb trail, course navigation menu
(previous/next activity), calendar, and search forum block.
If the theme does not set characters, appropriate defaults
are set automatically. Please DO NOT
use &lt; &gt; &raquo; - these are confusing for blind users.

return: string

larrow()   X-Ref
Accessibility: Left arrow-like character is
used in the breadcrumb trail, course navigation menu
(previous/next activity), calendar, and search forum block.
If the theme does not set characters, appropriate defaults
are set automatically. Please DO NOT
use &lt; &gt; &raquo; - these are confusing for blind users.

return: string

uarrow()   X-Ref
Accessibility: Up arrow-like character is used in
the book heirarchical navigation.
If the theme does not set characters, appropriate defaults
are set automatically. Please DO NOT
use ^ - this is confusing for blind users.

return: string

darrow()   X-Ref
Accessibility: Down arrow-like character.
If the theme does not set characters, appropriate defaults
are set automatically.

return: string

custom_menu($custommenuitems = '')   X-Ref
Returns the custom menu if one has been set

A custom menu can be configured by browsing to
Settings: Administration > Appearance > Themes > Theme settings
and then configuring the custommenu config setting as described.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_custom_menu()} instead.

param: string $custommenuitems - custom menuitems set by theme instead of global theme settings
return: string

custom_menu_flat()   X-Ref
We want to show the custom menus as a list of links in the footer on small screens.
Just return the menu object exported so we can render it differently.


render_custom_menu(custom_menu $menu)   X-Ref
Renders a custom menu object (located in outputcomponents.php)

The custom menu this method produces makes use of the YUI3 menunav widget
and requires very specific html elements and classes.

param: custom_menu $menu
return: string

render_custom_menu_item(custom_menu_item $menunode)   X-Ref
Renders a custom menu node as part of a submenu

The custom menu this method produces makes use of the YUI3 menunav widget
and requires very specific html elements and classes.

param: custom_menu_item $menunode
return: string

theme_switch_links()   X-Ref
Renders theme links for switching between default and other themes.

return: string

tabtree($tabs, $selected = null, $inactive = null)   X-Ref
Renders tabs

This function replaces print_tabs() used before Moodle 2.5 but with slightly different arguments

Theme developers: In order to change how tabs are displayed please override functions
{@link core_renderer::render_tabtree()} and/or {@link core_renderer::render_tabobject()}

param: array $tabs array of tabs, each of them may have it's own ->subtree
param: string|null $selected which tab to mark as selected, all parent tabs will
param: array|string|null $inactive list of ids of inactive tabs, regardless of
return: string

render_tabtree(tabtree $tabtree)   X-Ref
Renders tabtree

param: tabtree $tabtree
return: string

render_tabobject(tabobject $tabobject)   X-Ref
Renders tabobject (part of tabtree)

This function is called from {@link core_renderer::render_tabtree()}
and also it calls itself when printing the $tabobject subtree recursively.

Property $tabobject->level indicates the number of row of tabs.

param: tabobject $tabobject
return: string HTML fragment

blocks($region, $classes = array()   X-Ref
Get the HTML for blocks in the given region.

param: string $region The region to get HTML for.
param: array $classes Wrapping tag classes.
param: string $tag Wrapping tag.
param: boolean $fakeblocksonly Include fake blocks only.
return: string HTML.

custom_block_region($regionname)   X-Ref
Renders a custom block region.

Use this method if you want to add an additional block region to the content of the page.
Please note this should only be used in special situations.
We want to leave the theme is control where ever possible!

This method must use the same method that the theme uses within its layout file.
As such it asks the theme what method it is using.
It can be one of two values, blocks or blocks_for_region (deprecated).

param: string $regionname The name of the custom region to add.
return: string HTML for the block region.

body_css_classes(array $additionalclasses = array()   X-Ref
Returns the CSS classes to apply to the body tag.

param: array $additionalclasses Any additional classes to apply.
return: string

body_id()   X-Ref
The ID attribute to apply to the body tag.

return: string

body_attributes($additionalclasses = array()   X-Ref
Returns HTML attributes to use within the body tag. This includes an ID and classes.

param: string|array $additionalclasses Any additional classes to give the body tag,
return: string

page_heading($tag = 'h1')   X-Ref
Gets HTML for the page heading.

param: string $tag The tag to encase the heading in. h1 by default.
return: string HTML.

page_heading_button()   X-Ref
Gets the HTML for the page heading button.

return: string HTML.

page_doc_link($text = null)   X-Ref
Returns the Moodle docs link to use for this page.

param: string $text
return: string

supportemail(array $customattribs = [])   X-Ref
Returns the HTML for the site support email link

param: array $customattribs Array of custom attributes for the support email anchor tag.
return: string The html code for the support email link.

services_support_link()   X-Ref
Returns the services and support link for the help pop-up.

return: string

has_popover_links()   X-Ref
Helper function to decide whether to show the help popover header or not.

return: bool

page_heading_menu()   X-Ref
Returns the page heading menu.

return: string HTML.

page_title()   X-Ref
Returns the title to use on the page.

return: string

favicon()   X-Ref
Returns the moodle_url for the favicon.

return: moodle_url The moodle_url for the favicon

render_preferences_groups(preferences_groups $renderable)   X-Ref
Renders preferences groups.

param: preferences_groups $renderable The renderable
return: string The output.

render_preferences_group(preferences_group $renderable)   X-Ref
Renders preferences group.

param: preferences_group $renderable The renderable
return: string The output.

context_header($headerinfo = null, $headinglevel = 1)   X-Ref
No description

render_skip_links($links)   X-Ref
Renders the skip links for the page.

param: array $links List of skip links.
return: string HTML for the skip links.

render_context_header(context_header $contextheader)   X-Ref
Renders the header bar.

param: context_header $contextheader Header bar object.
return: string HTML for the header bar.

full_header()   X-Ref
Wrapper for header elements.

return: string HTML to display the main header.

context_header_settings_menu()   X-Ref
This is an optional menu that can be added to a layout by a theme. It contains the
menu for the course administration, only on the course main page.

return: string

build_action_menu_from_navigation(action_menu $menu,navigation_node $node,$indent = false,$onlytopleafnodes = false)   X-Ref
Take a node in the nav tree and make an action menu out of it.
The links are injected in the action menu.

param: action_menu $menu
param: navigation_node $node
param: boolean $indent
param: boolean $onlytopleafnodes
return: boolean nodesskipped - True if nodes were skipped in building the menu

region_main_settings_menu()   X-Ref
This is an optional menu that can be added to a layout by a theme. It contains the
menu for the most specific thing from the settings block. E.g. Module administration.

return: string

tag_list($tags, $label = null, $classes = '', $limit = 10,$pagecontext = null, $accesshidelabel = false)   X-Ref
Displays the list of tags associated with an entry

param: array $tags list of instances of core_tag or stdClass
param: string $label label to display in front, by default 'Tags' (get_string('tags')), set to null
param: string $classes additional classes for the enclosing div element
param: int $limit limit the number of tags to display, if size of $tags is more than this limit the "more" link
param: context $pagecontext specify if needed to overwrite the current page context for the view tag link
param: bool $accesshidelabel if true, the label should have class="accesshide" added.
return: string

render_inplace_editable(\core\output\inplace_editable $element)   X-Ref
Renders element for inline editing of any value

param: \core\output\inplace_editable $element
return: string

render_chart_bar(\core\chart_bar $chart)   X-Ref
Renders a bar chart.

param: \core\chart_bar $chart The chart.
return: string.

render_chart_line(\core\chart_line $chart)   X-Ref
Renders a line chart.

param: \core\chart_line $chart The chart.
return: string.

render_chart_pie(\core\chart_pie $chart)   X-Ref
Renders a pie chart.

param: \core\chart_pie $chart The chart.
return: string.

render_chart(\core\chart_base $chart, $withtable = true)   X-Ref
Renders a chart.

param: \core\chart_base $chart The chart.
param: bool $withtable Whether to include a data table with the chart.
return: string.

render_login(\core_auth\output\login $form)   X-Ref
Renders the login form.

param: \core_auth\output\login $form The renderable.
return: string

mform_element($element, $required, $advanced, $error, $ingroup)   X-Ref
Renders an mform element from a template.

param: HTML_QuickForm_element $element element
param: bool $required if input is required field
param: bool $advanced if input is an advanced field
param: string $error error message to display
param: bool $ingroup True if this element is rendered as part of a group
return: mixed string|bool

render_login_signup_form($form)   X-Ref
Render the login signup form into a nice template for the theme.

param: mform $form
return: string

render_verify_age_location_page($page)   X-Ref
Render the verify age and location page into a nice template for the theme.

param: \core_auth\output\verify_age_location_page $page The renderable
return: string

render_digital_minor_page($page)   X-Ref
Render the digital minor contact information page into a nice template for the theme.

param: \core_auth\output\digital_minor_page $page The renderable
return: string

render_progress_bar(progress_bar $bar)   X-Ref
Renders a progress bar.

Do not use $OUTPUT->render($bar), instead use progress_bar::create().

param: progress_bar $bar The bar.
return: string HTML fragment

render_progress_bar_update(string $id, float $percent, string $msg, string $estimate)   X-Ref
Renders an update to a progress bar.

Note: This does not cleanly map to a renderable class and should
never be used directly.

param: string $id
param: float $percent
param: string $msg Message
param: string $estimate time remaining message
return: string ascii fragment

render_checkbox_toggleall(\core\output\checkbox_toggleall $element)   X-Ref
Renders element for a toggle-all checkbox.

param: \core\output\checkbox_toggleall $element
return: string

render_participants_tertiary_nav(object $course, ?string $renderedbuttons = null)   X-Ref
Renders the tertiary nav for the participants page

param: object $course The course we are operating within
param: string|null $renderedbuttons Any additional buttons/content to be displayed in line with the nav
return: string

moodle_release()   X-Ref
Renders release information in the footer popup

return: string Moodle release info.

addblockbutton($region = '')   X-Ref
Generate the add block button when editing mode is turned on and the user can edit blocks.

param: string $region where new blocks should be added.
return: string html for the add block button.

Class: core_renderer_cli  - X-Ref

A renderer that generates output for command-line scripts.

The implementation of this renderer is probably incomplete.

header()   X-Ref
Returns the page header.

return: string HTML fragment

render_check_result(core\check\result $result)   X-Ref
Renders a Check API result

To aid in CLI consistency this status is NOT translated and the visual
width is always exactly 10 chars.

param: core\check\result $result
return: string HTML fragment

check_result(core\check\result $result)   X-Ref
Renders a Check API result

param: result $result
return: string fragment

render_progress_bar(progress_bar $bar)   X-Ref
Renders a progress bar.

Do not use $OUTPUT->render($bar), instead use progress_bar::create().

param: progress_bar $bar The bar.
return: string ascii fragment

render_progress_bar_update(string $id, float $percent, string $msg, string $estimate)   X-Ref
Renders an update to a progress bar.

Note: This does not cleanly map to a renderable class and should
never be used directly.

param: string $id
param: float $percent
param: string $msg Message
param: string $estimate time remaining message
return: string ascii fragment

heading($text, $level = 2, $classes = 'main', $id = null)   X-Ref
Returns a template fragment representing a Heading.

param: string $text The text of the heading
param: int $level The level of importance of the heading
param: string $classes A space-separated list of CSS classes
param: string $id An optional ID
return: string A template fragment for a heading

fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = "")   X-Ref
Returns a template fragment representing a fatal error.

param: string $message The message to output
param: string $moreinfourl URL where more info can be found about the error
param: string $link Link for the Continue button
param: array $backtrace The execution backtrace
param: string $debuginfo Debugging information
return: string A template fragment for a fatal error

notification($message, $type = null, $closebutton = true)   X-Ref
Returns a template fragment representing a notification.

param: string $message The message to print out.
param: string $type    The type of notification. See constants on \core\output\notification.
param: bool $closebutton Whether to show a close icon to remove the notification (default true).
return: string A template fragment for a notification

footer()   X-Ref
There is no footer for a cli request, however we must override the
footer method to prevent the default footer.


render_notification(\core\output\notification $notification)   X-Ref
Render a notification (that is, a status message about something that has
just happened).

param: \core\output\notification $notification the notification to print out
return: string plain text output

Class: core_renderer_ajax  - X-Ref

A renderer that generates output for ajax scripts.

This renderer prevents accidental sends back only json
encoded error messages, all other output is ignored.

fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = "")   X-Ref
Returns a template fragment representing a fatal error.

param: string $message The message to output
param: string $moreinfourl URL where more info can be found about the error
param: string $link Link for the Continue button
param: array $backtrace The execution backtrace
param: string $debuginfo Debugging information
return: string A template fragment for a fatal error

notification($message, $type = null, $closebutton = true)   X-Ref
Used to display a notification.
For the AJAX notifications are discarded.

param: string $message The message to print out.
param: string $type    The type of notification. See constants on \core\output\notification.
param: bool $closebutton Whether to show a close icon to remove the notification (default true).

redirect_message($encodedurl, $message, $delay, $debugdisableredirect,$messagetype = \core\output\notification::NOTIFY_INFO)   X-Ref
Used to display a redirection message.
AJAX redirections should not occur and as such redirection messages
are discarded.

param: moodle_url|string $encodedurl
param: string $message
param: int $delay
param: bool $debugdisableredirect
param: string $messagetype The type of notification to show the message in.

header()   X-Ref
Prepares the start of an AJAX output.


footer()   X-Ref
There is no footer for an AJAX request, however we must override the
footer method to prevent the default footer.


heading($text, $level = 2, $classes = 'main', $id = null)   X-Ref
No need for headers in an AJAX request... this should never happen.

param: string $text
param: int $level
param: string $classes
param: string $id

Class: core_renderer_maintenance  - X-Ref

The maintenance renderer.

The purpose of this renderer is to block out the core renderer methods that are not usable when the site
is running a maintenance related task.
It must always extend the core_renderer as we switch from the core_renderer to this renderer in a couple of places.

__construct(moodle_page $page, $target)   X-Ref
Initialises the renderer instance.

param: moodle_page $page
param: string $target

block(block_contents $bc, $region)   X-Ref
Does nothing. The maintenance renderer cannot produce blocks.

param: block_contents $bc
param: string $region
return: string

blocks($region, $classes = array()   X-Ref
Does nothing. The maintenance renderer cannot produce blocks.

param: string $region
param: array $classes
param: string $tag
param: boolean $fakeblocksonly
return: string

blocks_for_region($region, $fakeblocksonly = false)   X-Ref
Does nothing. The maintenance renderer cannot produce blocks.

param: string $region
param: boolean $fakeblocksonly Output fake block only.
return: string

course_content_header($onlyifnotcalledbefore = false)   X-Ref
Does nothing. The maintenance renderer cannot produce a course content header.

param: bool $onlyifnotcalledbefore
return: string

course_content_footer($onlyifnotcalledbefore = false)   X-Ref
Does nothing. The maintenance renderer cannot produce a course content footer.

param: bool $onlyifnotcalledbefore
return: string

course_header()   X-Ref
Does nothing. The maintenance renderer cannot produce a course header.

return: string

course_footer()   X-Ref
Does nothing. The maintenance renderer cannot produce a course footer.

return: string

custom_menu($custommenuitems = '')   X-Ref
Does nothing. The maintenance renderer cannot produce a custom menu.

param: string $custommenuitems
return: string

file_picker($options)   X-Ref
Does nothing. The maintenance renderer cannot produce a file picker.

param: array $options
return: string

htmllize_file_tree($dir)   X-Ref
Does nothing. The maintenance renderer cannot produce and HTML file tree.

param: array $dir
return: string

confirm($message, $continue, $cancel, array $displayoptions = [])   X-Ref
Overridden confirm message for upgrades.

param: string $message The question to ask the user
param: single_button|moodle_url|string $continue The single_button component representing the Continue answer.
param: single_button|moodle_url|string $cancel The single_button component representing the Cancel answer.
param: array $displayoptions optional extra display options
return: string HTML fragment

init_block_hider_js(block_contents $bc)   X-Ref
Does nothing. The maintenance renderer does not support JS.

param: block_contents $bc

lang_menu()   X-Ref
Does nothing. The maintenance renderer cannot produce language menus.

return: string

login_info($withlinks = null)   X-Ref
Does nothing. The maintenance renderer has no need for login information.

param: null $withlinks
return: string

secure_login_info()   X-Ref
Secure login info.

return: string

user_picture(stdClass $user, array $options = null)   X-Ref
Does nothing. The maintenance renderer cannot produce user pictures.

param: stdClass $user
param: array $options
return: string