summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-18 22:07:49 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-18 22:07:49 -0400
commit49f43090b214c4346a114922696b7d9d96d2c02e (patch)
tree418c2f2322cf59dc0a9bf0c65fe0d2c1030af6c3
parentbfd59d9e544028a1ea041806fd60e112f3a90167 (diff)
Added plugin controller (WIP)
-rw-r--r--app/Controller/Config.php13
-rw-r--r--app/Controller/PluginController.php38
-rw-r--r--app/Helper/LayoutHelper.php13
-rw-r--r--app/ServiceProvider/AuthenticationProvider.php1
-rw-r--r--app/ServiceProvider/RouteProvider.php5
-rw-r--r--app/Template/config/sidebar.php5
-rw-r--r--app/Template/header.php4
-rw-r--r--app/Template/plugin/directory.php30
-rw-r--r--app/Template/plugin/layout.php9
-rw-r--r--app/Template/plugin/show.php (renamed from app/Template/config/plugins.php)5
-rw-r--r--app/Template/plugin/sidebar.php11
-rw-r--r--app/constants.php2
12 files changed, 116 insertions, 20 deletions
diff --git a/app/Controller/Config.php b/app/Controller/Config.php
index deafd05b..abf6565c 100644
--- a/app/Controller/Config.php
+++ b/app/Controller/Config.php
@@ -65,19 +65,6 @@ class Config extends BaseController
}
/**
- * Display the plugin page
- *
- * @access public
- */
- public function plugins()
- {
- $this->response->html($this->helper->layout->config('config/plugins', array(
- 'plugins' => $this->pluginLoader->plugins,
- 'title' => t('Settings').' &gt; '.t('Plugins'),
- )));
- }
-
- /**
* Display the application settings page
*
* @access public
diff --git a/app/Controller/PluginController.php b/app/Controller/PluginController.php
new file mode 100644
index 00000000..8d5628f1
--- /dev/null
+++ b/app/Controller/PluginController.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Kanboard\Controller;
+
+/**
+ * Class PluginController
+ *
+ * @package Kanboard\Controller
+ * @author Frederic Guillot
+ */
+class PluginController extends BaseController
+{
+ /**
+ * Display the plugin page
+ *
+ * @access public
+ */
+ public function show()
+ {
+ $this->response->html($this->helper->layout->plugin('plugin/show', array(
+ 'plugins' => $this->pluginLoader->plugins,
+ 'title' => t('Installed Plugins'),
+ )));
+ }
+
+ /**
+ * Display list of available plugins
+ */
+ public function directory()
+ {
+ $plugins = $this->httpClient->getJson(PLUGIN_API_URL);
+
+ $this->response->html($this->helper->layout->plugin('plugin/directory', array(
+ 'plugins' => $plugins,
+ 'title' => t('Plugin Directory'),
+ )));
+ }
+}
diff --git a/app/Helper/LayoutHelper.php b/app/Helper/LayoutHelper.php
index 75cd178a..aeb0c846 100644
--- a/app/Helper/LayoutHelper.php
+++ b/app/Helper/LayoutHelper.php
@@ -121,6 +121,19 @@ class LayoutHelper extends Base
}
/**
+ * Common layout for plugin views
+ *
+ * @access public
+ * @param string $template
+ * @param array $params
+ * @return string
+ */
+ public function plugin($template, array $params)
+ {
+ return $this->subLayout('plugin/layout', 'plugin/sidebar', $template, $params);
+ }
+
+ /**
* Common layout for dashboard views
*
* @access public
diff --git a/app/ServiceProvider/AuthenticationProvider.php b/app/ServiceProvider/AuthenticationProvider.php
index 1ac4656c..6b037940 100644
--- a/app/ServiceProvider/AuthenticationProvider.php
+++ b/app/ServiceProvider/AuthenticationProvider.php
@@ -130,6 +130,7 @@ class AuthenticationProvider implements ServiceProviderInterface
$acl->add('AvatarFile', 'show', Role::APP_PUBLIC);
$acl->add('Config', '*', Role::APP_ADMIN);
+ $acl->add('PluginController', '*', Role::APP_ADMIN);
$acl->add('Currency', '*', Role::APP_ADMIN);
$acl->add('Gantt', array('projects', 'saveProjectDate'), Role::APP_MANAGER);
$acl->add('GroupListController', '*', Role::APP_ADMIN);
diff --git a/app/ServiceProvider/RouteProvider.php b/app/ServiceProvider/RouteProvider.php
index eb567e46..9001f176 100644
--- a/app/ServiceProvider/RouteProvider.php
+++ b/app/ServiceProvider/RouteProvider.php
@@ -165,7 +165,6 @@ class RouteProvider implements ServiceProviderInterface
// Config
$container['route']->addRoute('settings', 'config', 'index');
- $container['route']->addRoute('settings/plugins', 'config', 'plugins');
$container['route']->addRoute('settings/application', 'config', 'application');
$container['route']->addRoute('settings/project', 'config', 'project');
$container['route']->addRoute('settings/project', 'config', 'project');
@@ -177,6 +176,10 @@ class RouteProvider implements ServiceProviderInterface
$container['route']->addRoute('settings/links', 'link', 'index');
$container['route']->addRoute('settings/currencies', 'currency', 'index');
+ // Plugins
+ $container['route']->addRoute('extensions', 'PluginController', 'show');
+ $container['route']->addRoute('extensions/list', 'PluginController', 'directory');
+
// Doc
$container['route']->addRoute('documentation/:file', 'doc', 'show');
$container['route']->addRoute('documentation', 'doc', 'show');
diff --git a/app/Template/config/sidebar.php b/app/Template/config/sidebar.php
index dd51bc74..a2a5a6cb 100644
--- a/app/Template/config/sidebar.php
+++ b/app/Template/config/sidebar.php
@@ -4,9 +4,6 @@
<li <?= $this->app->checkMenuSelection('config', 'index') ?>>
<?= $this->url->link(t('About'), 'config', 'index') ?>
</li>
- <li <?= $this->app->checkMenuSelection('config', 'plugins') ?>>
- <?= $this->url->link(t('Plugins'), 'config', 'plugins') ?>
- </li>
<li <?= $this->app->checkMenuSelection('config', 'application') ?>>
<?= $this->url->link(t('Application settings'), 'config', 'application') ?>
</li>
@@ -36,4 +33,4 @@
</li>
<?= $this->hook->render('template:config:sidebar') ?>
</ul>
-</div> \ No newline at end of file
+</div>
diff --git a/app/Template/header.php b/app/Template/header.php
index 23906a9e..428cf477 100644
--- a/app/Template/header.php
+++ b/app/Template/header.php
@@ -83,6 +83,10 @@
<?= $this->url->link(t('Groups management'), 'GroupListController', 'index') ?>
</li>
<li>
+ <i class="fa fa-cubes" aria-hidden="true"></i>
+ <?= $this->url->link(t('Plugins'), 'PluginController', 'show') ?>
+ </li>
+ <li>
<i class="fa fa-cog fa-fw"></i>
<?= $this->url->link(t('Settings'), 'config', 'index') ?>
</li>
diff --git a/app/Template/plugin/directory.php b/app/Template/plugin/directory.php
new file mode 100644
index 00000000..82b9a441
--- /dev/null
+++ b/app/Template/plugin/directory.php
@@ -0,0 +1,30 @@
+<div class="page-header">
+ <h2><?= t('Plugin Directory') ?></h2>
+</div>
+
+<?php if (empty($plugins)): ?>
+ <p class="alert"><?= t('There is no plugin available.') ?></p>
+<?php else: ?>
+ <table class="table-stripped">
+ <tr>
+ <th class="column-20"><?= t('Name') ?></th>
+ <th class="column-20"><?= t('Author') ?></th>
+ <th class="column-10"><?= t('Version') ?></th>
+ <th><?= t('Description') ?></th>
+ <th><?= t('Action') ?></th>
+ </tr>
+
+ <?php foreach ($plugins as $plugin): ?>
+ <tr>
+ <td>
+ <a href="<?= $plugin['homepage'] ?>" target="_blank" rel="noreferrer"><?= $this->text->e($plugin['title']) ?></a>
+ </td>
+ <td><?= $this->text->e($plugin['author']) ?></td>
+ <td><?= $this->text->e($plugin['version']) ?></td>
+ <td><?= $this->text->e($plugin['description']) ?></td>
+ <td>
+ </td>
+ </tr>
+ <?php endforeach ?>
+ </table>
+<?php endif ?>
diff --git a/app/Template/plugin/layout.php b/app/Template/plugin/layout.php
new file mode 100644
index 00000000..6eafa593
--- /dev/null
+++ b/app/Template/plugin/layout.php
@@ -0,0 +1,9 @@
+<section id="main">
+ <section class="sidebar-container" id="config-section">
+ <?= $this->render($sidebar_template) ?>
+
+ <div class="sidebar-content">
+ <?= $content_for_sublayout ?>
+ </div>
+ </section>
+</section>
diff --git a/app/Template/config/plugins.php b/app/Template/plugin/show.php
index 04b3f095..8358fb2a 100644
--- a/app/Template/config/plugins.php
+++ b/app/Template/plugin/show.php
@@ -1,5 +1,5 @@
<div class="page-header">
- <h2><?= t('Plugins') ?></h2>
+ <h2><?= t('Installed Plugins') ?></h2>
</div>
<?php if (empty($plugins)): ?>
@@ -27,4 +27,5 @@
<td><?= $this->text->e($plugin->getPluginDescription()) ?></td>
</tr>
<?php endforeach ?>
-<?php endif ?> \ No newline at end of file
+ </table>
+<?php endif ?>
diff --git a/app/Template/plugin/sidebar.php b/app/Template/plugin/sidebar.php
new file mode 100644
index 00000000..e1b47632
--- /dev/null
+++ b/app/Template/plugin/sidebar.php
@@ -0,0 +1,11 @@
+<div class="sidebar">
+ <h2><?= t('Actions') ?></h2>
+ <ul>
+ <li <?= $this->app->checkMenuSelection('PluginController', 'show') ?>>
+ <?= $this->url->link(t('Installed Plugins'), 'PluginController', 'show') ?>
+ </li>
+ <li <?= $this->app->checkMenuSelection('PluginController', 'directory') ?>>
+ <?= $this->url->link(t('Plugin Directory'), 'PluginController', 'directory') ?>
+ </li>
+ </ul>
+</div>
diff --git a/app/constants.php b/app/constants.php
index 5e1e886f..31510c5f 100644
--- a/app/constants.php
+++ b/app/constants.php
@@ -131,3 +131,5 @@ defined('HTTP_PROXY_HOSTNAME') or define('HTTP_PROXY_HOSTNAME', '');
defined('HTTP_PROXY_PORT') or define('HTTP_PROXY_PORT', '3128');
defined('HTTP_PROXY_USERNAME') or define('HTTP_PROXY_USERNAME', '');
defined('HTTP_PROXY_PASSWORD') or define('HTTP_PROXY_PASSWORD', '');
+
+defined('PLUGIN_API_URL') or define('PLUGIN_API_URL', 'https://kanboard.net/plugins.json');