|
| format_string (?string $string, bool $striplinks=true, ?context $context=null, bool $filter=true, bool $escape=true,) |
| Given a simple string, this function returns the string processed by enabled string filters if $CFG->filterall is enabled.
|
|
| format_text (?string $text, string $format=FORMAT_MOODLE, ?context $context=null, bool $trusted=false, ?bool $clean=null, bool $filter=true, bool $para=true, bool $newlines=true, bool $overflowdiv=false, bool $blanktarget=false, bool $allowid=false,) |
| Given text in a variety of format codings, this function returns the text as safe HTML.
|
|
| get_filterall () |
| Get the current filterall value.
|
|
| get_forceclean () |
| Get the current forceclean value.
|
|
| get_striptags () |
| Get the current striptags value.
|
|
| set_filterall (bool $filterall) |
| Set the value of the filterall setting.
|
|
| set_forceclean (bool $forceclean) |
| Set the value of the forceclean setting.
|
|
| set_striptags (bool $striptags) |
| Set the value of the striptags setting.
|
|
|
| should_filter_string () |
| During initial install, or upgrade from a really old version of Moodle, we should not filter strings at all.
|
|
|
bool bool | $filterall |
| Whether to apply filters.
|
|
bool bool | $forceclean |
| Whether to apply forceclean.
|
|
array | $formatstringcache = [] |
| A string cache for format_string.
|
|
bool bool | $striptags |
| Whether to apply striptags.
|
|
◆ format_string()
core\formatting::format_string |
( |
?string | $string, |
|
|
bool | $striplinks = true, |
|
|
?context | $context = null, |
|
|
bool | $filter = true, |
|
|
bool | $escape = true ) |
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.
- Parameters
-
null | string | $string | The string to be filtered. Should be plain text, expect possibly for multilang tags. |
boolean | $striplinks | To strip any link in the result text. |
null | context | $context | The context used for formatting |
bool | $filter | Whether to apply filters |
bool | $escape | Whether to escape ampersands |
- Return values
-
◆ format_text()
core\formatting::format_text |
( |
?string | $text, |
|
|
string | $format = FORMAT_MOODLE, |
|
|
?context | $context = null, |
|
|
bool | $trusted = false, |
|
|
?bool | $clean = null, |
|
|
bool | $filter = true, |
|
|
bool | $para = true, |
|
|
bool | $newlines = true, |
|
|
bool | $overflowdiv = false, |
|
|
bool | $blanktarget = false, |
|
|
bool | $allowid = false ) |
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 format_string().
- Parameters
-
null | string | $text | The text to be formatted. This is raw text originally from user input. |
string | $format | Identifier of the text format to be used [FORMAT_MOODLE, FORMAT_HTML, FORMAT_PLAIN, FORMAT_MARKDOWN] |
null | context | $context | The context used for filtering |
bool | $trusted | If true the string won't be cleaned. Note: FORMAT_MARKDOWN does not support trusted text. |
null | bool | $clean | If true the string will be cleaned. Note: This parameter is overridden if the text is trusted |
bool | $filter | If true the string will be run through applicable filters as well. |
bool | $para | If true then the returned string will be wrapped in div tags. |
bool | $newlines | If true then lines newline breaks will be converted to HTML newline breaks. |
bool | $overflowdiv | If set to true the formatted text will be encased in a div |
bool | $blanktarget | If true all tags will have target="_blank" added unless target is explicitly specified. |
bool | $allowid | If true then id attributes will not be removed, even when using htmlpurifier. |
- Return values
-
◆ get_filterall()
core\formatting::get_filterall |
( |
| ) |
|
Get the current filterall value.
Reverts to CFG->filterall if not set.
- Return values
-
◆ get_forceclean()
core\formatting::get_forceclean |
( |
| ) |
|
Get the current forceclean value.
- Return values
-
◆ get_striptags()
core\formatting::get_striptags |
( |
| ) |
|
Get the current striptags value.
Reverts to CFG->formatstringstriptags if not set.
- Return values
-
◆ set_filterall()
core\formatting::set_filterall |
( |
bool | $filterall | ) |
|
Set the value of the filterall setting.
- Parameters
-
- Return values
-
◆ set_forceclean()
core\formatting::set_forceclean |
( |
bool | $forceclean | ) |
|
Set the value of the forceclean setting.
- Parameters
-
- Return values
-
◆ set_striptags()
core\formatting::set_striptags |
( |
bool | $striptags | ) |
|
Set the value of the striptags setting.
- Parameters
-
- Return values
-
◆ should_filter_string()
core\formatting::should_filter_string |
( |
| ) |
|
|
protected |
During initial install, or upgrade from a really old version of Moodle, we should not filter strings at all.
- Return values
-
The documentation for this class was generated from the following file:
- lib/classes/formatting.php