Skip to content

Commit

Permalink
Merge branch 'MDL-74235-master-2' of https://github.com/andrewnicols/…
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyatregubov committed Apr 7, 2022
2 parents 7310711 + 4b388fc commit 29da0c7
Show file tree
Hide file tree
Showing 93 changed files with 173 additions and 104 deletions.
2 changes: 1 addition & 1 deletion admin/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
39 changes: 25 additions & 14 deletions admin/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

/**
Expand Down Expand Up @@ -1087,12 +1080,21 @@ public function plugins_check_table(core_plugin_manager $pluginman, $version, ar
$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 = '';
}
Expand Down Expand Up @@ -1805,11 +1807,20 @@ public function plugins_control_panel(core_plugin_manager $pluginman, array $opt
}

foreach ($plugins as $name => $plugin) {
$component = "{$plugin->type}_{$plugin->name}";

$row = new html_table_row();
$row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
$row->attributes['class'] = "type-{$plugin->type} name-{$component}";

$iconidentifier = 'icon';
if ($plugin->type === 'mod') {
$iconidentifier = 'monologo';
}

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'));
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();
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/recyclebin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/backup_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ protected function define_settings() {
// - 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
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/restore_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ protected function define_settings() {
// - 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
Expand Down
2 changes: 1 addition & 1 deletion backup/util/ui/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function backup_details($details, $nextstageurl) {
$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,
Expand Down
4 changes: 2 additions & 2 deletions blocks/activity_modules/block_activity_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ function get_content() {

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>';
}
}
Expand Down
2 changes: 1 addition & 1 deletion blocks/feedback/block_feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function get_content() {
$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;
Expand Down
2 changes: 1 addition & 1 deletion calendar/classes/external/event_icon_exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(event_interface $event, $related = []) {
$isuserevent = ($user && !empty($userid));

if ($isactivityevent) {
$key = 'icon';
$key = 'monologo';
$component = $coursemodule->get('modname');

if (get_string_manager()->string_exists($event->get_type(), $component)) {
Expand Down
4 changes: 2 additions & 2 deletions completion/classes/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function get_activities_and_resources() {
$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);
Expand Down Expand Up @@ -543,4 +543,4 @@ public static function get_default_completion($course, $module, $flatten = true)
}
return $data;
}
}
}
2 changes: 1 addition & 1 deletion completion/criteria/completion_criteria_activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,6 @@ public function get_details($completion) {
* @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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function find_all(): array {
$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,
Expand Down Expand Up @@ -274,7 +274,7 @@ public function find_all_for_course(\stdClass $course, \stdClass $user): array {
$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,
Expand Down
2 changes: 1 addition & 1 deletion course/format/singleactivity/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected function navigation_add_activity(navigation_node $node, $cm) {
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)) {
Expand Down
4 changes: 2 additions & 2 deletions course/modedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@
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();
Expand Down
2 changes: 1 addition & 1 deletion course/recent.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
$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");
Expand Down
2 changes: 1 addition & 1 deletion course/templates/activityinstance.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions course/templates/bulkactivitycompletion.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -123,4 +123,4 @@ require([
}
});
});
{{/js}}
{{/js}}
2 changes: 1 addition & 1 deletion course/templates/defaultactivitycompletion.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion course/templates/editbulkactivitycompletion.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}]
}
}}
Expand Down
2 changes: 1 addition & 1 deletion course/templates/editdefaultcompletion.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}]
}
}}
Expand Down
2 changes: 1 addition & 1 deletion grade/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ public function get_element_icon(&$element, $spacerifnone=false) {
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));
Expand Down
4 changes: 2 additions & 2 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2319,7 +2319,7 @@ protected function load_section_activities(navigation_node $sectionnode, $sectio
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
Expand Down Expand Up @@ -2373,7 +2373,7 @@ protected function load_stealth_activity(navigation_node $coursenode, $modinfo)
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);
Expand Down
43 changes: 31 additions & 12 deletions lib/outputlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2103,24 +2103,43 @@ public function resolve_image_location($image, $component, $svg = false) {

} 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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>';
}

Expand Down
2 changes: 1 addition & 1 deletion message/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,7 @@ public static function get_messages($useridto, $useridfrom = 0, $type = 'both',
}

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');
}
Expand Down
2 changes: 1 addition & 1 deletion message/output/popup/classes/output/popup_notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function export_for_template(\renderer_base $output) {
$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');
}
Expand Down
Loading

0 comments on commit 29da0c7

Please sign in to comment.