MDL-51213 weblib: Allow filter=false option for format_string

And pass this from external_format_string correctly.
This commit is contained in:
Damyon Wiese 2015-09-10 12:55:52 +08:00
parent 3676873566
commit 08bda175de
2 changed files with 5 additions and 1 deletions

View File

@ -743,6 +743,7 @@ function external_format_string($str, $contextid, $striplinks = true, $options =
if (!$settings->get_raw()) {
$context = context::instance_by_id($contextid);
$options['context'] = $context;
$options['filter'] = $settings->get_filter();
$str = format_string($str, $striplinks, $options);
}

View File

@ -1354,6 +1354,9 @@ function format_string($string, $striplinks = true, $options = null) {
} else if (is_numeric($options['context'])) {
$options['context'] = context::instance_by_id($options['context']);
}
if (!isset($options['filter'])) {
$options['filter'] = true;
}
if (!$options['context']) {
// We did not find any context? weird.
@ -1372,7 +1375,7 @@ function format_string($string, $striplinks = true, $options = null) {
// Regular expression moved to its own method for easier unit testing.
$string = replace_ampersands_not_followed_by_entity($string);
if (!empty($CFG->filterall)) {
if (!empty($CFG->filterall) && $options['filter']) {
$filtermanager = filter_manager::instance();
$filtermanager->setup_page_for_filters($PAGE, $options['context']); // Setup global stuff filters may have.
$string = $filtermanager->filter_string($string, $options['context']);