Skip to content

Commit

Permalink
Merge pull request #54 from funktechno/f/updates
Browse files Browse the repository at this point in the history
F/updates public mode
  • Loading branch information
lastlink authored Nov 12, 2022
2 parents ab7d9ff + e3b8443 commit 34e8401
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 15 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Version 0.3.2
Improvements:

* width updates to wiki table list
* public mode
* initialize notifications(?) maybe works
* some syntax error fixes

Version 0.3.1-alpha

Bug fixes:
Expand Down
60 changes: 60 additions & 0 deletions Controller/WikiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Kanboard\Plugin\Wiki\Controller;

use Kanboard\Controller\BaseController;
use Kanboard\Core\Controller\AccessForbiddenException;

/**
* Wiki
Expand Down Expand Up @@ -53,6 +54,24 @@ public function index()
)));
}

public function readonly()
{
$token = $this->request->getStringParam('token');
$project = $this->projectModel->getByToken($token);

if (empty($project)) {
throw AccessForbiddenException::getInstance()->withoutLayout();
}

$this->response->html($this->helper->layout->app('wiki:wiki/show', array(
'project' => $project,
'no_layout' => true,
'not_editable' => true,
'title' => $project['name'] .= " ". t('Wiki'),
'wikipages' => $this->wiki->getWikipages($project['id']),
), 'wiki:wiki/sidebar'));
}

/**
* list for wikipages for a project
*/
Expand Down Expand Up @@ -117,12 +136,53 @@ public function edit(array $values = array(), array $errors = array())
), 'wiki:wiki/sidebar'));
}

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

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

if (empty($project)) {
throw AccessForbiddenException::getInstance()->withoutLayout();
}
$wiki_id = $this->request->getIntegerParam('wiki_id');

$wikipages = $this->wiki->getWikipages($project['id']);

foreach ($wikipages as $page) {
if (t($wiki_id) == t($page['id'])) {
$wikipage = $page;
break;
}
}

// If the last wikipage was deleted, select the new last wikipage.
if (!isset($wikipage)) {
$wikipage = end($wikipages);
}

// use a wiki helper for better side bar TODO:
$this->response->html($this->helper->layout->app('wiki:wiki/detail', array(
'project' => $project,
'title' => t('Wikipage'),
'wiki_id' => $wiki_id,
'wiki' => $wikipage,
'no_layout' => true,
'not_editable' => true,
'files' => $this->wikiFile->getAllDocuments($wiki_id),
'images' => $this->wikiFile->getAllImages($wiki_id),
// 'wikipage' => $this->wiki->getWikipage($wiki_id),
'wikipage' => $wikipage,
'wikipages' => $wikipages,
), 'wiki:wiki/sidebar'));
}

/**
* details for single wiki page
*/
public function detail()
{
$project = $this->getProject();

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

$wikipages = $this->wiki->getWikipages($project['id']);
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugin=Wiki
version=0.3.1
version=0.3.2
all:
@ echo "Build archive for plugin ${plugin} version=${version}"
@ git archive HEAD --prefix=${plugin}/ --format=zip -o ${plugin}-${version}.zip
5 changes: 4 additions & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ class Plugin extends Base
public function initialize()
{
$this->projectAccessMap->add('WikiController', '*', Role::PROJECT_MEMBER);
$this->applicationAccessMap->add('WikiController', array('readonly','detail_readonly'), Role::APP_PUBLIC);
$this->projectAccessMap->add('WikiFileController', '*', Role::PROJECT_MEMBER);
$this->projectAccessMap->add('WikiFileViewController', '*', Role::PROJECT_MEMBER);

// $this->route->addRoute('/wiki/project/:project_id', 'WikiController', 'readonly', 'wiki');
// dont think these are even currently used
$this->route->addRoute('/wiki/project/:project_id', 'WikiController', 'show', 'wiki');
$this->route->addRoute('/wiki/project/:project_id', 'WikiController', 'detail', 'wiki');
$this->route->addRoute('/wiki/project/:project_id', 'WikiController', 'editions', 'wiki');
Expand Down Expand Up @@ -87,7 +90,7 @@ public function getPluginAuthor()

public function getPluginVersion()
{
return '0.3.1';
return '0.3.2';
}

public function getPluginHomepage()
Expand Down
31 changes: 23 additions & 8 deletions Template/wiki/detail.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php if (!$not_editable): ?>
<?= $this->projectHeader->render($project, 'TaskListController', 'show') ?>
<?php endif ?>
<div class="page-header">
<h2>
<?= $this->url->link(t('Wiki overview'), 'WikiController', 'show', array('plugin' => 'wiki', 'project_id' => $project['id'])) ?>
<?php if (!$not_editable): ?>
<?= $this->url->link(t('Wiki overview'), 'WikiController', 'show', array('plugin' => 'wiki', 'project_id' => $project['id'])) ?>
<?php else: ?>
<?= $this->url->link(t('Wiki overview'), 'WikiController', 'readonly', array('plugin' => 'wiki', 'token' => $project['token'])) ?>
<?php endif ?>
</h2>
</div>

Expand Down Expand Up @@ -29,10 +35,14 @@
<?php if (!empty($wikipages)): ?>
<?php foreach ($wikipages as $page): ?>

<li class="wikipage" draggable="true">
<?=$this->url->link(t($page['title']), 'WikiController', 'detail', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $page['id']))?>
<li class="wikipage" <?php if (!$not_editable): ?>draggable="true"<?php endif ?>>
<?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']))?>
<?=$this->modal->confirm('trash-o', t(''), 'WikiController', 'confirm', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $page['id']))?>
<?php else: ?>
<?=$this->url->link(t($page['title']), 'WikiController', 'detail_readonly', array('plugin' => 'wiki', 'token' => $project['token'], 'wiki_id' => $page['id']))?>
<?php endif ?>
</li>


Expand All @@ -42,20 +52,23 @@
<?=t('There are no Wiki pages.')?>
</li>
<?php endif?>
<?php if (!$not_editable): ?>
<li>
<?=$this->modal->medium('plus', t('New Wiki page'), 'WikiController', 'create', array('plugin' => 'wiki', 'project_id' => $project['id']))?>
</li>
<?php endif ?>

</ul>
</div>

<div class="column content">
<div class="page-header">
<h2><?=t($wikipage['title'])?></h2>
<?=$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 if (!$not_editable): ?>
<?=$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 ?>
</div>
<ul class="panel">
<?php if ($wikipage['creator_id'] > 0): ?>
Expand All @@ -79,6 +92,7 @@
</article>
<?php endif?>

<?php if (!$not_editable): ?>
<div class="page-header">
<h2><?=t('Attachments')?></h2>
</div>
Expand All @@ -99,6 +113,7 @@
'images' => $images
)) ?>
<?php endif ?>
<?php endif ?>

</div>

20 changes: 15 additions & 5 deletions Template/wiki/show.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<?php if (!$not_editable): ?>
<?= $this->projectHeader->render($project, 'TaskListController', 'show') ?>
<?php endif ?>
<div class="page-header">
<h2><?=t('Wiki overview')?></h2>
<?=$this->modal->medium('plus', t('New Wiki page'), 'WikiController', 'create', array('plugin' => 'wiki', 'project_id' => $project['id']))?>

<?php if (!$not_editable): ?>
<?=$this->modal->medium('plus', t('New Wiki page'), 'WikiController', 'create', array('plugin' => 'wiki', 'project_id' => $project['id']))?>
<?php if ($project['is_public']): ?>
<br>
<?= $this->url->icon('share-alt', t('Public link'), 'WikiController', 'readonly', array('plugin' => 'wiki', 'token' => $project['token']), false, '', '', true) ?>
<?php endif ?>
<?php endif ?>
</div>

<style>
Expand Down Expand Up @@ -50,9 +57,12 @@
<?php foreach ($wikipages as $wikipage): ?>
<tr>
<td>
<?=$this->url->link(t($wikipage['title']), 'WikiController', 'detail', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $wikipage['id']))?>

<?=$this->modal->confirm('trash-o', t(''), 'WikiController', 'confirm', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $wikipage['id']))?>
<?php if (!$not_editable): ?>
<?=$this->url->link(t($wikipage['title']), 'WikiController', 'detail', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $wikipage['id']))?>
<?=$this->modal->confirm('trash-o', t(''), 'WikiController', 'confirm', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $wikipage['id']))?>
<?php else: ?>
<?=$this->url->link(t($wikipage['title']), 'WikiController', 'detail_readonly', array('plugin' => 'wiki', 'token' => $project['token'], 'wiki_id' => $wikipage['id']))?>
<?php endif ?>
</td>
<td><?=$wikipage['id']?></td>
<td><?=$wikipage['editions']?></td>
Expand Down

0 comments on commit 34e8401

Please sign in to comment.