Skip to content

Commit

Permalink
MDL-77105 core_course: Add 'nofilter' class for non-monologo icons
Browse files Browse the repository at this point in the history
When rendering content items, check whether the plugin has monologo
icons. If so, add a 'nofilter' class so the plugin icon can be
rendered as is and without the CSS filter.
  • Loading branch information
junpataleta committed Mar 27, 2023
1 parent 9721570 commit cd4cebd
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -26,6 +26,7 @@

defined('MOODLE_INTERNAL') || die();

use core_component;
use core_course\local\entity\content_item;
use core_course\local\entity\lang_string_title;
use core_course\local\entity\string_title;
Expand Down Expand Up @@ -195,12 +196,20 @@ public function find_all_for_course(\stdClass $course, \stdClass $user): array {
$archetype = plugin_supports('mod', $mod->name, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
$purpose = plugin_supports('mod', $mod->name, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER);

$icon = 'monologo';
// Quick check for monologo icons.
// Plugins that don't have monologo icons will be displayed as is and CSS filter will not be applied.
$hasmonologoicons = core_component::has_monologo_icon('mod', $mod->name);
$iconclass = '';
if (!$hasmonologoicons) {
$iconclass = 'nofilter';
}
$contentitem = new content_item(
$mod->id,
$mod->name,
new lang_string_title("modulename", $mod->name),
new \moodle_url('/course/mod.php', ['id' => $course->id, 'add' => $mod->name]),
$OUTPUT->pix_icon('monologo', '', $mod->name, ['class' => 'icon activityicon']),
$OUTPUT->pix_icon($icon, '', $mod->name, ['class' => "activityicon $iconclass"]),
$help,
$archetype,
'mod_' . $mod->name,
Expand Down

0 comments on commit cd4cebd

Please sign in to comment.