Commit da6b9b50 authored by Penny Leach's avatar Penny Leach
Browse files

Changes to the file plugin to support the internal media block

- serve_file now will allow overriding the mime type sent in content-type header
- you can also override the application/inline selector by setting force-download
- added swf to the filetypes.xml list and bumped the version.
parent 0615a41f
......@@ -34,6 +34,12 @@ require_once('file.php');
$fileid = param_integer('file');
$viewid = param_integer('view', null);
$size = get_imagesize_parameters();
$forcedl = param_boolean('download');
$options = array();
if ($forcedl) {
$options['forcedownload'] = true;
}
if ($viewid && $fileid) {
if (!artefact_in_view($fileid, $viewid)) {
......@@ -50,7 +56,10 @@ if ($viewid && $fileid) {
}
$path = $file->get_path(array('size' => $size));
$title = $file->download_title();
serve_file($path, $title);
if ($contenttype = $file->override_content_type()) {
$options['overridecontenttype'] = $contenttype;
}
serve_file($path, $title, $options);
}
// We just have a file ID
......@@ -84,6 +93,9 @@ if (!$fileispublic) {
$path = $file->get_path(array('size' => $size));
$title = $file->download_title();
serve_file($path, $title);
if ($contenttype = $file->override_content_type()) {
$options['overridecontenttype'] = $contenttype;
}
serve_file($path, $title, $options);
?>
......@@ -152,6 +152,13 @@
<mimetype>video/ms-wmv</mimetype>
</mimetypes>
</filetype>
<filetype>
<description>swf</description>
<enabled>0</enabled>
<mimetypes>
<mimetype>application/x-shockwave-flash</mimetype>
</mimetypes>
</filetype>
<!-- Audio types -->
<filetype>
......
......@@ -134,5 +134,13 @@ $string['wav'] = 'WAV Audio File';
$string['wmv'] = 'WMV Video File';
$string['xml'] = 'XML File';
$string['zip'] = 'ZIP Archive';
$string['swf'] = 'SWF Flash movie';
$string['flv'] = 'FLV Flash movie';
$string['mov'] = 'MOV Quicktime movie';
$string['mpg'] = 'MPEG Movie';
$string['ram'] = 'RAM Real Player Movie';
$string['rpm'] = 'RPM Real Player Movie';
$string['rm'] = 'RM Real Player Movie';
?>
......@@ -705,6 +705,20 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
get_string('folder', 'artefact.file') => $wwwroot . 'artefact/file/?folder=' . $id,
);
}
public function override_content_type() {
static $extensions;
if (empty($extensions)) {
$extensions = array(
'wmv' => 'video/x-ms-wmv',
'flv' => 'video/x-flv',
);
}
if (array_key_exists($this->get('oldextension'), $extensions)) {
return $extensions[$this->get('oldextension')];
}
return false;
}
}
class ArtefactTypeFolder extends ArtefactTypeFileBase {
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2007051800;
$config->version = 2007051801;
$config->release = '0.4.0';
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment