MDL-78884 files: Deprecate size parameter for icons

The parameter $size of the following functions has been deprecated and is not used any more:
  - file_extension_icon
  - file_file_icon
  - file_folder_icon
  - file_mimetype_icon
  - mimeinfo_from_type
  - url_guess_icon

That way, the sized icons (xxxxxxx-yyy.png) can be removed and replaced by SVG, to make it easier
to keep them updated because once they are replaced, there will only be one single file for each
MIME icon.
This commit is contained in:
Sara Arjona 2023-08-03 10:35:29 +02:00
parent cccc00954d
commit 7430208d56
No known key found for this signature in database
33 changed files with 135 additions and 133 deletions

View File

@ -979,7 +979,7 @@ class core_course_renderer extends plugin_renderer_base {
html_writer::empty_tag('img', ['src' => $url, 'alt' => '']),
['class' => 'courseimage']);
} else {
$image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
$image = $this->output->pix_icon(file_file_icon($file), $file->get_filename(), 'moodle');
$filename = html_writer::tag('span', $image, ['class' => 'fp-icon']).
html_writer::tag('span', $file->get_filename(), ['class' => 'fp-filename']);
$contentfiles .= html_writer::tag('span',

View File

@ -147,7 +147,7 @@ class stored_file_exporter extends \core\external\exporter {
$filenameshort .= substr($filename, -4);
}
$icon = $this->file->is_directory() ? file_folder_icon(128) : file_file_icon($this->file, 128);
$icon = $this->file->is_directory() ? file_folder_icon() : file_file_icon($this->file);
$url = moodle_url::make_pluginfile_url(
$this->file->get_contextid(),

View File

@ -70,10 +70,10 @@ class core_files_renderer extends plugin_renderer_base {
if ($file['filesize']) {
$filesize = display_size($file['filesize']);
}
$fileicon = file_file_icon($file, 24);
$fileicon = file_file_icon($file);
$filetype = get_mimetype_description($file);
} else {
$fileicon = file_folder_icon(24);
$fileicon = file_folder_icon();
}
$table->data[] = array(
html_writer::link($file['url'], $this->output->pix_icon($fileicon, get_string('icon')) . ' ' . $file['filename']),

View File

@ -798,11 +798,11 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
if ($file->is_directory()) {
$item->filesize = 0;
$item->icon = $OUTPUT->image_url(file_folder_icon(24))->out(false);
$item->icon = $OUTPUT->image_url(file_folder_icon())->out(false);
$item->type = 'folder';
$foldername = explode('/', trim($item->filepath, '/'));
$item->fullname = trim(array_pop($foldername), '/');
$item->thumbnail = $OUTPUT->image_url(file_folder_icon(90))->out(false);
$item->thumbnail = $OUTPUT->image_url(file_folder_icon())->out(false);
} else {
// do NOT use file browser here!
$item->mimetype = get_mimetype_description($file);
@ -813,8 +813,8 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
}
$itemurl = moodle_url::make_draftfile_url($draftitemid, $item->filepath, $item->filename);
$item->url = $itemurl->out();
$item->icon = $OUTPUT->image_url(file_file_icon($file, 24))->out(false);
$item->thumbnail = $OUTPUT->image_url(file_file_icon($file, 90))->out(false);
$item->icon = $OUTPUT->image_url(file_file_icon($file))->out(false);
$item->thumbnail = $OUTPUT->image_url(file_file_icon($file))->out(false);
// The call to $file->get_imageinfo() fails with an exception if the file can't be read on the file system.
// We still want to add such files to the list, so the owner can view and delete them if needed. So, we only call
@ -1811,7 +1811,7 @@ function mimeinfo($element, $filename) {
* the other way around.
*
* @category files
* @param string $element Desired information ('extension', 'icon', 'icon-24', etc.)
* @param string $element Desired information ('extension', 'icon', etc.)
* @param string $mimetype MIME type we're looking up
* @return string Requested piece of information from array
*/
@ -1860,10 +1860,14 @@ function mimeinfo_from_type($element, $mimetype) {
*
* @param stored_file|file_info|stdClass|array $file (in case of object attributes $file->filename
* and $file->mimetype are expected)
* @param int $size The size of the icon. Defaults to 16 can also be 24, 32, 64, 128, 256
* @param null $unused This parameter has been deprecated since 4.3 and should not be used anymore.
* @return string
*/
function file_file_icon($file, $size = null) {
function file_file_icon($file, $unused = null) {
if ($unused !== null) {
debugging('Deprecated argument passed to ' . __FUNCTION__, DEBUG_DEVELOPER);
}
if (!is_object($file)) {
$file = (object)$file;
}
@ -1888,14 +1892,14 @@ function file_file_icon($file, $size = null) {
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
if ($extension && !empty($mimetypes[$extension])) {
// if file name has known extension, return icon for this extension
return file_extension_icon($filename, $size);
return file_extension_icon($filename);
}
}
return file_mimetype_icon($mimetype, $size);
return file_mimetype_icon($mimetype);
}
/**
* Return the relative icon path for a folder image
* Return the relative icon path for a folder image.
*
* Usage:
* <code>
@ -1904,28 +1908,20 @@ function file_file_icon($file, $size = null) {
* </code>
* or
* <code>
* echo $OUTPUT->pix_icon(file_folder_icon(32), '');
* echo $OUTPUT->pix_icon(file_folder_icon(), '');
* </code>
*
* @param int $iconsize The size of the icon. Defaults to 16 can also be 24, 32, 48, 64, 72, 80, 96, 128, 256
* @param null $unused This parameter has been deprecated since 4.3 and should not be used anymore.
* @return string
*/
function file_folder_icon($iconsize = null) {
function file_folder_icon($unused = null) {
global $CFG;
static $iconpostfixes = array(256=>'-256', 128=>'-128', 96=>'-96', 80=>'-80', 72=>'-72', 64=>'-64', 48=>'-48', 32=>'-32', 24=>'-24', 16=>'');
static $cached = array();
$iconsize = max(array(16, (int)$iconsize));
if (!array_key_exists($iconsize, $cached)) {
foreach ($iconpostfixes as $size => $postfix) {
$fullname = $CFG->dirroot.'/pix/f/folder'.$postfix;
if ($iconsize >= $size &&
(file_exists($fullname.'.svg') || file_exists($fullname.'.png') || file_exists($fullname.'.gif'))) {
$cached[$iconsize] = 'f/folder'.$postfix;
break;
}
}
if ($unused !== null) {
debugging('Deprecated argument passed to ' . __FUNCTION__, DEBUG_DEVELOPER);
}
return $cached[$iconsize];
return 'f/folder';
}
/**
@ -1944,11 +1940,11 @@ function file_folder_icon($iconsize = null) {
* @todo MDL-31074 When an $OUTPUT->icon method is available this function should be altered
* to conform with that.
* @param string $mimetype The mimetype to fetch an icon for
* @param int $size The size of the icon. Defaults to 16 can also be 24, 32, 64, 128, 256
* @param null $unused This parameter has been deprecated since 4.3 and should not be used anymore.
* @return string The relative path to the icon
*/
function file_mimetype_icon($mimetype, $size = NULL) {
return 'f/'.mimeinfo_from_type('icon'.$size, $mimetype);
function file_mimetype_icon($mimetype, $unused = null) {
return 'f/'.mimeinfo_from_type('icon', $mimetype);
}
/**
@ -1968,11 +1964,14 @@ function file_mimetype_icon($mimetype, $size = NULL) {
* @todo MDL-31074 Implement $size
* @category files
* @param string $filename The filename to get the icon for
* @param int $size The size of the icon. Defaults to 16 can also be 24, 32, 64, 128, 256
* @param null $unused This parameter has been deprecated since 4.3 and should not be used anymore.
* @return string
*/
function file_extension_icon($filename, $size = NULL) {
return 'f/'.mimeinfo('icon'.$size, $filename);
function file_extension_icon($filename, $unused = null) {
if ($unused !== null) {
debugging('Deprecated argument passed to ' . __FUNCTION__, DEBUG_DEVELOPER);
}
return 'f/'.mimeinfo('icon', $filename);
}
/**
@ -2675,14 +2674,14 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring
* Note: it's up to the consumer to set it properly i.e. when serving a "versioned" URL.
*
* @category files
* @param stored_file $stored_file local file object
* @param stored_file $storedfile local file object
* @param int $lifetime Number of seconds before the file should expire from caches (null means $CFG->filelifetime)
* @param int $filter 0 (default)=no filtering, 1=all files, 2=html files only
* @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin
* @param array $options additional options affecting the file serving
* @return null script execution stopped unless $options['dontdie'] is true
*/
function send_stored_file($stored_file, $lifetime=null, $filter=0, $forcedownload=false, array $options=array()) {
function send_stored_file($storedfile, $lifetime=null, $filter=0, $forcedownload=false, array $options=array()) {
global $CFG, $COURSE;
static $recursion = 0;
@ -2706,22 +2705,15 @@ function send_stored_file($stored_file, $lifetime=null, $filter=0, $forcedownloa
if (!empty($options['preview'])) {
// replace the file with its preview
$fs = get_file_storage();
$preview_file = $fs->get_file_preview($stored_file, $options['preview']);
if (!$preview_file) {
// unable to create a preview of the file, send its default mime icon instead
if ($options['preview'] === 'tinyicon') {
$size = 24;
} else if ($options['preview'] === 'thumb') {
$size = 90;
} else {
$size = 256;
}
$fileicon = file_file_icon($stored_file, $size);
$previewfile = $fs->get_file_preview($storedfile, $options['preview']);
if (!$previewfile) {
// Unable to create a preview of the file, send its default mime icon instead.
$fileicon = file_file_icon($storedfile);
send_file($CFG->dirroot.'/pix/'.$fileicon.'.png', basename($fileicon).'.png');
} else {
// preview images have fixed cache lifetime and they ignore forced download
// (they are generated by GD and therefore they are considered reasonably safe).
$stored_file = $preview_file;
$storedfile = $previewfile;
$lifetime = DAYSECS;
$filter = 0;
$forcedownload = false;
@ -2729,7 +2721,7 @@ function send_stored_file($stored_file, $lifetime=null, $filter=0, $forcedownloa
}
// handle external resource
if ($stored_file && $stored_file->is_external_file() && !isset($options['sendcachedexternalfile'])) {
if ($storedfile && $storedfile->is_external_file() && !isset($options['sendcachedexternalfile'])) {
// Have we been here before?
$recursion++;
@ -2737,22 +2729,22 @@ function send_stored_file($stored_file, $lifetime=null, $filter=0, $forcedownloa
throw new coding_exception('Recursive file serving detected');
}
$stored_file->send_file($lifetime, $filter, $forcedownload, $options);
$storedfile->send_file($lifetime, $filter, $forcedownload, $options);
die;
}
if (!$stored_file or $stored_file->is_directory()) {
// nothing to serve
if (!$storedfile || $storedfile->is_directory()) {
// Nothing to serve.
if ($dontdie) {
return;
}
die;
}
$filename = is_null($filename) ? $stored_file->get_filename() : $filename;
$filename = is_null($filename) ? $storedfile->get_filename() : $filename;
// Use given MIME type if specified.
$mimetype = $stored_file->get_mimetype();
$mimetype = $storedfile->get_mimetype();
// Allow cross-origin requests only for Web Services.
// This allow to receive requests done by Web Workers or webapps in different domains.
@ -2760,7 +2752,7 @@ function send_stored_file($stored_file, $lifetime=null, $filter=0, $forcedownloa
header('Access-Control-Allow-Origin: *');
}
send_file($stored_file, $filename, $lifetime, $filter, false, $forcedownload, $mimetype, $dontdie, $options);
send_file($storedfile, $filename, $lifetime, $filter, false, $forcedownload, $mimetype, $dontdie, $options);
}
/**

View File

@ -131,7 +131,7 @@ class google_docs {
'url' => "{$gdoc->link[0]->attributes()->href}",
'source' => $source,
'date' => strtotime($gdoc->updated),
'thumbnail' => (string) $OUTPUT->image_url(file_extension_icon($title, 32))
'thumbnail' => (string) $OUTPUT->image_url(file_extension_icon($title))
);
}
core_date::set_default_server_timezone();

View File

@ -87,6 +87,13 @@ information provided here is intended especially for developers.
to ensure in some test that the block drawer is closed. This helps with random failures due to the block drawer
being forced open in all behat tests.
* The core_useragent::get_device_type_list() function has been deprecated. Use core_useragent::devicetypes instead as a replacement.
* The parameter $size of the following functions has been deprecated and is not used any more:
- file_extension_icon
- file_file_icon
- file_folder_icon
- file_mimetype_icon
- mimeinfo_from_type
- url_guess_icon
=== 4.2 ===

View File

@ -205,7 +205,7 @@ class files {
);
return [
'icondesc' => get_mimetype_description($file),
'iconname' => file_file_icon($file, 24),
'iconname' => file_file_icon($file),
'name' => $file->get_filename(),
'url' => $url->out(false),
];

View File

@ -625,7 +625,7 @@ function folder_get_recent_mod_activity(&$activities, &$index, $timestart, $cour
$image = $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');
$image = $OUTPUT->pix_icon(file_file_icon($file), $file->get_filename(), 'moodle');
}
$tmpactivity->content = (object) [

View File

@ -121,7 +121,7 @@ class mod_folder_renderer extends plugin_renderer_base {
}
$result = '<ul>';
foreach ($dir['subdirs'] as $subdir) {
$image = $this->output->pix_icon(file_folder_icon(24), $subdir['dirname'], 'moodle');
$image = $this->output->pix_icon(file_folder_icon(), $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'));
@ -136,7 +136,7 @@ class mod_folder_renderer extends plugin_renderer_base {
$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), $filenamedisplay, 'moodle');
$image = $this->output->pix_icon(file_file_icon($file), $filenamedisplay, 'moodle');
}
$filename = html_writer::tag('span', $image, array('class' => 'fp-icon')).
html_writer::tag('span', $filenamedisplay, array('class' => 'fp-filename'));

View File

@ -59,9 +59,9 @@ class externallib_test extends externallib_advanced_testcase {
/**
* Get the expected attachment.
*
* @param stored_file $file
* @param \stored_file $file
* @param array $values
* @param moodle_url|null $url
* @param \moodle_url|null $url
* @return array
*/
protected function get_expected_attachment(\stored_file $file, array $values = [], ?\moodle_url $url = null): array {
@ -94,7 +94,7 @@ class externallib_test extends externallib_advanced_testcase {
'license' => $file->get_license(),
'filenameshort' => $file->get_filename(),
'filesizeformatted' => display_size((int) $file->get_filesize()),
'icon' => $file->is_directory() ? file_folder_icon(128) : file_file_icon($file, 128),
'icon' => $file->is_directory() ? file_folder_icon() : file_file_icon($file),
'timecreatedformatted' => userdate($file->get_timecreated()),
'timemodifiedformatted' => userdate($file->get_timemodified()),
'url' => $url->out(),

View File

@ -220,8 +220,8 @@ function url_get_coursemodule_info($coursemodule) {
$info = new cached_cm_info();
$info->name = $url->name;
//note: there should be a way to differentiate links from normal resources
$info->icon = url_guess_icon($url->externalurl, 24);
// Note: there should be a way to differentiate links from normal resources.
$info->icon = url_guess_icon($url->externalurl);
$display = url_get_final_display_type($url);

View File

@ -528,13 +528,17 @@ function url_get_encrypted_parameter($url, $config) {
/**
* Optimised mimetype detection from general URL
* @param $fullurl
* @param int $size of the icon.
* @param null $unused This parameter has been deprecated since 4.3 and should not be used anymore.
* @return string|null mimetype or null when the filetype is not relevant.
*/
function url_guess_icon($fullurl, $size = null) {
function url_guess_icon($fullurl, $unused = null) {
global $CFG;
require_once("$CFG->libdir/filelib.php");
if ($unused !== null) {
debugging('Deprecated argument passed to ' . __FUNCTION__, DEBUG_DEVELOPER);
}
if (substr_count($fullurl, '/') < 3 or substr($fullurl, -1) === '/') {
// Most probably default directory - index.php, index.html, etc. Return null because
// we want to use the default module icon instead of the HTML file icon.
@ -551,10 +555,10 @@ function url_guess_icon($fullurl, $size = null) {
return null;
}
$icon = file_extension_icon($fullurl, $size);
$htmlicon = file_extension_icon('.htm', $size);
$unknownicon = file_extension_icon('', $size);
$phpicon = file_extension_icon('.php', $size); // Exception for php files.
$icon = file_extension_icon($fullurl);
$htmlicon = file_extension_icon('.htm');
$unknownicon = file_extension_icon('');
$phpicon = file_extension_icon('.php'); // Exception for php files.
// We do not want to return those icon types, the module icon is more appropriate.
if ($icon === $unknownicon || $icon === $htmlicon || $icon === $phpicon) {

View File

@ -89,8 +89,8 @@ class repository_areafiles extends repository {
'children' => array(),
'datemodified' => $file->get_timemodified(),
'datecreated' => $file->get_timecreated(),
'icon' => $OUTPUT->image_url(file_folder_icon(24))->out(false),
'thumbnail' => $OUTPUT->image_url(file_folder_icon(90))->out(false)
'icon' => $OUTPUT->image_url(file_folder_icon())->out(false),
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false)
);
$ret['list'][] = $node;
$ret['path'] = $retpath; // Show path if subfolders exist.
@ -107,8 +107,8 @@ class repository_areafiles extends repository {
'license' => $file->get_license(),
'isref' => $file->is_external_file(),
'iscontrolledlink' => $file->is_controlled_link(),
'icon' => $OUTPUT->image_url(file_file_icon($file, 24))->out(false),
'thumbnail' => $OUTPUT->image_url(file_file_icon($file, 90))->out(false)
'icon' => $OUTPUT->image_url(file_file_icon($file))->out(false),
'thumbnail' => $OUTPUT->image_url(file_file_icon($file))->out(false)
);
if ($file->get_status() == 666) {
$node['originalmissing'] = true;

View File

@ -68,7 +68,7 @@ class helper {
'datemodified' => '',
'datecreated' => '',
'path' => $path,
'thumbnail' => $OUTPUT->image_url(file_folder_icon(90))->out(false),
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false),
'children' => []
];
}

View File

@ -109,7 +109,7 @@ class repository_coursefiles extends repository {
'datecreated' => $child->get_timecreated(),
'path' => $encodedpath,
'children'=>array(),
'thumbnail' => $OUTPUT->image_url(file_folder_icon(90))->out(false)
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false)
);
$list[] = $node;
} else {
@ -123,7 +123,7 @@ class repository_coursefiles extends repository {
'datecreated' => $child->get_timecreated(),
'source'=> $encodedpath,
'isref' => $child->is_external_file(),
'thumbnail' => $OUTPUT->image_url(file_file_icon($child, 90))->out(false)
'thumbnail' => $OUTPUT->image_url(file_file_icon($child))->out(false)
);
if ($child->get_status() == 666) {
$node['originalmissing'] = true;

View File

@ -687,7 +687,7 @@ class repository_dropbox extends repository {
// Use the display path here rather than lower.
// Dropbox is case insensitive but this leads to more accurate breadcrumbs.
'path' => file_correct_filepath($entrydata->path_display),
'thumbnail' => $OUTPUT->image_url(file_folder_icon(64))->out(false),
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false),
'thumbnail_height' => 64,
'thumbnail_width' => 64,
'children' => array(),
@ -699,7 +699,7 @@ class repository_dropbox extends repository {
'source' => $entrydata->path_lower,
'size' => $entrydata->size,
'date' => strtotime($entrydata->client_modified),
'thumbnail' => $OUTPUT->image_url(file_extension_icon($entrydata->path_lower, 64))->out(false),
'thumbnail' => $OUTPUT->image_url(file_extension_icon($entrydata->path_lower))->out(false),
'realthumbnail' => $this->get_thumbnail_url($entrydata),
'thumbnail_height' => 64,
'thumbnail_width' => 64,

View File

@ -44,5 +44,5 @@ if ($thumbnailavailable) {
}
// Send default icon for the file type.
$fileicon = file_extension_icon($source, 64);
$fileicon = file_extension_icon($source);
send_file($CFG->dirroot . '/pix/' . $fileicon . '.png', basename($fileicon) . '.png');

View File

@ -311,14 +311,14 @@ class repository_filesystem extends repository {
if ($isdir) {
$node['children'] = array();
$node['thumbnail'] = $OUTPUT->image_url(file_folder_icon(90))->out(false);
$node['thumbnail'] = $OUTPUT->image_url(file_folder_icon())->out(false);
$node['path'] = $this->build_node_path('browse', $relpath, $name, $rootnodepath);
} else {
$node['source'] = $relpath;
$node['size'] = filesize($abspath);
$node['thumbnail'] = $OUTPUT->image_url(file_extension_icon($name, 90))->out(false);
$node['icon'] = $OUTPUT->image_url(file_extension_icon($name, 24))->out(false);
$node['thumbnail'] = $OUTPUT->image_url(file_extension_icon($name))->out(false);
$node['icon'] = $OUTPUT->image_url(file_extension_icon($name))->out(false);
$node['path'] = $relpath;
if (file_extension_in_typegroup($name, 'image') && ($imageinfo = @getimagesize($abspath))) {
@ -848,7 +848,7 @@ function repository_filesystem_pluginfile($course, $cm, $context, $filearea, $ar
if (!($file = $repo->get_thumbnail($filepath, $filearea))) {
// Generation failed, redirect to default icon for file extension.
// Do not use redirect() here because is not compatible with webservice/pluginfile.php.
header('Location: ' . $OUTPUT->image_url(file_extension_icon($file, 90)));
header('Location: ' . $OUTPUT->image_url(file_extension_icon($file)));
}
// The thumbnails should not be changing much, but maybe the default lifetime is too long.
$lifetime = $CFG->filelifetime;

View File

@ -407,7 +407,7 @@ class repository_flickr_public extends repository {
if (!@getimagesize($thumbnailsource)) {
// Use the file extension icon as a thumbnail if the original thumbnail does not exist to avoid
// displaying broken thumbnails in the repository.
$thumbnailsource = $OUTPUT->image_url(file_extension_icon($p['title'], 90))->out(false);
$thumbnailsource = $OUTPUT->image_url(file_extension_icon($p['title']))->out(false);
}
// Perform a HEAD request to the image to obtain it's Content-Length.

View File

@ -67,7 +67,7 @@ class folder_node implements node {
'title' => $this->title,
'path' => helper::build_node_path($this->id, $this->title, $this->path),
'date' => $this->modified,
'thumbnail' => $OUTPUT->image_url(file_folder_icon(64))->out(false),
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false),
'thumbnail_height' => 64,
'thumbnail_width' => 64,
'children' => [],

View File

@ -389,7 +389,7 @@ class repository_googledocs extends repository {
'title' => $gfile->name,
'path' => $this->build_node_path($gfile->id, $gfile->name, $path),
'date' => strtotime($gfile->modifiedTime),
'thumbnail' => $OUTPUT->image_url(file_folder_icon(64))->out(false),
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false),
'thumbnail_height' => 64,
'thumbnail_width' => 64,
'children' => array()

View File

@ -42,7 +42,7 @@ abstract class repository_googledocs_testcase extends \advanced_testcase {
'title' => $name,
'path' => repository_googledocs\helper::build_node_path($id, $name, $path),
'date' => $modified,
'thumbnail' => "{$CFG->wwwroot}/theme/image.php/_s/boost/core/1/" . file_folder_icon(64),
'thumbnail' => "{$CFG->wwwroot}/theme/image.php/_s/boost/core/1/" . file_folder_icon(),
'thumbnail_height' => 64,
'thumbnail_width' => 64,
'children' => [],

View File

@ -1390,7 +1390,7 @@ abstract class repository implements cacheable_object {
'url'=>moodle_url::make_draftfile_url($file->get_itemid(), $file->get_filepath(), $file->get_filename())->out(),
'id'=>$file->get_itemid(),
'file'=>$file->get_filename(),
'icon' => $OUTPUT->image_url(file_extension_icon($thefile, 32))->out(),
'icon' => $OUTPUT->image_url(file_extension_icon($thefile))->out(),
);
} else {
return null;
@ -1436,7 +1436,7 @@ abstract class repository implements cacheable_object {
'size' => 0,
'date' => $filedate,
'path' => array_reverse($path),
'thumbnail' => $OUTPUT->image_url(file_folder_icon(90))->out(false)
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false)
);
//if ($dynamicmode && $child->is_writable()) {
@ -1473,8 +1473,8 @@ abstract class repository implements cacheable_object {
'date' => $filedate,
//'source' => $child->get_url(),
'source' => base64_encode($source),
'icon'=>$OUTPUT->image_url(file_file_icon($child, 24))->out(false),
'thumbnail'=>$OUTPUT->image_url(file_file_icon($child, 90))->out(false),
'icon' => $OUTPUT->image_url(file_file_icon($child))->out(false),
'thumbnail' => $OUTPUT->image_url(file_file_icon($child))->out(false),
);
$filecount++;
}
@ -2207,7 +2207,7 @@ abstract class repository implements cacheable_object {
*/
protected static function prepare_breadcrumb($breadcrumb) {
global $OUTPUT;
$foldericon = $OUTPUT->image_url(file_folder_icon(24))->out(false);
$foldericon = $OUTPUT->image_url(file_folder_icon())->out(false);
$len = count($breadcrumb);
for ($i = 0; $i < $len; $i++) {
if (is_array($breadcrumb[$i]) && !isset($breadcrumb[$i]['icon'])) {
@ -2228,7 +2228,7 @@ abstract class repository implements cacheable_object {
*/
protected static function prepare_list($list) {
global $OUTPUT;
$foldericon = $OUTPUT->image_url(file_folder_icon(24))->out(false);
$foldericon = $OUTPUT->image_url(file_folder_icon())->out(false);
// Reset the array keys because non-numeric keys will create an object when converted to JSON.
$list = array_values($list);
@ -2288,7 +2288,7 @@ abstract class repository implements cacheable_object {
if ($isfolder) {
$file['icon'] = $foldericon;
} else if ($filename) {
$file['icon'] = $OUTPUT->image_url(file_extension_icon($filename, 24))->out(false);
$file['icon'] = $OUTPUT->image_url(file_extension_icon($filename))->out(false);
}
}

View File

@ -213,7 +213,7 @@ class repository_local extends repository {
);
if ($fileinfo->is_directory()) {
$node['path'] = $encodedpath;
$node['thumbnail'] = $OUTPUT->image_url(file_folder_icon(90))->out(false);
$node['thumbnail'] = $OUTPUT->image_url(file_folder_icon())->out(false);
$node['children'] = array();
} else {
$node['size'] = $fileinfo->get_filesize();
@ -224,8 +224,8 @@ class repository_local extends repository {
$node['originalmissing'] = true;
}
$node['source'] = $encodedpath;
$node['thumbnail'] = $OUTPUT->image_url(file_file_icon($fileinfo, 90))->out(false);
$node['icon'] = $OUTPUT->image_url(file_file_icon($fileinfo, 24))->out(false);
$node['thumbnail'] = $OUTPUT->image_url(file_file_icon($fileinfo))->out(false);
$node['icon'] = $OUTPUT->image_url(file_file_icon($fileinfo))->out(false);
if ($imageinfo = $fileinfo->get_imageinfo()) {
// what a beautiful picture, isn't it
$fileurl = new moodle_url($fileinfo->get_url());

View File

@ -103,11 +103,11 @@ class repository_merlot extends repository {
$xml = simplexml_load_string($content);
foreach ($xml->results->material as $entry) {
$list[] = array(
'title'=>(string)$entry->title,
'thumbnail'=>$OUTPUT->image_url(file_extension_icon($entry->title, 90))->out(false),
'date'=>userdate((int)$entry->creationDate),
'size'=>'',
'source'=>(string)$entry->URL
'title' => (string)$entry->title,
'thumbnail' => $OUTPUT->image_url(file_extension_icon($entry->title))->out(false),
'date' => userdate((int)$entry->creationDate),
'size' => '',
'source' => (string)$entry->URL,
);
}
return $list;
@ -184,4 +184,3 @@ class repository_merlot extends repository {
return false;
}
}

View File

@ -815,7 +815,7 @@ class repository_nextcloud extends repository {
$folders[strtoupper($title)] = array(
'title' => rtrim($title, '/'),
'thumbnail' => $OUTPUT->image_url(file_folder_icon(90))->out(false),
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false),
'children' => array(),
'datemodified' => $item['lastmodified'],
'path' => $item['href']
@ -825,7 +825,7 @@ class repository_nextcloud extends repository {
$size = !empty($item['getcontentlength']) ? $item['getcontentlength'] : '';
$files[strtoupper($title)] = array(
'title' => $title,
'thumbnail' => $OUTPUT->image_url(file_extension_icon($title, 90))->out(false),
'thumbnail' => $OUTPUT->image_url(file_extension_icon($title))->out(false),
'size' => $size,
'datemodified' => $item['lastmodified'],
'source' => $item['href']

View File

@ -356,7 +356,7 @@ class repository_onedrive extends repository {
'title' => $remotefile->name,
'path' => $this->build_node_path($remotefile->id, $remotefile->name, $path),
'date' => strtotime($remotefile->lastModifiedDateTime),
'thumbnail' => $OUTPUT->image_url(file_folder_icon(64))->out(false),
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false),
'thumbnail_height' => 64,
'thumbnail_width' => 64,
'children' => []

View File

@ -164,8 +164,8 @@ class repository_recent extends repository {
'author' => $fileinfo->get_author(),
'license' => $fileinfo->get_license(),
'source'=> $params,
'icon' => $OUTPUT->image_url(file_file_icon($fileinfo, 24))->out(false),
'thumbnail' => $OUTPUT->image_url(file_file_icon($fileinfo, 90))->out(false),
'icon' => $OUTPUT->image_url(file_file_icon($fileinfo))->out(false),
'thumbnail' => $OUTPUT->image_url(file_file_icon($fileinfo))->out(false),
);
if ($imageinfo = $fileinfo->get_imageinfo()) {
$fileurl = new moodle_url($fileinfo->get_url());

View File

@ -265,7 +265,7 @@ switch ($action) {
'url'=>moodle_url::make_draftfile_url($storedfile->get_itemid(), $storedfile->get_filepath(), $storedfile->get_filename())->out(),
'id'=>$storedfile->get_itemid(),
'file'=>$storedfile->get_filename(),
'icon' => $OUTPUT->image_url(file_file_icon($storedfile, 32))->out(),
'icon' => $OUTPUT->image_url(file_file_icon($storedfile))->out(),
);
}
// Repository plugin callback

View File

@ -152,7 +152,7 @@ class repository_s3 extends repository {
$folder = array(
'title' => $bucket,
'children' => array(),
'thumbnail' => $OUTPUT->image_url(file_folder_icon(90))->out(false),
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false),
'path' => $bucket
);
$tree[] = $folder;
@ -197,8 +197,8 @@ class repository_s3 extends repository {
$folders[] = array(
'title' => $title,
'children' => array(),
'thumbnail'=> $OUTPUT->image_url(file_folder_icon(90))->out(false),
'path' => $bucket . '/' . $object['prefix']
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false),
'path' => $bucket . '/' . $object['prefix'],
);
} else {
$files[] = array(
@ -206,7 +206,7 @@ class repository_s3 extends repository {
'size' => $object['size'],
'datemodified' => $object['time'],
'source' => $bucket . '/' . $object['name'],
'thumbnail' => $OUTPUT->image_url(file_extension_icon($title, 90))->out(false)
'thumbnail' => $OUTPUT->image_url(file_extension_icon($title))->out(false)
);
}
}

View File

@ -102,7 +102,7 @@ class repository_user extends repository {
'datecreated' => $child->get_timecreated(),
'path' => $encodedpath,
'children'=>array(),
'thumbnail' => $OUTPUT->image_url(file_folder_icon(90))->out(false)
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false)
);
$list[] = $node;
} else {
@ -116,8 +116,8 @@ class repository_user extends repository {
'license' => $child->get_license(),
'isref' => $child->is_external_file(),
'source'=> $encodedpath,
'icon' => $OUTPUT->image_url(file_file_icon($child, 24))->out(false),
'thumbnail' => $OUTPUT->image_url(file_file_icon($child, 90))->out(false)
'icon' => $OUTPUT->image_url(file_file_icon($child))->out(false),
'thumbnail' => $OUTPUT->image_url(file_file_icon($child))->out(false)
);
if ($child->get_status() == 666) {
$node['originalmissing'] = true;

View File

@ -142,25 +142,25 @@ class repository_webdav extends repository {
$title = substr($v['href'], strlen($path));
if (!empty($v['resourcetype']) && $v['resourcetype'] == 'collection') {
// a folder
// A folder.
if ($path != $v['href']) {
$folders[strtoupper($title)] = array(
'title'=>rtrim($title, '/'),
'thumbnail'=>$OUTPUT->image_url(file_folder_icon(90))->out(false),
'children'=>array(),
'datemodified'=>$v['lastmodified'],
'path'=>$v['href']
'title' => rtrim($title, '/'),
'thumbnail' => $OUTPUT->image_url(file_folder_icon())->out(false),
'children' => array(),
'datemodified' => $v['lastmodified'],
'path' => $v['href'],
);
}
}else{
// a file
// A file.
$size = !empty($v['getcontentlength'])? $v['getcontentlength']:'';
$files[strtoupper($title)] = array(
'title'=>$title,
'thumbnail' => $OUTPUT->image_url(file_extension_icon($title, 90))->out(false),
'size'=>$size,
'datemodified'=>$v['lastmodified'],
'source'=>$v['href']
'title' => $title,
'thumbnail' => $OUTPUT->image_url(file_extension_icon($title))->out(false),
'size' => $size,
'datemodified' => $v['lastmodified'],
'source' => $v['href'],
);
}
}

View File

@ -134,7 +134,7 @@ class wikimedia {
$short_path = str_replace($commons_main_dir, '', $image_url);
$extension = strtolower(pathinfo($short_path, PATHINFO_EXTENSION));
if (strcmp($extension, 'gif') == 0) { //no thumb for gifs
return $OUTPUT->image_url(file_extension_icon('.gif', $thumb_width))->out(false);
return $OUTPUT->image_url(file_extension_icon('.gif'))->out(false);
}
$dir_parts = explode('/', $short_path);
$file_name = end($dir_parts);