MDL-74235 output: Fall back to icon and support monologo

This commit is contained in:
Andrew Nicols
2022-04-07 12:56:13 +08:00
parent ad6dc71c56
commit ffc227c9d5
2 changed files with 33 additions and 12 deletions
+31 -12
View File
@@ -2103,24 +2103,43 @@ class theme_config {
} else {
if (strpos($component, '_') === false) {
$component = 'mod_'.$component;
$component = "mod_{$component}";
}
list($type, $plugin) = explode('_', $component, 2);
if ($imagefile = $this->image_exists("$this->dir/pix_plugins/$type/$plugin/$image", $svg)) {
return $imagefile;
// In Moodle 4.0 we introduced a new image format.
// Support that image format here.
$candidates = [$image];
if ($type === 'mod') {
if ($image === 'icon') {
debugging(
"The 'icon' image for activity modules has been replaced with a new 'monologo'. " .
"Please update your calling code to fetch the new icon where possible. " .
"Called for component {$component}.",
DEBUG_DEVELOPER
);
}
$candidates = ['monologo', 'icon'];
}
foreach (array_reverse($this->parent_configs) as $parent_config) { // base first, the immediate parent last
if ($imagefile = $this->image_exists("$parent_config->dir/pix_plugins/$type/$plugin/$image", $svg)) {
foreach ($candidates as $image) {
if ($imagefile = $this->image_exists("$this->dir/pix_plugins/$type/$plugin/$image", $svg)) {
return $imagefile;
}
// Base first, the immediate parent last.
foreach (array_reverse($this->parent_configs) as $parentconfig) {
if ($imagefile = $this->image_exists("$parentconfig->dir/pix_plugins/$type/$plugin/$image", $svg)) {
return $imagefile;
}
}
if ($imagefile = $this->image_exists("$CFG->dataroot/pix_plugins/$type/$plugin/$image", $svg)) {
return $imagefile;
}
$dir = core_component::get_plugin_directory($type, $plugin);
if ($imagefile = $this->image_exists("$dir/pix/$image", $svg)) {
return $imagefile;
}
}
if ($imagefile = $this->image_exists("$CFG->dataroot/pix_plugins/$type/$plugin/$image", $svg)) {
return $imagefile;
}
$dir = core_component::get_plugin_directory($type, $plugin);
if ($imagefile = $this->image_exists("$dir/pix/$image", $svg)) {
return $imagefile;
}
return null;
}
+2
View File
@@ -7,6 +7,8 @@ information provided here is intended especially for developers.
the settings_navigation class in order to obtain the correct moodle_page information associated to the given settings
navigation. After the recent changes to the navigation in single activity courses, using the global $PAGE may result
in returning inaccurate data in this course format, therefore it is advisable to use $settingsnavigation->get_page().
* A new style of icons has been created for activities. When creating an icon in the new style it should be named
'monologo' and can site alongside the legacy icon if desired. Only the new logo types will be used.
=== 3.9 ===