Repository navigation
Expand file tree
/
Copy pathPlugin.php
More file actions
executable file
·183 lines (160 loc) · 8.73 KB
/
Copy pathPlugin.php
File metadata and controls
executable file
·183 lines (160 loc) · 8.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
namespace Kanboard\Plugin\Wiki;
use Kanboard\Core\Plugin\Base;
use Kanboard\Core\Security\Role;
use Kanboard\Core\Translator;
use Kanboard\Plugin\Wiki\Api\Procedure\WikiPageProcedure;
class Plugin extends Base
{
public function initialize()
{
// access map
$this->projectAccessMap->add('WikiController', '*', Role::PROJECT_MEMBER);
$this->projectAccessMap->add('WikiAjaxController', '*', Role::PROJECT_MEMBER);
$this->projectAccessMap->add('WikiFileController', '*', Role::PROJECT_MEMBER);
$this->projectAccessMap->add('WikiFileViewController', '*', Role::PROJECT_VIEWER);
$this->projectAccessMap->add(
'WikiController',
array('show', 'detail', 'editions', 'readonly', 'detail_readonly'),
Role::PROJECT_VIEWER
);
$this->applicationAccessMap->add('WikiController', array('readonly','detail_readonly'), Role::APP_PUBLIC);
$this->applicationAccessMap->add('WikiPublicFileController', array('image', 'thumbnail', 'browser', 'download'), Role::APP_PUBLIC);
if ($this->container->offsetExists('api') && $this->container->offsetExists('apiProjectAccessMap')) {
$this->registerWikiApi();
}
// page routes wiki pages
$this->route->addRoute('/wiki/index', 'WikiController', 'index', 'wiki');
$this->route->addRoute('/wiki/project/:project_id', 'WikiController', 'show', 'wiki');
$this->route->addRoute('/wiki/project/:project_id/readonly', 'WikiController', 'readonly', 'wiki');
$this->route->addRoute('/wiki/project/:project_id/detail/:wiki_id', 'WikiController', 'detail', 'wiki');
$this->route->addRoute('/wiki/project/:project_id/detail/:wiki_id/readonly', 'WikiController', 'detail_readonly', 'wiki');
$this->route->addRoute('/wiki/project/:project_id/editions/:wiki_id', 'WikiController', 'editions', 'wiki');
// $this->route->addRoute('/wiki/project/:project_id/breakdown', 'WikiController', 'breakdown', 'wiki');
$this->route->addRoute('/wiki/project/:project_id/create', 'WikiController', 'create', 'wiki');
$this->route->addRoute('/wiki/edit/:wiki_id', 'WikiController', 'edit', 'wiki');
$this->route->addRoute('/wiki/project/:project_id/remove/:wiki_id', 'WikiController', 'confirm', 'wiki');
$this->route->addRoute('/wiki/project/:project_id/restore/:wiki_id/:edition', 'WikiController', 'confirm_restore', 'wiki');
$this->route->addRoute('/wiki/project/:project_id/purge/:wiki_id/:edition', 'WikiController', 'confirm_purge', 'wiki');
// page routes wiki files
$this->route->addRoute('/wiki/file/:project_id/create/:wiki_id', 'WikiFileController', 'create', 'wiki');
$this->route->addRoute('/wiki/file/:project_id/screenshot/:wiki_id', 'WikiFileController', 'screenshot', 'wiki');
$this->route->addRoute('/wiki/file/:project_id/remove/:wiki_id/:file_id', 'WikiFileController', 'confirm', 'wiki');
$this->route->addRoute('/wiki/file/:file_id', 'WikiFileViewController', 'show', 'wiki');
$this->route->addRoute('/wiki/file/:file_id/image', 'WikiFileViewController', 'image', 'wiki');
$this->route->addRoute('/wiki/file/:file_id/thumbnail', 'WikiFileViewController', 'thumbnail', 'wiki');
$this->route->addRoute('/wiki/file/:file_id/browser', 'WikiFileViewController', 'browser', 'wiki');
$this->route->addRoute('/wiki/file/:file_id/download', 'WikiFileViewController', 'download', 'wiki');
$this->route->addRoute('/wiki/public/:token/file/:file_id/image', 'WikiPublicFileController', 'image', 'wiki');
$this->route->addRoute('/wiki/public/:token/file/:file_id/thumbnail', 'WikiPublicFileController', 'thumbnail', 'wiki');
$this->route->addRoute('/wiki/public/:token/file/:file_id/browser', 'WikiPublicFileController', 'browser', 'wiki');
$this->route->addRoute('/wiki/public/:token/file/:file_id/download', 'WikiPublicFileController', 'download', 'wiki');
// page routes wiki settings
$this->route->addRoute('settings/wiki', 'ConfigController', 'show', 'wiki');
// template hooks
$this->template->hook->attach('template:config:sidebar', 'Wiki:config/sidebar');
$this->template->hook->attach('template:project:dropdown', 'wiki:project/dropdown');
$this->template->hook->attach('template:header:dropdown', 'wiki:header/dropdown');
$this->template->hook->attach('template:project-header:view-switcher', 'Wiki:project_header/views');
$this->template->hook->attach('template:layout:head', 'wiki:layout/head');
// template overrides
$this->template->setTemplateOverride('board/view_public', 'wiki:board/view_public');
$this->template->setTemplateOverride('file_viewer/show', 'wiki:file_viewer/show');
// CSS + JS
$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/main.js'));
// $this->template->setTemplateOverride('wiki', 'wiki:wiki/layout');
// can't figure out how to register helper template
// $this->layout->register('wiki', '\Kanboard\Plugin\Wiki\Helper\layout');
// $this->helper->register('wiki', '\Kanboard\Plugin\Wiki\Helper\layout');
// helpers
$this->helper->register('wikiHelper', '\Kanboard\Plugin\Wiki\Helper\WikiHelper');
// markdown with wiki:<id> and wiki-file:<id> references, everywhere Kanboard renders markdown
$this->helper->register('text', '\Kanboard\Plugin\Wiki\Helper\WikiTextHelper');
}
private function registerWikiApi()
{
$readMethods = array(
'getWikiPages',
'getWikiPage',
'searchWikiPages',
'getWikiPageRevisions',
'getWikiPageRevisionDiff',
'getWikiPageFiles',
'downloadWikiPageFile',
);
$writeMethods = array(
'createWikiPage',
'updateWikiPage',
'archiveWikiPage',
'restoreWikiPage',
'restoreWikiPageRevision',
'createWikiPageFile',
'removeWikiPageFile',
);
$procedure = new WikiPageProcedure($this->container);
foreach ($readMethods as $method) {
$this->apiProjectAccessMap->add('WikiPageProcedure', $method, Role::PROJECT_VIEWER);
$this->api->getProcedureHandler()->withClassAndMethod($method, $procedure, $method);
}
foreach ($writeMethods as $method) {
$this->apiProjectAccessMap->add('WikiPageProcedure', $method, Role::PROJECT_MEMBER);
$this->api->getProcedureHandler()->withClassAndMethod($method, $procedure, $method);
}
}
public function onStartup()
{
// initialize translator, default locale en_US
$path = __DIR__ . '/Locale';
$language = $this->languageModel->getCurrentLanguage();
$filename = implode(DIRECTORY_SEPARATOR, array($path, $language, 'translations.php'));
if (file_exists($filename)) {
Translator::load($language, $path);
} else {
Translator::load('en_US', $path);
}
}
public function getClasses()
{
return array(
'Plugin\Wiki\Controller' => [
'WikiAjaxController'
],
'Plugin\Wiki\Model' => array(
'WikiModel',
'WikiFileModel',
'WikiPageModel',
'WikiEditionStore'
),
);
}
public function getPluginName()
{
return 'Wiki';
}
public function getPluginDescription()
{
return t('Wiki to document projects');
}
public function getPluginAuthor()
{
return 'lastlink';
}
/**
* Auto-generated. The Release Bundle workflow (.github/workflows/release.yml) writes the release version here
* when it builds the zip, and never commits it: release zips carry the real version, while the repository keeps
* the placeholder 0.1.0.
*/
public function getPluginVersion()
{
return '0.1.0';
}
public function getPluginHomepage()
{
return 'https://github.com/funktechno/kanboard-plugin-wiki';
}
public function getCompatibleVersion()
{
return '>=1.2.46';
}
}