Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
/lib/ -> weblib.php (source)

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

Library of functions for web output Library of all general-purpose Moodle PHP functions and constants that produce HTML output

Copyright: 1999 onwards Martin Dougiamas {@link http://moodle.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 3743 lines (129 kb)
Included or required:0 times
Referenced: 3 times
Includes or requires: 0 files

Defines 9 classes

moodle_url:: (86 methods):
  __construct()
  params()
  remove_params()
  remove_all_params()
  param()
  merge_overrideparams()
  get_query_string()
  __toString()
  out()
  raw_out()
  out_omit_querystring()
  compare()
  set_anchor()
  set_scheme()
  set_slashargument()
  make_file_url()
  make_pluginfile_url()
  make_webservice_pluginfile_url()
  make_draftfile_url()
  make_legacyfile_url()
  out_as_local_url()
  get_path()
  get_param()
  get_scheme()
  get_host()
  get_port()
  data_submitted()
  break_up_long_words()
  close_window()
  page_doc_link()
  page_get_doc_link_path()
  validate_email()
  get_file_argument()
  format_text_menu()
  format_text()
  reset_text_filters_cache()
  format_string()
  replace_ampersands_not_followed_by_entity()
  strip_links()
  wikify_links()
  format_text_email()
  format_module_intro()
  strip_pluginfile_content()
  trusttext_strip()
  trusttext_pre_edit()
  trusttext_trusted()
  trusttext_active()
  clean_text()
  is_purify_html_necessary()
  purify_html()
  text_to_html()
  markdown_to_html()
  html_to_text()
  content_to_text()
  extract_draft_file_urls_from_text()
  highlight()
  highlightfast()
  get_html_lang()
  send_headers()
  link_arrow_right()
  link_arrow_left()
  get_accesshide()
  get_separator()
  print_collapsible_region()
  print_collapsible_region_start()
  print_collapsible_region_end()
  print_group_picture()
  get_group_picture_url()
  print_recent_activity_note()
  navmenulist()
  print_grade_menu()
  mdie()
  notice()
  redirect()
  obfuscate_email()
  obfuscate_text()
  obfuscate_mailto()
  rebuildnolinktag()
  print_maintenance_message()
  print_tabs()
  set_debugging()
  debugging()
  print_location_comment()
  right_to_left()
  fix_align_rtl()
  is_in_popup()

progress_trace:: (1 method):
  finished()

null_progress_trace:: (1 method):
  output()

text_progress_trace:: (1 method):
  output()

html_progress_trace:: (1 method):
  output()

html_list_progress_trace:: (2 methods):
  output()
  finished()

error_log_progress_trace:: (2 methods):
  __construct()
  output()

progress_trace_buffer:: (5 methods):
  __construct()
  output()
  finished()
  reset_buffer()
  get_buffer()

combined_progress_trace:: (5 methods):
  __construct()
  output()
  finished()
  print_password_policy()
  get_formatted_help_string()

Defines 5 functions

  s()
  p()
  addslashes_js()
  strip_querystring()
  me()
  qualified_me()
  is_https()
  get_local_referer()

Class: moodle_url  - X-Ref

Class for creating and manipulating urls.

It can be used in moodle pages where config.php has been included without any further includes.

It is useful for manipulating urls with long lists of params.
One situation where it will be useful is a page which links to itself to perform various actions
and / or to process form data. A moodle_url object :
can be created for a page to refer to itself with all the proper get params being passed from page call to
page call and methods can be used to output a url including all the params, optionally adding and overriding
params and can also be used to
- output the url without any get params
- and output the params as hidden fields to be output within a form

__construct($url, array $params = null, $anchor = null)   X-Ref
Create new instance of moodle_url.

param: moodle_url|string $url - moodle_url means make a copy of another
param: array $params these params override current params or add new
param: string $anchor The anchor to use as part of the URL if there is one.

params(array $params = null)   X-Ref
Add an array of params to the params for this url.

The added params override existing ones if they have the same name.

param: array $params Defaults to null. If null then returns all params.
return: array Array of Params for url.

remove_params($params = null)   X-Ref
Remove all params if no arguments passed.
Remove selected params if arguments are passed.

Can be called as either remove_params('param1', 'param2')
or remove_params(array('param1', 'param2')).

param: string[]|string $params,... either an array of param names, or 1..n string params to remove as args.
return: array url parameters

remove_all_params($params = null)   X-Ref
Remove all url parameters.

param: array $params Unused param
return: void

param($paramname, $newvalue = '')   X-Ref
Add a param to the params for this url.

The added param overrides existing one if they have the same name.

param: string $paramname name
param: string $newvalue Param value. If new value specified current value is overriden or parameter is added
return: mixed string parameter value, null if parameter does not exist

merge_overrideparams(array $overrideparams = null)   X-Ref
Merges parameters and validates them

param: array $overrideparams
return: array merged parameters

get_query_string($escaped = true, array $overrideparams = null)   X-Ref
Get the params as as a query string.

This method should not be used outside of this method.

param: bool $escaped Use & as params separator instead of plain &
param: array $overrideparams params to add to the output params, these
return: string query string that can be added to a url.

__toString()   X-Ref
Shortcut for printing of encoded URL.

return: string

out($escaped = true, array $overrideparams = null)   X-Ref
Output url.

If you use the returned URL in HTML code, you want the escaped ampersands. If you use
the returned URL in HTTP headers, you want $escaped=false.

param: bool $escaped Use & as params separator instead of plain &
param: array $overrideparams params to add to the output url, these override existing ones with the same name.
return: string Resulting URL

raw_out($escaped = true, array $overrideparams = null)   X-Ref
Output url without any rewrites

This is identical in signature and use to out() but doesn't call the rewrite handler.

param: bool $escaped Use & as params separator instead of plain &
param: array $overrideparams params to add to the output url, these override existing ones with the same name.
return: string Resulting URL

out_omit_querystring($includeanchor = false)   X-Ref
Returns url without parameters, everything before '?'.

param: bool $includeanchor if {@link self::anchor} is defined, should it be returned?
return: string

compare(moodle_url $url, $matchtype = URL_MATCH_EXACT)   X-Ref
Compares this moodle_url with another.

See documentation of constants for an explanation of the comparison flags.

param: moodle_url $url The moodle_url object to compare
param: int $matchtype The type of comparison (URL_MATCH_BASE, URL_MATCH_PARAMS, URL_MATCH_EXACT)
return: bool

set_anchor($anchor)   X-Ref
Sets the anchor for the URI (the bit after the hash)

param: string $anchor null means remove previous

set_scheme($scheme)   X-Ref
Sets the scheme for the URI (the bit before ://)

param: string $scheme

set_slashargument($path, $parameter = 'file', $supported = null)   X-Ref
Sets the url slashargument value.

param: string $path usually file path
param: string $parameter name of page parameter if slasharguments not supported
param: bool $supported usually null, then it depends on $CFG->slasharguments, use true or false for other servers
return: void

make_file_url($urlbase, $path, $forcedownload = false)   X-Ref
General moodle file url.

param: string $urlbase the script serving the file
param: string $path
param: bool $forcedownload
return: moodle_url

make_pluginfile_url($contextid, $component, $area, $itemid, $pathname, $filename,$forcedownload = false, $includetoken = false)   X-Ref
Factory method for creation of url pointing to plugin file.

Please note this method can be used only from the plugins to
create urls of own files, it must not be used outside of plugins!

param: int $contextid
param: string $component
param: string $area
param: int $itemid
param: string $pathname
param: string $filename
param: bool $forcedownload
param: mixed $includetoken Whether to use a user token when displaying this group image.
return: moodle_url

make_webservice_pluginfile_url($contextid, $component, $area, $itemid, $pathname, $filename,$forcedownload = false)   X-Ref
Factory method for creation of url pointing to plugin file.
This method is the same that make_pluginfile_url but pointing to the webservice pluginfile.php script.
It should be used only in external functions.

param: int $contextid
param: string $component
param: string $area
param: int $itemid
param: string $pathname
param: string $filename
param: bool $forcedownload
return: moodle_url

make_draftfile_url($draftid, $pathname, $filename, $forcedownload = false)   X-Ref
Factory method for creation of url pointing to draft file of current user.

param: int $draftid draft item id
param: string $pathname
param: string $filename
param: bool $forcedownload
return: moodle_url

make_legacyfile_url($courseid, $filepath, $forcedownload = false)   X-Ref
Factory method for creating of links to legacy course files.

param: int $courseid
param: string $filepath
param: bool $forcedownload
return: moodle_url

out_as_local_url($escaped = true, array $overrideparams = null)   X-Ref
Returns URL a relative path from $CFG->wwwroot

Can be used for passing around urls with the wwwroot stripped

param: boolean $escaped Use & as params separator instead of plain &
param: array $overrideparams params to add to the output url, these override existing ones with the same name.
return: string Resulting URL

get_path($includeslashargument = true)   X-Ref
Returns the 'path' portion of a URL. For example, if the URL is
http://www.example.org:447/my/file/is/here.txt?really=1 then this will
return '/my/file/is/here.txt'.

By default the path includes slash-arguments (for example,
'/myfile.php/extra/arguments') so it is what you would expect from a
URL path. If you don't want this behaviour, you can opt to exclude the
slash arguments. (Be careful: if the $CFG variable slasharguments is
disabled, these URLs will have a different format and you may need to
look at the 'file' parameter too.)

param: bool $includeslashargument If true, includes slash arguments
return: string Path of URL

get_param($name)   X-Ref
Returns a given parameter value from the URL.

param: string $name Name of parameter
return: string Value of parameter or null if not set

get_scheme()   X-Ref
Returns the 'scheme' portion of a URL. For example, if the URL is
http://www.example.org:447/my/file/is/here.txt?really=1 then this will
return 'http' (without the colon).

return: string Scheme of the URL.

get_host()   X-Ref
Returns the 'host' portion of a URL. For example, if the URL is
http://www.example.org:447/my/file/is/here.txt?really=1 then this will
return 'www.example.org'.

return: string Host of the URL.

get_port()   X-Ref
Returns the 'port' portion of a URL. For example, if the URL is
http://www.example.org:447/my/file/is/here.txt?really=1 then this will
return '447'.

return: string Port of the URL.

data_submitted()   X-Ref
Determine if there is data waiting to be processed from a form

Used on most forms in Moodle to check for data
Returns the data as an object, if it's found.
This object can be used in foreach loops without
casting because it's cast to (array) automatically

Checks that submitted POST data exists and returns it as object.

return: mixed false or object

break_up_long_words($string, $maxsize=20, $cutchar=' ')   X-Ref
Given some normal text this function will break up any
long words to a given size by inserting the given character

It's multibyte savvy and doesn't change anything inside html tags.

param: string $string the string to be modified
param: int $maxsize maximum length of the string to be returned
param: string $cutchar the string used to represent word breaks
return: string

close_window($delay = 0, $reloadopener = false)   X-Ref
Try and close the current window using JavaScript, either immediately, or after a delay.

Echo's out the resulting XHTML & javascript

param: integer $delay a delay in seconds before closing the window. Default 0.
param: boolean $reloadopener if true, we will see if this window was a pop-up, and try

page_doc_link($text='')   X-Ref
Returns a string containing a link to the user documentation for the current page.

Also contains an icon by default. Shown to teachers and admin only.

param: string $text The text to be displayed for the link
return: string The link to user documentation for this current page

page_get_doc_link_path(moodle_page $page)   X-Ref
Returns the path to use when constructing a link to the docs.

param: moodle_page $page
return: string

validate_email($address)   X-Ref
Validates an email to make sure it makes sense.

param: string $address The email address to validate.
return: boolean

get_file_argument()   X-Ref
Extracts file argument either from file parameter or PATH_INFO

Note: $scriptname parameter is not needed anymore

return: string file path (only safe characters)

format_text_menu()   X-Ref
Just returns an array of text formats suitable for a popup menu

return: array

format_text($text, $format = FORMAT_MOODLE, $options = null, $courseiddonotuse = null)   X-Ref
Given text in a variety of format codings, this function returns the text as safe HTML.

This function should mainly be used for long strings like posts,
answers, glossary items etc. For short strings {@link format_string()}.

<pre>
Options:
trusted     :   If true the string won't be cleaned. Default false required noclean=true.
noclean     :   If true the string won't be cleaned, unless $CFG->forceclean is set. Default false required trusted=true.
nocache     :   If true the strign will not be cached and will be formatted every call. Default false.
filter      :   If true the string will be run through applicable filters as well. Default true.
para        :   If true then the returned string will be wrapped in div tags. Default true.
newlines    :   If true then lines newline breaks will be converted to HTML newline breaks. Default true.
context     :   The context that will be used for filtering.
overflowdiv :   If set to true the formatted text will be encased in a div
with the class no-overflow before being returned. Default false.
allowid     :   If true then id attributes will not be removed, even when
using htmlpurifier. Default false.
blanktarget :   If true all <a> tags will have target="_blank" added unless target is explicitly specified.
</pre>

param: string $text The text to be formatted. This is raw text originally from user input.
param: int $format Identifier of the text format to be used
param: object/array $options text formatting options
param: int $courseiddonotuse deprecated course id, use context option instead
return: string

reset_text_filters_cache($phpunitreset = false)   X-Ref
Resets some data related to filters, called during upgrade or when general filter settings change.

param: bool $phpunitreset true means called from our PHPUnit integration test reset
return: void

format_string($string, $striplinks = true, $options = null)   X-Ref
Given a simple string, this function returns the string
processed by enabled string filters if $CFG->filterall is enabled

This function should be used to print short strings (non html) that
need filter processing e.g. activity titles, post subjects,
glossary concepts.

param: string $string The string to be filtered. Should be plain text, expect
param: boolean $striplinks To strip any link in the result text. Moodle 1.8 default changed from false to true! MDL-8713
param: array $options options array/object or courseid
return: string

replace_ampersands_not_followed_by_entity($string)   X-Ref
Given a string, performs a negative lookahead looking for any ampersand character
that is not followed by a proper HTML entity. If any is found, it is replaced
by &amp;. The string is then returned.

param: string $string
return: string

strip_links($string)   X-Ref
Given a string, replaces all <a>.*</a> by .* and returns the string.

param: string $string
return: string

wikify_links($string)   X-Ref
This expression turns links into something nice in a text format. (Russell Jungwirth)

param: string $string
return: string

format_text_email($text, $format)   X-Ref
Given text in a variety of format codings, this function returns the text as plain text suitable for plain email.

param: string $text The text to be formatted. This is raw text originally from user input.
param: int $format Identifier of the text format to be used
return: string

format_module_intro($module, $activity, $cmid, $filter=true)   X-Ref
Formats activity intro text

param: string $module name of module
param: object $activity instance of activity
param: int $cmid course module id
param: bool $filter filter resulting html text
return: string

strip_pluginfile_content($source)   X-Ref
Removes the usage of Moodle files from a text.

In some rare cases we need to re-use a text that already has embedded links
to some files hosted within Moodle. But the new area in which we will push
this content does not support files... therefore we need to remove those files.

param: string $source The text
return: string The stripped text

trusttext_strip($text)   X-Ref
Legacy function, used for cleaning of old forum and glossary text only.

param: string $text text that may contain legacy TRUSTTEXT marker
return: string text without legacy TRUSTTEXT marker

trusttext_pre_edit($object, $field, $context)   X-Ref
Must be called before editing of all texts with trust flag. Removes all XSS nasties from texts stored in database if needed.

param: stdClass $object data object with xxx, xxxformat and xxxtrust fields
param: string $field name of text field
param: context $context active context
return: stdClass updated $object

trusttext_trusted($context)   X-Ref
Is current user trusted to enter no dangerous XSS in this context?

Please note the user must be in fact trusted everywhere on this server!!

param: context $context
return: bool true if user trusted

trusttext_active()   X-Ref
Is trusttext feature active?

return: bool

clean_text($text, $format = FORMAT_HTML, $options = array()   X-Ref
Cleans raw text removing nasties.

Given raw text (eg typed in by a user) this function cleans it up and removes any nasty tags that could mess up
Moodle pages through XSS attacks.

The result must be used as a HTML text fragment, this function can not cleanup random
parts of html tags such as url or src attributes.

NOTE: the format parameter was deprecated because we can safely clean only HTML.

param: string $text The text to be cleaned
param: int|string $format deprecated parameter, should always contain FORMAT_HTML or FORMAT_MOODLE
param: array $options Array of options; currently only option supported is 'allowid' (if true,
return: string The cleaned up text

is_purify_html_necessary($text)   X-Ref
Is it necessary to use HTMLPurifier?

param: string $text
return: bool false means html is safe and valid, true means use HTMLPurifier

purify_html($text, $options = array()   X-Ref
KSES replacement cleaning function - uses HTML Purifier.

param: string $text The (X)HTML string to purify
param: array $options Array of options; currently only option supported is 'allowid' (if set,
return: string

text_to_html($text, $smileyignored = null, $para = true, $newlines = true)   X-Ref
Given plain text, makes it into HTML as nicely as possible.

May contain HTML tags already.

Do not abuse this function. It is intended as lower level formatting feature used
by {@link format_text()} to convert FORMAT_MOODLE to HTML. You are supposed
to call format_text() in most of cases.

param: string $text The string to convert.
param: boolean $smileyignored Was used to determine if smiley characters should convert to smiley images, ignored now
param: boolean $para If true then the returned string will be wrapped in div tags
param: boolean $newlines If true then lines newline breaks will be converted to HTML newline breaks.
return: string

markdown_to_html($text)   X-Ref
Given Markdown formatted text, make it into XHTML using external function

param: string $text The markdown formatted text to be converted.
return: string Converted text

html_to_text($html, $width = 75, $dolinks = true)   X-Ref
Given HTML text, make it into plain text using external function

param: string $html The text to be converted.
param: integer $width Width to wrap the text at. (optional, default 75 which
param: boolean $dolinks By default, any links in the HTML are collected, and
return: string plain text equivalent of the HTML.

content_to_text($content, $contentformat)   X-Ref
Converts texts or strings to plain text.

- When used to convert user input introduced in an editor the text format needs to be passed in $contentformat like we usually
do in format_text.
- When this function is used for strings that are usually passed through format_string before displaying them
we need to set $contentformat to false. This will execute html_to_text as these strings can contain multilang tags if
multilang filter is applied to headings.

param: string $content The text as entered by the user
param: int|false $contentformat False for strings or the text format: FORMAT_MOODLE/FORMAT_HTML/FORMAT_PLAIN/FORMAT_MARKDOWN
return: string Plain text.

extract_draft_file_urls_from_text($text, $forcehttps = false, $contextid = null, $component = null,$filearea = null, $itemid = null, $filename = null)   X-Ref
Factory method for extracting draft file links from arbitrary text using regular expressions. Only text
is required; other file fields may be passed to filter.

param: string $text Some html content.
param: bool $forcehttps force https urls.
param: int $contextid This parameter and the next three identify the file area to save to.
param: string $component The component name.
param: string $filearea The filearea.
param: int $itemid The item id for the filearea.
param: string $filename The specific filename of the file.
return: array

highlight($needle, $haystack, $matchcase = false,$prefix = '<span class="highlight">', $suffix = '</span>')   X-Ref
This function will highlight search words in a given string

It cares about HTML and will not ruin links.  It's best to use
this function after performing any conversions to HTML.

param: string $needle The search string. Syntax like "word1 +word2 -word3" is dealt with correctly.
param: string $haystack The string (HTML) within which to highlight the search terms.
param: boolean $matchcase whether to do case-sensitive. Default case-insensitive.
param: string $prefix the string to put before each search term found.
param: string $suffix the string to put after each search term found.
return: string The highlighted HTML.

highlightfast($needle, $haystack)   X-Ref
This function will highlight instances of $needle in $haystack

It's faster that the above function {@link highlight()} and doesn't care about
HTML or anything.

param: string $needle The string to search for
param: string $haystack The string to search for $needle in
return: string The highlighted HTML

get_html_lang($dir = false)   X-Ref
Return a string containing 'lang', xml:lang and optionally 'dir' HTML attributes.

Internationalisation, for print_header and backup/restorelib.

param: bool $dir Default false
return: string Attributes

send_headers($contenttype, $cacheable = true)   X-Ref
Send the HTTP headers that Moodle requires.

There is a backwards compatibility hack for legacy code
that needs to add custom IE compatibility directive.

Example:
<code>
if (!isset($CFG->additionalhtmlhead)) {
$CFG->additionalhtmlhead = '';
}
$CFG->additionalhtmlhead .= '<meta http-equiv="X-UA-Compatible" content="IE=8" />';
header('X-UA-Compatible: IE=8');
echo $OUTPUT->header();
</code>

Please note the $CFG->additionalhtmlhead alone might not work,
you should send the IE compatibility header() too.

param: string $contenttype
param: bool $cacheable Can this page be cached on back?
return: void, sends HTTP headers

link_arrow_right($text, $url='', $accesshide=false, $addclass='', $addparams = [])   X-Ref
Return the right arrow with text ('next'), and optionally embedded in a link.

param: string $text HTML/plain text label (set to blank only for breadcrumb separator cases).
param: string $url An optional link to use in a surrounding HTML anchor.
param: bool $accesshide True if text should be hidden (for screen readers only).
param: string $addclass Additional class names for the link, or the arrow character.
return: string HTML string.

link_arrow_left($text, $url='', $accesshide=false, $addclass='', $addparams = [])   X-Ref
Return the left arrow with text ('previous'), and optionally embedded in a link.

param: string $text HTML/plain text label (set to blank only for breadcrumb separator cases).
param: string $url An optional link to use in a surrounding HTML anchor.
param: bool $accesshide True if text should be hidden (for screen readers only).
param: string $addclass Additional class names for the link, or the arrow character.
return: string HTML string.

get_accesshide($text, $elem='span', $class='', $attrs='')   X-Ref
Return a HTML element with the class "accesshide", for accessibility.

Please use cautiously - where possible, text should be visible!

param: string $text Plain text.
param: string $elem Lowercase element name, default "span".
param: string $class Additional classes for the element.
param: string $attrs Additional attributes string in the form, "name='value' name2='value2'"
return: string HTML string.

get_separator()   X-Ref
Return the breadcrumb trail navigation separator.

return: string HTML string.

print_collapsible_region($contents, $classes, $id, $caption, $userpref = '', $default = false, $return = false)   X-Ref
Print (or return) a collapsible region, that has a caption that can be clicked to expand or collapse the region.

If JavaScript is off, then the region will always be expanded.

param: string $contents the contents of the box.
param: string $classes class names added to the div that is output.
param: string $id id added to the div that is output. Must not be blank.
param: string $caption text displayed at the top. Clicking on this will cause the region to expand or contract.
param: string $userpref the name of the user preference that stores the user's preferred default state.
param: boolean $default Initial collapsed state to use if the user_preference it not set.
param: boolean $return if true, return the HTML as a string, rather than printing it.
return: string|void If $return is false, returns nothing, otherwise returns a string of HTML.

print_collapsible_region_start($classes, $id, $caption, $userpref = '', $default = false, $return = false,$extracontent = null)   X-Ref
Print (or return) the start of a collapsible region

The collapsibleregion has a caption that can be clicked to expand or collapse the region. If JavaScript is off, then the region
will always be expanded.

param: string $classes class names added to the div that is output.
param: string $id id added to the div that is output. Must not be blank.
param: string $caption text displayed at the top. Clicking on this will cause the region to expand or contract.
param: string $userpref the name of the user preference that stores the user's preferred default state.
param: boolean $default Initial collapsed state to use if the user_preference it not set.
param: boolean $return if true, return the HTML as a string, rather than printing it.
param: string $extracontent the extra content will show next to caption, eg.Help icon.
return: string|void if $return is false, returns nothing, otherwise returns a string of HTML.

print_collapsible_region_end($return = false)   X-Ref
Close a region started with print_collapsible_region_start.

param: boolean $return if true, return the HTML as a string, rather than printing it.
return: string|void if $return is false, returns nothing, otherwise returns a string of HTML.

print_group_picture($group, $courseid, $large = false, $return = false, $link = true, $includetoken = false)   X-Ref
Print a specified group's avatar.

param: array|stdClass $group A single {@link group} object OR array of groups.
param: int $courseid The course ID.
param: boolean $large Default small picture, or large.
param: boolean $return If false print picture, otherwise return the output as string
param: boolean $link Enclose image in a link to view specified course?
param: boolean $includetoken Whether to use a user token when displaying this group image.
return: string|void Depending on the setting of $return

get_group_picture_url($group, $courseid, $large = false, $includetoken = false)   X-Ref
Return the url to the group picture.

param: stdClass $group A group object.
param: int $courseid The course ID for the group.
param: bool $large A large or small group picture? Default is small.
param: boolean $includetoken Whether to use a user token when displaying this group image.
return: moodle_url Returns the url for the group picture.

print_recent_activity_note($time, $user, $text, $link, $return=false, $viewfullnames=null)   X-Ref
Display a recent activity note

param: int $time A timestamp int.
param: stdClass $user A user object from the database.
param: string $text Text for display for the note
param: string $link The link to wrap around the text
param: bool $return If set to true the HTML is returned rather than echo'd
param: string $viewfullnames
return: string If $retrun was true returns HTML for a recent activity notice.

navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $width=50, $cmid=0)   X-Ref
Returns a popup menu with course activity modules

Given a course this function returns a small popup menu with all the course activity modules in it, as a navigation menu
outputs a simple list structure in XHTML.
The data is taken from the serialised array stored in the course record.

param: course $course A {@link $COURSE} object.
param: array $sections
param: course_modinfo $modinfo
param: string $strsection
param: string $strjumpto
param: int $width
param: string $cmid
return: string The HTML block

print_grade_menu($courseid, $name, $current, $includenograde=true, $return=false)   X-Ref
Prints a grade menu (as part of an existing form) with help showing all possible numerical grades and scales.

param: int $courseid The course ID
param: string $name
param: string $current
param: boolean $includenograde Include those with no grades
param: boolean $return If set to true returns rather than echo's
return: string|bool Depending on value of $return

mdie($msg='', $errorcode=1)   X-Ref
Print an error to STDOUT and exit with a non-zero code. For commandline scripts.

Default errorcode is 1.

Very useful for perl-like error-handling:
do_somethting() or mdie("Something went wrong");

param: string  $msg       Error message
param: integer $errorcode Error code to emit

notice($message, $link='', $course=null)   X-Ref
Print a message and exit.

param: string $message The message to print in the notice
param: moodle_url|string $link The link to use for the continue button
param: object $course A course object. Unused.
return: void This function simply exits

redirect($url, $message='', $delay=null, $messagetype = \core\output\notification::NOTIFY_INFO)   X-Ref
Redirects the user to another page, after printing a notice.

This function calls the OUTPUT redirect method, echo's the output and then dies to ensure nothing else happens.

<strong>Good practice:</strong> You should call this method before starting page
output by using any of the OUTPUT methods.

param: moodle_url|string $url A moodle_url to redirect to. Strings are not to be trusted!
param: string $message The message to display to the user
param: int $delay The delay before redirecting
param: string $messagetype The type of notification to show the message in. See constants on \core\output\notification.

obfuscate_email($email)   X-Ref
Given an email address, this function will return an obfuscated version of it.

param: string $email The email address to obfuscate
return: string The obfuscated email address

obfuscate_text($plaintext)   X-Ref
This function takes some text and replaces about half of the characters
with HTML entity equivalents.   Return string is obviously longer.

param: string $plaintext The text to be obfuscated
return: string The obfuscated text

obfuscate_mailto($email, $label='', $dimmed=false, $subject = '', $body = '')   X-Ref
This function uses the {@link obfuscate_email()} and {@link obfuscate_text()}
to generate a fully obfuscated email link, ready to use.

param: string $email The email address to display
param: string $label The text to displayed as hyperlink to $email
param: boolean $dimmed If true then use css class 'dimmed' for hyperlink
param: string $subject The subject of the email in the mailto link
param: string $body The content of the email in the mailto link
return: string The obfuscated mailto link

rebuildnolinktag($text)   X-Ref
This function is used to rebuild the <nolink> tag because some formats (PLAIN and WIKI)
will transform it to html entities

param: string $text Text to search for nolink tag in
return: string

print_maintenance_message()   X-Ref
Prints a maintenance message from $CFG->maintenance_message or default if empty.


print_tabs($tabrows, $selected = null, $inactive = null, $activated = null, $return = false)   X-Ref
Returns a string containing a nested list, suitable for formatting into tabs with CSS.

It is not recommended to use this function in Moodle 2.5 but it is left for backward
compartibility.

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.

param: array $tabrows An array of rows where each row is an array of tab objects
param: string $selected  The id of the selected tab (whatever row it's on)
param: array  $inactive  An array of ids of inactive tabs that are not selectable.
param: array  $activated An array of ids of other tabs that are currently activated
param: bool $return If true output is returned rather then echo'd
return: string HTML output if $return was set to true.

set_debugging($level, $debugdisplay = null)   X-Ref
Alter debugging level for the current request,
the change is not saved in database.

param: int $level one of the DEBUG_* constants
param: bool $debugdisplay

debugging($message = '', $level = DEBUG_NORMAL, $backtrace = null)   X-Ref
Standard Debugging Function

Returns true if the current site debugging settings are equal or above specified level.
If passed a parameter it will emit a debugging notice similar to trigger_error(). The
routing of notices is controlled by $CFG->debugdisplay
eg use like this:

1)  debugging('a normal debug notice');
2)  debugging('something really picky', DEBUG_ALL);
3)  debugging('annoying debug message only for developers', DEBUG_DEVELOPER);
4)  if (debugging()) { perform extra debugging operations (do not use print or echo) }

In code blocks controlled by debugging() (such as example 4)
any output should be routed via debugging() itself, or the lower-level
trigger_error() or error_log(). Using echo or print will break XHTML
JS and HTTP headers.

It is also possible to define NO_DEBUG_DISPLAY which redirects the message to error_log.

param: string $message a message to print
param: int $level the level at which this debugging statement should show
param: array $backtrace use different backtrace
return: bool

print_location_comment($file, $line, $return = false)   X-Ref
Outputs a HTML comment to the browser.

This is used for those hard-to-debug pages that use bits from many different files in very confusing ways (e.g. blocks).

<code>print_location_comment(__FILE__, __LINE__);</code>

param: string $file
param: integer $line
param: boolean $return Whether to return or print the comment
return: string|void Void unless true given as third parameter

right_to_left()   X-Ref
Returns true if the user is using a right-to-left language.

return: boolean true if the current language is right-to-left (Hebrew, Arabic etc)

fix_align_rtl($align)   X-Ref
Returns swapped left<=> right if in RTL environment.

Part of RTL Moodles support.

param: string $align align to check
return: string

is_in_popup()   X-Ref
Returns true if the page is displayed in a popup window.

Gets the information from the URL parameter inpopup.

return: boolean

Class: progress_trace  - X-Ref

Progress trace class.

Use this class from long operations where you want to output occasional information about
what is going on, but don't know if, or in what format, the output should be.

finished()   X-Ref
Called when the processing is finished.


Class: null_progress_trace  - X-Ref

This subclass of progress_trace does not ouput anything.

output($message, $depth = 0)   X-Ref
Does Nothing

param: string $message
param: int $depth
return: void Does Nothing

Class: text_progress_trace  - X-Ref

This subclass of progress_trace outputs to plain text.

output($message, $depth = 0)   X-Ref
Output the trace message.

param: string $message
param: int $depth
return: void Output is echo'd

Class: html_progress_trace  - X-Ref

This subclass of progress_trace outputs as HTML.

output($message, $depth = 0)   X-Ref
Output the trace message.

param: string $message
param: int $depth
return: void Output is echo'd

Class: html_list_progress_trace  - X-Ref

HTML List Progress Tree

output($message, $depth = 0)   X-Ref
Echo out the list

param: string $message The message to display
param: int $depth
return: void Output is echoed

finished()   X-Ref
Called when the processing is finished.


Class: error_log_progress_trace  - X-Ref

This subclass of progress_trace outputs to error log.

__construct($prefix = '')   X-Ref
Constructor.

param: string $prefix optional log prefix

output($message, $depth = 0)   X-Ref
Output the trace message.

param: string $message
param: int $depth
return: void Output is sent to error log.

Class: progress_trace_buffer  - X-Ref

Special type of trace that can be used for catching of output of other traces.

__construct(progress_trace $trace, $passthrough = true)   X-Ref
Constructor.

param: progress_trace $trace
param: bool $passthrough true means output and buffer, false means just buffer and no output

output($message, $depth = 0)   X-Ref
Output the trace message.

param: string $message the message to output.
param: int $depth indent depth for this message.
return: void output stored in buffer

finished()   X-Ref
Called when the processing is finished.


reset_buffer()   X-Ref
Reset internal text buffer.


get_buffer()   X-Ref
Return internal text buffer.

return: string buffered plain text

Class: combined_progress_trace  - X-Ref

Special type of trace that can be used for redirecting to multiple other traces.

__construct(array $traces)   X-Ref
Constructs a new instance.

param: array $traces multiple traces

output($message, $depth = 0)   X-Ref
Output an progress message in whatever format.

param: string $message the message to output.
param: integer $depth indent depth for this message.

finished()   X-Ref
Called when the processing is finished.


print_password_policy()   X-Ref
Returns a localized sentence in the current language summarizing the current password policy

return: string

get_formatted_help_string($identifier, $component, $ajax = false, $a = null)   X-Ref
Get the value of a help string fully prepared for display in the current language.

param: string $identifier The identifier of the string to search for.
param: string $component The module the string is associated with.
param: boolean $ajax Whether this help is called from an AJAX script.
param: string|object|array $a An object, string or number that can be used
return: Object An object containing:

Functions that are not part of a class:

s($var)   X-Ref
Add quotes to HTML characters.

Returns $var with HTML characters (like "<", ">", etc.) properly quoted.
Related function {@link p()} simply prints the output of this function.

param: string $var the string potentially containing HTML characters
return: string

p($var)   X-Ref
Add quotes to HTML characters.

Prints $var with HTML characters (like "<", ">", etc.) properly quoted.
This function simply calls & displays {@link s()}.
param: string $var the string potentially containing HTML characters
return: string

addslashes_js($var)   X-Ref
Does proper javascript quoting.

Do not use addslashes anymore, because it does not work when magic_quotes_sybase is enabled.

param: mixed $var String, Array, or Object to add slashes to
return: mixed quoted result

strip_querystring($url)   X-Ref
Remove query string from url.

Takes in a URL and returns it without the querystring portion.

param: string $url the url which may have a query string attached.
return: string The remaining URL.

me()   X-Ref
Returns the name of the current script, WITH the querystring portion.

This function is necessary because PHP_SELF and REQUEST_URI and SCRIPT_NAME
return different things depending on a lot of things like your OS, Web
server, and the way PHP is compiled (ie. as a CGI, module, ISAPI, etc.)
<b>NOTE:</b> This function returns false if the global variables needed are not set.

return: mixed String or false if the global variables needed are not set.

qualified_me()   X-Ref
Guesses the full URL of the current script.

This function is using $PAGE->url, but may fall back to $FULLME which
is constructed from  PHP_SELF and REQUEST_URI or SCRIPT_NAME

return: mixed full page URL string or false if unknown

is_https()   X-Ref
Determines whether or not the Moodle site is being served over HTTPS.

This is done simply by checking the value of $CFG->wwwroot, which seems
to be the only reliable method.

return: boolean True if site is served over HTTPS, false otherwise.

get_local_referer($stripquery = true)   X-Ref
Returns the cleaned local URL of the HTTP_REFERER less the URL query string parameters if required.

param: bool $stripquery if true, also removes the query part of the url.
return: string The resulting referer or empty string.