forked from cristidraghici/Kanext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.php
executable file
·144 lines (121 loc) · 5.61 KB
/
Plugin.php
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
<?php
namespace Kanboard\Plugin\Kanext;
use Kanboard\Core\Plugin\Base;
use Kanboard\Core\Translator;
use DirectoryIterator;
class Plugin extends Base
{
public function initialize()
{
// Hooks
$this->template->hook->attach('template:dashboard:sidebar', 'kanext:kanext_hooks/dashboard/sidebar-hook');
$this->template->hook->attach('template:layout:head', 'kanext:kanext_hooks/layout/head-hook');
// Override
$this->template->setTemplateOverride('dashboard/layout', 'kanext:kanext_overrides/dashboard/layout');
// Kanext configuration - attach the link to the settings sidebar
$this->template->hook->attach('template:config:sidebar', 'kanext:kanext_configuration/settings-sidebar-item');
// Close dropdown on second click
if ($this->configModel->get('kanext_close_dropdown_on_second_click') == 1) {
$this->hook->on('template:layout:js', array('template' => 'plugins/Kanext/Assets/SecondClickClose/script.js'));
}
// Close modal on overlay click
if ($this->configModel->get('kanext_close_modal_on_overlay_click') == 1) {
$this->hook->on('template:layout:js', array('template' => 'plugins/Kanext/Assets/OverlayClickClose/script.js'));
}
// General style fixes
if ($this->configModel->get('kanext_general_style_fixes') == 1) {
$this->hook->on('template:layout:css', array('template' => 'plugins/Kanext/Assets/StyleFixes/style.css'));
}
// The sidebar toggle
if ($this->configModel->get('kanext_feature_toggle_sidebar') == 1) {
$this->hook->on('template:layout:js', array('template' => 'plugins/Kanext/Assets/ToggleSidebar/script.js'));
$this->hook->on('template:layout:css', array('template' => 'plugins/Kanext/Assets/ToggleSidebar/style.css'));
}
// Custom dashboard
if ($this->configModel->get('kanext_feature_kanext_dashboard') == 1) {
$this->hook->on('template:layout:js', array('template' => 'plugins/Kanext/Assets/KanextDashboard/script.js'));
$this->hook->on('template:layout:css', array('template' => 'plugins/Kanext/Assets/KanextDashboard/style.css'));
$this->template->setTemplateOverride('dashboard/overview', 'kanext:kanext_dashboard/dashboard/overview');
}
}
public function onStartup()
{
// Load the locales
Translator::load($this->languageModel->getCurrentLanguage(), __DIR__.'/Locale');
// Limit the number of tasks in a column (in `onStartup` for later loading them)
if ($this->configModel->get('kanext_feature_limit_tasks') == 1) {
$this->route->addRoute('kanext/tasks/:column/:swimlane', 'KanextTasksController', 'allTasksInColumn');
$this->hook->on('template:layout:js', array('template' => 'plugins/Kanext/Assets/KanextLimitTasks/script.js'));
$this->hook->on('template:layout:css', array('template' => 'plugins/Kanext/Assets/KanextLimitTasks/style.css'));
$this->template->setTemplateOverride('board/table_tasks', 'kanext:kanext_limit_tasks/board/table_tasks');
}
// Load custom CSS for plugins
if ($this->configModel->get('kanext_feature_fixes_for_theme_plugins') == 1) {
$kanext_skins = PLUGINS_DIR . '/Kanext/Assets/PluginSkins/';
$overwritables_plugins_css = array();
// Get the list of overwritable values
$dir = new DirectoryIterator($kanext_skins);
foreach ($dir as $fileInfo) {
if ($fileInfo->isFile()) {
$overwritables_plugins_css[] = strtolower($fileInfo->getBasename('.css'));
}
}
// Get the installed plugins
$installed_plugins = array();
foreach ($this->pluginLoader->getPlugins() as $plugin) {
$installed_plugins[strtolower($plugin->getPluginName())] = $plugin->getPluginVersion();
}
foreach ($overwritables_plugins_css as $theme) {
if (isset($installed_plugins[$theme])) {
$this->hook->on('template:layout:css', array('template' => 'plugins/Kanext/Assets/PluginSkins/'.$theme.'.css'));
}
}
}
}
public function getClasses()
{
$classes = array(
'Plugin\Kanext\Helper' => array(
'ConfigHelper'
)
);
// Custom dashboard
if ($this->configModel->get('kanext_feature_kanext_dashboard') == 1) {
$classes['Plugin\Kanext\Model'] = array(
'KanextDashboardModel',
);
}
return $classes;
}
public function getPluginName()
{
return 'Kanext';
}
public function getPluginDescription()
{
return t('This theme modifies the default functionality of kanboard and enhances the user experience.', 'kanext');
}
public function getPluginAuthor()
{
return 'Cristi Draghici';
}
public function getPluginVersion()
{
return '3.0.1';
}
public function getPluginHomepage()
{
return 'https://github.com/cristidraghici/Kanext';
}
/**
* This plugin alters php templates, thus is tightly dependent on the kanboard version.
* It is recommended that the plugin be checked with every release,
* but mandatory to have it checked when kanboard releases minors or majors. Thus,
* we use a lesser than condition, assuming that people who new-ish :) plugins, also care to update
* the version of Kanboard.
*/
public function getCompatibleVersion()
{
return '<1.3.0';
}
}