libSmalldb
v0.7-66-gb94d22a
|
Static Public Member Functions | |
static | template_format ($template, $values, $escaping_function='htmlspecialchars') |
Format data using template string with placeholders. More... | |
static | filename_format ($template, $values) |
Helper method to invoke template_format() without HTML escaping. More... | |
static | write_json_file ($filename, $json_array, array $whitelist=null, $json_options=null) |
Encode array to JSON using json_encode, but insert PHP snippet to protect sensitive data. More... | |
static | parse_json_file ($filename) |
JSON version of parse_ini_file(). More... | |
static | parse_json_string ($json_str, $filename=null) |
Decode JSON string. More... | |
|
static |
Format data using template string with placeholders.
The placeholders to replace are in the following format: {name}
or {name:function}
or {name:function:format_string}
.
The function is formatting function (like sprintf
) and format string is the first parameter of the formatting function.
Available formatting functions:
sprintf
strftime
floor
ceil
frac
frac_str
intval
floatval
All except strftime
accept same formatting string as sprintf
. The strftime
accepts strftime
format string.
Hello {user}, now is {time:strftime:%H} o'clock and the temperature is {temp:sprintf:%0.2f} degree Celsius.
|
static |
Helper method to invoke template_format() without HTML escaping.
|
static |
Encode array to JSON using json_encode, but insert PHP snippet to protect sensitive data.
If $filename is set, JSON will be written to given file. Otherwise you are expected to store returned string into *.json.php file.
Stop snippet: When JSON file is evaluated as PHP, stop snippet will interrupt evaluation without breaking JSON syntax, only underscore key is appended (and overwritten if exists).
To make sure that whitelisted keys does not contain PHP tags, all occurrences of '<?' are replaced with '<_?' in whitelisted values.
Default $json_options are:
Options JSON_HEX_TAG and JSON_HEX_APOS are disabled, becouse they break PHP snippet.
|
static |
JSON version of parse_ini_file().
Throws JsonException on error.
|
static |
Decode JSON string.
$json_str | String to parse. |
$filename | If set the exception message will contain $filename. |