MDL-82488 customfield: allow for unescaped field formatted names.

Resolves double encoding of the same in Report builder editor.
This commit is contained in:
Paul Holden 2024-07-16 09:46:56 +01:00
parent 072fb90384
commit 8c5d9819dc
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
3 changed files with 16 additions and 4 deletions

View File

@ -0,0 +1,8 @@
issueNumber: MDL-82488
notes:
core_customfield:
- message: >
The field controller `get_formatted_name()` method now accepts an
optional `$escape` parameter to define whether to escape the returned
name
type: changed

View File

@ -255,11 +255,15 @@ abstract class field_controller {
/**
* Returns the field name formatted according to configuration context.
*
* @param bool $escape
* @return string
*/
public function get_formatted_name(): string {
public function get_formatted_name(bool $escape = true): string {
$context = $this->get_handler()->get_configuration_context();
return format_string($this->get('name'), true, ['context' => $context]);
return format_string($this->get('name'), true, [
'context' => $context,
'escape' => $escape,
]);
}
/**

View File

@ -140,7 +140,7 @@ class custom_fields {
$columns[] = (new column(
'customfield_' . $field->get('shortname'),
new lang_string('customfieldcolumn', 'core_reportbuilder', $field->get_formatted_name()),
new lang_string('customfieldcolumn', 'core_reportbuilder', $field->get_formatted_name(false)),
$this->entityname
))
->add_joins($this->get_joins())
@ -251,7 +251,7 @@ class custom_fields {
$filter = (new filter(
$this->get_filter_class_type($datacontroller),
'customfield_' . $field->get('shortname'),
new lang_string('customfieldcolumn', 'core_reportbuilder', $field->get_formatted_name()),
new lang_string('customfieldcolumn', 'core_reportbuilder', $field->get_formatted_name(false)),
$this->entityname,
$customdatasql,
$customdataparams,