Merge branch 'MDL-70486-master-get_region_name' of git://github.com/mudrd8mz/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2021-01-11 22:55:19 +01:00
commit d64aa10197
2 changed files with 22 additions and 10 deletions

View File

@ -2451,22 +2451,22 @@ class theme_config {
* @return string
*/
protected function get_region_name($region, $theme) {
$regionstring = get_string('region-' . $region, 'theme_' . $theme);
// A name exists in this theme, so use it
if (substr($regionstring, 0, 1) != '[') {
return $regionstring;
$stringman = get_string_manager();
// Check if the name is defined in the theme.
if ($stringman->string_exists('region-' . $region, 'theme_' . $theme)) {
return get_string('region-' . $region, 'theme_' . $theme);
}
// Otherwise, try to find one elsewhere
// Check parents, if any
// Check the theme parents.
foreach ($this->parents as $parentthemename) {
$regionstring = get_string('region-' . $region, 'theme_' . $parentthemename);
if (substr($regionstring, 0, 1) != '[') {
return $regionstring;
if ($stringman->string_exists('region-' . $region, 'theme_' . $parentthemename)) {
return get_string('region-' . $region, 'theme_' . $parentthemename);
}
}
// Last resort, try the boost theme for names
// Last resort, try the boost theme for names.
return get_string('region-' . $region, 'theme_boost');
}

View File

@ -213,4 +213,16 @@ class core_theme_config_testcase extends advanced_testcase {
$this->assertEquals($cssexpected, $cssactual);
}
/**
* Test that {@see theme_config::get_all_block_regions()} returns localised list of region names.
*/
public function test_get_all_block_regions() {
$this->resetAfterTest();
$theme = theme_config::load(theme_config::DEFAULT_THEME);
$regions = $theme->get_all_block_regions();
$this->assertEquals('Right', $regions['side-pre']);
}
}