Added plugin controller (WIP)

This commit is contained in:
Frederic Guillot 2016-05-18 22:07:49 -04:00
parent bfd59d9e54
commit 49f43090b2
12 changed files with 116 additions and 20 deletions

View File

@ -64,19 +64,6 @@ class Config extends BaseController
$this->response->redirect($this->helper->url->to('config', $redirect));
}
/**
* 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').' > '.t('Plugins'),
)));
}
/**
* Display the application settings page
*

View File

@ -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'),
)));
}
}

View File

@ -120,6 +120,19 @@ class LayoutHelper extends Base
return $this->subLayout('config/layout', 'config/sidebar', $template, $params);
}
/**
* 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
*

View File

@ -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);

View File

@ -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');

View File

@ -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>
</div>

View File

@ -82,6 +82,10 @@
<i class="fa fa-group fa-fw"></i>
<?= $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') ?>

View File

@ -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 ?>

View File

@ -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>

View File

@ -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 ?>
</table>
<?php endif ?>

View File

@ -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>

View File

@ -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');