From 82e868fd38191cc6a72b9f97ac80b1864534395d Mon Sep 17 00:00:00 2001 From: Stefan Topfstedt Date: Mon, 27 Jul 2020 16:05:33 -0700 Subject: [PATCH] MDL-69168 block_recentlyaccesseditems: apply custom icon Overwrite the default mod icon with the configured icon url if applicable. --- .../recentlyaccesseditems_item_exporter.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/blocks/recentlyaccesseditems/classes/external/recentlyaccesseditems_item_exporter.php b/blocks/recentlyaccesseditems/classes/external/recentlyaccesseditems_item_exporter.php index f26b43d1efb..934433d9cc1 100644 --- a/blocks/recentlyaccesseditems/classes/external/recentlyaccesseditems_item_exporter.php +++ b/blocks/recentlyaccesseditems/classes/external/recentlyaccesseditems_item_exporter.php @@ -49,13 +49,18 @@ class recentlyaccesseditems_item_exporter extends \core\external\exporter { * @return array Additional properties with values */ protected function get_other_values(renderer_base $output) { - global $OUTPUT; + global $CFG; + require_once($CFG->libdir.'/modinfolib.php'); return array( - 'viewurl' => (new moodle_url('/mod/'.$this->data->modname.'/view.php', - array('id' => $this->data->cmid)))->out(false), - 'courseviewurl' => (new moodle_url('/course/view.php', array('id' => $this->data->courseid)))->out(false), - 'icon' => $OUTPUT->image_icon('icon', get_string('pluginname', $this->data->modname), $this->data->modname) + 'viewurl' => (new moodle_url('/mod/'.$this->data->modname.'/view.php', + array('id' => $this->data->cmid)))->out(false), + 'courseviewurl' => (new moodle_url('/course/view.php', array('id' => $this->data->courseid)))->out(false), + 'icon' => \html_writer::img( + get_fast_modinfo($this->data->courseid)->cms[$this->data->cmid]->get_icon_url(), + get_string('pluginname', $this->data->modname), + ['title' => get_string('pluginname', $this->data->modname), 'class' => 'icon'] + ) ); } @@ -111,4 +116,4 @@ class recentlyaccesseditems_item_exporter extends \core\external\exporter { ) ); } -} \ No newline at end of file +}