From 4b388fc239e0b45deb071f98549ccef45dffe929 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 18 Mar 2022 14:00:53 +0800 Subject: [PATCH] MDL-74235 core: Update core uses of activity icons to monologo --- admin/modules.php | 2 +- admin/renderer.php | 41 +++++--- admin/tool/recyclebin/index.php | 2 +- backup/moodle2/backup_activity_task.class.php | 2 +- .../moodle2/restore_activity_task.class.php | 2 +- backup/util/ui/renderer.php | 2 +- .../block_activity_modules.php | 4 +- blocks/feedback/block_feedback.php | 2 +- .../classes/external/event_icon_exporter.php | 2 +- completion/classes/manager.php | 4 +- .../criteria/completion_criteria_activity.php | 2 +- .../content_item_readonly_repository.php | 4 +- course/format/singleactivity/lib.php | 2 +- course/modedit.php | 4 +- course/recent.php | 2 +- course/templates/activityinstance.mustache | 2 +- .../templates/bulkactivitycompletion.mustache | 4 +- .../defaultactivitycompletion.mustache | 2 +- .../editbulkactivitycompletion.mustache | 2 +- .../templates/editdefaultcompletion.mustache | 2 +- grade/lib.php | 2 +- lib/navigationlib.php | 4 +- lib/weblib.php | 2 +- message/externallib.php | 2 +- .../classes/output/popup_notification.php | 2 +- message/tests/externallib_test.php | 2 +- mod/assign/lib.php | 2 +- mod/bigbluebuttonbn/db/mobile.php | 2 +- mod/data/tests/generator/lib.php | 2 +- mod/feedback/lib.php | 2 +- mod/forum/lib.php | 2 +- mod/h5pactivity/lib.php | 2 +- mod/lti/lib.php | 2 +- mod/quiz/lib.php | 2 +- mod/workshop/lib.php | 4 +- report/outline/index.php | 2 +- report/outline/locallib.php | 2 +- report/outline/user.php | 2 +- report/progress/index.php | 2 +- search/classes/base_mod.php | 2 +- search/tests/base_activity_test.php | 2 +- theme/boost/classes/output/core_renderer.php | 2 +- theme/image.php | 97 +++++++++++++------ 43 files changed, 141 insertions(+), 93 deletions(-) diff --git a/admin/modules.php b/admin/modules.php index 5bfe9cd2477..1ec117e82e5 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -75,7 +75,7 @@ $missing = true; } else { // took out hspace="\10\", because it does not validate. don't know what to replace with. - $icon = "image_url('icon', $module->name) . "\" class=\"icon\" alt=\"\" />"; + $icon = "image_url('monologo', $module->name) . "\" class=\"icon\" alt=\"\" />"; $strmodulename = $icon.' '.get_string('modulename', $module->name); $missing = false; } diff --git a/admin/renderer.php b/admin/renderer.php index 943a212fcae..57d4f98c76f 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -15,20 +15,13 @@ // along with Moodle. If not, see . /** - * Renderer for core_admin subsystem + * Standard HTML output renderer for core_admin subsystem. * * @package core * @subpackage admin * @copyright 2011 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - -defined('MOODLE_INTERNAL') || die(); - - -/** - * Standard HTML output renderer for core_admin subsystem - */ class core_admin_renderer extends plugin_renderer_base { /** @@ -1087,12 +1080,21 @@ class core_admin_renderer extends plugin_renderer_base { $plugintyperows = array(); foreach ($plugins as $name => $plugin) { + $component = "{$plugin->type}_{$plugin->name}"; + $sumtotal++; $row = new html_table_row(); - $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name; + $row->attributes['class'] = "type-{$plugin->type} name-{$component}"; - if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name, null)) { - $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon')); + $iconidentifier = 'icon'; + if ($plugin->type === 'mod') { + $iconidentifier = 'monologo'; + } + + if ($this->page->theme->resolve_image_location($iconidentifier, $component, null)) { + $icon = $this->output->pix_icon($iconidentifier, '', $component, [ + 'class' => 'smallicon pluginicon', + ]); } else { $icon = ''; } @@ -1805,11 +1807,20 @@ class core_admin_renderer extends plugin_renderer_base { } foreach ($plugins as $name => $plugin) { - $row = new html_table_row(); - $row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name; + $component = "{$plugin->type}_{$plugin->name}"; - if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name, null)) { - $icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'icon pluginicon')); + $row = new html_table_row(); + $row->attributes['class'] = "type-{$plugin->type} name-{$component}"; + + $iconidentifier = 'icon'; + if ($plugin->type === 'mod') { + $iconidentifier = 'monologo'; + } + + if ($this->page->theme->resolve_image_location($iconidentifier, $component, null)) { + $icon = $this->output->pix_icon($iconidentifier, '', $component, [ + 'class' => 'icon pluginicon', + ]); } else { $icon = $this->output->spacer(); } diff --git a/admin/tool/recyclebin/index.php b/admin/tool/recyclebin/index.php index 747d4f61086..1c587ff741e 100644 --- a/admin/tool/recyclebin/index.php +++ b/admin/tool/recyclebin/index.php @@ -187,7 +187,7 @@ foreach ($items as $item) { if (isset($modules[$item->module])) { $mod = $modules[$item->module]; $modname = get_string('modulename', $mod->name); - $name = $OUTPUT->image_icon('icon', $modname, $mod->name) . $name; + $name = $OUTPUT->image_icon('monologo', $modname, $mod->name) . $name; } } diff --git a/backup/moodle2/backup_activity_task.class.php b/backup/moodle2/backup_activity_task.class.php index 5567d919dab..f5a0348da00 100644 --- a/backup/moodle2/backup_activity_task.class.php +++ b/backup/moodle2/backup_activity_task.class.php @@ -271,7 +271,7 @@ abstract class backup_activity_task extends backup_task { // - section_included setting (if exists) $settingname = $settingprefix . 'included'; $activity_included = new backup_activity_generic_setting($settingname, base_setting::IS_BOOLEAN, true); - $activity_included->get_ui()->set_icon(new image_icon('icon', get_string('pluginname', $this->modulename), + $activity_included->get_ui()->set_icon(new image_icon('monologo', get_string('pluginname', $this->modulename), $this->modulename, array('class' => 'iconlarge icon-post ml-1'))); $this->add_setting($activity_included); // Look for "activities" root setting diff --git a/backup/moodle2/restore_activity_task.class.php b/backup/moodle2/restore_activity_task.class.php index c27d6a4c0aa..19a0d76e3b3 100644 --- a/backup/moodle2/restore_activity_task.class.php +++ b/backup/moodle2/restore_activity_task.class.php @@ -305,7 +305,7 @@ abstract class restore_activity_task extends restore_task { // - section_included setting (if exists) $settingname = $settingprefix . 'included'; $activity_included = new restore_activity_generic_setting($settingname, base_setting::IS_BOOLEAN, true); - $activity_included->get_ui()->set_icon(new image_icon('icon', get_string('pluginname', $this->modulename), + $activity_included->get_ui()->set_icon(new image_icon('monologo', get_string('pluginname', $this->modulename), $this->modulename, array('class' => 'iconlarge icon-post ml-1'))); $this->add_setting($activity_included); // Look for "activities" root setting diff --git a/backup/util/ui/renderer.php b/backup/util/ui/renderer.php index d4041266fac..7a1774d5772 100644 --- a/backup/util/ui/renderer.php +++ b/backup/util/ui/renderer.php @@ -203,7 +203,7 @@ class core_backup_renderer extends plugin_renderer_base { $table->data = array(); } $name = get_string('pluginname', $activity->modulename); - $icon = new image_icon('icon', '', $activity->modulename, ['class' => 'iconlarge icon-pre']); + $icon = new image_icon('monologo', '', $activity->modulename, ['class' => 'iconlarge icon-pre']); $table->data[] = array( $this->output->render($icon).$name, $activity->title, diff --git a/blocks/activity_modules/block_activity_modules.php b/blocks/activity_modules/block_activity_modules.php index 6d3a60c062d..cbf6c804fc1 100644 --- a/blocks/activity_modules/block_activity_modules.php +++ b/blocks/activity_modules/block_activity_modules.php @@ -75,10 +75,10 @@ class block_activity_modules extends block_list { foreach ($modfullnames as $modname => $modfullname) { if ($modname === 'resources') { - $icon = $OUTPUT->pix_icon('icon', '', 'mod_page', array('class' => 'icon')); + $icon = $OUTPUT->pix_icon('monologo', '', 'mod_page', array('class' => 'icon')); $this->content->items[] = ''.$icon.$modfullname.''; } else { - $icon = $OUTPUT->image_icon('icon', get_string('pluginname', $modname), $modname); + $icon = $OUTPUT->image_icon('monologo', get_string('pluginname', $modname), $modname); $this->content->items[] = ''.$icon.$modfullname.''; } } diff --git a/blocks/feedback/block_feedback.php b/blocks/feedback/block_feedback.php index b10163aedc9..252c4f07f40 100644 --- a/blocks/feedback/block_feedback.php +++ b/blocks/feedback/block_feedback.php @@ -53,7 +53,7 @@ class block_feedback extends block_list { $courseid = SITEID; } - $icon = $OUTPUT->image_icon('icon', get_string('pluginname', 'mod_feedback'), 'mod_feedback'); + $icon = $OUTPUT->image_icon('monologo', get_string('pluginname', 'mod_feedback'), 'mod_feedback'); if (empty($this->instance->pageid)) { $this->instance->pageid = SITEID; diff --git a/calendar/classes/external/event_icon_exporter.php b/calendar/classes/external/event_icon_exporter.php index 1f866d8d3c9..9f474075900 100644 --- a/calendar/classes/external/event_icon_exporter.php +++ b/calendar/classes/external/event_icon_exporter.php @@ -63,7 +63,7 @@ class event_icon_exporter extends exporter { $isuserevent = ($user && !empty($userid)); if ($isactivityevent) { - $key = 'icon'; + $key = 'monologo'; $component = $coursemodule->get('modname'); if (get_string_manager()->string_exists($event->get_type(), $component)) { diff --git a/completion/classes/manager.php b/completion/classes/manager.php index 48ae29d0f0b..99cb4ee7a98 100644 --- a/completion/classes/manager.php +++ b/completion/classes/manager.php @@ -223,7 +223,7 @@ class manager { $canmanage = has_capability('moodle/course:manageactivities', $coursecontext); $course = get_course($this->courseid); foreach ($data->modules as $module) { - $module->icon = $OUTPUT->image_url('icon', $module->name)->out(); + $module->icon = $OUTPUT->image_url('monologo', $module->name)->out(); $module->formattedname = format_string(get_string('modulenameplural', 'mod_' . $module->name), true, ['context' => $coursecontext]); $module->canmanage = $canmanage && course_allowed_module($course, $module->name); @@ -543,4 +543,4 @@ class manager { } return $data; } -} \ No newline at end of file +} diff --git a/completion/criteria/completion_criteria_activity.php b/completion/criteria/completion_criteria_activity.php index 3b80836636a..a4e5ede9b65 100644 --- a/completion/criteria/completion_criteria_activity.php +++ b/completion/criteria/completion_criteria_activity.php @@ -261,6 +261,6 @@ class completion_criteria_activity extends completion_criteria { * @return pix_icon */ public function get_icon($alt, array $attributes = null) { - return new pix_icon('icon', $alt, 'mod_'.$this->module, $attributes); + return new pix_icon('monologo', $alt, "mod_{$this->module}", $attributes); } } diff --git a/course/classes/local/repository/content_item_readonly_repository.php b/course/classes/local/repository/content_item_readonly_repository.php index 1b361658288..54e58156d54 100644 --- a/course/classes/local/repository/content_item_readonly_repository.php +++ b/course/classes/local/repository/content_item_readonly_repository.php @@ -209,7 +209,7 @@ class content_item_readonly_repository implements content_item_readonly_reposito $mod->name, new lang_string_title("modulename", $mod->name), new \moodle_url(''), // No course scope, so just an empty link. - $OUTPUT->pix_icon('icon', '', $mod->name, ['class' => 'icon activityicon']), + $OUTPUT->pix_icon('monologo', '', $mod->name, ['class' => 'icon activityicon']), $help, $archetype, 'mod_' . $mod->name, @@ -274,7 +274,7 @@ class content_item_readonly_repository implements content_item_readonly_reposito $mod->name, new lang_string_title("modulename", $mod->name), new \moodle_url($urlbase, ['add' => $mod->name]), - $OUTPUT->pix_icon('icon', '', $mod->name, ['class' => 'icon activityicon']), + $OUTPUT->pix_icon('monologo', '', $mod->name, ['class' => 'icon activityicon']), $help, $archetype, 'mod_' . $mod->name, diff --git a/course/format/singleactivity/lib.php b/course/format/singleactivity/lib.php index 952c7241586..7f6161ce47a 100644 --- a/course/format/singleactivity/lib.php +++ b/course/format/singleactivity/lib.php @@ -113,7 +113,7 @@ class format_singleactivity extends core_courseformat\base { if ($cm->icon) { $icon = new pix_icon($cm->icon, $cm->modfullname, $cm->iconcomponent); } else { - $icon = new pix_icon('icon', $cm->modfullname, $cm->modname); + $icon = new pix_icon('monologo', $cm->modfullname, $cm->modname); } $activitynode = $node->add($activityname, $action, navigation_node::TYPE_ACTIVITY, null, $cm->id, $icon); if (global_navigation::module_extends_navigation($cm->modname)) { diff --git a/course/modedit.php b/course/modedit.php index 3cad0119f7c..7a2088057da 100644 --- a/course/modedit.php +++ b/course/modedit.php @@ -207,9 +207,9 @@ if ($mform->is_cancelled()) { echo $OUTPUT->header(); if (get_string_manager()->string_exists('modulename_help', $module->name)) { - echo $OUTPUT->heading_with_help($pageheading, 'modulename', $module->name, 'icon'); + echo $OUTPUT->heading_with_help($pageheading, 'modulename', $module->name, 'monologo'); } else { - echo $OUTPUT->heading_with_help($pageheading, '', $module->name, 'icon'); + echo $OUTPUT->heading_with_help($pageheading, '', $module->name, 'monologo'); } $mform->display(); diff --git a/course/recent.php b/course/recent.php index 13e02078c3c..a1bdca7e91d 100644 --- a/course/recent.php +++ b/course/recent.php @@ -231,7 +231,7 @@ if (!empty($activities)) { $name = format_string($cm->name); $modfullname = $modnames[$cm->modname]; - $image = $OUTPUT->pix_icon('icon', $modfullname, $cm->modname, array('class' => 'icon smallicon')); + $image = $OUTPUT->pix_icon('monologo', $modfullname, $cm->modname, array('class' => 'icon smallicon')); $link = html_writer::link(new moodle_url("/mod/$cm->modname/view.php", array("id" => $cm->id)), $name, array('class' => $class)); echo html_writer::tag('li', "$image $modfullname $link"); diff --git a/course/templates/activityinstance.mustache b/course/templates/activityinstance.mustache index 64232e28462..18342323f30 100644 --- a/course/templates/activityinstance.mustache +++ b/course/templates/activityinstance.mustache @@ -24,7 +24,7 @@ "activities": [{ "cmid": "4", "modname": "Test activity", - "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/feedback/pix/icon.png", + "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/feedback/pix/monologo.png", "completionstatus": { "string": "Manual", "icon": "https://raw.githubusercontent.com/moodle/moodle/master/pix/i/completion-manual-enabled.png" diff --git a/course/templates/bulkactivitycompletion.mustache b/course/templates/bulkactivitycompletion.mustache index 8043be96808..5714a66b476 100644 --- a/course/templates/bulkactivitycompletion.mustache +++ b/course/templates/bulkactivitycompletion.mustache @@ -29,7 +29,7 @@ "activities": [{ "cmid": "4", "modname": "Test activity", - "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/feedback/pix/icon.png", + "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/feedback/pix/monologo.png", "completionstatus": { "string": "Manual", "icon": "https://raw.githubusercontent.com/moodle/moodle/master/pix/i/completion-manual-enabled.png" @@ -123,4 +123,4 @@ require([ } }); }); -{{/js}} \ No newline at end of file +{{/js}} diff --git a/course/templates/defaultactivitycompletion.mustache b/course/templates/defaultactivitycompletion.mustache index f76da9f428e..f744f05c522 100644 --- a/course/templates/defaultactivitycompletion.mustache +++ b/course/templates/defaultactivitycompletion.mustache @@ -27,7 +27,7 @@ "id": "10", "formattedname": "Assignment", "canmanage": true, - "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/assign/pix/icon.png", + "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/assign/pix/monologo.png", "completionstatus": { "string": "Manual", "icon": "https://raw.githubusercontent.com/moodle/moodle/master/pix/i/completion-manual-enabled.png" diff --git a/course/templates/editbulkactivitycompletion.mustache b/course/templates/editbulkactivitycompletion.mustache index 01498c42cb3..f8f91dbe0a8 100644 --- a/course/templates/editbulkactivitycompletion.mustache +++ b/course/templates/editbulkactivitycompletion.mustache @@ -26,7 +26,7 @@ "activities": [{ "cmid": "4", "modname": "Test activity", - "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/feedback/pix/icon.png" + "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/feedback/pix/monologo.png" }] } }} diff --git a/course/templates/editdefaultcompletion.mustache b/course/templates/editdefaultcompletion.mustache index 5058a5184a8..ee6b0346f98 100644 --- a/course/templates/editdefaultcompletion.mustache +++ b/course/templates/editdefaultcompletion.mustache @@ -26,7 +26,7 @@ "modules": [{ "id": "10", "formattedname": "Assignment", - "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/assign/pix/icon.png" + "icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/assign/pix/monologo.png" }] } }} diff --git a/grade/lib.php b/grade/lib.php index 5afb658642c..5e895f6154d 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -1451,7 +1451,7 @@ class grade_structure { if (isset($modinfo->instances[$module][$instanceid])) { $icon->url = $modinfo->instances[$module][$instanceid]->get_icon_url(); } else { - $icon->pix = 'icon'; + $icon->pix = 'monologo'; $icon->component = $element['object']->itemmodule; } $icon->title = s(get_string('modulename', $element['object']->itemmodule)); diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 7265b9317f7..ba43bad0829 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2319,7 +2319,7 @@ class global_navigation extends navigation_node { if ($activity->icon) { $icon = new pix_icon($activity->icon, get_string('modulename', $activity->modname), $activity->iconcomponent); } else { - $icon = new pix_icon('icon', get_string('modulename', $activity->modname), $activity->modname); + $icon = new pix_icon('monologo', get_string('modulename', $activity->modname), $activity->modname); } // Prepare the default name and url for the node @@ -2373,7 +2373,7 @@ class global_navigation extends navigation_node { if ($cm->icon) { $icon = new pix_icon($cm->icon, get_string('modulename', $cm->modname), $cm->iconcomponent); } else { - $icon = new pix_icon('icon', get_string('modulename', $cm->modname), $cm->modname); + $icon = new pix_icon('monologo', get_string('modulename', $cm->modname), $cm->modname); } $url = $cm->url; $activitynode = $coursenode->add(format_string($cm->name), $url, navigation_node::TYPE_ACTIVITY, null, $cm->id, $icon); diff --git a/lib/weblib.php b/lib/weblib.php index 34ba16b7b2c..7b142723eed 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2711,7 +2711,7 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid $class = 'activity '.$mod->modname; $class .= ($cmid == $mod->id) ? ' selected' : ''; $menu[] = '
  • '. - $OUTPUT->image_icon('icon', '', $mod->modname). + $OUTPUT->image_icon('monologo', '', $mod->modname). ''.$mod->name.'
  • '; } diff --git a/message/externallib.php b/message/externallib.php index 6b8d18a3ec4..6e6bc119497 100644 --- a/message/externallib.php +++ b/message/externallib.php @@ -2103,7 +2103,7 @@ class core_message_external extends external_api { } if (!empty($message->component) && substr($message->component, 0, 4) == 'mod_') { - $iconurl = $output->image_url('icon', $message->component); + $iconurl = $output->image_url('monologo', $message->component); } else { $iconurl = $output->image_url('i/marker', 'core'); } diff --git a/message/output/popup/classes/output/popup_notification.php b/message/output/popup/classes/output/popup_notification.php index 0511873237a..b76b67c311f 100644 --- a/message/output/popup/classes/output/popup_notification.php +++ b/message/output/popup/classes/output/popup_notification.php @@ -68,7 +68,7 @@ class popup_notification implements templatable, renderable { $context->shortenedsubject = shorten_text($context->subject, 125); if (!empty($context->component) && substr($context->component, 0, 4) == 'mod_') { - $iconurl = $output->image_url('icon', $context->component); + $iconurl = $output->image_url('monologo', $context->component); } else { $iconurl = $output->image_url('i/marker', 'core'); } diff --git a/message/tests/externallib_test.php b/message/tests/externallib_test.php index 76e65115752..1ff834c6e9d 100644 --- a/message/tests/externallib_test.php +++ b/message/tests/externallib_test.php @@ -1485,7 +1485,7 @@ class externallib_test extends externallib_advanced_testcase { $this->assertObjectHasAttribute('datakey', json_decode($messages['messages'][0]['customdata'])); $this->assertEquals('mod_feedback', $messages['messages'][0]['component']); $this->assertEquals('submission', $messages['messages'][0]['eventtype']); - $feedbackicon = clean_param($PAGE->get_renderer('core')->image_url('icon', 'mod_feedback')->out(), PARAM_URL); + $feedbackicon = clean_param($PAGE->get_renderer('core')->image_url('monologo', 'mod_feedback')->out(), PARAM_URL); $this->assertEquals($feedbackicon, $messages['messages'][0]['iconurl']); // Test warnings. diff --git a/mod/assign/lib.php b/mod/assign/lib.php index c7f43645a82..abd2c77f4f9 100644 --- a/mod/assign/lib.php +++ b/mod/assign/lib.php @@ -939,7 +939,7 @@ function assign_print_recent_mod_activity($activity, $courseid, $detail, $modnam if ($detail) { $modname = $modnames[$activity->type]; echo '
    '; - echo $OUTPUT->image_icon('icon', $modname, 'assign'); + echo $OUTPUT->image_icon('monologo', $modname, 'assign'); echo ''; echo $activity->name; echo ''; diff --git a/mod/bigbluebuttonbn/db/mobile.php b/mod/bigbluebuttonbn/db/mobile.php index 5c32c69db72..dd600a0e0aa 100644 --- a/mod/bigbluebuttonbn/db/mobile.php +++ b/mod/bigbluebuttonbn/db/mobile.php @@ -31,7 +31,7 @@ $addons = [ 'coursebigbluebuttonbn' => [ // Handler unique name (can be anything). 'displaydata' => [ 'title' => 'pluginname', - 'icon' => $CFG->wwwroot . '/mod/bigbluebuttonbn/pix/dynamicicon.png', + 'icon' => $CFG->wwwroot . '/mod/bigbluebuttonbn/pix/monologo.png', 'class' => '', ], 'delegate' => 'CoreCourseModuleDelegate', // Delegate (where to display the link to the add-on). diff --git a/mod/data/tests/generator/lib.php b/mod/data/tests/generator/lib.php index 09fa31c03a9..719552dfa24 100644 --- a/mod/data/tests/generator/lib.php +++ b/mod/data/tests/generator/lib.php @@ -311,7 +311,7 @@ class mod_data_generator extends testing_module_generator { get_file_storage()->create_file_from_string(['component' => 'user', 'filearea' => 'draft', 'contextid' => $usercontext->id, 'itemid' => $itemid, 'filepath' => '/', 'filename' => $filename], - file_get_contents($CFG->dirroot.'/mod/data/pix/dynamicicon.png')); + file_get_contents($CFG->dirroot.'/mod/data/pix/monologo.png')); } $fieldname = 'field_' . $fieldid . '_file'; diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index 039cde5c7ea..7a707ae8514 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -496,7 +496,7 @@ function feedback_print_recent_mod_activity($activity, $courseid, $detail, $modn if ($detail) { $modname = $modnames[$activity->type]; echo '
    '; - echo $OUTPUT->image_icon('icon', $modname, $activity->type); + echo $OUTPUT->image_icon('monologo', $modname, $activity->type); echo "wwwroot/mod/feedback/view.php?id={$activity->cmid}\">{$activity->name}"; echo '
    '; } diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 8bbdcfe0644..3ad968c3881 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -4208,7 +4208,7 @@ function forum_print_recent_mod_activity($activity, $courseid, $detail, $modname $output .= html_writer::start_div($class); if ($detail) { $aname = s($activity->name); - $output .= $OUTPUT->image_icon('icon', $aname, $activity->type); + $output .= $OUTPUT->image_icon('monologo', $aname, $activity->type); } $discussionurl = new moodle_url('/mod/forum/discuss.php', ['d' => $content->discussion]); $discussionurl->set_anchor('p' . $activity->content->id); diff --git a/mod/h5pactivity/lib.php b/mod/h5pactivity/lib.php index 667daaa05de..f35965fade5 100644 --- a/mod/h5pactivity/lib.php +++ b/mod/h5pactivity/lib.php @@ -727,7 +727,7 @@ function h5pactivity_print_recent_mod_activity(stdClass $activity, int $courseid if ($detail) { $modinfo['modname'] = $activity->name; $modinfo['modurl'] = new moodle_url('/mod/h5pactivity/view.php', ['id' => $activity->cmid]); - $modinfo['modicon'] = $OUTPUT->image_icon('icon', $modnames[$activity->type], 'h5pactivity'); + $modinfo['modicon'] = $OUTPUT->image_icon('monologo', $modnames[$activity->type], 'h5pactivity'); } $userpicture = $OUTPUT->user_picture($activity->user); diff --git a/mod/lti/lib.php b/mod/lti/lib.php index 3c324c2f0fd..528bc2c863c 100644 --- a/mod/lti/lib.php +++ b/mod/lti/lib.php @@ -359,7 +359,7 @@ function mod_lti_get_all_content_items(\core_course\local\entity\content_item $d $type->helplink = get_string('modulename_shortcut_link', 'lti'); } if (empty($ltitype->icon)) { - $type->icon = $OUTPUT->pix_icon('icon', '', 'lti', array('class' => 'icon')); + $type->icon = $OUTPUT->pix_icon('monologo', '', 'lti', array('class' => 'icon')); } else { $type->icon = html_writer::empty_tag('img', array('src' => $ltitype->icon, 'alt' => $ltitype->name, 'class' => 'icon')); } diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 87a87a4bd3d..2100cb12b77 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -996,7 +996,7 @@ function quiz_print_recent_mod_activity($activity, $courseid, $detail, $modnames if ($detail) { $modname = $modnames[$activity->type]; echo '
    '; - echo $OUTPUT->image_icon('icon', $modname, $activity->type); + echo $OUTPUT->image_icon('monologo', $modname, $activity->type); echo '' . $activity->name . ''; echo '
    '; diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index c2bd468f082..e56a2ef4ffd 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -989,7 +989,7 @@ function workshop_print_recent_mod_activity($activity, $courseid, $detail, $modn echo html_writer::start_tag('h4', array('class'=>'workshop')); $url = new moodle_url('/mod/workshop/view.php', array('id'=>$activity->cmid)); $name = s($activity->name); - echo $OUTPUT->image_icon('icon', $name, $activity->type); + echo $OUTPUT->image_icon('monologo', $name, $activity->type); echo ' ' . $modnames[$activity->type]; echo html_writer::link($url, $name, array('class'=>'name', 'style'=>'margin-left: 5px')); echo html_writer::end_tag('h4'); @@ -1026,7 +1026,7 @@ function workshop_print_recent_mod_activity($activity, $courseid, $detail, $modn echo html_writer::start_tag('h4', array('class'=>'workshop')); $url = new moodle_url('/mod/workshop/view.php', array('id'=>$activity->cmid)); $name = s($activity->name); - echo $OUTPUT->image_icon('icon', $name, $activity->type); + echo $OUTPUT->image_icon('monologo', $name, $activity->type); echo ' ' . $modnames[$activity->type]; echo html_writer::link($url, $name, array('class'=>'name', 'style'=>'margin-left: 5px')); echo html_writer::end_tag('h4'); diff --git a/report/outline/index.php b/report/outline/index.php index 532d49428a8..2078ebb5f66 100644 --- a/report/outline/index.php +++ b/report/outline/index.php @@ -252,7 +252,7 @@ foreach ($modinfo->sections as $sectionnum=>$section) { $activitycell = new html_table_cell(); $activitycell->attributes['class'] = 'activity'; - $activityicon = $OUTPUT->pix_icon('icon', $modulename, $cm->modname, array('class'=>'icon')); + $activityicon = $OUTPUT->pix_icon('monologo', $modulename, $cm->modname, array('class'=>'icon')); $attributes = array(); if (!$cm->visible) { diff --git a/report/outline/locallib.php b/report/outline/locallib.php index 9d734b7073b..87067cddde6 100644 --- a/report/outline/locallib.php +++ b/report/outline/locallib.php @@ -31,7 +31,7 @@ require_once($CFG->dirroot.'/course/lib.php'); function report_outline_print_row($mod, $instance, $result) { global $OUTPUT, $CFG; - $image = $OUTPUT->image_icon('icon', $mod->modfullname, $mod->modname); + $image = $OUTPUT->image_icon('monologo', $mod->modfullname, $mod->modname); echo ""; echo "$image"; diff --git a/report/outline/user.php b/report/outline/user.php index da3b58386f2..2731b0421a1 100644 --- a/report/outline/user.php +++ b/report/outline/user.php @@ -152,7 +152,7 @@ foreach ($sections as $i => $section) { break; case "complete": $user_complete = $mod->modname."_user_complete"; - $image = $OUTPUT->pix_icon('icon', $mod->modfullname, 'mod_'.$mod->modname, array('class'=>'icon')); + $image = $OUTPUT->pix_icon('monologo', $mod->modfullname, 'mod_'.$mod->modname, array('class'=>'icon')); echo "

    $image $mod->modfullname: ". "wwwroot/mod/$mod->modname/view.php?id=$mod->id\">". format_string($instance->name,true)."

    "; diff --git a/report/progress/index.php b/report/progress/index.php index 6456ff2512a..db2920a1d6a 100644 --- a/report/progress/index.php +++ b/report/progress/index.php @@ -316,7 +316,7 @@ foreach($activities as $activity) { '/view.php?id='.$activity->id.'" title="' . s($displayname) . '">'. '
    '.$shortenedname.'
    '. '
    '. - $OUTPUT->image_icon('icon', get_string('modulename', $activity->modname), $activity->modname) . + $OUTPUT->image_icon('monologo', get_string('modulename', $activity->modname), $activity->modname) . '
    '. ''; if ($activity->completionexpected) { diff --git a/search/classes/base_mod.php b/search/classes/base_mod.php index ae5e4590a0a..6015f86d3e5 100644 --- a/search/classes/base_mod.php +++ b/search/classes/base_mod.php @@ -294,7 +294,7 @@ abstract class base_mod extends base { * @return \core_search\document_icon */ public function get_doc_icon(document $doc) : document_icon { - return new document_icon('icon', $this->get_module_name()); + return new document_icon('monologo', $this->get_module_name()); } /** diff --git a/search/tests/base_activity_test.php b/search/tests/base_activity_test.php index 0d855badf75..d74ddead2fb 100644 --- a/search/tests/base_activity_test.php +++ b/search/tests/base_activity_test.php @@ -391,7 +391,7 @@ class search_base_activity_testcase extends advanced_testcase { $result = $baseactivity->get_doc_icon($document); - $this->assertEquals('icon', $result->get_name()); + $this->assertEquals('monologo', $result->get_name()); $this->assertEquals('test_activity', $result->get_component()); } } diff --git a/theme/boost/classes/output/core_renderer.php b/theme/boost/classes/output/core_renderer.php index b01ba4138d5..5270d1465d2 100644 --- a/theme/boost/classes/output/core_renderer.php +++ b/theme/boost/classes/output/core_renderer.php @@ -154,7 +154,7 @@ class core_renderer extends \core_renderer { $heading = $this->page->course->fullname; } else { $heading = $this->page->cm->get_formatted_name(); - $imagedata = $this->pix_icon('icon', '', $this->page->activityname, ['class' => 'activityicon']); + $imagedata = $this->pix_icon('monologo.icon', '', $this->page->activityname, ['class' => 'activityicon']); $purposeclass = plugin_supports('mod', $this->page->activityname, FEATURE_MOD_PURPOSE); $purposeclass .= ' activityiconcontainer'; $purposeclass .= ' modicon_' . $this->page->activityname; diff --git a/theme/image.php b/theme/image.php index e9cc853f81d..8cc571b7da7 100644 --- a/theme/image.php +++ b/theme/image.php @@ -48,15 +48,19 @@ if ($slashargument = min_get_slash_argument()) { $themename = min_clean_param($themename, 'SAFEDIR'); $component = min_clean_param($component, 'SAFEDIR'); $rev = min_clean_param($rev, 'INT'); - $image = min_clean_param($image, 'SAFEPATH'); - + $images = explode('.', $image); } else { $themename = min_optional_param('theme', 'standard', 'SAFEDIR'); $component = min_optional_param('component', 'core', 'SAFEDIR'); $rev = min_optional_param('rev', -1, 'INT'); - $image = min_optional_param('image', '', 'SAFEPATH'); + $images = min_optional_param('images', '', 'RAW'); + $images = explode('.', $images); $usesvg = (bool)min_optional_param('svg', '1', 'INT'); } +$images = array_map(function (string $image) { + return min_clean_param($image, 'SAFEPATH'); +}, $images); +$image = reset($images); if (empty($component) or $component === 'moodle' or $component === 'core') { $component = 'core'; @@ -78,31 +82,48 @@ $candidatelocation = "$CFG->localcachedir/theme/$rev/$themename/pix/$component"; $etag = sha1("$rev/$themename/$component/$image"); if ($rev > 0) { - if (file_exists("$candidatelocation/$image.error")) { - // This is a major speedup if there are multiple missing images, - // the only problem is that random requests may pollute our cache. + $cacheimage = false; + $lookuprequired = false; + foreach ($images as $image) { + if (file_exists("$candidatelocation/$image.error")) { + // This is a major speedup if there are multiple missing images, + // the only problem is that random requests may pollute our cache. + continue; + } + + $lookuprequired = true; + if ($usesvg && file_exists("$candidatelocation/$image.svg")) { + $cacheimage = "$candidatelocation/$image.svg"; + $ext = 'svg'; + } else if (file_exists("$candidatelocation/$image.png")) { + $cacheimage = "$candidatelocation/$image.png"; + $ext = 'png'; + } else if (file_exists("$candidatelocation/$image.gif")) { + $cacheimage = "$candidatelocation/$image.gif"; + $ext = 'gif'; + } else if (file_exists("$candidatelocation/$image.jpg")) { + $cacheimage = "$candidatelocation/$image.jpg"; + $ext = 'jpg'; + } else if (file_exists("$candidatelocation/$image.jpeg")) { + $cacheimage = "$candidatelocation/$image.jpeg"; + $ext = 'jpeg'; + } else if (file_exists("$candidatelocation/$image.ico")) { + $cacheimage = "$candidatelocation/$image.ico"; + $ext = 'ico'; + } + + if ($cacheimage) { + // The image was found in a candidate location. + // It will be served outside of the loop. + break; + } + } + + if (!$lookuprequired) { + // None of the images required a lookup - all had previously cached error states. image_not_found(); } - $cacheimage = false; - if ($usesvg && file_exists("$candidatelocation/$image.svg")) { - $cacheimage = "$candidatelocation/$image.svg"; - $ext = 'svg'; - } else if (file_exists("$candidatelocation/$image.png")) { - $cacheimage = "$candidatelocation/$image.png"; - $ext = 'png'; - } else if (file_exists("$candidatelocation/$image.gif")) { - $cacheimage = "$candidatelocation/$image.gif"; - $ext = 'gif'; - } else if (file_exists("$candidatelocation/$image.jpg")) { - $cacheimage = "$candidatelocation/$image.jpg"; - $ext = 'jpg'; - } else if (file_exists("$candidatelocation/$image.jpeg")) { - $cacheimage = "$candidatelocation/$image.jpeg"; - $ext = 'jpeg'; - } else if (file_exists("$candidatelocation/$image.ico")) { - $cacheimage = "$candidatelocation/$image.ico"; - $ext = 'ico'; - } + if ($cacheimage) { if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { // We do not actually need to verify the etag value because our files @@ -136,8 +157,15 @@ $themerev = theme_get_revision(); if ($themerev <= 0 or $rev != $themerev) { // Do not send caching headers if they do not request current revision, // we do not want to pollute browser caches with outdated images. - $imagefile = $theme->resolve_image_location($image, $component, $usesvg); - if (empty($imagefile) or !is_readable($imagefile)) { + foreach ($images as $image) { + $imagefile = $theme->resolve_image_location($image, $component, $usesvg); + if (!empty($imagefile) && is_readable($imagefile)) { + break; + } + $imagefile = null; + } + + if (empty($imagefile)) { image_not_found(); } send_uncached_image($imagefile); @@ -154,9 +182,13 @@ make_localcache_directory('theme', false); // * if the browser has requested the non-SVG version, we *must* cache _both_ the SVG, and the non-SVG versions. // First get all copies - including, potentially, the SVG version. -$imagefile = $theme->resolve_image_location($image, $component, true); +$imagefile = null; +foreach ($images as $image) { + $imagefile = $theme->resolve_image_location($image, $component, true); + if (!empty($imagefile) && is_readable($imagefile)) { + break; + } -if (empty($imagefile) || !is_readable($imagefile)) { // Unable to find a copy of the image file in any format. // We write a .error file for the image now - this will be used above when searching for cached copies to prevent // trying to find the image in the future. @@ -167,6 +199,11 @@ if (empty($imagefile) || !is_readable($imagefile)) { $cacheimage = "$candidatelocation/$image.error"; $fp = fopen($cacheimage, 'w'); fclose($fp); + + $imagefile = null; +} + +if ($imagefile == null) { image_not_found(); }