diff options
author | Andreas Gohr <andi@splitbrain.org> | 2008-12-02 22:03:22 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2008-12-02 22:03:22 +0100 |
commit | ecebf3a8627f527cbd184b7907dd91f65764617b (patch) | |
tree | b8cc9e688deccab5f9b3a78258f666ecc624c4c5 /inc | |
parent | 02a002e903ab4b1afa2e1c3d7c2b3e44d77783fa (diff) | |
download | rpg-ecebf3a8627f527cbd184b7907dd91f65764617b.tar.gz rpg-ecebf3a8627f527cbd184b7907dd91f65764617b.tar.bz2 |
Make content-disposition configurable in mime.conf FS#1541
With this patch it is possible to define if a file should be served as download
or be displayed inside the browser (if supported) by configuring it in
conf/mime.conf
Mimetypes that should be served with a "Content-Disposition: attachment" header
need to be prefixed with a exclamation mark. All others will be served inline.
This will also fix a Problem with Flash 10.
darcs-hash:20081202210322-7ad00-6e7ef30aff9322cd135311be77809187da121f3b.gz
Diffstat (limited to 'inc')
-rw-r--r-- | inc/confutils.php | 8 | ||||
-rw-r--r-- | inc/media.php | 6 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 6 |
3 files changed, 12 insertions, 8 deletions
diff --git a/inc/confutils.php b/inc/confutils.php index a7799b9d4..1ef0942f8 100644 --- a/inc/confutils.php +++ b/inc/confutils.php @@ -14,7 +14,7 @@ * @author Andreas Gohr <andi@splitbrain.org> */ function mimetype($file){ - $ret = array(false,false); // return array + $ret = array(false,false,false); // return array $mtypes = getMimeTypes(); // known mimetypes $exts = join('|',array_keys($mtypes)); // known extensions (regexp) if(preg_match('#\.('.$exts.')$#i',$file,$matches)){ @@ -22,7 +22,11 @@ function mimetype($file){ } if($ext && $mtypes[$ext]){ - $ret = array($ext, $mtypes[$ext]); + if($mtypes[$ext][0] == '!'){ + $ret = array($ext, substr($mtypes[$ext],1), true); + }else{ + $ret = array($ext, $mtypes[$ext], false); + } } return $ret; diff --git a/inc/media.php b/inc/media.php index 3e54db512..29b2ec986 100644 --- a/inc/media.php +++ b/inc/media.php @@ -233,8 +233,8 @@ function media_upload($ns,$auth){ } // check extensions - list($fext,$fmime) = mimetype($file['name']); - list($iext,$imime) = mimetype($id); + list($fext,$fmime,$dl) = mimetype($file['name']); + list($iext,$imime,$dl) = mimetype($id); if($fext && !$iext){ // no extension specified in id - read original one $id .= '.'.$fext; @@ -492,7 +492,7 @@ function media_printfile($item,$auth,$jump){ } // Prepare fileicons - list($ext,$mime) = mimetype($item['file']); + list($ext,$mime,$dl) = mimetype($item['file']); $class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext); $class = 'select mediafile mf_'.$class; diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index fda1ef36e..58ff5e7b1 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -675,7 +675,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $render = ($linking == 'linkonly') ? false : true; $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render); - list($ext,$mime) = mimetype($src); + list($ext,$mime,$dl) = mimetype($src); if(substr($mime,0,5) == 'image' && $render){ $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),($linking=='direct')); }elseif($mime == 'application/x-shockwave-flash' && $render){ @@ -705,7 +705,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $link['url'] = ml($src,array('cache'=>$cache)); - list($ext,$mime) = mimetype($src); + list($ext,$mime,$dl) = mimetype($src); if(substr($mime,0,5) == 'image' && $render){ // link only jpeg images // if ($ext != 'jpg' && $ext != 'jpeg') $noLink = true; @@ -909,7 +909,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $ret = ''; - list($ext,$mime) = mimetype($src); + list($ext,$mime,$dl) = mimetype($src); if(substr($mime,0,5) == 'image'){ // first get the $title if (!is_null($title)) { |