From: Robin Appelman Date: Sat, 8 Oct 2011 19:18:47 +0000 (+0200) Subject: mimetype icon improvements X-Git-Tag: v3.0~93^2~35^2~1^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=949494ccfd89d7ff4af26d8da83475e2ee382f73;p=nextcloud-server.git mimetype icon improvements --- diff --git a/core/img/filetypes/code-script.png b/core/img/filetypes/code-script.png new file mode 100644 index 00000000000..63fe6ceff5b Binary files /dev/null and b/core/img/filetypes/code-script.png differ diff --git a/core/img/filetypes/php.png b/core/img/filetypes/php.png deleted file mode 100644 index 7868a25945c..00000000000 Binary files a/core/img/filetypes/php.png and /dev/null differ diff --git a/core/img/filetypes/script.png b/core/img/filetypes/script.png deleted file mode 100644 index 63fe6ceff5b..00000000000 Binary files a/core/img/filetypes/script.png and /dev/null differ diff --git a/core/img/filetypes/text-x-php.png b/core/img/filetypes/text-x-php.png new file mode 100644 index 00000000000..7868a25945c Binary files /dev/null and b/core/img/filetypes/text-x-php.png differ diff --git a/files/ajax/mimeicon.php b/files/ajax/mimeicon.php new file mode 100644 index 00000000000..8724016b3a1 --- /dev/null +++ b/files/ajax/mimeicon.php @@ -0,0 +1,8 @@ + diff --git a/files/js/filelist.js b/files/js/filelist.js index 84762bb561d..e6da922700d 100644 --- a/files/js/filelist.js +++ b/files/js/filelist.js @@ -101,10 +101,14 @@ FileList={ $('.file_upload_filename').removeClass('highlight'); }, loadingDone:function(name){ - $('tr[data-file="'+name+'"]').data('loading',false); - var mime=$('tr[data-file="'+name+'"]').data('mime'); - $('tr[data-file="'+name+'"] td.filename').attr('style','background-image:url('+getMimeIcon(mime)+')'); - $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions); + var tr=$('tr[data-file="'+name+'"]'); + tr.data('loading',false); + var mime=tr.data('mime'); + tr.attr('data-mime',mime); + getMimeIcon(mime,function(path){ + tr.find('td.filename').attr('style','background-image:url('+path+')'); + }); + tr.find('td.filename').draggable(dragOptions); }, isLoading:function(name){ return $('tr[data-file="'+name+'"]').data('loading'); diff --git a/files/js/files.js b/files/js/files.js index 9342642b4ff..079646070d4 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -473,11 +473,14 @@ function relative_modified_date(timestamp) { else { return diffyears+' '+t('files','years ago'); } } -function getMimeIcon(mime){ - mime=mime.substr(0,mime.indexOf('/')); - var knownMimes=['image','audio']; - if(knownMimes.indexOf(mime)==-1){ - mime='file'; +function getMimeIcon(mime, ready){ + if(getMimeIcon.cache[mime]){ + ready(getMimeIcon.cache[mime]); + }else{ + $.get( OC.filePath('files','ajax','mimeicon.php')+'?mime='+mime, function(path){ + getMimeIcon.cache[mime]=path; + ready(getMimeIcon.cache[mime]); + }); } - return OC.imagePath('core','filetypes/'+mime); } +getMimeIcon.cache={}; diff --git a/lib/helper.php b/lib/helper.php index c2a81ba3306..5b3e394cafd 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -96,6 +96,12 @@ class OC_Helper { * Returns the path to the image of this file type. */ public static function mimetypeIcon( $mimetype ){ + $alias=array('application/xml'=>'code/xml'); +// echo $mimetype; + if(isset($alias[$mimetype])){ + $mimetype=$alias[$mimetype]; +// echo $mimetype; + } // Replace slash with a minus $mimetype = str_replace( "/", "-", $mimetype );