From dacc464414c4ab4c45940573b7f1e7a44ad3eaa9 Mon Sep 17 00:00:00 2001 From: Stephan Robotta Date: Thu, 5 Mar 2026 08:46:48 +0100 Subject: [PATCH] Translate displayed elements in admin settings on management. --- classes/local/utils.php | 15 +++++++++++++++ management.php | 8 ++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/classes/local/utils.php b/classes/local/utils.php index 7ad689c..0510121 100644 --- a/classes/local/utils.php +++ b/classes/local/utils.php @@ -564,4 +564,19 @@ public static function filter_string(?string $string = ''): string { ) ); } + + /** + * For a list of db records, use the objects and pass the displayname property value through the filter(s). + * + * @param array $records + * @return array the $records with the filters applied at displayname + */ + public static function filter_string_records(array $records): array { + foreach ($records as &$record) { + if (isset($record->displayname)) { + $record->displayname = self::filter_string($record->displayname); + } + } + return $records; + } } diff --git a/management.php b/management.php index 26ba621..9f7d745 100644 --- a/management.php +++ b/management.php @@ -50,10 +50,10 @@ $dbcompvariant = $DB->get_records('tiny_elements_comp_variant'); // Use array_values so mustache can parse it. -$compcats = array_values($dbcompcats); -$flavor = array_values($dbflavor); -$component = array_values($dbcomponent); -$variant = array_values($dbvariant); +$compcats = array_values(utils::filter_string_records($dbcompcats)); +$flavor = array_values(utils::filter_string_records($dbflavor)); +$component = array_values(utils::filter_string_records($dbcomponent)); +$variant = array_values(utils::filter_string_records($dbvariant)); // Build component preview images for management. foreach ($component as $key => $value) {