Moodle APIs 3.11
Moodle 3.11.11+ (Build: 20221125)
|
Parser of Moodle strings defined as associative array. More...
Public Member Functions | |
__clone () | |
Prevent from cloning the instance. | |
parse (string $data, int $format=2) | |
Parses the given data in Moodle PHP string format. More... | |
Static Public Member Functions | |
static | get_instance () |
Get the singleton instance fo this class. More... | |
Protected Member Functions | |
decapsulate (string $text) | |
Given one T_CONSTANT_ENCAPSED_STRING, return its value without quotes. More... | |
extract_strings (string $data) | |
Low level parsing method. More... | |
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.
|
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.
string | $text | value obtained by token_get_all() |
string | value without quotes |
|
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.
string | $data |
string[] | the data strings |
|
static |
Get the singleton instance fo this class.
phpparser | singleton instance of phpparser |
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.
string | $data | definition of the associative array |
int | $format | the data format on the input, defaults to the one used since 2.0 |
langstring[] | array of langstrings of this file |