Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files Browse the repository at this point in the history
lastlink committed Nov 14, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents aa60a18 + 01f716f commit d5d7126
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
@@ -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
{
/**
@@ -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'));

@@ -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']));
}

@@ -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);
@@ -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();
4 changes: 4 additions & 0 deletions Model/WikiFile.php
Original file line number Diff line number Diff line change
@@ -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
@@ -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'));
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
@@ -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'])),
)
)) ?>

@@ -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>

0 comments on commit d5d7126

Please sign in to comment.