add image thumbnail to task detail view, add icons to common file extensions, better layout in task attachments
This commit is contained in:
@@ -441,7 +441,8 @@ class Board extends Base
|
|||||||
$task = $this->getTask();
|
$task = $this->getTask();
|
||||||
|
|
||||||
$this->response->html($this->template->render('board/files', array(
|
$this->response->html($this->template->render('board/files', array(
|
||||||
'files' => $this->file->getAll($task['id']),
|
'files' => $this->file->getAllDocuments($task['id']),
|
||||||
|
'images' => $this->file->getAllImages($task['id']),
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ class File extends Base
|
|||||||
$task = $this->getTask();
|
$task = $this->getTask();
|
||||||
|
|
||||||
$this->response->html($this->taskLayout('file/new', array(
|
$this->response->html($this->taskLayout('file/new', array(
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
'max_size' => ini_get('upload_max_filesize'),
|
'max_size' => ini_get('upload_max_filesize'),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,8 +74,8 @@ class File extends Base
|
|||||||
|
|
||||||
if ($file['task_id'] == $task['id']) {
|
if ($file['task_id'] == $task['id']) {
|
||||||
$this->response->html($this->template->render('file/open', array(
|
$this->response->html($this->template->render('file/open', array(
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,6 +101,69 @@ class File extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the file content (work only for images) resized
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
public function imageThumbnail() {
|
||||||
|
$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'];
|
||||||
|
|
||||||
|
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 ));
|
||||||
|
} elseif ($width_param == 0 && $height_param > 0) {
|
||||||
|
$newwidth = floor($width * ( $height_param / $height ));
|
||||||
|
$newheight = $height_param;
|
||||||
|
} else {
|
||||||
|
$newwidth = $width_param;
|
||||||
|
$newheight = $height_param;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load
|
||||||
|
$thumb = imagecreatetruecolor($newwidth, $newheight);
|
||||||
|
|
||||||
|
$info = pathinfo($file['name']);
|
||||||
|
$extension = strtolower($info['extension']);
|
||||||
|
|
||||||
|
switch ($extension) {
|
||||||
|
case 'jpeg':
|
||||||
|
case 'jpg':
|
||||||
|
$source = imagecreatefromjpeg($filename);
|
||||||
|
break;
|
||||||
|
case 'png':
|
||||||
|
$source = imagecreatefrompng($filename);
|
||||||
|
break;
|
||||||
|
case 'gif':
|
||||||
|
$source = imagecreatefromgif($filename);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
die('File "' . $filename . '" is not valid jpg, png or gif image.');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
* Remove a file
|
||||||
*
|
*
|
||||||
@@ -132,8 +195,8 @@ class File extends Base
|
|||||||
$file = $this->file->getById($this->request->getIntegerParam('file_id'));
|
$file = $this->file->getById($this->request->getIntegerParam('file_id'));
|
||||||
|
|
||||||
$this->response->html($this->taskLayout('file/remove', array(
|
$this->response->html($this->taskLayout('file/remove', array(
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,74 @@ class File extends Base
|
|||||||
*/
|
*/
|
||||||
public function isImage($filename)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,7 +287,7 @@ class File extends Base
|
|||||||
$task_id,
|
$task_id,
|
||||||
$original_filename,
|
$original_filename,
|
||||||
$destination_filename,
|
$destination_filename,
|
||||||
$this->isImage(FILES_DIR.$destination_filename)
|
$this->isImage($original_filename)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,33 @@
|
|||||||
<section>
|
<section>
|
||||||
<?php foreach ($files as $file): ?>
|
<table>
|
||||||
<i class="fa fa-file-o fa-fw"></i>
|
<?php if (!empty($images)): ?>
|
||||||
|
<?php foreach ($images as $file): ?>
|
||||||
<?= $this->a(
|
<tr>
|
||||||
$this->e($file['name']),
|
<td><i class="fa fa-file-image-o fa-fw"></i>
|
||||||
'file',
|
<?=
|
||||||
'download',
|
$this->e($file['name'])
|
||||||
array('file_id' => $file['id'], 'task_id' => $file['task_id'], 'project_id' => $task['project_id'])
|
?>
|
||||||
) ?>
|
</td>
|
||||||
|
<td>
|
||||||
<br/>
|
<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'])) ?>
|
||||||
<?php endforeach ?>
|
<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 foreach ($files as $file): ?>
|
||||||
|
<tr>
|
||||||
|
<td><i class="fa <?= $this->file->get_icon($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'])) ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach ?>
|
||||||
|
<?php endif ?>
|
||||||
|
</table>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<?php foreach ($images as $file): ?>
|
<?php foreach ($images as $file): ?>
|
||||||
<li>
|
<li>
|
||||||
<div class="img_container">
|
<div class="img_container">
|
||||||
<img src="<?= $this->u('file', 'image', array('file_id' => $file['id'], 'project_id' => $task['project_id'], 'task_id' => $file['task_id'])) ?>" alt="<?= $this->e($file['name']) ?>"/>
|
<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>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
<?= $this->e($file['name']) ?>
|
<?= $this->e($file['name']) ?>
|
||||||
@@ -31,17 +31,20 @@
|
|||||||
<h3>
|
<h3>
|
||||||
<?= t('Files') ?>
|
<?= t('Files') ?>
|
||||||
</h3>
|
</h3>
|
||||||
<ul class="task-show-files">
|
<table class="task-show-file-table">
|
||||||
<?php foreach ($files as $file): ?>
|
<?php foreach ($files as $file): ?>
|
||||||
<li>
|
<tr>
|
||||||
<?= $this->a($this->e($file['name']), 'file', 'download', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'file_id' => $file['id'])) ?>
|
<td><i class="fa <?= $this->file->get_icon($file['name']) ?> fa-fw"></i></td>
|
||||||
<span class="task-show-file-actions">
|
<td>
|
||||||
<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'])) ?>
|
<?= $this->e($file['name']) ?>
|
||||||
</span>
|
</td><td>
|
||||||
</li>
|
<span class="task-show-file-actions">
|
||||||
<?php endforeach ?>
|
<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'])) ?>
|
||||||
</ul>
|
<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>
|
</div>
|
||||||
<?php endif
|
<?php endif
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1583,3 +1583,6 @@ td li.dropit-trigger {
|
|||||||
.task-show-images li .img_container:hover {
|
.task-show-images li .img_container:hover {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
.task-show-file-table {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
@@ -277,3 +277,6 @@ span.task-board-date-overdue {
|
|||||||
.task-show-images li .img_container:hover {
|
.task-show-images li .img_container:hover {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
.task-show-file-table {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user