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 representing HTML elements, used by $OUTPUT methods Please see 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: 5129 lines (169 kb)
Included or required: 2 times
Referenced: 0 times
Includes or requires: 0 files

Defines 36 classes

renderable:: (0 methods):

templatable:: (1 method):
  export_for_template()

file_picker:: (1 method):
  __construct()

user_picture:: (4 methods):
  __construct()
  fields()
  unalias()
  get_url()

help_icon:: (3 methods):
  __construct()
  diag_strings()
  export_for_template()

pix_icon_font:: (3 methods):
  __construct()
  is_mapped()
  export_for_template()

pix_icon_fontawesome:: (0 methods):

pix_icon:: (3 methods):
  __construct()
  export_for_template()
  export_for_pix()

image_icon:: (0 methods):

pix_emoticon:: (1 method):
  __construct()

single_button:: (5 methods):
  __construct()
  add_confirm_action()
  add_action()
  set_attribute()
  export_for_template()

single_select:: (7 methods):
  __construct()
  add_confirm_action()
  add_action()
  set_old_help_icon()
  set_help_icon()
  set_label()
  export_for_template()

url_select:: (7 methods):
  __construct()
  set_old_help_icon()
  set_help_icon()
  set_label()
  clean_url()
  flatten_options()
  export_for_template()

action_link:: (6 methods):
  __construct()
  add_action()
  add_class()
  has_class()
  get_icon_html()
  export_for_template()

html_writer:: (28 methods):
  tag()
  start_tag()
  end_tag()
  empty_tag()
  nonempty_tag()
  attribute()
  attributes()
  img()
  random_id()
  link()
  checkbox()
  select_yes_no()
  select()
  select_option()
  select_optgroup()
  select_time()
  alist()
  input_hidden_params()
  script()
  table()
  label()
  add_class()
  div()
  start_div()
  end_div()
  span()
  start_span()
  end_span()

js_writer:: (5 methods):
  function_call()
  function_call_with_Y()
  object_init()
  set_variable()
  event_handler()

html_table:: (1 method):
  __construct()

html_table_row:: (1 method):
  __construct()

html_table_cell:: (1 method):
  __construct()

paging_bar:: (3 methods):
  __construct()
  prepare()
  export_for_template()

initials_bar:: (2 methods):
  __construct()
  export_for_template()

block_contents:: (3 methods):
  __construct()
  add_class()
  is_fake()

block_move_target:: (1 method):
  __construct()

custom_menu_item:: (15 methods):
  __construct()
  add()
  remove_child()
  get_text()
  get_url()
  get_title()
  get_children()
  get_sort_order()
  get_parent()
  sort()
  has_children()
  set_text()
  set_title()
  set_url()
  export_for_template()

custom_menu:: (4 methods):
  __construct()
  override_children()
  convert_text_to_menu_nodes()
  sort_custom_menu_items()

tabobject:: (5 methods):
  __construct()
  set_selected()
  find()
  set_level()
  export_for_template()

context_header:: (2 methods):
  __construct()
  format_button_images()

tabtree:: (2 methods):
  __construct()
  export_for_template()

action_menu:: (21 methods):
  __construct()
  set_action_label()
  set_menu_trigger()
  is_empty()
  initialise_js()
  add()
  add_primary_action()
  add_secondary_action()
  get_primary_actions()
  get_secondary_actions()
  set_owner_selector()
  set_alignment()
  get_align_string()
  set_menu_left()
  set_constraint()
  set_boundary()
  do_not_enhance()
  will_be_enhanced()
  set_nowrap_on_items()
  set_additional_classes()
  export_for_template()

action_menu_filler:: (1 method):
  __construct()

action_menu_link:: (2 methods):
  __construct()
  export_for_template()

action_menu_link_primary:: (1 method):
  __construct()

action_menu_link_secondary:: (1 method):
  __construct()

preferences_groups:: (1 method):
  __construct()

preferences_group:: (1 method):
  __construct()

progress_bar:: (9 methods):
  __construct()
  get_id()
  create()
  _update()
  estimate()
  update_full()
  update()
  restart()
  export_for_template()


Interface: renderable  - X-Ref

Interface marking other classes as suitable for renderer_base::render()

Interface: templatable  - X-Ref

Interface marking other classes having the ability to export their data for use by templates.

export_for_template(renderer_base $output)   X-Ref
Function to export the renderer data in a format that is suitable for a
mustache template. This means:
1. No complex types - only stdClass, array, int, string, float, bool
2. Any additional info that is required for the template is pre-calculated (e.g. capability checks).

param: renderer_base $output Used to do a final render of any components that need to be rendered for export.
return: stdClass|array

Class: file_picker  - X-Ref

Data structure representing a file picker.

__construct(stdClass $options)   X-Ref
Constructs a file picker object.

The following are possible options for the filepicker:
- accepted_types  (*)
- return_types    (FILE_INTERNAL)
- env             (filepicker)
- client_id       (uniqid)
- itemid          (0)
- maxbytes        (-1)
- maxfiles        (1)
- buttonname      (false)

param: stdClass $options An object containing options for the file picker.

Class: user_picture  - X-Ref

Data structure representing a user picture.

__construct(stdClass $user)   X-Ref
User picture constructor.

param: stdClass $user user record with at least id, picture, imagealt, firstname and lastname set.

fields($tableprefix = '', array $extrafields = NULL, $idalias = 'id', $fieldprefix = '')   X-Ref
Returns a list of required user fields, useful when fetching required user info from db.

In some cases we have to fetch the user data together with some other information,
the idalias is useful there because the id would otherwise override the main
id of the result record. Please note it has to be converted back to id before rendering.

param: string $tableprefix name of database table prefix in query
param: array $extrafields extra fields to be included in result (do not include TEXT columns because it would break SELECT DISTINCT in MSSQL and ORACLE)
param: string $idalias alias of id field
param: string $fieldprefix prefix to add to all columns in their aliases, does not apply to 'id'
return: string

unalias(stdClass $record, array $extrafields = null, $idalias = 'id', $fieldprefix = '')   X-Ref
Extract the aliased user fields from a given record

Given a record that was previously obtained using {@link self::fields()} with aliases,
this method extracts user related unaliased fields.

param: stdClass $record containing user picture fields
param: array $extrafields extra fields included in the $record
param: string $idalias alias of the id field
param: string $fieldprefix prefix added to all columns in their aliases, does not apply to 'id'
return: stdClass object with unaliased user fields

get_url(moodle_page $page, renderer_base $renderer = null)   X-Ref
Works out the URL for the users picture.

This method is recommended as it avoids costly redirects of user pictures
if requests are made for non-existent files etc.

param: moodle_page $page
param: renderer_base $renderer
return: moodle_url

Class: help_icon  - X-Ref

Data structure representing a help icon.

__construct($identifier, $component)   X-Ref
Constructor

param: string $identifier string for help page title,
param: string $component

diag_strings()   X-Ref
Verifies that both help strings exists, shows debug warnings if not


export_for_template(renderer_base $output)   X-Ref
Export this data so it can be used as the context for a mustache template.

param: renderer_base $output Used to do a final render of any components that need to be rendered for export.
return: array

Class: pix_icon_font  - X-Ref

Data structure representing an icon font.

__construct(pix_icon $pixicon)   X-Ref
Constructor

param: pix_icon $pixicon The original icon

is_mapped()   X-Ref
Return true if this pix_icon was successfully mapped to an icon font.

return: bool

export_for_template(renderer_base $output)   X-Ref
Export this data so it can be used as the context for a mustache template.

param: renderer_base $output Used to do a final render of any components that need to be rendered for export.
return: array

Class: pix_icon_fontawesome  - X-Ref

Data structure representing an icon subtype.

Class: pix_icon  - X-Ref

Data structure representing an icon.

__construct($pix, $alt, $component='moodle', array $attributes = null)   X-Ref
Constructor

param: string $pix short icon name
param: string $alt The alt text to use for the icon
param: string $component component name
param: array $attributes html attributes

export_for_template(renderer_base $output)   X-Ref
Export this data so it can be used as the context for a mustache template.

param: renderer_base $output Used to do a final render of any components that need to be rendered for export.
return: array

export_for_pix()   X-Ref
Much simpler version of export that will produce the data required to render this pix with the
pix helper in a mustache tag.

return: array

Class: image_icon  - X-Ref

Data structure representing an activity icon.

The difference is that activity icons will always render with the standard icon system (no font icons).

Class: pix_emoticon  - X-Ref

Data structure representing an emoticon image

__construct($pix, $alt, $component = 'moodle', array $attributes = array()   X-Ref
Constructor

param: string $pix short icon name
param: string $alt alternative text
param: string $component emoticon image provider
param: array $attributes explicit HTML attributes

Class: single_button  - X-Ref

Data structure representing a simple form with only one button.

__construct(moodle_url $url, $label, $method='post', $primary=false, $attributes = [])   X-Ref
Constructor

param: moodle_url $url
param: string $label button text
param: string $method get or post submit method
param: bool $primary whether this is a primary button, used for styling
param: array $attributes Attributes for the HTML button tag

add_confirm_action($confirmmessage)   X-Ref
Shortcut for adding a JS confirm dialog when the button is clicked.
The message must be a yes/no question.

param: string $confirmmessage The yes/no confirmation question. If "Yes" is clicked, the original action will occur.

add_action(component_action $action)   X-Ref
Add action to the button.

param: component_action $action

set_attribute($name, $value)   X-Ref
Sets an attribute for the HTML button tag.

param: string $name  The attribute name
param: mixed  $value The value
return: null

export_for_template(renderer_base $output)   X-Ref
Export data.

param: renderer_base $output Renderer.
return: stdClass

Class: single_select  - X-Ref

Simple form with just one select field that gets submitted automatically.

If JS not enabled small go button is printed too.

__construct(moodle_url $url, $name, array $options, $selected = '', $nothing = array('' => 'choosedots')   X-Ref
Constructor

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

add_confirm_action($confirmmessage)   X-Ref
Shortcut for adding a JS confirm dialog when the button is clicked.
The message must be a yes/no question.

param: string $confirmmessage The yes/no confirmation question. If "Yes" is clicked, the original action will occur.

add_action(component_action $action)   X-Ref
Add action to the button.

param: component_action $action

set_old_help_icon($helppage, $title, $component = 'moodle')   X-Ref
Adds help icon.


set_help_icon($identifier, $component = 'moodle')   X-Ref
Adds help icon.

param: string $identifier The keyword that defines a help page
param: string $component

set_label($label, $attributes = array()   X-Ref
Sets select's label

param: string $label
param: array $attributes (optional)

export_for_template(renderer_base $output)   X-Ref
Export data.

param: renderer_base $output Renderer.
return: stdClass

Class: url_select  - X-Ref

Simple URL selection widget description.

__construct(array $urls, $selected = '', $nothing = array('' => 'choosedots')   X-Ref
Constructor

param: array $urls list of options
param: string $selected selected element
param: array $nothing
param: string $formid
param: string $showbutton Set to text of button if it should be visible

set_old_help_icon($helppage, $title, $component = 'moodle')   X-Ref
Adds help icon.


set_help_icon($identifier, $component = 'moodle')   X-Ref
Adds help icon.

param: string $identifier The keyword that defines a help page
param: string $component

set_label($label, $attributes = array()   X-Ref
Sets select's label

param: string $label
param: array $attributes (optional)

clean_url($value)   X-Ref
Clean a URL.

param: string $value The URL.
return: The cleaned URL.

flatten_options($options, $nothing)   X-Ref
Flatten the options for Mustache.

This also cleans the URLs.

param: array $options The options.
param: array $nothing The nothing option.
return: array

export_for_template(renderer_base $output)   X-Ref
Export for template.

param: renderer_base $output Renderer.
return: stdClass

Class: action_link  - X-Ref

Data structure describing html link with special action attached.

__construct(moodle_url $url,$text,component_action $action=null,array $attributes=null,pix_icon $icon=null)   X-Ref
Constructor

param: 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 $icon optional pix_icon to render with the link text

add_action(component_action $action)   X-Ref
Add action to the link.

param: component_action $action

add_class($class)   X-Ref
Adds a CSS class to this action link object

param: string $class

has_class($class)   X-Ref
Returns true if the specified class has been added to this link.

param: string $class
return: bool

get_icon_html()   X-Ref
Return the rendered HTML for the icon. Useful for rendering action links in a template.

return: string

export_for_template(renderer_base $output)   X-Ref
Export for template.

param: renderer_base $output The renderer.
return: stdClass

Class: html_writer  - X-Ref

Simple html output class

tag($tagname, $contents, array $attributes = null)   X-Ref
Outputs a tag with attributes and contents

param: string $tagname The name of tag ('a', 'img', 'span' etc.)
param: string $contents What goes between the opening and closing tags
param: array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
return: string HTML fragment

start_tag($tagname, array $attributes = null)   X-Ref
Outputs an opening tag with attributes

param: string $tagname The name of tag ('a', 'img', 'span' etc.)
param: array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
return: string HTML fragment

end_tag($tagname)   X-Ref
Outputs a closing tag

param: string $tagname The name of tag ('a', 'img', 'span' etc.)
return: string HTML fragment

empty_tag($tagname, array $attributes = null)   X-Ref
Outputs an empty tag with attributes

param: string $tagname The name of tag ('input', 'img', 'br' etc.)
param: array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
return: string HTML fragment

nonempty_tag($tagname, $contents, array $attributes = null)   X-Ref
Outputs a tag, but only if the contents are not empty

param: string $tagname The name of tag ('a', 'img', 'span' etc.)
param: string $contents What goes between the opening and closing tags
param: array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
return: string HTML fragment

attribute($name, $value)   X-Ref
Outputs a HTML attribute and value

param: string $name The name of the attribute ('src', 'href', 'class' etc.)
param: string $value The value of the attribute. The value will be escaped with {@link s()}
return: string HTML fragment

attributes(array $attributes = null)   X-Ref
Outputs a list of HTML attributes and values

param: array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
return: string HTML fragment

img($src, $alt, array $attributes = null)   X-Ref
Generates a simple image tag with attributes.

param: string $src The source of image
param: string $alt The alternate text for image
param: array $attributes The tag attributes (array('height' => $max_height, 'class' => 'class1') etc.)
return: string HTML fragment

random_id($base='random')   X-Ref
Generates random html element id.

param: string $base A string fragment that will be included in the random ID.
return: string A unique ID

link($url, $text, array $attributes = null)   X-Ref
Generates a simple html link

param: string|moodle_url $url The URL
param: string $text The text
param: array $attributes HTML attributes
return: string HTML fragment

checkbox($name, $value, $checked = true, $label = '',array $attributes = null, array $labelattributes = null)   X-Ref
Generates a simple checkbox with optional label

param: string $name The name of the checkbox
param: string $value The value of the checkbox
param: bool $checked Whether the checkbox is checked
param: string $label The label for the checkbox
param: array $attributes Any attributes to apply to the checkbox
param: array $labelattributes Any attributes to apply to the label, if present
return: string html fragment

select_yes_no($name, $selected=true, array $attributes = null)   X-Ref
Generates a simple select yes/no form field

param: string $name name of select element
param: bool $selected
param: array $attributes - html select element attributes
return: string HTML fragment

select(array $options, $name, $selected = '', $nothing = array('' => 'choosedots')   X-Ref
Generates a simple select form field

Note this function does HTML escaping on the optgroup labels, but not on the choice labels.

param: array $options associative array value=>label ex.:
param: string $name name of select element
param: string|array $selected value or array of values depending on multiple attribute
param: array|bool $nothing add nothing selected option, or false of not added
param: array $attributes html select element attributes
return: string HTML fragment

select_option($label, $value, array $selected)   X-Ref
Returns HTML to display a select box option.

param: string $label The label to display as the option.
param: string|int $value The value the option represents
param: array $selected An array of selected options
return: string HTML fragment

select_optgroup($groupname, $options, array $selected)   X-Ref
Returns HTML to display a select box option group.

param: string $groupname The label to use for the group
param: array $options The options in the group
param: array $selected An array of selected values.
return: string HTML fragment.

select_time($type, $name, $currenttime = 0, $step = 5, array $attributes = null)   X-Ref
This is a shortcut for making an hour selector menu.

param: string $type The type of selector (years, months, days, hours, minutes)
param: string $name fieldname
param: int $currenttime A default timestamp in GMT
param: int $step minute spacing
param: array $attributes - html select element attributes
return: HTML fragment

alist(array $items, array $attributes = null, $tag = 'ul')   X-Ref
Shortcut for quick making of lists

Note: 'list' is a reserved keyword ;-)

param: array $items
param: array $attributes
param: string $tag ul or ol
return: string

input_hidden_params(moodle_url $url, array $exclude = null)   X-Ref
Returns hidden input fields created from url parameters.

param: moodle_url $url
param: array $exclude list of excluded parameters
return: string HTML fragment

script($jscode, $url=null)   X-Ref
Generate a script tag containing the the specified code.

param: string $jscode the JavaScript code
param: moodle_url|string $url optional url of the external script, $code ignored if specified
return: string HTML, the code wrapped in <script> tags.

table(html_table $table)   X-Ref
Renders HTML table

This method may modify the passed instance by adding some default properties if they are not set yet.
If this is not what you want, you should make a full clone of your data before passing them to this
method. In most cases this is not an issue at all so we do not clone by default for performance
and memory consumption reasons.

param: html_table $table data to be rendered
return: string HTML code

label($text, $for, $colonize = true, array $attributes=array()   X-Ref
Renders form element label

By default, the label is suffixed with a label separator defined in the
current language pack (colon by default in the English lang pack).
Adding the colon can be explicitly disabled if needed. Label separators
are put outside the label tag itself so they are not read by
screenreaders (accessibility).

Parameter $for explicitly associates the label with a form control. When
set, the value of this attribute must be the same as the value of
the id attribute of the form control in the same document. When null,
the label being defined is associated with the control inside the label
element.

param: string $text content of the label tag
param: string|null $for id of the element this label is associated with, null for no association
param: bool $colonize add label separator (colon) to the label text, if it is not there yet
param: array $attributes to be inserted in the tab, for example array('accesskey' => 'a')
return: string HTML of the label element

add_class($class = '', array $attributes = null)   X-Ref
Combines a class parameter with other attributes. Aids in code reduction
because the class parameter is very frequently used.

If the class attribute is specified both in the attributes and in the
class parameter, the two values are combined with a space between.

param: string $class Optional CSS class (or classes as space-separated list)
param: array $attributes Optional other attributes as array
return: array Attributes (or null if still none)

div($content, $class = '', array $attributes = null)   X-Ref
Creates a <div> tag. (Shortcut function.)

param: string $content HTML content of tag
param: string $class Optional CSS class (or classes as space-separated list)
param: array $attributes Optional other attributes as array
return: string HTML code for div

start_div($class = '', array $attributes = null)   X-Ref
Starts a <div> tag. (Shortcut function.)

param: string $class Optional CSS class (or classes as space-separated list)
param: array $attributes Optional other attributes as array
return: string HTML code for open div tag

end_div()   X-Ref
Ends a <div> tag. (Shortcut function.)

return: string HTML code for close div tag

span($content, $class = '', array $attributes = null)   X-Ref
Creates a <span> tag. (Shortcut function.)

param: string $content HTML content of tag
param: string $class Optional CSS class (or classes as space-separated list)
param: array $attributes Optional other attributes as array
return: string HTML code for span

start_span($class = '', array $attributes = null)   X-Ref
Starts a <span> tag. (Shortcut function.)

param: string $class Optional CSS class (or classes as space-separated list)
param: array $attributes Optional other attributes as array
return: string HTML code for open span tag

end_span()   X-Ref
Ends a <span> tag. (Shortcut function.)

return: string HTML code for close span tag

Class: js_writer  - X-Ref

Simple javascript output class

function_call($function, array $arguments = null, $delay=0)   X-Ref
Returns javascript code calling the function

param: string $function function name, can be complex like Y.Event.purgeElement
param: array $arguments parameters
param: int $delay execution delay in seconds
return: string JS code fragment

function_call_with_Y($function, array $extraarguments = null)   X-Ref
Special function which adds Y as first argument of function call.

param: string $function The function to call
param: array $extraarguments Any arguments to pass to it
return: string Some JS code

object_init($var, $class, array $arguments = null, array $requirements = null, $delay=0)   X-Ref
Returns JavaScript code to initialise a new object

param: string $var If it is null then no var is assigned the new object.
param: string $class The class to initialise an object for.
param: array $arguments An array of args to pass to the init method.
param: array $requirements Any modules required for this class.
param: int $delay The delay before initialisation. 0 = no delay.
return: string Some JS code

set_variable($name, $value, $usevar = true)   X-Ref
Returns code setting value to variable

param: string $name
param: mixed $value json serialised value
param: bool $usevar add var definition, ignored for nested properties
return: string JS code fragment

event_handler($selector, $event, $function, array $arguments = null)   X-Ref
Writes event handler attaching code

param: array|string $selector standard YUI selector for elements, may be
param: string $event A valid DOM event (click, mousedown, change etc.)
param: string $function The name of the function to call
param: array $arguments An optional array of argument parameters to pass to the function
return: string JS code fragment

Class: html_table  - X-Ref

Holds all the information required to render a <table> by {@link core_renderer::table()}

Example of usage:
$t = new html_table();
... // set various properties of the object $t as described below
echo html_writer::table($t);

__construct()   X-Ref
Constructor


Class: html_table_row  - X-Ref

Component representing a table row.

__construct(array $cells=null)   X-Ref
Constructor

param: array $cells

Class: html_table_cell  - X-Ref

Component representing a table cell.

__construct($text = null)   X-Ref
Constructs a table cell

param: string $text

Class: paging_bar  - X-Ref

Component representing a paging bar.

__construct($totalcount, $page, $perpage, $baseurl, $pagevar = 'page')   X-Ref
Constructor paging_bar with only the required params.

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

prepare(renderer_base $output, moodle_page $page, $target)   X-Ref
Prepares the paging bar for output.

This method validates the arguments set up for the paging bar and then
produces fragments of HTML to assist display later on.

param: renderer_base $output
param: moodle_page $page
param: string $target

export_for_template(renderer_base $output)   X-Ref
Export for template.

param: renderer_base $output The renderer.
return: stdClass

Class: initials_bar  - X-Ref

Component representing initials bar.

__construct($current, $class, $title, $urlvar, $url, $alpha = null)   X-Ref
Constructor initials_bar with only the required params.

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.

export_for_template(renderer_base $output)   X-Ref
Export for template.

param: renderer_base $output The renderer.
return: stdClass

Class: block_contents  - X-Ref

This class represents how a block appears on a page.

During output, each block instance is asked to return a block_contents object,
those are then passed to the $OUTPUT->block function for display.

contents should probably be generated using a moodle_block_..._renderer.

Other block-like things that need to appear on the page, for example the
add new block UI, are also represented as block_contents objects.

__construct(array $attributes = null)   X-Ref
Create new instance of block content

param: array $attributes

add_class($class)   X-Ref
Add html class to block

param: string $class

is_fake()   X-Ref
Check if the block is a fake block.

return: boolean

Class: block_move_target  - X-Ref

This class represents a target for where a block can go when it is being moved.

This needs to be rendered as a form with the given hidden from fields, and
clicking anywhere in the form should submit it. The form action should be
$PAGE->url.

__construct(moodle_url $url)   X-Ref
Constructor

param: moodle_url $url

Class: custom_menu_item  - X-Ref

Custom menu item

This class is used to represent one item within a custom menu that may or may
not have children.

__construct($text, moodle_url $url = null, $title = null, $sort = null, custom_menu_item $parent = null,array $attributes = [])   X-Ref
Constructs the new custom menu item

param: string $text
param: moodle_url $url A moodle url to apply as the link for this item [Optional]
param: string $title A title to apply to this item [Optional]
param: int $sort A sort or to use if we need to sort differently [Optional]
param: custom_menu_item $parent A reference to the parent custom_menu_item this child
param: array $attributes Array of other HTML attributes for the custom menu item.

add($text, moodle_url $url = null, $title = null, $sort = null, $attributes = [])   X-Ref
Adds a custom menu item as a child of this node given its properties.

param: string $text
param: moodle_url $url
param: string $title
param: int $sort
param: array $attributes Array of other HTML attributes for the custom menu item.
return: custom_menu_item

remove_child(custom_menu_item $menuitem)   X-Ref
Removes a custom menu item that is a child or descendant to the current menu.

Returns true if child was found and removed.

param: custom_menu_item $menuitem
return: bool

get_text()   X-Ref
Returns the text for this item

return: string

get_url()   X-Ref
Returns the url for this item

return: moodle_url

get_title()   X-Ref
Returns the title for this item

return: string

get_children()   X-Ref
Sorts and returns the children for this item

return: array

get_sort_order()   X-Ref
Gets the sort order for this child

return: int

get_parent()   X-Ref
Gets the parent this child belong to

return: custom_menu_item

sort()   X-Ref
Sorts the children this item has


has_children()   X-Ref
Returns true if this item has any children

return: bool

set_text($text)   X-Ref
Sets the text for the node

param: string $text

set_title($title)   X-Ref
Sets the title for the node

param: string $title

set_url(moodle_url $url)   X-Ref
Sets the url for the node

param: moodle_url $url

export_for_template(renderer_base $output)   X-Ref
Export this data so it can be used as the context for a mustache template.

param: renderer_base $output Used to do a final render of any components that need to be rendered for export.
return: array

Class: custom_menu  - X-Ref

Custom menu class

This class is used to operate a custom menu that can be rendered for the page.
The custom menu is built using $CFG->custommenuitems and is a structured collection
of custom_menu_item nodes that can be rendered by the core renderer.

To configure the custom menu:
Settings: Administration > Appearance > Themes > Theme settings

__construct($definition = '', $currentlanguage = null)   X-Ref
Creates the custom menu

param: string $definition the menu items definition in syntax required by {@link convert_text_to_menu_nodes()}
param: string $currentlanguage the current language code, null disables multilang support

override_children(array $children)   X-Ref
Overrides the children of this custom menu. Useful when getting children
from $CFG->custommenuitems

param: array $children

convert_text_to_menu_nodes($text, $language = null)   X-Ref
Converts a string into a structured array of custom_menu_items which can
then be added to a custom menu.

Structure:
text|url|title|langs
The number of hyphens at the start determines the depth of the item. The
languages are optional, comma separated list of languages the line is for.

Example structure:
First level first item|http://www.moodle.com/
-Second level first item|http://www.moodle.com/partners/
-Second level second item|http://www.moodle.com/hq/
--Third level first item|http://www.moodle.com/jobs/
-Second level third item|http://www.moodle.com/development/
First level second item|http://www.moodle.com/feedback/
First level third item
English only|http://moodle.com|English only item|en
German only|http://moodle.de|Deutsch|de,de_du,de_kids


param: string $text the menu items definition
param: string $language the language code, null disables multilang support
return: array

sort_custom_menu_items(custom_menu_item $itema, custom_menu_item $itemb)   X-Ref
Sorts two custom menu items

This function is designed to be used with the usort method
usort($this->children, array('custom_menu','sort_custom_menu_items'));

param: custom_menu_item $itema
param: custom_menu_item $itemb
return: int

Class: tabobject  - X-Ref

Stores one tab

__construct($id, $link = null, $text = '', $title = '', $linkedwhenselected = false)   X-Ref
Constructor

param: string $id unique id of the tab in this tree, it is used to find selected and/or inactive tabs
param: string|moodle_url $link
param: string $text text on the tab
param: string $title title under the link, by defaul equals to text
param: bool $linkedwhenselected whether to display a link under the tab name when it's selected

set_selected($selected)   X-Ref
Travels through tree and finds the tab to mark as selected, all parents are automatically marked as activated

param: string $selected the id of the selected tab (whatever row it's on),
return: bool whether this tab is selected or contains selected tab in its subtree

find($id)   X-Ref
Travels through tree and finds a tab with specified id

param: string $id
return: tabtree|null

set_level($level)   X-Ref
Allows to mark each tab's level in the tree before rendering.

param: int $level

export_for_template(renderer_base $output)   X-Ref
Export for template.

param: renderer_base $output Renderer.
return: object

Class: context_header  - X-Ref

Renderable for the main page header.

__construct($heading = null, $headinglevel = 1, $imagedata = null, $additionalbuttons = null, $prefix = null)   X-Ref
Constructor.

param: string $heading Main heading data.
param: int $headinglevel Main heading 'h' tag level.
param: string|null $imagedata HTML code for the picture in the page header.
param: string $additionalbuttons Buttons for the header e.g. Messaging button for the user header.
param: string $prefix Text that precedes the heading.

format_button_images()   X-Ref
Adds an array element for a formatted image.


Class: tabtree  - X-Ref

Stores tabs list

Example how to print a single line tabs:
$rows = array(
new tabobject(...),
new tabobject(...)
);
echo $OUTPUT->tabtree($rows, $selectedid);

Multiple row tabs may not look good on some devices but if you want to use them
you can specify ->subtree for the active tabobject.

__construct($tabs, $selected = null, $inactive = null)   X-Ref
Constuctor

It is highly recommended to call constructor when list of tabs is already
populated, this way you ensure that selected and inactive tabs are located
and attribute level is set correctly.

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

export_for_template(renderer_base $output)   X-Ref
Export for template.

param: renderer_base $output Renderer.
return: object

Class: action_menu  - X-Ref

An action menu.

This action menu component takes a series of primary and secondary actions.
The primary actions are displayed permanently and the secondary attributes are displayed within a drop
down menu.

__construct(array $actions = array()   X-Ref
Constructs the action menu with the given items.

param: array $actions An array of actions (action_menu_link|pix_icon|string).

set_action_label($label)   X-Ref
Sets the label for the menu trigger.

param: string $label The text

set_menu_trigger($trigger, $extraclasses = '')   X-Ref
Sets the menu trigger text.

param: string $trigger The text
param: string $extraclasses Extra classes to style the secondary menu toggle.

is_empty()   X-Ref
Return true if there is at least one visible link in the menu.

return: bool

initialise_js(moodle_page $page)   X-Ref
Initialises JS required fore the action menu.
The JS is only required once as it manages all action menu's on the page.

param: moodle_page $page

add($action)   X-Ref
Adds an action to this action menu.

param: action_menu_link|pix_icon|string $action

add_primary_action($action)   X-Ref
Adds a primary action to the action menu.

param: action_menu_link|action_link|pix_icon|string $action

add_secondary_action($action)   X-Ref
Adds a secondary action to the action menu.

param: action_link|pix_icon|string $action

get_primary_actions(core_renderer $output = null)   X-Ref
Returns the primary actions ready to be rendered.

param: core_renderer $output The renderer to use for getting icons.
return: array

get_secondary_actions()   X-Ref
Returns the secondary actions ready to be rendered.

return: array

set_owner_selector($selector)   X-Ref
Sets the selector that should be used to find the owning node of this menu.

param: string $selector A CSS/YUI selector to identify the owner of the menu.

set_alignment($dialogue, $button)   X-Ref
Sets the alignment of the dialogue in relation to button used to toggle it.

param: int $dialogue One of action_menu::TL, action_menu::TR, action_menu::BL, action_menu::BR.
param: int $button One of action_menu::TL, action_menu::TR, action_menu::BL, action_menu::BR.

get_align_string($align)   X-Ref
Returns a string to describe the alignment.

param: int $align One of action_menu::TL, action_menu::TR, action_menu::BL, action_menu::BR.
return: string

set_menu_left()   X-Ref
Aligns the left corner of the dropdown.


set_constraint($ancestorselector)   X-Ref
Sets a constraint for the dialogue.

The constraint is applied when the dialogue is shown and limits the display of the dialogue to within the
element the constraint identifies.

This is required whenever the action menu is displayed inside any CSS element with the .no-overflow class
(flexible_table and any of it's child classes are a likely candidate).

param: string $ancestorselector A snippet of CSS used to identify the ancestor to contrain the dialogue to.

set_boundary(string $boundary)   X-Ref
Set the overflow constraint boundary of the dropdown menu.

param: string $boundary Accepts the values of 'viewport', 'window', or 'scrollParent'.

do_not_enhance()   X-Ref
If you call this method the action menu will be displayed but will not be enhanced.

By not displaying the menu enhanced all items will be displayed in a single row.


will_be_enhanced()   X-Ref
Returns true if this action menu will be enhanced.

return: bool

set_nowrap_on_items($value = true)   X-Ref
Sets nowrap on items. If true menu items should not wrap lines if they are longer than the available space.

This property can be useful when the action menu is displayed within a parent element that is either floated
or relatively positioned.
In that situation the width of the menu is determined by the width of the parent element which may not be large
enough for the menu items without them wrapping.
This disables the wrapping so that the menu takes on the width of the longest item.

param: bool $value If true nowrap gets set, if false it gets removed. Defaults to true.

set_additional_classes(string $class = '')   X-Ref
Add classes to the action menu for an easier styling.

param: string $class The class to add to attributes.

export_for_template(renderer_base $output)   X-Ref
Export for template.

param: renderer_base $output The renderer.
return: stdClass

Class: action_menu_filler  - X-Ref

An action menu filler

__construct()   X-Ref
Constructs the object.


Class: action_menu_link  - X-Ref

An action menu action

__construct(moodle_url $url, ?pix_icon $icon, $text, $primary = true, array $attributes = array()   X-Ref
Constructs the object.

param: moodle_url $url The URL for the action.
param: pix_icon|null $icon The icon to represent the action.
param: string $text The text to represent the action.
param: bool $primary Whether this is a primary action or not.
param: array $attributes Any attribtues associated with the action.

export_for_template(renderer_base $output)   X-Ref
Export for template.

param: renderer_base $output The renderer.
return: stdClass

Class: action_menu_link_primary  - X-Ref

A primary action menu action

__construct(moodle_url $url, ?pix_icon $icon, $text, array $attributes = array()   X-Ref
Constructs the object.

param: moodle_url $url
param: pix_icon|null $icon
param: string $text
param: array $attributes

Class: action_menu_link_secondary  - X-Ref

A secondary action menu action

__construct(moodle_url $url, ?pix_icon $icon, $text, array $attributes = array()   X-Ref
Constructs the object.

param: moodle_url $url
param: pix_icon|null $icon
param: string $text
param: array $attributes

Class: preferences_groups  - X-Ref

Represents a set of preferences groups.

__construct($groups)   X-Ref
Constructor.

param: array $groups of preferences_group

Class: preferences_group  - X-Ref

Represents a group of preferences page link.

__construct($title, $nodes)   X-Ref
Constructor.

param: string $title The title.
param: array $nodes of navigation_node.

Class: progress_bar  - X-Ref

Progress bar class.

Manages the display of a progress bar.

To use this class.
- construct
- call create (or use the 3rd param to the constructor)
- call update or update_full() or update() repeatedly

__construct($htmlid = '', $width = 500, $autostart = false)   X-Ref
Constructor

Prints JS code if $autostart true.

param: string $htmlid The container ID.
param: int $width The suggested width.
param: bool $autostart Whether to start the progress bar right away.

get_id()   X-Ref
Getter for ID

return: string id

create()   X-Ref
Create a new progress bar, this function will output html.

return: void Echo's output

_update($percent, $msg)   X-Ref
Update the progress bar.

param: int $percent From 1-100.
param: string $msg The message.
return: void Echo's output

estimate($pt)   X-Ref
Estimate how much time it is going to take.

param: int $pt From 1-100.
return: mixed Null (unknown), or int.

update_full($percent, $msg)   X-Ref
Update progress bar according percent.

param: int $percent From 1-100.
param: string $msg The message needed to be shown.

update($cur, $total, $msg)   X-Ref
Update progress bar according the number of tasks.

param: int $cur Current task number.
param: int $total Total task number.
param: string $msg The message needed to be shown.

restart()   X-Ref
Restart the progress bar.


export_for_template(renderer_base $output)   X-Ref
Export for template.

param: renderer_base $output The renderer.
return: array