Skip to content

Commit

Permalink
Merge pull request #96 from funktechno/dev
Browse files Browse the repository at this point in the history
release 0.3.8
lastlink authored Aug 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 9cc54e2 + 827f174 commit 63902fb
Showing 12 changed files with 63 additions and 115 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 0.3.8
Improvements:

* Fixed file viewer for attachments.
* Added screenshot support.
* fixes for composer install support

Version 0.3.7
Improvements:

13 changes: 7 additions & 6 deletions Controller/WikiController.php
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ public function index()


// echo json_encode($query->findAll());
// exit();
// exit();
// $wikipages = $this->wikiModel->getWikipages($project['id']);

$search = $this->request->getStringParam('search');
@@ -149,7 +149,7 @@ public function edit(array $values = array(), array $errors = array())

public function detail_readonly() {
$token = $this->request->getStringParam('token');

$project = $this->projectModel->getByToken($token);

if (empty($project)) {
@@ -207,7 +207,7 @@ function getNestedChildren($parent_id, $items) {
public function detail()
{
$project = $this->getProject();

$wiki_id = $this->request->getIntegerParam('wiki_id');

$wikipages = $this->wikiModel->getWikipages($project['id']);
@@ -218,9 +218,9 @@ public function detail()
$wikipage = $page;
}
if(!isset($page['parent_id'])){

$page['children'] = $this->getNestedChildren($page['id'], $wikipages);

array_push($wikiPagesResult, $page);
}
}
@@ -449,7 +449,8 @@ public function remove()
$this->flash->failure(t('Unable to remove this wiki page.'));
}

// FIXME This works only if there are remaining pages.
$this->response->redirect($this->helper->url->to('WikiController', 'show', array('plugin' => 'wiki', 'project_id' => $project['id'])), true);
}

}
86 changes: 16 additions & 70 deletions Controller/WikiFileViewController.php
Original file line number Diff line number Diff line change
@@ -2,78 +2,29 @@

namespace Kanboard\Plugin\Wiki\Controller;

use Kanboard\Controller\FileViewerController;
use Kanboard\Core\ObjectStorage\ObjectStorageException;
use Kanboard\Controller\BaseController;


class WikiFileViewController extends BaseController
class WikiFileViewController extends FileViewerController
{
/**
* Get file content from object storage
*
* @access protected
* @param array $file
* @return string
*/
protected function getFileContent(array $file)
{
$content = '';

try {
if ($file['is_image'] == 0) {
$content = $this->objectStorage->get($file['path']);
}
} catch (ObjectStorageException $e) {
$this->logger->error($e->getMessage());
}

return $content;
}

/**
* Output file with cache
*
* @param array $file
* @param $mimetype
*/
protected function renderFileWithCache(array $file, $mimetype)
{
$etag = md5($file['path']);

if ($this->request->getHeader('If-None-Match') === '"'.$etag.'"') {
$this->response->status(304);
} else {
try {
$this->response->withContentType($mimetype);
$this->response->withCache(5 * 86400, $etag);
$this->response->send();
$this->objectStorage->output($file['path']);
} catch (ObjectStorageException $e) {
$this->logger->error($e->getMessage());
}
}
}

/**
* Show file content in a popover
*
* @access public
*/
public function show()
{
$file = $this->wikiFileModel->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'));


$params['wikipage_id'] = $file['wikipage_id'];

$file = $this->wikiFileModel->getById($this->request->getIntegerParam('file_id'));

$this->response->html($this->template->render('file_viewer/show', array(
'file' => $file,
'params' => $params,
'type' => $type,
'type' => $this->helper->file->getPreviewType($file['name']),
'content' => $this->getFileContent($file),
'params' => array(
'file_id' => $file['id'],
'project_id' => $this->request->getIntegerParam('project_id'),
'wikipage_id' => $file['wikipage_id'],
)
)));
}

@@ -95,7 +46,7 @@ public function image()
*/
public function browser()
{
$file = $this->wikiFileModel->getById($this->request->getIntegerParam('fid'));
$file = $this->wikiFileModel->getById($this->request->getIntegerParam('file_id'));
$this->renderFileWithCache($file, $this->helper->file->getBrowserViewType($file['name']));
}

@@ -107,29 +58,25 @@ public function browser()
public function thumbnail()
{
$file = $this->wikiFileModel->getById($this->request->getIntegerParam('file_id'));
$model = 'wikiFile';
$filename = $this->$model->getThumbnailPath($file['path']);
$etag = md5($filename);
$filename = $this->wikiFileModel->getThumbnailPath($file['path']);

$this->response->withCache(5 * 86400, $etag);
$this->response->withContentType('image/jpeg');
$this->response->withCache(5 * 86400, $file['etag']);
$this->response->withContentType('image/png');

if ($this->request->getHeader('If-None-Match') === '"'.$etag.'"') {
if ($this->request->getHeader('If-None-Match') === '"'.$file['etag'].'"') {
$this->response->status(304);
} else {

$this->response->send();

try {

$this->objectStorage->output($filename);
} catch (ObjectStorageException $e) {
$this->logger->error($e->getMessage());

// Try to generate thumbnail on the fly for images uploaded before Kanboard < 1.0.19
$data = $this->objectStorage->get($file['path']);
$this->$model->generateThumbnailFromData($file['path'], $data);
$this->objectStorage->output($this->$model->getThumbnailPath($file['path']));
$this->wikiFileModel->generateThumbnailFromData($file['path'], $data);
$this->objectStorage->output($this->wikiFileModel->getThumbnailPath($file['path']));
}
}
}
@@ -143,7 +90,6 @@ public function download()
{
try {
$file = $this->wikiFileModel->getById($this->request->getIntegerParam('file_id'));
$file['model'] = 'wikiFile';
$this->response->withFileDownload($file['name']);
$this->response->send();
$this->objectStorage->output($file['path']);
10 changes: 4 additions & 6 deletions Helper/WikiHelper.php
Original file line number Diff line number Diff line change
@@ -31,15 +31,13 @@ public function getWikipages($project_id)
/**
* Add a Javascript asset
*
* @param string $filename Filename
* @param string $filepath Filepath
* @param bool $async
* @return string
*/
public function js($filename, $async = false)
public function js($filepath, $async = false)
{
$dir = dirname(__DIR__,2);
$filepath = $dir.'/'.$filename;
return '<script '.($async ? 'async' : '').' defer type="text/javascript" src="'.$this->helper->url->dir()."plugins".$filename.'?'.filemtime($filepath).'"></script>';
return '<script '.($async ? 'async' : '').' defer type="text/javascript" src="'.$this->helper->url->dir().$filepath.'?'.filemtime($filepath).'"></script>';
}
/**
* render wiki page html children recursively
@@ -76,4 +74,4 @@ public function renderChildren($children, $parent_id, $project, $not_editable){
// {
// return 'foobar';
// }
}
}
7 changes: 3 additions & 4 deletions Model/WikiFileModel.php
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
namespace Kanboard\Plugin\Wiki\Model;

use Kanboard\Model\FileModel;
use Kanboard\Plugin\Wiki\Model\Wiki;

/**
* Wiki File Model
@@ -26,7 +25,7 @@ class WikiFileModel extends FileModel
* @var string
*/
const EVENT_CREATE = 'wiki.file.create';


/**
* Get the table
@@ -39,7 +38,7 @@ protected function getTable()
{
return self::TABLE;
}


/**
* Define the foreign key
@@ -105,7 +104,7 @@ protected function fireCreationEvent($file_id)
{
return null;
}

protected function fireDestructionEvent($file_id)
{
return null;
9 changes: 4 additions & 5 deletions Model/WikiModel.php
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
use Kanboard\Core\Base;
use Kanboard\Core\Controller\PageNotFoundException;
use Kanboard\Core\Controller\AccessForbiddenException;
// use Kanboard\Model\WikiModel;
use Kanboard\Model\UserModel;
use SimpleValidator\Validator;
use SimpleValidator\Validators;
@@ -53,7 +52,7 @@ public function getEditions($wiki_id)
const EVENT_UPDATE = 'wikipage.update';
const EVENT_CREATE = 'wikipage.create';
const EVENT_DELETE = 'wikipage.delete';


/**
* retrieve wikipages by parent id
@@ -178,7 +177,7 @@ public function reorderPagesByIndex($project_id, $src_wiki_id, $index, $parent_i

// echo json_encode($wikiPages), true;

// echo "project_id: " . $project_id . " src_wiki_id: " . $src_wiki_id . " index: " .
// echo "project_id: " . $project_id . " src_wiki_id: " . $src_wiki_id . " index: " .
$index . " parent_id: " . $parent_id ." count list: " . count($wikiPages) . "<br>";
// change order of each in for loop, move matching id to one before target
$orderColumn = 0;
@@ -260,7 +259,7 @@ public function reorderPages($project_id, $src_wiki_id, $target_wiki_id){
if(!$result){
return false;
}
}
}
}
$orderColumn++;
}
@@ -436,7 +435,7 @@ public function updatepage($paramvalues, $editions, $date = '')
if ($this->userSession->isLogged()) {
$values['modifier_id'] = $this->userSession->getId();
}

$wikiEventJob = new WikiEventJob($this->container);
$wikiEventJob->executeWithId($paramvalues['id'], self::EVENT_UPDATE);
// $wikiEventJob = new WikiEventJob($this->container);
2 changes: 1 addition & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ public function getPluginAuthor()

public function getPluginVersion()
{
return '0.3.7';
return '0.3.8';
}

public function getPluginHomepage()
18 changes: 9 additions & 9 deletions Template/wiki/detail.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php (isset($not_editable)) ?: $not_editable = false;
?>
<?php if (!$not_editable): ?>
<?=$this->wikiHelper->js("/Wiki/Asset/vendor/jquery-sortable/jquery-sortable.js")?>
<?=$this->wikiHelper->js("/Wiki/Asset/Javascript/wiki.js")?>
<?=$this->wikiHelper->js("plugins/Wiki/Asset/vendor/jquery-sortable/jquery-sortable.js")?>
<?=$this->wikiHelper->js("plugins/Wiki/Asset/Javascript/wiki.js")?>
<?= $this->projectHeader->render($project, 'TaskListController', 'show') ?>
<?php endif ?>
<div class="page-header">
@@ -37,22 +37,22 @@
<div class="sidebar column list">
<?php if (!empty($wikipages)): ?>
<ul id="columns" <?php if (!$not_editable): ?>data-reorder-url="<?= $this->url->href('WikiAjaxController', 'reorder_by_index', array('plugin' => 'wiki', 'project_id' => $project['id'], 'csrf_token' => $this->app->getToken()->getReusableCSRFToken())) ?>"<?php endif ?>>

<?php foreach ($wikipages as $page): ?>
<li class="wikipage" data-project-id="<?=$project['id']?>" data-page-order="<?=$page['ordercolumn']?>" data-page-id="<?=$page['id']?>">
<?php if (!$not_editable): ?>
<?=$this->url->link(t($page['title']), 'WikiController', 'detail', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $page['id']))?>

<?=$this->modal->confirm('trash-o', t(''), 'WikiController', 'confirm', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $page['id']))?>
<?php else: ?>
<?php else: ?>
<?=$this->url->link(t($page['title']), 'WikiController', 'detail_readonly', array('plugin' => 'wiki', 'token' => $project['token'], 'wiki_id' => $page['id']))?>
<?php endif ?>
<?php endif ?>
<?php if (count($page['children']) > 0): ?>
<?=$this->wikiHelper->renderChildren($page['children'], $page['id'], $project, $not_editable)?>
<?php endif ?>
</li>


<?php endforeach?>
</ul>
<?php else: ?>
@@ -68,7 +68,7 @@
<?=$this->modal->medium('plus', t('New Wiki page'), 'WikiController', 'create', array('plugin' => 'wiki', 'project_id' => $project['id']))?>
</li>
</ul>
<?php endif ?>
<?php endif ?>

</ul>
</div>
@@ -90,7 +90,7 @@
<?=$this->modal->large('edit', t('Edit page'), 'WikiController', 'edit', array('plugin' => 'wiki', 'wiki_id' => $wikipage['id']))?>
<br>
<?=$this->url->icon('window-restore', t('View Editions'), 'WikiController', 'editions', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $wikipage['id']))?>
<?php endif ?>
<?php endif ?>
</div>
<ul class="panel">
<?php if ($wikipage['creator_id'] > 0): ?>
@@ -125,6 +125,7 @@
error_reporting(E_ALL);
?>
<?=$this->modal->medium('file', t('Attach a document'), 'WikiFileController', 'create', array('plugin' => 'wiki', 'wiki_id' => $wikipage['id'], 'project_id' => $wikipage['project_id']))?>
<?= $this->modal->medium('camera', t('Add a screenshot'), 'WikiFileController', 'screenshot', array('plugin' => 'wiki', 'wiki_id' => $wikipage['id'], 'project_id' => $wikipage['project_id'])) ?>
</ul>

<?php if (!empty($files) || !empty($images)): ?>
@@ -138,4 +139,3 @@
<?php endif ?>

</div>

6 changes: 3 additions & 3 deletions Template/wiki_file/files.php
Original file line number Diff line number Diff line change
@@ -15,16 +15,16 @@
<ul>
<?php if ($this->file->getPreviewType($file['name']) !== null): ?>
<li>
<?= $this->modal->large('eye', t('View file'), 'WikiFileViewController', 'show', array('plugin' => 'wiki', 'wikipage_id' => $wiki['id'], 'project_id' => $wiki['project_id'], 'file_id' => $file['id'], 'fid' => $file['id'])) ?>
<?= $this->modal->large('eye', t('View file'), 'WikiFileViewController', 'show', array('plugin' => 'wiki', 'wikipage_id' => $wiki['id'], 'project_id' => $wiki['project_id'], 'file_id' => $file['id'])) ?>
</li>
<?php elseif ($this->file->getBrowserViewType($file['name']) !== null): ?>
<li>
<i class="fa fa-eye fa-fw"></i>
<?= $this->url->link(t('View file'), 'WikiFileViewController', 'browser', array('plugin' => 'wiki', 'wikipage_id' => $wiki['id'], 'project_id' => $wiki['project_id'], 'file_id' => $file['id'], 'fid' => $file['id']), false, '', '', true) ?>
<?= $this->url->link(t('View file'), 'WikiFileViewController', 'browser', array('plugin' => 'wiki', 'wikipage_id' => $wiki['id'], 'project_id' => $wiki['project_id'], 'file_id' => $file['id']), false, '', '', true) ?>
</li>
<?php endif ?>
<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'])) ?>
</li>
<?php if ($this->user->hasProjectAccess('WikiFileController', 'remove', $wiki['project_id'])): ?>
<li>
7 changes: 4 additions & 3 deletions Template/wiki_file/images.php
Original file line number Diff line number Diff line change
@@ -5,11 +5,12 @@
<?= $this->app->component('image-slideshow', array(
'images' => $images,
'image' => $file,
'regex' => 'FILE_ID',
'regex_file_id' => 'FILE_ID',
'regex_etag' => 'ETAG',
'url' => array(
'image' => $this->url->to('WikiFileViewController', 'image', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['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'])),
'download' => $this->url->to('WikiFileViewController', 'download', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'])),
)
)) ?>

3 changes: 0 additions & 3 deletions Template/wiki_file/show.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<section class="accordion-section <?= empty($files) && empty($images) ? 'accordion-collapsed' : '' ?>">
<div class="accordion-title">
<h3><a href="#" class="fa accordion-toggle"></a> <?= t('Attachments') ?></h3>
</div>
<div class="accordion-content">
<?= $this->render('wiki:wiki_file/images', array('wiki' => $wiki, 'images' => $images)) ?>
<?= $this->render('wiki:wiki_file/files', array('wiki' => $wiki, 'files' => $files)) ?>
10 changes: 5 additions & 5 deletions Template/wiki_list/sort_menu.php
Original file line number Diff line number Diff line change
@@ -2,16 +2,16 @@
<a href="#" class="dropdown-menu dropdown-menu-link-icon"><strong><?= t('Sort') ?> <i class="fa fa-caret-down"></i></strong></a>
<ul>
<li>
<?= $paginator->order(t('Project ID'), \Kanboard\Plugin\Wiki\Model\Wiki::WIKITABLE.'.id') ?>
<?= $paginator->order(t('Project ID'), \Kanboard\Plugin\Wiki\Model\WikiModel::WIKITABLE.'.id') ?>
</li>
<li>
<?= $paginator->order(t('Wiki page Title'), \Kanboard\Plugin\Wiki\Model\Wiki::WIKITABLE.'.title') ?>
<?= $paginator->order(t('Wiki page Title'), \Kanboard\Plugin\Wiki\Model\WikiModel::WIKITABLE.'.title') ?>
</li>
<li>
<?= $paginator->order(t('Date Created'), \Kanboard\Plugin\Wiki\Model\Wiki::WIKITABLE.'.date_creation') ?>
<?= $paginator->order(t('Date Created'), \Kanboard\Plugin\Wiki\Model\WikiModel::WIKITABLE.'.date_creation') ?>
</li>
<li>
<?= $paginator->order(t('Date Modified'), \Kanboard\Plugin\Wiki\Model\Wiki::WIKITABLE.'.date_modification') ?>
</li>
<?= $paginator->order(t('Date Modified'), \Kanboard\Plugin\Wiki\Model\WikiModel::WIKITABLE.'.date_modification') ?>
</li>
</ul>
</div>

0 comments on commit 63902fb

Please sign in to comment.