diff options
author | BlueTeck <tili2@gmx.de> | 2015-03-07 11:31:53 +0100 |
---|---|---|
committer | BlueTeck <tili2@gmx.de> | 2015-03-07 11:31:53 +0100 |
commit | 5e5af86638d301658d3910b94c68e8a35f676c00 (patch) | |
tree | 157242e063b1b986699a1f9a430601bad9b5ded3 /app/Model | |
parent | 88ba0c0953395e18dbdd871e96831d885f59740c (diff) |
add image thumbnail to task detail view, add icons to common file extensions, better layout in task attachments
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/File.php | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/app/Model/File.php b/app/Model/File.php index 46710658..3c2f2b68 100644 --- a/app/Model/File.php +++ b/app/Model/File.php @@ -153,10 +153,77 @@ class File extends Base */ public function isImage($filename) { - return getimagesize($filename) !== false; + $info = pathinfo($filename); + $extension = strtolower($info['extension']); + + switch ($extension) { + case 'jpeg': + case 'jpg': + case 'png': + case 'gif': + return true; + break; + default: + return false; + break; + } } /** + * get Font-Awesome Icon for file extension + * + * @access public + * @param string $filename Filename + * @return string Font-Awesome-Icon-Name + */ + public function get_icon($filename){ + $info = pathinfo($filename); + $extension = strtolower($info['extension']); + switch ($extension) { + case 'jpeg': + case 'jpg': + case 'png': + case 'gif': + $icon = 'fa-file-image-o'; + break; + case 'xls': + case 'xlsx': + $icon = 'fa-file-excel-o'; + break; + case 'doc': + case 'docx': + $icon = 'fa-file-word-o'; + break; + case 'ppt': + case 'pptx': + $icon = 'fa-file-powerpoint-o'; + break; + case 'zip': + case 'rar': + $icon = 'fa-archive-o'; + break; + case 'mp3': + $icon = 'fa-audio-o'; + break; + case 'avi': + $icon = 'fa-video-o'; + break; + case 'php': + case 'html': + case 'css': + $icon = 'fa-code-o'; + break; + case 'pdf': + $icon = 'fa-file-pdf-o'; + break; + default: + $icon = 'fa-file-o'; + break; + } + return $icon; + } + + /** * Generate the path for a new filename * * @access public @@ -220,7 +287,7 @@ class File extends Base $task_id, $original_filename, $destination_filename, - $this->isImage(FILES_DIR.$destination_filename) + $this->isImage($original_filename) ); } } |