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-08-30 09:44:47 +01:00
parent 3f94e61e49
commit b7c05d2cc4
3 changed files with 13 additions and 5 deletions
+6 -2
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,
]);
}
/**
+5 -1
View File
@@ -1,7 +1,11 @@
This files describes API changes in /customfield/*,
Information provided here is intended especially for developers.
=== 4.4.6 ===
=== 4.3.8 ===
* The field controller `get_formatted_name()` method now accepts an optional `$escape` parameter to define whether to
escape the returned name
=== 4.3.6 ===
* The customfield_select field controller `get_options` method now returns each option pre-formatted
=== 4.3 ===
@@ -172,7 +172,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())
@@ -261,7 +261,7 @@ class custom_fields {
$filter = (new filter(
$typeclass,
'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,
$datafieldsql
))