diff --git a/classes/renderer.php b/classes/renderer.php index 90495a3299d61f0b949c1627d4c4a609a58bb136..1e05a607f2079109b90a497bed869ab49acb5704 100644 --- a/classes/renderer.php +++ b/classes/renderer.php @@ -163,12 +163,24 @@ class renderer { $item->modtext = self::replace_image_with_string($item->modtext); } + try { + // Create a download button for .mbz file. + $storage = new storage(); + $file = $storage->get($item->filename); + $downloadurl = \moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), + null, $file->get_filepath(), $file->get_filename(), true); + $downloadbutton = html_writer::link($downloadurl, '<i class="fa fa-download" alt="' . get_string('download') . '"></i>', + [ 'title' => get_string('downloadfile') ]); + } catch (\block_sharing_cart\exceptions\cannot_find_file_exception $e) { + $downloadbutton = ''; + } + return ' <li class="activity ' . $class . '" id="block_sharing_cart-item-' . $item->id . '" data-disable-copy="'. ($item->uninstalled_plugin ?? 0) .'"> <div class="sc-indent-' . $depth . '" title="' . $title . '"> ' . self::render_modicon($item) . ' <span class="instancename">' . format_string($item->modtext) . '</span> - <span class="commands"></span> + <span class="commands">' . $downloadbutton . '</span> </div> </li>'; }