Commit 2b584e8e authored by Clare Lenihan's avatar Clare Lenihan
Browse files
parents 880bcb8d fdf5f675
// Documentation & updates available at:
// http://codecentre.eplica.is/js/eolasfix/test.htm
(function( Eolas_Fixed,
win, doc,
getElementsByTagName,
outerHTML,
parentNode,
tags,
elmsToRemoveOnload,
x,
is_ie,
y,z,elm,childNode,HTML,dummy,eolasfix)
{
// run only once!
if (win[Eolas_Fixed]) return;
win[Eolas_Fixed] = 1;
eolasfix = function ()
{
// for each tag name specified in Array t
while (tags[++x])
{
// find all elements of that type in the document
// loop through the elements
y = 0;
while (elm = doc[getElementsByTagName](tags[x])[y++])
{
if (is_ie)
{
HTML = '>';
z = 0;
// <param> elements don't show up in innerHTML IE
// so we need to collect their outerHTML.
while (childNode = elm.childNodes[z++])
HTML += childNode[outerHTML];
// create a 'dummy' element
dummy = doc.createElement('i');
// inject it next to `elm`,
elm[parentNode].insertBefore(dummy, elm);
// and turn it into an `elm` clone
dummy[outerHTML] = elm[outerHTML].replace(/>/, HTML);
// increment y to skip over it
y++;
// then hide the original elm
elm.style.display = 'none';
// and save it in 'The List of Elements to Remove Later'.
elmsToRemoveOnload[elmsToRemoveOnload.length] = elm;
}
else
{
elm[outerHTML] = elm[outerHTML];
}
}
}
};
// For IE run the fix straight away (because the defer="defer"
// attribute has delayed execution until the DOM has loaded).
// Then assign a window.onload event to purge the old elements.
is_ie && !eolasfix() && win.attachEvent('onload', function(){
x=0;
while(elm = elmsToRemoveOnload[x++])
elm[parentNode].removeChild(elm);
});
// For Opera set an `DOMContentLoaded` event to run the fix.
win.opera && doc.addEventListener('DOMContentLoaded', eolasfix, 0);
})( '__Eolas_Fixed',
window, document,
'getElementsByTagName',
'outerHTML',
'parentNode',
['object','embed','applet'],
[],
-1 /*@cc_on,1 @*/
);
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage blocktype-internalmedia
* @author Penny Leach <penny@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$string['title'] = 'Embedded media';
$string['description'] = 'Select files for embedded viewing';
$string['media'] = 'Media';
$string['flashanimation'] = 'Flash animation';
?>
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage blocktype-internalmedia
* @author Penny Leach <penny@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
class PluginBlocktypeInternalmedia extends PluginBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.file/internalmedia');
}
public static function get_description() {
return get_string('description', 'blocktype.file/internalmedia');
}
public static function get_categories() {
return array('multimedia', 'file');
}
public static function has_config() {
return true;
}
public static function postinst($oldversion) {
if ($oldversion == 0) {
$enabledtypes = array_map(
create_function('$a', 'return 1;'),
self::get_all_extensions());
unset($enabledtypes['swf']); // disable by default
$enabledtypes = array_keys($enabledtypes);
set_config_plugin('blocktype', 'internalmedia', 'enabledtypes', serialize($enabledtypes));
}
}
public static function render_instance(BlockInstance $instance) {
$configdata = $instance->get('configdata');
if (empty($configdata['artefactid'])) {
return '';
}
$result = self::get_js_source();
require_once('artefact.php');
$artefact = artefact_instance_from_id($configdata['artefactid']);
$width = (!empty($configdata['width'])) ? hsc($configdata['width']) : '300';
$height = (!empty($configdata['height'])) ? hsc($configdata['height']) : '300';
$extn = $artefact->get('oldextension');
if (!in_array($extn, self::get_allowed_extensions())) {
return 'This has been removed as an allowed type'; // TODO
}
$callbacks = self::get_all_extensions();
$result .= call_static_method('PluginBlocktypeInternalmedia', $callbacks[$extn], $artefact, $instance, $width, $height);
return $result;
}
public static function has_instance_config() {
return true;
}
public static function instance_config_form($instance) {
$configdata = $instance->get('configdata');
$form = array(
self::artefactchooser_element((isset($configdata['artefactid'])) ? $configdata['artefactid'] : null),
);
$form['width'] = array(
'type' => 'text',
'title' => get_string('width'),
'size' => 3,
'defaultvalue' => (isset($configdata['width'])) ? $configdata['width'] : '',
);
$form['height'] = array(
'type' => 'text',
'title' => get_string('height'),
'size' => 3,
'defaultvalue' => (isset($configdata['height'])) ? $configdata['height'] : '',
);
return $form;
}
public static function get_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
if (isset($configdata['artefactid'])) {
return array($configdata['artefactid']);
}
return false;
}
public static function artefactchooser_element($default=null) {
$extraselect = '(' . implode(' OR ', array_map(
create_function('$a', 'return "title LIKE \'%.$a\'";'),
self::get_allowed_extensions())
) . ')';
return array(
'name' => 'artefactid',
'type' => 'artefactchooser',
'title' => get_string('media', 'blocktype.file/internalmedia'),
'defaultvalue' => $default,
'rules' => array(
'required' => true,
),
'blocktype' => 'internalmedia',
'limit' => 5,
'selectone' => true,
'artefacttypes' => array('file'),
'extraselect' => $extraselect,
'template' => 'artefact:file:artefactchooser-element.tpl',
);
}
public static function save_config_options($values) {
$enabledtypes = array();
foreach ($values as $type => $enabled) {
if (!empty($enabled)) {
$enabledtypes[] = $type;
}
}
set_config_plugin('blocktype', 'internalmedia', 'enabledtypes', serialize($enabledtypes));
}
public static function get_config_options() {
$elements = array();
// Allowed file types
$filetypes = array();
$currenttypes = self::get_allowed_extensions();
foreach (array_keys(self::get_all_extensions()) as $filetype) {
// TODO add checks for types that have been disabled by the file plugin
$filetypes[$filetype] = array(
'type' => 'checkbox',
'title' => get_string($filetype, 'artefact.file'),
'defaultvalue' => in_array($filetype, $currenttypes),
);
}
uasort($filetypes, create_function('$a, $b', 'return $a["title"] > $b["title"];'));
$filetypes = array_merge(
array(
'description' => array(
'value' => 'Some stuff goes here' // TODO
),
),
$filetypes
);
return array(
'elements' => $filetypes,
'renderer' => 'table'
);
}
private static function get_allowed_extensions() {
if ($data = get_config_plugin('blocktype', 'internalmedia', 'enabledtypes')) {
return unserialize($data);
}
return array();
}
private static function get_all_extensions() {
return array(
'mp3' => 'flash_player', // tested
'swf' => 'flash_player', // tested
'flv' => 'flash_player', // tested
'mov' => 'qt_player', // tested
'wmv' => 'wmp_player', // tested
'mpg' => 'qt_player', // tested
'mpeg' => 'qt_player', // tested
'avi' => 'wmp_player', // tested
'ram' => 'real_player',
'rm' => 'real_player',
'rpm' => 'real_player',
);
}
public static function flash_player($artefact, $block, $width, $height) {
static $count = 0;
$count++;
$extn = $artefact->get('oldextension');
if ($extn == 'mp3') {
$height = 0; // one line
}
$id = 'blocktype_internalmedia_flash_' . time() . $count;
$url = self::get_download_link($artefact, $block);
$playerurl = get_config('wwwroot') . "artefact/file/blocktype/internalmedia/mediaplayer.swf";
$params = array();
if ($extn == 'swf') {
$playerurl = $url;
$params['play'] = 'false';
}
$html = '<a href="' . $url . '">' . hsc($artefact->get('title')) . '</a><br />
<span class="blocktype_internalmedia_mp3" id="' . $id . '">('
. get_string('flash', 'blocktype.file/internalmedia') . ')</span>
<script type="text/javascript">
var so = new SWFObject(" ' . $playerurl . '","player","400","400","7");
so.addParam("allowfullscreen","false");
so.addVariable("file","' . urlencode($url) . '");
so.addVariable("displayheight"," ' . $height . '");
so.addVariable("type", "' . $artefact->get('oldextension') . '");
so.addVariable("height", "' . $height . '");
so.addVariable("width", "' . $width . '");
';
foreach ($params as $key => $value) {
$html .= ' so.addParam("' . $key . '", "' . $value . '"); '. "\n";
}
$html .= '
so.write("' . $id . '");
</script>
';
return $html;
}
public static function real_player($artefact, $block, $width, $height) {
$url = self::get_download_link($artefact, $block);
require_once('file.php');
$mimetype = get_mime_type($artefact->get_path());
$autostart = 'false';
return '<a href="' . $url . '">' . hsc($artefact->get('title')) . '</a><br />'
. '<span class="blocktype_internalmedia_real">
<script type="text/javascript">
//<![CDATA[
document.write(\'<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="240" height="180">\\
<param name="src" value="' . $url . '" />\\
<param name="autostart" value="' . $autostart . '" />\\
<param name="controls" value="imagewindow" />\\
<param name="console" value="video" />\\
<param name="loop" value="true" />\\
<embed src="' . $url . '" width=240" height="180" loop="true" type="' . $mimetype . '" controls="imagewindow" console="video" autostart="' . $autostart . '" />\\
</object><br />\\
<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="240" height="30">\\
<param name="src" value="' . $url . '" />\\
<param name="autostart" value="' . $autostart . '" />\\
<param name="controls" value="ControlPanel" />\\
<param name="console" value="video" />\\
<embed src="' . $url . '" width="240" height="30" controls="ControlPanel" type="' . $mimetype . '" console="video" autostart="' . $autostart . '" />\\
</object>\');
//]]>
</script></span>';
}
public static function wmp_player($artefact, $block, $width, $height) {
$url = self::get_download_link($artefact, $block, true);
$size = 'width="' . $width . '" height="' . $height . '"';
$autosize = 'false';
$mimetype = 'video/x-ms-wmv'; // hardcode this
$autostart = 'false';
return '<a href="' . $url . '">' . hsc($artefact->get('title')) . '</a><br />'
. '<span class="mediaplugin mediaplugin_wmp">
<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" ' . $size . '
standby="Loading Microsoft(R) Windows(R) Media Player components..."
type="application/x-oleobject">
<param name="Filename" value="' . $url . '" />' /* hsc($artefact->get('title')) . '" /> */ . '
<param name="src" value="' . $url . '" />
<param name="url" value="' . $url . '" />
<param name="ShowControls" value="true" />
<param name="AutoRewind" value="true" />
<param name="AutoStart" value="' . $autostart . '" />
<param name="Autosize" value="' . $autosize . '" />
<param name="EnableContextMenu" value="true" />
<param name="TransparentAtStart" value="false" />
<param name="AnimationAtStart" value="false" />
<param name="ShowGotoBar" value="false" />
<param name="EnableFullScreenControls" value="true" />
<!--[if !IE]>-->
<object data="' . $url . '" type="' . $mimetype . '" ' . $size . '>
<param name="src" value="' . $url . '" />
<param name="controller" value="true" />
<param name="autoplay" value="' . $autostart . '" />
<param name="autostart" value="' . $autostart . '" />
<param name="resize" value="scale" />
</object>
<!--<![endif]-->
</object></span>';
}
public static function qt_player($artefact, $block, $width, $height) {
$url = self::get_download_link($artefact, $block);
$size = 'width="' . $width . '" height="' . $height . '"';
require_once('file.php');
$mimetype = get_mime_type($artefact->get_path());
$autostart = 'false';
return '<a href="' . $url . '">' . hsc($artefact->get('title')) . '</a><br />'
. '<span class="mediaplugin mediaplugin_qt">
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
codebase="http://www.apple.com/qtactivex/qtplugin.cab" ' . $size . '>
<param name="pluginspage" value="http://www.apple.com/quicktime/download/" />
<param name="src" value="' . $url . '" />
<param name="coltroller" value="true" />
<param name="loop" value="false" />
<param name="autoplay" value="' . $autostart . '" />
<param name="autostart" value="' . $autostart . '" />
<param name="scale" value="aspect" />
<!--[if !IE]>-->
<object data="' . $url . '" type="' . $mimetype . '" ' . $size . '>
<param name="src" value="'.$url.'" />
<param name="pluginurl" value="http://www.apple.com/quicktime/download/" />
<param name="controller" value="true" />
<param name="loop" value="false" />
<param name="autoplay" value="' . $autostart . '" />
<param name="autostart" value="' . $autostart . '" />
<param name="scale" value="aspect" />
</object>
<!--<![endif]-->
</object></span>';
}
private static function get_download_link(ArtefactTypeFile $artefact, BlockInstance $instance, $wmp=false) {
return get_config('wwwroot') . 'artefact/file/download.php?file='
. $artefact->get('id') . '&view=' . $instance->get('view')
. ($wmp ? '&download=1' : '');
}
private static function get_js_source() {
if (defined('BLOCKTYPE_INTERNALMEDIA_JS_INCLUDED')) {
return '';
}
define('BLOCKTYPE_INTERNALMEDIA_JS_INCLUDED', true);
return '<script src="' . get_config('wwwroot') . 'artefact/file/blocktype/internalmedia/swfobject.js"></script>
<script defer="true" src="' . get_config('wwwroot') . 'artefact/file/blocktype/internalmedia/eolas_fix.js"></script>';
}
}
?>
/**
* SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
*
* SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
*/
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
\ No newline at end of file
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage blocktype-internalmedia
* @author Penny Leach <penny@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2007110700;
$config->release = '0.9';
?>
......@@ -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);
?>