From e3b154dc3272515c4676f48655def67a280c1105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Mon, 20 Jul 2015 20:28:30 +0200 Subject: [PATCH] Add Necessary templates for plugins handling --- lib/Alchemy/Phrasea/Application.php | 3 +++ .../Phrasea/Core/Provider/PluginServiceProvider.php | 5 ++++- templates/web/prod/WorkZone/plugin.html.twig | 2 ++ templates/web/prod/index.html.twig | 11 +++++++++++ templates/web/prod/tab_headers.html.twig | 7 +++++++ 5 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 templates/web/prod/WorkZone/plugin.html.twig diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 5553e0aa78..02784761c6 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -433,6 +433,9 @@ class Application extends SilexApplication $twig->addExtension(new \Twig_Extension_Core()); $twig->addExtension(new \Twig_Extension_Optimizer()); $twig->addExtension(new \Twig_Extension_Escaper()); + if ($app['debug']) { + $twig->addExtension(new \Twig_Extension_Debug()); + } // add filter trans $twig->addExtension(new TranslationExtension($app['translator'])); diff --git a/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php index 71984c8dc4..06c4c13415 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php @@ -39,12 +39,15 @@ 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['plugin.workzone'] = $app->share(function () { + return new \Pimple(); + }); } public function boot(Application $app) { $app['twig'] = $app->share( - $app->extend('twig', function ($twig, Application $app) { + $app->extend('twig', function (\Twig_Environment $twig) { $function = new \Twig_SimpleFunction('plugin_asset', ['Alchemy\Phrasea\Plugin\Management\AssetsManager', 'twigPluginAsset']); $twig->addFunction($function); diff --git a/templates/web/prod/WorkZone/plugin.html.twig b/templates/web/prod/WorkZone/plugin.html.twig new file mode 100644 index 0000000000..92c63176b1 --- /dev/null +++ b/templates/web/prod/WorkZone/plugin.html.twig @@ -0,0 +1,2 @@ +

{% block plugin_workzone_header_caption %}{{ plugin_id }}{% endblock plugin_workzone_header_caption %}

+
{% block plugin_workzone_content %}{% endblock plugin_workzone_content %}
diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig index 7f27bd5c49..3325ebf6e5 100644 --- a/templates/web/prod/index.html.twig +++ b/templates/web/prod/index.html.twig @@ -157,6 +157,11 @@ {% block javascript %} {% include "common/templates.html.twig" %} + {% endblock %} {% block content %} @@ -183,6 +188,12 @@ {% block tabs_panel %}
{% include 'prod/tab_headers.html.twig' %} +
+ {% set workzone_plugins = app['plugin.workzone'] %} + {% for plugin in workzone_plugins.keys() %} + {% include workzone_plugins[plugin].getWorkzoneTemplate() with {'app': app, 'plugin_id': plugin} only %} + {% endfor %} +
{% import 'prod/WorkZone/Macros.html.twig' as WorkZoneMacros %} {{WorkZoneMacros.make_bloc(app, WorkZone)}} diff --git a/templates/web/prod/tab_headers.html.twig b/templates/web/prod/tab_headers.html.twig index 2ca2883cee..2a81da4055 100644 --- a/templates/web/prod/tab_headers.html.twig +++ b/templates/web/prod/tab_headers.html.twig @@ -16,6 +16,13 @@ {% endif %} + {% if app['plugin.workzone'].keys() is not empty %} +
  • + + + +
  • + {% endif %}