diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 23fcee71ea..a95f75889e 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -287,6 +287,7 @@ class Application extends SilexApplication 'Alchemy\Phrasea\ControllerProvider\Admin\Databoxes' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Feeds' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Fields' => [], + 'Alchemy\Phrasea\ControllerProvider\Admin\Plugins' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Root' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Setup' => [], @@ -649,6 +650,7 @@ class Application extends SilexApplication '/admin/databoxes' => 'Alchemy\Phrasea\ControllerProvider\Admin\Databoxes', '/admin/fields' => 'Alchemy\Phrasea\ControllerProvider\Admin\Fields', '/admin/publications' => 'Alchemy\Phrasea\ControllerProvider\Admin\Feeds', + '/admin/plugins' => 'Alchemy\Phrasea\ControllerProvider\Admin\Plugins', '/admin/search-engine' => 'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine', '/admin/setup' => 'Alchemy\Phrasea\ControllerProvider\Admin\Setup', '/admin/subdefs' => 'Alchemy\Phrasea\ControllerProvider\Admin\Subdefs', diff --git a/lib/Alchemy/Phrasea/Controller/Admin/PluginsController.php b/lib/Alchemy/Phrasea/Controller/Admin/PluginsController.php new file mode 100644 index 0000000000..33886dcbde --- /dev/null +++ b/lib/Alchemy/Phrasea/Controller/Admin/PluginsController.php @@ -0,0 +1,57 @@ +app = $app; + } + + public function indexAction() + { + return $this->render('admin/plugins/index.html.twig', [ + 'plugins' => $this->app['plugins'], + ]); + } + + /** + * @param string $view + * @param array $parameters + * @param Response|null $response + * @return Response + */ + public function render($view, array $parameters = array(), Response $response = null) + { + /** @var \Twig_Environment $twig */ + $twig = $this->app['twig']; + + if ($response instanceof StreamedResponse) { + $response->setCallback(function () use ($twig, $view, $parameters) { + $twig->display($view, $parameters); + }); + } else { + if (null === $response) { + $response = new Response(); + } + $response->setContent($twig->render($view, $parameters)); + } + + return $response; + } +} diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Admin/Plugins.php b/lib/Alchemy/Phrasea/ControllerProvider/Admin/Plugins.php new file mode 100644 index 0000000000..159d44f33e --- /dev/null +++ b/lib/Alchemy/Phrasea/ControllerProvider/Admin/Plugins.php @@ -0,0 +1,52 @@ +share(function (PhraseaApplication $app) { + return new PluginsController($app); + }); + } + + public function boot(Application $app) + { + // Nothing to do + } + + public function connect(Application $app) + { + /** @var ControllerCollection $controllers */ + $controllers = $app['controllers_factory']; + /** @var Firewall $firewall */ + $firewall = $app['firewall']; + $firewall->addMandatoryAuthentication($controllers); + + $controllers->before(function () use ($firewall) { + $firewall->requireAccessToModule('admin'); + }); + + $controllers + ->get('/', 'controller.admin_plugin:indexAction') + ->bind('admin_plugins_list'); + + return $controllers; + } +} diff --git a/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php index 7eb2c985a5..58ebd39906 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php @@ -43,6 +43,10 @@ class PluginServiceProvider implements ServiceProviderInterface $app['plugins.manager'] = $app->share(function (Application $app) { return new PluginManager($app['plugin.path'], $app['plugins.plugins-validator'], $app['conf']); }); + $app['plugins'] = $app->share(function () { + return new Pimple(); + }); + $app['plugin.workzone.basket.actionbar'] = $app->share(function () { return new Pimple(); }); diff --git a/lib/Alchemy/Phrasea/Plugin/BasePluginMetadata.php b/lib/Alchemy/Phrasea/Plugin/BasePluginMetadata.php new file mode 100644 index 0000000000..de1794f99f --- /dev/null +++ b/lib/Alchemy/Phrasea/Plugin/BasePluginMetadata.php @@ -0,0 +1,56 @@ +name = $name; + $this->version = $version; + $this->iconUrl = $iconUrl; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @return string + */ + public function getVersion() + { + return $this->version; + } + + /** + * @return string + */ + public function getIconUrl() + { + return $this->iconUrl; + } +} diff --git a/lib/Alchemy/Phrasea/Plugin/PluginMetadataInterface.php b/lib/Alchemy/Phrasea/Plugin/PluginMetadataInterface.php new file mode 100644 index 0000000000..2cd618fb3d --- /dev/null +++ b/lib/Alchemy/Phrasea/Plugin/PluginMetadataInterface.php @@ -0,0 +1,28 @@ + +

{% trans 'admin::plugins: plugins' %}

+ + +
+ {% for pluginKey in plugins.keys() %} + {% set plugin = plugins[pluginKey] %} +
{{ plugin.name }}
+ {% endfor %} +
+{% endblock %} diff --git a/templates/web/admin/tree.html.twig b/templates/web/admin/tree.html.twig index 884da5578a..4f1ee05e47 100644 --- a/templates/web/admin/tree.html.twig +++ b/templates/web/admin/tree.html.twig @@ -69,6 +69,13 @@ {% endif %} +
  • + + + {% trans 'admin::plugins: plugins' %} + +
  • +