Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
weblib.php File Reference

Classes

class  combined_progress_trace
 Special type of trace that can be used for redirecting to multiple other traces. More...
 
class  error_log_progress_trace
 This subclass of progress_trace outputs to error log. More...
 
class  html_list_progress_trace
 HTML List Progress Tree. More...
 
class  html_progress_trace
 This subclass of progress_trace outputs as HTML. More...
 
class  moodle_url
 Class for creating and manipulating urls. More...
 
class  null_progress_trace
 This subclass of progress_trace does not ouput anything. More...
 
class  progress_trace
 Progress trace class. More...
 
class  progress_trace_buffer
 Special type of trace that can be used for catching of output of other traces. More...
 
class  text_progress_trace
 This subclass of progress_trace outputs to plain text. More...
 

Functions

 addslashes_js ($var)
 Does proper javascript quoting.
 
 break_up_long_words ($string, $maxsize=20, $cutchar=' ')
 Given some normal text this function will break up any long words to a given size by inserting the given character.
 
 clean_text ($text, $format=FORMAT_HTML, $options=array())
 Cleans raw text removing nasties.
 
 close_window ($delay=0, $reloadopener=false)
 Try and close the current window using JavaScript, either immediately, or after a delay.
 
 content_to_text ($content, $contentformat)
 Converts texts or strings to plain text.
 
 data_submitted ()
 Determine if there is data waiting to be processed from a form.
 
 debugging ($message='', $level=DEBUG_NORMAL, $backtrace=null)
 Standard Debugging Function.
 
 extract_draft_file_urls_from_text ($text, $forcehttps=false, $contextid=null, $component=null, $filearea=null, $itemid=null, $filename=null)
 Factory method for extracting draft file links from arbitrary text using regular expressions.
 
 fix_align_rtl ($align)
 Returns swapped left<=> right if in RTL environment.
 
 format_module_intro ($module, $activity, $cmid, $filter=true)
 Formats activity intro text.
 
 format_string ($string, $striplinks=true, $options=null)
 Given a simple string, this function returns the string processed by enabled string filters if $CFG->filterall is enabled.
 
 format_text ($text, $format=FORMAT_MOODLE, $options=null, $courseiddonotuse=null)
 Given text in a variety of format codings, this function returns the text as safe HTML.
 
 format_text_email ($text, $format)
 Given text in a variety of format codings, this function returns the text as plain text suitable for plain email.
 
 format_text_menu ()
 Just returns an array of text formats suitable for a popup menu.
 
 get_accesshide ($text, $elem='span', $class='', $attrs='')
 Return a HTML element with the class "accesshide", for accessibility.
 
 get_file_argument ()
 Extracts file argument either from file parameter or PATH_INFO.
 
 get_formatted_help_string ($identifier, $component, $ajax=false, $a=null)
 Get the value of a help string fully prepared for display in the current language.
 
 get_group_picture_url ($group, $courseid, $large=false, $includetoken=false)
 Return the url to the group picture.
 
 get_html_lang ($dir=false)
 Return a string containing 'lang', xml:lang and optionally 'dir' HTML attributes.
 
 get_html_lang_attribute_value (string $langcode)
 Converts a language code to hyphen-separated format in accordance to the BCP47 syntax.
 
 get_local_referer ($stripquery=true)
 Returns the cleaned local URL of the HTTP_REFERER less the URL query string parameters if required.
 
 get_separator ()
 Return the breadcrumb trail navigation separator.
 
 highlight ($needle, $haystack, $matchcase=false, $prefix='< span class="highlight">', $suffix='</span >')
 This function will highlight search words in a given string.
 
 highlightfast ($needle, $haystack)
 This function will highlight instances of $needle in $haystack.
 
 html_to_text ($html, $width=75, $dolinks=true)
 Given HTML text, make it into plain text using external function.
 
 is_https ()
 Determines whether or not the Moodle site is being served over HTTPS.
 
 is_in_popup ()
 Returns true if the page is displayed in a popup window.
 
 link_arrow_left ($text, $url='', $accesshide=false, $addclass='', $addparams=[])
 Return the left arrow with text ('previous'), and optionally embedded in a link.
 
 link_arrow_right ($text, $url='', $accesshide=false, $addclass='', $addparams=[])
 Return the right arrow with text ('next'), and optionally embedded in a link.
 
 markdown_to_html ($text)
 Given Markdown formatted text, make it into XHTML using external function.
 
 mdie ($msg='', $errorcode=1)
 Print an error to STDOUT and exit with a non-zero code.
 
 me ()
 Returns the name of the current script, WITH the querystring portion.
 
 navmenulist ($course, $sections, $modinfo, $strsection, $strjumpto, $width=50, $cmid=0)
 Returns a popup menu with course activity modules.
 
 notice ($message, $link='', $course=null)
 Print a message and exit.
 
 obfuscate_email ($email)
 Given an email address, this function will return an obfuscated version of it.
 
 obfuscate_mailto ($email, $label='', $dimmed=false, $subject='', $body='')
 This function uses the obfuscate_email() and obfuscate_text() to generate a fully obfuscated email link, ready to use.
 
 obfuscate_text ($plaintext)
 This function takes some text and replaces about half of the characters with HTML entity equivalents.
 
 p ($var)
 Add quotes to HTML characters.
 
 page_doc_link ($text='')
 Returns a string containing a link to the user documentation for the current page.
 
 page_get_doc_link_path (moodle_page $page)
 Returns the path to use when constructing a link to the docs.
 
 print_collapsible_region ($contents, $classes, $id, $caption, $userpref='', $default=false, $return=false)
 Print (or return) a collapsible region, that has a caption that can be clicked to expand or collapse the region.
 
 print_collapsible_region_end ($return=false)
 Close a region started with print_collapsible_region_start.
 
 print_collapsible_region_start ($classes, $id, $caption, $userpref='', $default=false, $return=false, $extracontent=null)
 Print (or return) the start of a collapsible region.
 
 print_grade_menu ($courseid, $name, $current, $includenograde=true, $return=false)
 Prints a grade menu (as part of an existing form) with help showing all possible numerical grades and scales.
 
 print_group_picture ($group, $courseid, $large=false, $return=false, $link=true, $includetoken=false)
 Print a specified group's avatar.
 
 print_location_comment ($file, $line, $return=false)
 Outputs a HTML comment to the browser.
 
 print_maintenance_message ()
 Prints a maintenance message from $CFG->maintenance_message or default if empty.
 
 print_password_policy ()
 Returns a localized sentence in the current language summarizing the current password policy.
 
 print_recent_activity_note ($time, $user, $text, $link, $return=false, $viewfullnames=null)
 Display a recent activity note.
 
 print_tabs ($tabrows, $selected=null, $inactive=null, $activated=null, $return=false)
 Returns a string containing a nested list, suitable for formatting into tabs with CSS.
 
 purify_html ($text, $options=array())
 KSES replacement cleaning function - uses HTML Purifier.
 
 qualified_me ()
 Guesses the full URL of the current script.
 
 rebuildnolinktag ($text)
 This function is used to rebuild the <nolink> tag because some formats (PLAIN and WIKI) will transform it to html entities.
 
 redirect ($url, $message='', $delay=null, $messagetype=core\output\notification::NOTIFY_INFO)
 Redirects the user to another page, after printing a notice.
 
 replace_ampersands_not_followed_by_entity ($string)
 Given a string, performs a negative lookahead looking for any ampersand character that is not followed by a proper HTML entity.
 
 reset_text_filters_cache ($phpunitreset=false)
 Resets some data related to filters, called during upgrade or when general filter settings change.
 
 right_to_left ()
 Returns true if the user is using a right-to-left language.
 
 s ($var)
 Add quotes to HTML characters.
 
 send_headers ($contenttype, $cacheable=true)
 Send the HTTP headers that Moodle requires.
 
 set_debugging ($level, $debugdisplay=null)
 Alter debugging level for the current request, the change is not saved in database.
 
 strip_links ($string)
 Given a string, replaces all .
 
 strip_pluginfile_content ($source)
 Removes the usage of Moodle files from a text.
 
 strip_querystring ($url)
 Remove query string from url.
 
 text_to_html ($text, $smileyignored=null, $para=true, $newlines=true)
 Given plain text, makes it into HTML as nicely as possible.
 
 trusttext_active ()
 Is trusttext feature active?
 
 trusttext_pre_edit ($object, $field, $context)
 Must be called before editing of all texts with trust flag.
 
 trusttext_trusted ($context)
 Is current user trusted to enter no dangerous XSS in this context?
 
 validate_email ($address)
 Validates an email to make sure it makes sense.
 
 wikify_links ($string)
 This expression turns links into something nice in a text format.
 

Variables

const FORMAT_HTML '1'
 Plain HTML (with some tags stripped).
 
const FORMAT_MARKDOWN '4'
 Markdown-formatted text http://daringfireball.net/projects/markdown/.
 
const FORMAT_MOODLE '0'
 Does all sorts of transformations and filtering.
 
const FORMAT_PLAIN '2'
 Plain text (even tags are printed in full).
 
const FORMAT_WIKI '3'
 Wiki-formatted text.
 
const URL_MATCH_BASE 0
 A moodle_url comparison using this flag will return true if the base URLs match, params are ignored.
 
const URL_MATCH_EXACT 2
 A moodle_url comparison using this flag will return true if the two URLs are identical, except for the order of the params.
 
const URL_MATCH_PARAMS 1
 A moodle_url comparison using this flag will return true if the base URLs match and the params of url1 are part of url2.