/** * Returns information about file in this repository by reference * {@link repository::get_file_reference()} * {@link repository::get_file()} * * Returns null if file not found or is not readable * * @param stdClass $reference file reference db record * @return null|stdClass that has 'filepath' property */ public function get_file_by_reference($reference) { global $USER; $ref = unserialize($reference->reference); if (!isset($ref->url)) { // this is an old-style reference in DB. We need to fix it $ref = unserialize($this->fix_old_style_reference($reference->reference)); } if (!isset($ref->url)) { return null; } $c = new curl; $url = $this->get_file_download_link($ref->url); if (file_extension_in_typegroup($ref->path, 'web_image')) { $saveas = $this->prepare_file(''); try { $result = $c->download_one($url, array(), array('filepath' => $saveas, 'timeout' => self::SYNCIMAGE_TIMEOUT, 'followlocation' => true)); $info = $c->get_info(); if ($result === true && isset($info['http_code']) && $info['http_code'] == 200) { return (object)array('filepath' => $saveas); } } catch (Exception $e) {} } $c->get($url, null, array('timeout' => self::SYNCIMAGE_TIMEOUT, 'followlocation' => true, 'nobody' => true)); $info = $c->get_info(); if (isset($info['http_code']) && $info['http_code'] == 200 && array_key_exists('download_content_length', $info) && $info['download_content_length'] >= 0) { return (object)array('filesize' => (int)$info['download_content_length']); } return null; }
/** * Synchronize the references. * * @param stored_file $file Stored file. * @return boolean */ public function sync_reference(stored_file $file) { if ($file->get_referencelastsync() + DAYSECS > time()) { // Synchronise not more often than once a day. return false; } $c = new curl(); $reference = unserialize(self::convert_to_valid_reference($file->get_reference())); $url = $reference->downloadurl; if (file_extension_in_typegroup($file->get_filename(), 'web_image')) { $path = $this->prepare_file(''); $result = $c->download_one($url, null, array('filepath' => $path, 'timeout' => $CFG->repositorysyncimagetimeout)); $info = $c->get_info(); if ($result === true && isset($info['http_code']) && $info['http_code'] == 200) { $fs = get_file_storage(); list($contenthash, $filesize, $newfile) = $fs->add_file_to_pool($path); $file->set_synchronized($contenthash, $filesize); return true; } } $c->get($url, null, array('timeout' => $CFG->repositorysyncimagetimeout, 'followlocation' => true, 'nobody' => true)); $info = $c->get_info(); if (isset($info['http_code']) && $info['http_code'] == 200 && array_key_exists('download_content_length', $info) && $info['download_content_length'] >= 0) { $filesize = (int) $info['download_content_length']; $file->set_synchronized(null, $filesize); return true; } $file->set_missingsource(); return true; }
/** * Returns information about file in this repository by reference * * If the file is an image we download the contents and save it in our filesystem * so we can generate thumbnails. Otherwise we just request the file size. * Returns null if file not found or can not be accessed * * @param stdClass $reference file reference db record * @return stdClass|null contains one of the following: * - 'filesize' (for non-image files or files we failed to retrieve fully because of timeout) * - 'filepath' (for image files that we retrieived and saved) */ public function get_file_by_reference($reference) { global $USER; $ref = @unserialize(base64_decode($reference->reference)); if (!isset($ref->url) || !($url = $this->appendtoken($ref->url))) { // Occurs when the user isn't known.. return null; } $return = null; $cookiepathname = $this->prepare_file($USER->id. '_'. uniqid('', true). '.cookie'); $c = new curl(array('cookie' => $cookiepathname)); if (file_extension_in_typegroup($ref->filename, 'web_image')) { $path = $this->prepare_file(''); $result = $c->download_one($url, null, array('filepath' => $path, 'followlocation' => true, 'timeout' => self::SYNCIMAGE_TIMEOUT)); if ($result === true) { $return = (object)array('filepath' => $path); } } else { $result = $c->head($url, array('followlocation' => true, 'timeout' => self::SYNCFILE_TIMEOUT)); } // Delete cookie jar. if (file_exists($cookiepathname)) { unlink($cookiepathname); } $this->connection_result($c->get_errno()); $curlinfo = $c->get_info(); if ($return === null && isset($curlinfo['http_code']) && $curlinfo['http_code'] == 200 && array_key_exists('download_content_length', $curlinfo) && $curlinfo['download_content_length'] >= 0) { // we received a correct header and at least can tell the file size $return = (object)array('filesize' => $curlinfo['download_content_length']); } return $return; }
if (empty($CFG->courseoverviewfileslimit)) { return array(); } require_once $CFG->libdir . '/filestorage/file_storage.php'; require_once $CFG->dirroot . '/course/lib.php'; $fs = get_file_storage(); $context = context_course::instance($COURSE->id); $files = $fs->get_area_files($context->id, 'course', 'overviewfiles', false, 'filename', false); if (count($files)) { $overviewfilesoptions = course_overviewfiles_options($COURSE->id); $acceptedtypes = $overviewfilesoptions['accepted_types']; if ($acceptedtypes !== '*') { // Filter only files with allowed extensions. require_once $CFG->libdir . '/filelib.php'; foreach ($files as $key => $file) { if (!file_extension_in_typegroup($file->get_filename(), $acceptedtypes)) { unset($files[$key]); } } } if (count($files) > $CFG->courseoverviewfileslimit) { // Return no more than $CFG->courseoverviewfileslimit files. $files = array_slice($files, 0, $CFG->courseoverviewfileslimit, true); } } // Display course overview files. $courseimage = ''; foreach ($files as $file) { $isimage = $file->is_valid_image(); if ($isimage) { $courseimage = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
public function sync_reference(stored_file $file) { global $USER; if ($file->get_referencelastsync() + DAYSECS > time() || !$this->connection_result()) { // Synchronise not more often than once a day. // if we had several unsuccessfull attempts to connect to server - do not try any more. return false; } $ref = @unserialize(base64_decode($file->get_reference())); if (!isset($ref->url) || !($url = $this->appendtoken($ref->url))) { // Occurs when the user isn't known.. $file->set_missingsource(); return true; } $cookiepathname = $this->prepare_file($USER->id . '_' . uniqid('', true) . '.cookie'); $c = new curl(array('cookie' => $cookiepathname)); if (file_extension_in_typegroup($ref->filename, 'web_image')) { $path = $this->prepare_file(''); $result = $c->download_one($url, null, array('filepath' => $path, 'followlocation' => true, 'timeout' => $CFG->repositorysyncimagetimeout)); if ($result === true) { $fs = get_file_storage(); list($contenthash, $filesize, $newfile) = $fs->add_file_to_pool($path); $file->set_synchronized($contenthash, $filesize); return true; } } else { $result = $c->head($url, array('followlocation' => true, 'timeout' => $CFG->repositorysyncfiletimeout)); } // Delete cookie jar. if (file_exists($cookiepathname)) { unlink($cookiepathname); } $this->connection_result($c->get_errno()); $curlinfo = $c->get_info(); if (isset($curlinfo['http_code']) && $curlinfo['http_code'] == 200 && array_key_exists('download_content_length', $curlinfo) && $curlinfo['download_content_length'] >= 0) { // we received a correct header and at least can tell the file size $file->set_synchronized(null, $curlinfo['download_content_length']); return true; } $file->set_missingsource(); return true; }
public function sync_reference(stored_file $file) { if ($file->get_referencelastsync() + 60 > time()) { // Does not cost us much to synchronise within our own filesystem, check every 1 minute. return false; } static $issyncing = false; if ($issyncing) { // Avoid infinite recursion when calling $file->get_filesize() and get_contenthash(). return false; } $filepath = $this->get_rootpath() . ltrim($file->get_reference(), '/'); if ($this->is_in_repository($file->get_reference()) && file_exists($filepath) && is_readable($filepath)) { $fs = get_file_storage(); $issyncing = true; if (file_extension_in_typegroup($filepath, 'web_image')) { $contenthash = sha1_file($filepath); if ($file->get_contenthash() == $contenthash) { // File did not change since the last synchronisation. $filesize = filesize($filepath); } else { // Copy file into moodle filepool (used to generate an image thumbnail). list($contenthash, $filesize, $newfile) = $fs->add_file_to_pool($filepath); } } else { // Update only file size so file will NOT be copied into moodle filepool. $emptyfile = $contenthash = sha1(''); $currentcontenthash = $file->get_contenthash(); if ($currentcontenthash !== $emptyfile && $currentcontenthash === sha1_file($filepath)) { // File content was synchronised and has not changed since then, leave it. $contenthash = null; } $filesize = filesize($filepath); } $issyncing = false; $file->set_synchronized($contenthash, $filesize); } else { $file->set_missingsource(); } return true; }
/** * Returns information about file in this repository by reference * * Returns null if file not found or is not readable * * @param stdClass $reference file reference db record * @return stdClass|null contains one of the following: * - 'filesize' if file should not be copied to moodle filepool * - 'filepath' if file should be copied to moodle filepool */ public function get_file_by_reference($reference) { $ref = $reference->reference; if ($ref{0} == '/') { $filepath = $this->root_path.substr($ref, 1, strlen($ref)-1); } else { $filepath = $this->root_path.$ref; } if (file_exists($filepath) && is_readable($filepath)) { if (file_extension_in_typegroup($filepath, 'web_image')) { // return path to image files so it will be copied into moodle filepool // we need the file in filepool to generate an image thumbnail return (object)array('filepath' => $filepath); } else { // return just the file size so file will NOT be copied into moodle filepool return (object)array( 'filesize' => filesize($filepath) ); } } else { return null; } }
require_login(); require_capability('tool/unittest:execute', get_context_instance(CONTEXT_SYSTEM)); // get file requested $relativepath = get_file_argument(); // basic check, start by slash if (!$relativepath) { print_error('invalidargorconf'); } else { if ($relativepath[0] != '/') { print_error('pathdoesnotstartslash'); } } // determine which disk file is going to be served // and how it's going to be named $filepath = $CFG->dataroot . '/codecoverage' . $relativepath; $filename = basename($filepath); // extract relative path components $args = explode('/', ltrim($relativepath, '/')); // only serve from some controlled subdirs $alloweddirs = array('dbtest', 'unittest'); if (!isset($args[0]) || !in_array($args[0], $alloweddirs)) { print_error('invalidarguments'); } // only serve some controlled extensions/mimetypes if (!file_extension_in_typegroup($filepath, array('web_file', 'web_image'), true)) { print_error('invalidarguments'); } // arrived here, send the file session_get_instance()->write_close(); // unlock session during fileserving send_file($filepath, $filename, 0, false);
/** * Returns all uploads since a given time in specified folder. * * @param array $activities * @param int $index * @param int $timestart * @param int $courseid * @param int $cmid * @param int $userid * @param int $groupid not used, but required for compatibilty with other modules */ function folder_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid = 0, $groupid = 0) { global $COURSE, $DB, $OUTPUT; if ($COURSE->id == $courseid) { $course = $COURSE; } else { $course = $DB->get_record('course', array('id' => $courseid)); } $modinfo = get_fast_modinfo($course); $cm = $modinfo->cms[$cmid]; $context = context_module::instance($cm->id); if (!has_capability('mod/folder:view', $context)) { return; } $files = folder_get_recent_activity($context, $timestart, $userid); foreach ($files as $file) { $tmpactivity = new stdClass(); $tmpactivity->type = 'folder'; $tmpactivity->cmid = $cm->id; $tmpactivity->sectionnum = $cm->sectionnum; $tmpactivity->timestamp = $file->get_timemodified(); $tmpactivity->user = core_user::get_user($file->get_userid()); $tmpactivity->content = new stdClass(); $tmpactivity->content->url = moodle_url::make_pluginfile_url($file->get_contextid(), 'mod_folder', 'content', $file->get_itemid(), $file->get_filepath(), $file->get_filename()); if (file_extension_in_typegroup($file->get_filename(), 'web_image')) { $image = $tmpactivity->content->url->out(false, array('preview' => 'tinyicon', 'oid' => $file->get_timemodified())); $image = html_writer::empty_tag('img', array('src' => $image)); } else { $image = $OUTPUT->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle'); } $tmpactivity->content->image = $image; $tmpactivity->content->filename = $file->get_filename(); $activities[$index++] = $tmpactivity; } }
/** * Returns information about file in this repository by reference * {@link repository::get_file_reference()} * {@link repository::get_file()} * * Returns null if file not found or is not readable * * @param stdClass $reference file reference db record * @return null|stdClass with attribute 'filepath' */ public function get_file_by_reference($reference) { $array = explode('/', $reference->reference); $fileid = array_pop($array); $fileinfo = $this->boxclient->get_file_info($fileid, self::SYNCFILE_TIMEOUT); if ($fileinfo) { $size = (int)$fileinfo->size; if (file_extension_in_typegroup($fileinfo->file_name, 'web_image')) { // this is an image - download it to moodle $path = $this->prepare_file(''); $c = new curl; $result = $c->download_one($reference->reference, null, array('filepath' => $path, 'timeout' => self::SYNCIMAGE_TIMEOUT)); if ($result === true) { return (object)array('filepath' => $path); } } return (object)array('filesize' => $size); } return null; }
/** * Returns human-readable string of supported file/link types for the "Manage media players" page * @param array $usedextensions extensions that should NOT be highlighted * @return string */ public function supports($usedextensions = []) { $out = []; if ($extensions = $this->get_supported_extensions()) { $video = $audio = $other = []; foreach ($extensions as $key => $extension) { $displayextension = $extension; if (!in_array($extension, $usedextensions)) { $displayextension = '<strong>' . $extension . '</strong>'; } if (file_extension_in_typegroup('file.' . $extension, 'audio')) { $audio[] = $displayextension; } else { if (file_extension_in_typegroup('file.' . $extension, 'video')) { $video[] = $displayextension; } else { $other[] = $displayextension; } } } if ($video) { $out[] = get_string('videoextensions', 'core_media', join(', ', $video)); } if ($audio) { $out[] = get_string('audioextensions', 'core_media', join(', ', $audio)); } if ($other) { $out[] = get_string('extensions', 'core_media', join(', ', $other)); } } return join('<br>', $out); }
public function sync_reference(stored_file $file) { global $CFG; if ($file->get_referencelastsync() + DAYSECS > time()) { // Synchronise not more often than once a day. return false; } $ref = unserialize($file->get_reference()); if (!isset($ref->url)) { // this is an old-style reference in DB. We need to fix it $ref = unserialize($this->fix_old_style_reference($file->get_reference())); } if (!isset($ref->url)) { return false; } $c = new curl(); $url = $this->get_file_download_link($ref->url); if (file_extension_in_typegroup($ref->path, 'web_image')) { $saveas = $this->prepare_file(''); try { $result = $c->download_one($url, array(), array('filepath' => $saveas, 'timeout' => $CFG->repositorysyncimagetimeout, 'followlocation' => true)); $info = $c->get_info(); if ($result === true && isset($info['http_code']) && $info['http_code'] == 200) { $fs = get_file_storage(); list($contenthash, $filesize, $newfile) = $fs->add_file_to_pool($saveas); $file->set_synchronized($contenthash, $filesize); return true; } } catch (Exception $e) { } } $c->get($url, null, array('timeout' => $CFG->repositorysyncimagetimeout, 'followlocation' => true, 'nobody' => true)); $info = $c->get_info(); if (isset($info['http_code']) && $info['http_code'] == 200 && array_key_exists('download_content_length', $info) && $info['download_content_length'] >= 0) { $filesize = (int) $info['download_content_length']; $file->set_synchronized(null, $filesize); return true; } $file->set_missingsource(); return true; }
/** * Performs synchronisation of an external file if the previous one has expired. * * This function must be implemented for external repositories supporting * FILE_REFERENCE, it is called for existing aliases when their filesize, * contenthash or timemodified are requested. It is not called for internal * repositories (see {@link repository::has_moodle_files()}), references to * internal files are updated immediately when source is modified. * * Referenced files may optionally keep their content in Moodle filepool (for * thumbnail generation or to be able to serve cached copy). In this * case both contenthash and filesize need to be synchronized. Otherwise repositories * should use contenthash of empty file and correct filesize in bytes. * * Note that this function may be run for EACH file that needs to be synchronised at the * moment. If anything is being downloaded or requested from external sources there * should be a small timeout. The synchronisation is performed to update the size of * the file and/or to update image and re-generated image preview. There is nothing * fatal if syncronisation fails but it is fatal if syncronisation takes too long * and hangs the script generating a page. * * Note: If you wish to call $file->get_filesize(), $file->get_contenthash() or * $file->get_timemodified() make sure that recursion does not happen. * * Called from {@link stored_file::sync_external_file()} * * @inheritDocs */ public function sync_reference(stored_file $file) { global $CFG; if ($file->get_referencelastsync() + DAYSECS > time()) { // Only synchronise once per day. return false; } $reference = $this->unpack_reference($file->get_reference()); if (!isset($reference->url)) { // The URL to sync with is missing. return false; } $c = new curl(); $url = $this->get_file_download_link($reference->url); if (file_extension_in_typegroup($reference->path, 'web_image')) { $saveas = $this->prepare_file(''); try { $result = $c->download_one($url, [], ['filepath' => $saveas, 'timeout' => $CFG->repositorysyncimagetimeout, 'followlocation' => true]); $info = $c->get_info(); if ($result === true && isset($info['http_code']) && $info['http_code'] == 200) { $fs = get_file_storage(); list($contenthash, $filesize, ) = $fs->add_file_to_pool($saveas); $file->set_synchronized($contenthash, $filesize); return true; } } catch (Exception $e) { // IF the download_one fails, we will attempt to download // again with get() anyway. } } $c->get($url, null, array('timeout' => $CFG->repositorysyncimagetimeout, 'followlocation' => true, 'nobody' => true)); $info = $c->get_info(); if (isset($info['http_code']) && $info['http_code'] == 200 && array_key_exists('download_content_length', $info) && $info['download_content_length'] >= 0) { $filesize = (int) $info['download_content_length']; $file->set_synchronized(null, $filesize); return true; } $file->set_missingsource(); return true; }
foreach ($files->list as $file) { if ($file->type != 'folder') { $drafturl = $file->url; // a file echo '<li>'; echo $OUTPUT->pix_icon(file_file_icon($file), '', 'moodle', array('class' => 'iconsmall')); echo html_writer::link($drafturl, $file->filename); $home_url->param('filename', $file->filename); $home_url->param('draftpath', $file->filepath); $home_url->param('action', 'deletedraft'); echo ' [<a href="' . $home_url->out() . '" class="fm-operation">' . get_string('delete') . '</a>]'; $home_url->param('action', 'movefile'); echo ' [<a href="' . $home_url->out() . '" class="fm-operation">' . get_string('move') . '</a>]'; $home_url->param('action', 'renameform'); echo ' [<a href="' . $home_url->out() . '" class="fm-operation">' . get_string('rename') . '</a>]'; if (file_extension_in_typegroup($file->filename, 'archive', true)) { $home_url->param('action', 'unzip'); $home_url->param('draftpath', $file->filepath); echo ' [<a href="' . $home_url->out() . '" class="fm-operation">' . get_string('unzip') . '</a>]'; } echo '</li>'; } else { // a folder echo '<li>'; echo '<img src="' . $OUTPUT->pix_url(file_folder_icon()) . '" class="iconsmall" />'; $home_url->param('action', 'browse'); $home_url->param('draftpath', $file->filepath); $filepathchunks = explode('/', trim($file->filepath, '/')); $foldername = trim(array_pop($filepathchunks), '/'); echo html_writer::link($home_url, $foldername); $home_url->param('draftpath', $file->filepath);
/** * Listing all files (including folders) in current path (draft area) * used by file manager * @param int $draftitemid * @param string $filepath * @return stdClass */ function file_get_drafarea_files($draftitemid, $filepath = '/') { global $USER, $OUTPUT, $CFG; $context = context_user::instance($USER->id); $fs = get_file_storage(); $data = new stdClass(); $data->path = array(); $data->path[] = array('name' => get_string('files'), 'path' => '/'); // will be used to build breadcrumb $trail = '/'; if ($filepath !== '/') { $filepath = file_correct_filepath($filepath); $parts = explode('/', $filepath); foreach ($parts as $part) { if ($part != '' && $part != null) { $trail .= $part . '/'; $data->path[] = array('name' => $part, 'path' => $trail); } } } $list = array(); $maxlength = 12; if ($files = $fs->get_directory_files($context->id, 'user', 'draft', $draftitemid, $filepath, false)) { foreach ($files as $file) { $item = new stdClass(); $item->filename = $file->get_filename(); $item->filepath = $file->get_filepath(); $item->fullname = trim($item->filename, '/'); $filesize = $file->get_filesize(); $item->size = $filesize ? $filesize : null; $item->filesize = $filesize ? display_size($filesize) : ''; $item->sortorder = $file->get_sortorder(); $item->author = $file->get_author(); $item->license = $file->get_license(); $item->datemodified = $file->get_timemodified(); $item->datecreated = $file->get_timecreated(); $item->isref = $file->is_external_file(); if ($item->isref && $file->get_status() == 666) { $item->originalmissing = true; } // find the file this draft file was created from and count all references in local // system pointing to that file $source = @unserialize($file->get_source()); if (isset($source->original)) { $item->refcount = $fs->search_references_count($source->original); } if ($file->is_directory()) { $item->filesize = 0; $item->icon = $OUTPUT->pix_url(file_folder_icon(24))->out(false); $item->type = 'folder'; $foldername = explode('/', trim($item->filepath, '/')); $item->fullname = trim(array_pop($foldername), '/'); $item->thumbnail = $OUTPUT->pix_url(file_folder_icon(90))->out(false); } else { // do NOT use file browser here! $item->mimetype = get_mimetype_description($file); if (file_extension_in_typegroup($file->get_filename(), 'archive')) { $item->type = 'zip'; } else { $item->type = 'file'; } $itemurl = moodle_url::make_draftfile_url($draftitemid, $item->filepath, $item->filename); $item->url = $itemurl->out(); $item->icon = $OUTPUT->pix_url(file_file_icon($file, 24))->out(false); $item->thumbnail = $OUTPUT->pix_url(file_file_icon($file, 90))->out(false); if ($imageinfo = $file->get_imageinfo()) { $item->realthumbnail = $itemurl->out(false, array('preview' => 'thumb', 'oid' => $file->get_timemodified())); $item->realicon = $itemurl->out(false, array('preview' => 'tinyicon', 'oid' => $file->get_timemodified())); $item->image_width = $imageinfo['width']; $item->image_height = $imageinfo['height']; } } $list[] = $item; } } $data->itemid = $draftitemid; $data->list = $list; return $data; }
/** * Returns all course overview files * * @return array array of stored_file objects */ public function get_course_overviewfiles() { global $CFG; if (empty($CFG->courseoverviewfileslimit)) { return array(); } require_once $CFG->libdir . '/filestorage/file_storage.php'; require_once $CFG->dirroot . '/course/lib.php'; $fs = get_file_storage(); $context = context_course::instance($this->id); $files = $fs->get_area_files($context->id, 'course', 'overviewfiles', false, 'filename', false); if (count($files)) { $overviewfilesoptions = course_overviewfiles_options($this->id); $acceptedtypes = $overviewfilesoptions['accepted_types']; if ($acceptedtypes !== '*') { // Filter only files with allowed extensions. require_once $CFG->libdir . '/filelib.php'; foreach ($files as $key => $file) { if (!file_extension_in_typegroup($file->get_filename(), $acceptedtypes)) { unset($files[$key]); } } } if (count($files) > $CFG->courseoverviewfileslimit) { // Return no more than $CFG->courseoverviewfileslimit files. $files = array_slice($files, 0, $CFG->courseoverviewfileslimit, true); } } return $files; }
/** * Internal function - creates htmls structure suitable for YUI tree. */ protected function htmllize_tree($tree, $dir) { global $CFG; if (empty($dir['subdirs']) and empty($dir['files'])) { return ''; } $result = '<ul>'; foreach ($dir['subdirs'] as $subdir) { $image = $this->output->pix_icon(file_folder_icon(24), $subdir['dirname'], 'moodle'); $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', s($subdir['dirname']), array('class' => 'fp-filename')); $filename = html_writer::tag('div', $filename, array('class' => 'fp-filename-icon')); $result .= html_writer::tag('li', $filename. $this->htmllize_tree($tree, $subdir)); } foreach ($dir['files'] as $file) { $filename = $file->get_filename(); $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $filename, false); if (file_extension_in_typegroup($filename, 'web_image')) { $image = $url->out(false, array('preview' => 'tinyicon', 'oid' => $file->get_timemodified())); $image = html_writer::empty_tag('img', array('src' => $image)); } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $filename, 'moodle'); } $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', $filename, array('class' => 'fp-filename')); $filename = html_writer::tag('span', html_writer::link($url->out(false, array('forcedownload' => 1)), $filename), array('class' => 'fp-filename-icon')); $result .= html_writer::tag('li', $filename); } $result .= '</ul>'; return $result; }