Skip to content

Commit

Permalink
Merge pull request #21 from creecros/patch-1
Browse files Browse the repository at this point in the history
Patch 1
  • Loading branch information
lastlink authored Nov 14, 2018
2 parents 75308cd + 9eb6262 commit 01f716f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
15 changes: 5 additions & 10 deletions Controller/WikiFileViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
use Kanboard\Core\ObjectStorage\ObjectStorageException;
use Kanboard\Controller\BaseController;

/**
* File Viewer Controller
*
* @package Kanbaord\Controller
* @author Frederic Guillot
*/

class WikiFileViewController extends BaseController
{
/**
Expand Down Expand Up @@ -66,7 +61,7 @@ protected function renderFileWithCache(array $file, $mimetype)
*/
public function show()
{
$file = $file = $this->wikiFile->getById($this->request->getIntegerParam('fid'));
$file = $this->wikiFile->getById($this->request->getIntegerParam('fid'));
$type = $this->helper->file->getPreviewType($file['name']);
$params = array('file_id' => $file['id'], 'project_id' => $this->request->getIntegerParam('project_id'));

Expand All @@ -89,7 +84,7 @@ public function show()
*/
public function image()
{
$file = $this->wikiFile->getById($this->request->getIntegerParam('fid'));
$file = $this->wikiFile->getById($this->request->getIntegerParam('file_id'));
$this->renderFileWithCache($file, $this->helper->file->getImageMimeType($file['name']));
}

Expand All @@ -111,7 +106,7 @@ public function browser()
*/
public function thumbnail()
{
$file = $this->wikiFile->getById($this->request->getIntegerParam('fid'));
$file = $this->wikiFile->getById($this->request->getIntegerParam('file_id'));
$model = 'wikiFile';
$filename = $this->$model->getThumbnailPath($file['path']);
$etag = md5($filename);
Expand Down Expand Up @@ -147,7 +142,7 @@ public function thumbnail()
public function download()
{
try {
$file = $this->wikiFile->getById($this->request->getIntegerParam('fid'));
$file = $this->wikiFile->getById($this->request->getIntegerParam('file_id'));
$file['model'] = 'wikiFile';
$this->response->withFileDownload($file['name']);
$this->response->send();
Expand Down
4 changes: 4 additions & 0 deletions Model/WikiFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,8 @@ protected function fireCreationEvent($file_id)
return null;
}

protected function fireDestructionEvent($file_id)
{
return null;
}
}
2 changes: 2 additions & 0 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public function initialize()
$this->template->hook->attach('template:project-list:menu:after', 'wiki:wiki_list/menu');

$this->template->hook->attach('template:header:dropdown', 'wiki:header/dropdown');

$this->template->setTemplateOverride('file_viewer/show', 'wiki:file_viewer/show');

$this->hook->on('template:layout:css', array('template' => 'plugins/Wiki/Asset/css/wiki.css'));
$this->hook->on('template:layout:js', array('template' => 'plugins/Wiki/Asset/Javascript/wiki.js'));
Expand Down
14 changes: 14 additions & 0 deletions Template/file_viewer/show.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="page-header">
<h2><?= $this->text->e($file['name']) ?></h2>
</div>
<div class="file-viewer">
<?php if ($file['is_image']): ?>
<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']) ?>">
<?php elseif ($type === 'markdown'): ?>
<article class="markdown">
<?= $this->text->markdown($content) ?>
</article>
<?php elseif ($type === 'text'): ?>
<pre><?= $content ?></pre>
<?php endif ?>
</div>
8 changes: 4 additions & 4 deletions Template/wiki_file/images.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
'image' => $file,
'regex' => 'FILE_ID',
'url' => array(
'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'])),
'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'])),
'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'])),
'image' => $this->url->to('WikiFileViewController', 'image', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'])),
'thumbnail' => $this->url->to('WikiFileViewController', 'thumbnail', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'])),
'download' => $this->url->to('WikiFileViewController', 'download', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'])),
)
)) ?>

Expand All @@ -19,7 +19,7 @@
<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>
<ul>
<li>
<?= $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'])) ?>
<?= $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'])) ?>
</li>
<?php if ($this->user->hasProjectAccess('WikiFileController', 'remove', $wiki['project_id'])): ?>
<li>
Expand Down

0 comments on commit 01f716f

Please sign in to comment.