Parser of Moodle strings defined as associative array.
More...
|
| __clone () |
| Prevent from cloning the instance.
|
|
| parse (string $data, int $format=2) |
| Parses the given data in Moodle PHP string format.
|
|
|
static | get_instance () |
| Get the singleton instance fo this class.
|
|
|
| decapsulate (string $text) |
| Given one T_CONSTANT_ENCAPSED_STRING, return its value without quotes.
|
|
| extract_strings (string $data) |
| Low level parsing method.
|
|
Parser of Moodle strings defined as associative array.
Moodle core just includes this file format directly as normal PHP code. However for security reasons, we must not do this for files uploaded by anonymous users. This parser reconstructs the associative $string array without actually including the file.
◆ decapsulate()
tool_customlang\local\mlang\phpparser::decapsulate |
( |
string | $text | ) |
|
|
protected |
Given one T_CONSTANT_ENCAPSED_STRING, return its value without quotes.
Also processes escaped quotes inside the text.
Note: This method is taken directly from local_amos as it is highly tested and robust.
- Parameters
-
string | $text | value obtained by token_get_all() |
- Return values
-
string | value without quotes |
◆ extract_strings()
tool_customlang\local\mlang\phpparser::extract_strings |
( |
string | $data | ) |
|
|
protected |
Low level parsing method.
Note: This method is adapted from local_amos as it is highly tested and robust. The priority is keeping it similar to the original one to make it easier to mantain.
- Parameters
-
- Return values
-
◆ get_instance()
static tool_customlang\local\mlang\phpparser::get_instance |
( |
| ) |
|
|
static |
Get the singleton instance fo this class.
- Return values
-
phpparser | singleton instance of phpparser |
◆ parse()
tool_customlang\local\mlang\phpparser::parse |
( |
string | $data, |
|
|
int | $format = 2 ) |
Parses the given data in Moodle PHP string format.
Note: This method is adapted from local_amos as it is highly tested and robust. The priority is keeping it similar to the original one to make it easier to mantain.
- Parameters
-
string | $data | definition of the associative array |
int | $format | the data format on the input, defaults to the one used since 2.0 |
- Return values
-
langstring[] | array of langstrings of this file |
The documentation for this class was generated from the following file: