From 49f43090b214c4346a114922696b7d9d96d2c02e Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 18 May 2016 22:07:49 -0400 Subject: Added plugin controller (WIP) --- app/Controller/Config.php | 13 --------- app/Controller/PluginController.php | 38 ++++++++++++++++++++++++++ app/Helper/LayoutHelper.php | 13 +++++++++ app/ServiceProvider/AuthenticationProvider.php | 1 + app/ServiceProvider/RouteProvider.php | 5 +++- app/Template/config/plugins.php | 30 -------------------- app/Template/config/sidebar.php | 5 +--- app/Template/header.php | 4 +++ app/Template/plugin/directory.php | 30 ++++++++++++++++++++ app/Template/plugin/layout.php | 9 ++++++ app/Template/plugin/show.php | 31 +++++++++++++++++++++ app/Template/plugin/sidebar.php | 11 ++++++++ app/constants.php | 2 ++ 13 files changed, 144 insertions(+), 48 deletions(-) create mode 100644 app/Controller/PluginController.php delete mode 100644 app/Template/config/plugins.php create mode 100644 app/Template/plugin/directory.php create mode 100644 app/Template/plugin/layout.php create mode 100644 app/Template/plugin/show.php create mode 100644 app/Template/plugin/sidebar.php 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 @@ -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 * 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 @@ +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 @@ -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 * 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/plugins.php b/app/Template/config/plugins.php deleted file mode 100644 index 04b3f095..00000000 --- a/app/Template/config/plugins.php +++ /dev/null @@ -1,30 +0,0 @@ - - - -

- - - - - - - - - - - - - - - - - - \ No newline at end of file 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 @@
  • app->checkMenuSelection('config', 'index') ?>> url->link(t('About'), 'config', 'index') ?>
  • -
  • app->checkMenuSelection('config', 'plugins') ?>> - url->link(t('Plugins'), 'config', 'plugins') ?> -
  • app->checkMenuSelection('config', 'application') ?>> url->link(t('Application settings'), 'config', 'application') ?>
  • @@ -36,4 +33,4 @@ hook->render('template:config:sidebar') ?> - \ No newline at end of file + 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 @@ -82,6 +82,10 @@ url->link(t('Groups management'), 'GroupListController', 'index') ?> +
  • + + url->link(t('Plugins'), 'PluginController', 'show') ?> +
  • url->link(t('Settings'), 'config', 'index') ?> 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 @@ + + + +

    + +
  • - getPluginHomepage()): ?> - text->e($plugin->getPluginName()) ?> - - text->e($plugin->getPluginName()) ?> - - text->e($plugin->getPluginAuthor()) ?>text->e($plugin->getPluginVersion()) ?>text->e($plugin->getPluginDescription()) ?>
    + + + + + + + + + + + + + + + + + +
    + text->e($plugin['title']) ?> + text->e($plugin['author']) ?>text->e($plugin['version']) ?>text->e($plugin['description']) ?> +
    + 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 @@ +
    + +
    diff --git a/app/Template/plugin/show.php b/app/Template/plugin/show.php new file mode 100644 index 00000000..8358fb2a --- /dev/null +++ b/app/Template/plugin/show.php @@ -0,0 +1,31 @@ + + + +

    + + + + + + + + + + + + + + + + + +
    + getPluginHomepage()): ?> + text->e($plugin->getPluginName()) ?> + + text->e($plugin->getPluginName()) ?> + + text->e($plugin->getPluginAuthor()) ?>text->e($plugin->getPluginVersion()) ?>text->e($plugin->getPluginDescription()) ?>
    + 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 @@ + 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'); -- cgit v1.2.3