Skip to content

Commit d5d7126

Browse files
committed
2 parents aa60a18 + 01f716f commit d5d7126

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

Controller/WikiFileViewController.php

+5-10
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
use Kanboard\Core\ObjectStorage\ObjectStorageException;
66
use Kanboard\Controller\BaseController;
77

8-
/**
9-
* File Viewer Controller
10-
*
11-
* @package Kanbaord\Controller
12-
* @author Frederic Guillot
13-
*/
8+
149
class WikiFileViewController extends BaseController
1510
{
1611
/**
@@ -66,7 +61,7 @@ protected function renderFileWithCache(array $file, $mimetype)
6661
*/
6762
public function show()
6863
{
69-
$file = $file = $this->wikiFile->getById($this->request->getIntegerParam('fid'));
64+
$file = $this->wikiFile->getById($this->request->getIntegerParam('fid'));
7065
$type = $this->helper->file->getPreviewType($file['name']);
7166
$params = array('file_id' => $file['id'], 'project_id' => $this->request->getIntegerParam('project_id'));
7267

@@ -89,7 +84,7 @@ public function show()
8984
*/
9085
public function image()
9186
{
92-
$file = $this->wikiFile->getById($this->request->getIntegerParam('fid'));
87+
$file = $this->wikiFile->getById($this->request->getIntegerParam('file_id'));
9388
$this->renderFileWithCache($file, $this->helper->file->getImageMimeType($file['name']));
9489
}
9590

@@ -111,7 +106,7 @@ public function browser()
111106
*/
112107
public function thumbnail()
113108
{
114-
$file = $this->wikiFile->getById($this->request->getIntegerParam('fid'));
109+
$file = $this->wikiFile->getById($this->request->getIntegerParam('file_id'));
115110
$model = 'wikiFile';
116111
$filename = $this->$model->getThumbnailPath($file['path']);
117112
$etag = md5($filename);
@@ -147,7 +142,7 @@ public function thumbnail()
147142
public function download()
148143
{
149144
try {
150-
$file = $this->wikiFile->getById($this->request->getIntegerParam('fid'));
145+
$file = $this->wikiFile->getById($this->request->getIntegerParam('file_id'));
151146
$file['model'] = 'wikiFile';
152147
$this->response->withFileDownload($file['name']);
153148
$this->response->send();

Model/WikiFile.php

+4
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,8 @@ protected function fireCreationEvent($file_id)
106106
return null;
107107
}
108108

109+
protected function fireDestructionEvent($file_id)
110+
{
111+
return null;
112+
}
109113
}

Plugin.php

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public function initialize()
3838
$this->template->hook->attach('template:project-list:menu:after', 'wiki:wiki_list/menu');
3939

4040
$this->template->hook->attach('template:header:dropdown', 'wiki:header/dropdown');
41+
42+
$this->template->setTemplateOverride('file_viewer/show', 'wiki:file_viewer/show');
4143

4244
$this->hook->on('template:layout:css', array('template' => 'plugins/Wiki/Asset/css/wiki.css'));
4345
$this->hook->on('template:layout:js', array('template' => 'plugins/Wiki/Asset/Javascript/wiki.js'));

Template/file_viewer/show.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<div class="page-header">
2+
<h2><?= $this->text->e($file['name']) ?></h2>
3+
</div>
4+
<div class="file-viewer">
5+
<?php if ($file['is_image']): ?>
6+
<img src="<?= $this->url->href('WikiFileViewController', 'image', $params, array('plugin' => 'wiki', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'], 'file_id' => $file['id']) ?>" alt="<?= $this->text->e($file['name']) ?>">
7+
<?php elseif ($type === 'markdown'): ?>
8+
<article class="markdown">
9+
<?= $this->text->markdown($content) ?>
10+
</article>
11+
<?php elseif ($type === 'text'): ?>
12+
<pre><?= $content ?></pre>
13+
<?php endif ?>
14+
</div>

Template/wiki_file/images.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
'image' => $file,
88
'regex' => 'FILE_ID',
99
'url' => array(
10-
'image' => $this->url->to('WikiFileViewController', 'image', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'], 'fid' => $file['id'])),
11-
'thumbnail' => $this->url->to('WikiFileViewController', 'thumbnail', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'], 'fid' => $file['id'])),
12-
'download' => $this->url->to('WikiFileViewController', 'download', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'], 'fid' => $file['id'])),
10+
'image' => $this->url->to('WikiFileViewController', 'image', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'])),
11+
'thumbnail' => $this->url->to('WikiFileViewController', 'thumbnail', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'])),
12+
'download' => $this->url->to('WikiFileViewController', 'download', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'])),
1313
)
1414
)) ?>
1515

@@ -19,7 +19,7 @@
1919
<a href="#" class="dropdown-menu dropdown-menu-link-text" title="<?= $this->text->e($file['name']) ?>"><?= $this->text->e($file['name']) ?> <i class="fa fa-caret-down"></i></a>
2020
<ul>
2121
<li>
22-
<?= $this->url->icon('download', t('Download'), 'WikiFileViewController', 'download', array('plugin' => 'wiki', 'wikipage_id' => $wiki['id'], 'project_id' => $wiki['project_id'], 'file_id' => $file['id'], 'fid' => $file['id'])) ?>
22+
<?= $this->url->icon('download', t('Download'), 'WikiFileViewController', 'download', array('plugin' => 'wiki', 'wikipage_id' => $wiki['id'], 'project_id' => $wiki['project_id'], 'file_id' => $file['id'], 'file_id' => $file['id'])) ?>
2323
</li>
2424
<?php if ($this->user->hasProjectAccess('WikiFileController', 'remove', $wiki['project_id'])): ?>
2525
<li>

0 commit comments

Comments
 (0)