MDL-74235 core: Update core uses of activity icons to monologo

This commit is contained in:
Andrew Nicols
2022-04-07 12:56:14 +08:00
parent eb0a95956f
commit 4b388fc239
43 changed files with 141 additions and 93 deletions
+1 -1
View File
@@ -75,7 +75,7 @@
$missing = true;
} else {
// took out hspace="\10\", because it does not validate. don't know what to replace with.
$icon = "<img src=\"" . $OUTPUT->image_url('icon', $module->name) . "\" class=\"icon\" alt=\"\" />";
$icon = "<img src=\"" . $OUTPUT->image_url('monologo', $module->name) . "\" class=\"icon\" alt=\"\" />";
$strmodulename = $icon.' '.get_string('modulename', $module->name);
$missing = false;
}
+26 -15
View File
@@ -15,20 +15,13 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Renderer for core_admin subsystem
* Standard HTML output renderer for core_admin subsystem.
*
* @package core
* @subpackage admin
* @copyright 2011 David Mudrak <[email protected]>
* @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();
}
+1 -1
View File
@@ -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;
}
}
@@ -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
@@ -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
+1 -1
View File
@@ -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,
@@ -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[] = '<a href="'.$CFG->wwwroot.'/course/resources.php?id='.$course->id.'">'.$icon.$modfullname.'</a>';
} else {
$icon = $OUTPUT->image_icon('icon', get_string('pluginname', $modname), $modname);
$icon = $OUTPUT->image_icon('monologo', get_string('pluginname', $modname), $modname);
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$course->id.'">'.$icon.$modfullname.'</a>';
}
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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)) {
+2 -2
View File
@@ -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;
}
}
}
@@ -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);
}
}
@@ -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,
+1 -1
View File
@@ -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)) {
+2 -2
View File
@@ -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();
+1 -1
View File
@@ -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");
+1 -1
View File
@@ -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"
@@ -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}}
{{/js}}
@@ -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"
@@ -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"
}]
}
}}
@@ -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"
}]
}
}}
+1 -1
View File
@@ -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));
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -2711,7 +2711,7 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid
$class = 'activity '.$mod->modname;
$class .= ($cmid == $mod->id) ? ' selected' : '';
$menu[] = '<li class="'.$class.'">'.
$OUTPUT->image_icon('icon', '', $mod->modname).
$OUTPUT->image_icon('monologo', '', $mod->modname).
'<a href="'.$CFG->wwwroot.'/mod/'.$url.'">'.$mod->name.'</a></li>';
}
+1 -1
View File
@@ -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');
}
@@ -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');
}
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -939,7 +939,7 @@ function assign_print_recent_mod_activity($activity, $courseid, $detail, $modnam
if ($detail) {
$modname = $modnames[$activity->type];
echo '<div class="title">';
echo $OUTPUT->image_icon('icon', $modname, 'assign');
echo $OUTPUT->image_icon('monologo', $modname, 'assign');
echo '<a href="' . $CFG->wwwroot . '/mod/assign/view.php?id=' . $activity->cmid . '">';
echo $activity->name;
echo '</a>';
+1 -1
View File
@@ -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).
+1 -1
View File
@@ -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';
+1 -1
View File
@@ -496,7 +496,7 @@ function feedback_print_recent_mod_activity($activity, $courseid, $detail, $modn
if ($detail) {
$modname = $modnames[$activity->type];
echo '<div class="title">';
echo $OUTPUT->image_icon('icon', $modname, $activity->type);
echo $OUTPUT->image_icon('monologo', $modname, $activity->type);
echo "<a href=\"$CFG->wwwroot/mod/feedback/view.php?id={$activity->cmid}\">{$activity->name}</a>";
echo '</div>';
}
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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'));
}
+1 -1
View File
@@ -996,7 +996,7 @@ function quiz_print_recent_mod_activity($activity, $courseid, $detail, $modnames
if ($detail) {
$modname = $modnames[$activity->type];
echo '<div class="title">';
echo $OUTPUT->image_icon('icon', $modname, $activity->type);
echo $OUTPUT->image_icon('monologo', $modname, $activity->type);
echo '<a href="' . $CFG->wwwroot . '/mod/quiz/view.php?id=' .
$activity->cmid . '">' . $activity->name . '</a>';
echo '</div>';
+2 -2
View File
@@ -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');
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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 "<tr>";
echo "<td valign=\"top\">$image</td>";
+1 -1
View File
@@ -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 "<h4>$image $mod->modfullname: ".
"<a href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
format_string($instance->name,true)."</a></h4>";
+1 -1
View File
@@ -316,7 +316,7 @@ foreach($activities as $activity) {
'/view.php?id='.$activity->id.'" title="' . s($displayname) . '">'.
'<div class="rotated-text-container"><span class="rotated-text">'.$shortenedname.'</span></div>'.
'<div class="modicon">'.
$OUTPUT->image_icon('icon', get_string('modulename', $activity->modname), $activity->modname) .
$OUTPUT->image_icon('monologo', get_string('modulename', $activity->modname), $activity->modname) .
'</div>'.
'</a>';
if ($activity->completionexpected) {
+1 -1
View File
@@ -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());
}
/**
+1 -1
View File
@@ -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());
}
}
+1 -1
View File
@@ -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;
+67 -30
View File
@@ -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();
}