diff options
-rw-r--r-- | app/Controller/File.php | 33 | ||||
-rw-r--r-- | app/Core/Helper.php | 44 | ||||
-rw-r--r-- | app/Locale/da_DK/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/de_DE/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/es_ES/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/fi_FI/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/fr_FR/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/hu_HU/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/it_IT/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/ja_JP/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/pl_PL/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/pt_BR/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/ru_RU/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/sv_SE/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/th_TH/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/tr_TR/translations.php | 2 | ||||
-rw-r--r-- | app/Locale/zh_CN/translations.php | 2 | ||||
-rw-r--r-- | app/Model/File.php | 71 | ||||
-rw-r--r-- | app/Template/board/files.php | 20 | ||||
-rw-r--r-- | app/Template/file/show.php | 96 |
20 files changed, 151 insertions, 143 deletions
diff --git a/app/Controller/File.php b/app/Controller/File.php index 1e719d2f..3963e2d7 100644 --- a/app/Controller/File.php +++ b/app/Controller/File.php @@ -20,8 +20,8 @@ class File extends Base $task = $this->getTask(); $this->response->html($this->taskLayout('file/new', array( - 'task' => $task, - 'max_size' => ini_get('upload_max_filesize'), + 'task' => $task, + 'max_size' => ini_get('upload_max_filesize'), ))); } @@ -74,8 +74,8 @@ class File extends Base if ($file['task_id'] == $task['id']) { $this->response->html($this->template->render('file/open', array( - 'file' => $file, - 'task' => $task, + 'file' => $file, + 'task' => $task, ))); } } @@ -102,29 +102,31 @@ class File extends Base } /** - * Return the file content (work only for images) resized + * Return image thumbnails * * @access public */ - public function imageThumbnail() { + public function thumbnail() + { $task = $this->getTask(); $file = $this->file->getById($this->request->getIntegerParam('file_id')); $width_param = $this->request->getIntegerParam('width'); $height_param = $this->request->getIntegerParam('height'); - $filename = FILES_DIR . $file['path']; + $filename = FILES_DIR.$file['path']; if ($file['task_id'] == $task['id'] && file_exists($filename)) { // Get new sizes list($width, $height) = getimagesize($filename); + if ($width_param == 0 && $height_param == 0) { $newwidth = 100; $newheight = 100; } elseif ($width_param > 0 && $height_param == 0) { $newwidth = $width_param; - $newheight = floor($height * ( $width_param / $width )); + $newheight = floor($height * ($width_param / $width)); } elseif ($width_param == 0 && $height_param > 0) { - $newwidth = floor($width * ( $height_param / $height )); + $newwidth = floor($width * ($height_param / $height)); $newheight = $height_param; } else { $newwidth = $width_param; @@ -133,9 +135,7 @@ class File extends Base // Load $thumb = imagecreatetruecolor($newwidth, $newheight); - - $info = pathinfo($file['name']); - $extension = strtolower($info['extension']); + $extension = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); switch ($extension) { case 'jpeg': @@ -153,17 +153,18 @@ class File extends Base break; } - // Resize + // Resize imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); $metadata = getimagesize($filename); + if (isset($metadata['mime'])) { $this->response->contentType($metadata['mime']); imagejpeg($thumb); } } } - + /** * Remove a file * @@ -195,8 +196,8 @@ class File extends Base $file = $this->file->getById($this->request->getIntegerParam('file_id')); $this->response->html($this->taskLayout('file/remove', array( - 'task' => $task, - 'file' => $file, + 'task' => $task, + 'file' => $file, ))); } } diff --git a/app/Core/Helper.php b/app/Core/Helper.php index 78267feb..34a5e6ab 100644 --- a/app/Core/Helper.php +++ b/app/Core/Helper.php @@ -726,4 +726,48 @@ class Helper { return dt('%A', strtotime('next Monday +'.($day - 1).' days')); } + + /** + * Get file icon + * + * @access public + * @param string $filename Filename + * @return string Font-Awesome-Icon-Name + */ + public function getFileIcon($filename){ + + $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); + + switch ($extension) { + case 'jpeg': + case 'jpg': + case 'png': + case 'gif': + return 'fa-file-image-o'; + case 'xls': + case 'xlsx': + return 'fa-file-excel-o'; + case 'doc': + case 'docx': + return 'fa-file-word-o'; + case 'ppt': + case 'pptx': + return 'fa-file-powerpoint-o'; + case 'zip': + case 'rar': + return 'fa-archive-o'; + case 'mp3': + return 'fa-audio-o'; + case 'avi': + return 'fa-video-o'; + case 'php': + case 'html': + case 'css': + return 'fa-code-o'; + case 'pdf': + return 'fa-file-pdf-o'; + } + + return 'fa-file-o'; + } } diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php index f31bfa08..42381e27 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index ec1d20ca..ecdeab64 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index aaacd7f8..36f4b699 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index bd3a7d68..b1774fe4 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index df1d8428..5354970a 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -775,4 +775,6 @@ return array( 'Remove time slot' => 'Supprimer un créneau horaire', 'Add new time slot' => 'Ajouter un créneau horaire', 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => 'Ces horaires sont utilisés lorsque la case « Toute la journée » est cochée pour les heures d\'absences ou supplémentaires programmées.', + 'Files' => 'Fichiers', + 'Images' => 'Images', ); diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php index fed84522..5c2cd7d7 100644 --- a/app/Locale/hu_HU/translations.php +++ b/app/Locale/hu_HU/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index d6c57371..c13ebdf5 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index dd727d0e..fc0dd04e 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index deb5a280..51382137 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index f81bc675..0cd63ce5 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index a4caa545..e53efee0 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index 47ac8b26..5516b90e 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index 43395db5..5b127162 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php index e2d4e72c..82321bdd 100644 --- a/app/Locale/tr_TR/translations.php +++ b/app/Locale/tr_TR/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index f1bbd87c..0d2d551e 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -773,4 +773,6 @@ return array( // 'Remove time slot' => '', // 'Add new time slot' => '', // 'This timetable is used when the checkbox "all day" is checked for scheduled time off and overtime.' => '', + // 'Files' => '', + // 'Images' => '', ); diff --git a/app/Model/File.php b/app/Model/File.php index 3c2f2b68..a8cce9f4 100644 --- a/app/Model/File.php +++ b/app/Model/File.php @@ -111,7 +111,7 @@ class File extends Base ->asc('name') ->findAll(); } - + /** * Get all images for a given task * @@ -127,7 +127,7 @@ class File extends Base ->asc('name') ->findAll(); } - + /** * Get all files without images for a given task * @@ -153,76 +153,19 @@ class File extends Base */ public function isImage($filename) { - $info = pathinfo($filename); - $extension = strtolower($info['extension']); + $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); switch ($extension) { case 'jpeg': - case 'jpg': - case 'png': + 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; + return false; } - + /** * Generate the path for a new filename * diff --git a/app/Template/board/files.php b/app/Template/board/files.php index 61529434..851a118d 100644 --- a/app/Template/board/files.php +++ b/app/Template/board/files.php @@ -1,27 +1,25 @@ <section> <table> - <?php if (!empty($images)): ?> + <?php if (! empty($images)): ?> <?php foreach ($images as $file): ?> <tr> - <td><i class="fa fa-file-image-o fa-fw"></i> - <?= - $this->e($file['name']) - ?> + <td class="column-70"> + <i class="fa fa-file-image-o fa-fw"></i> + <?= $this->e($file['name']) ?> </td> <td> <i class="fa fa-download"></i> <?= $this->a(t('download'), 'file', 'download', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])) ?> - <i class="fa fa-eye"></i> <?= $this->a(t('open'), 'file', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id']), false, 'popover') ?> + <i class="fa fa-eye"></i> <?= $this->a(t('open'), 'file', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id']), false, 'popover') ?> </td> </tr> <?php endforeach ?> <?php endif ?> - <?php if (!empty($files)): ?> + <?php if (! empty($files)): ?> <?php foreach ($files as $file): ?> <tr> - <td><i class="fa <?= $this->file->get_icon($file['name']) ?> fa-fw"></i> - <?= - $this->e($file['name']) - ?> + <td> + <i class="fa <?= $this->getFileIcon($file['name']) ?> fa-fw"></i> + <?= $this->e($file['name']) ?> </td> <td> <i class="fa fa-download"></i> <?= $this->a(t('download'), 'file', 'download', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])) ?> diff --git a/app/Template/file/show.php b/app/Template/file/show.php index 0f5bd4ee..b181ab54 100644 --- a/app/Template/file/show.php +++ b/app/Template/file/show.php @@ -1,56 +1,48 @@ -<?php if (!empty($files) || !empty($images)): ?> - <div id="attachments" class="task-show-section"> +<?php if (! empty($files) || ! empty($images)): ?> +<div id="attachments" class="task-show-section"> - <div class="page-header"> - <h2><?= t('Attachments') ?></h2> - </div> - <?php if (!empty($images)): ?> - <h3> - <?= t('Images') ?> - </h3> - <ul class="task-show-images"> - <?php foreach ($images as $file): ?> - <li> - <div class="img_container"> - <img src="<?= $this->u('file', 'imageThumbnail', array('width' => 250, 'file_id' => $file['id'], 'project_id' => $task['project_id'], 'task_id' => $file['task_id'])) ?>" alt="<?= $this->e($file['name']) ?>"/> - </div> - <p> - <?= $this->e($file['name']) ?> - </p> - <span class="task-show-file-actions task-show-image-actions"> - <i class="fa fa-eye"></i> <?= $this->a(t('open'), 'file', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id']), false, 'popover') ?> + <div class="page-header"> + <h2><?= t('Attachments') ?></h2> + </div> + <?php if (!empty($images)): ?> + <h3><?= t('Images') ?></h3> + <ul class="task-show-images"> + <?php foreach ($images as $file): ?> + <li> + <div class="img_container"> + <img src="<?= $this->u('file', 'thumbnail', array('width' => 250, 'file_id' => $file['id'], 'project_id' => $task['project_id'], 'task_id' => $file['task_id'])) ?>" alt="<?= $this->e($file['name']) ?>"/> + </div> + <p> + <?= $this->e($file['name']) ?> + </p> + <span class="task-show-file-actions task-show-image-actions"> + <i class="fa fa-eye"></i> <?= $this->a(t('open'), 'file', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id']), false, 'popover') ?> + <i class="fa fa-trash"></i> <?= $this->a(t('remove'), 'file', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])) ?> + <i class="fa fa-download"></i> <?= $this->a(t('download'), 'file', 'download', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])) ?> + </span> + </li> + <?php endforeach ?> + </ul> + <?php endif ?> + + <?php if (! empty($files)): ?> + <h3><?= t('Files') ?></h3> + <table class="task-show-file-table"> + <?php foreach ($files as $file): ?> + <tr> + <td><i class="fa <?= $this->getFileIcon($file['name']) ?> fa-fw"></i></td> + <td> + <?= $this->e($file['name']) ?> + </td> + <td> + <span class="task-show-file-actions"> <i class="fa fa-trash"></i> <?= $this->a(t('remove'), 'file', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])) ?> <i class="fa fa-download"></i> <?= $this->a(t('download'), 'file', 'download', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])) ?> </span> - </li> - <?php endforeach ?> - </ul> - <?php endif - ?> - <?php if (!empty($files)): ?> - <h3> - <?= t('Files') ?> - </h3> - <table class="task-show-file-table"> - <?php foreach ($files as $file): ?> - <tr> - <td><i class="fa <?= $this->file->get_icon($file['name']) ?> fa-fw"></i></td> - <td> - <?= $this->e($file['name']) ?> - </td><td> - <span class="task-show-file-actions"> - <i class="fa fa-trash"></i> <?= $this->a(t('remove'), 'file', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])) ?> - <i class="fa fa-download"></i> <?= $this->a(t('download'), 'file', 'download', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])) ?> - </span> - </td></tr> - <?php endforeach ?> - </table> - </div> - <?php endif - ?> - <?php - - - - - endif ?>
\ No newline at end of file + </td> + </tr> + <?php endforeach ?> + </table> + <?php endif ?> +</div> +<?php endif ?>
\ No newline at end of file |