Add basic template and hooks in Admin

This commit is contained in:
Benoît Burnichon
2015-08-27 17:16:07 +02:00
parent 68aab17157
commit c01f3f238f
8 changed files with 221 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,57 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Controller\Admin;
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
class PluginsController
{
/** @var Application */
private $app;
public function __construct(Application $app)
{
$this->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;
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\ControllerProvider\Admin;
use Alchemy\Phrasea\Application as PhraseaApplication;
use Alchemy\Phrasea\Controller\Admin\PluginsController;
use Alchemy\Phrasea\Security\Firewall;
use Silex\Application;
use Silex\ControllerCollection;
use Silex\ControllerProviderInterface;
use Silex\ServiceProviderInterface;
class Plugins implements ControllerProviderInterface, ServiceProviderInterface
{
public function register(Application $app)
{
$app['controller.admin_plugin'] = $app->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;
}
}

View File

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

View File

@@ -0,0 +1,56 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Plugin;
class BasePluginMetadata implements PluginMetadataInterface
{
/** @var string */
private $name;
/** @var string */
private $version;
/** @var string */
private $iconUrl;
/**
* @param string $name
* @param string $version
* @param string $iconUrl
*/
public function __construct($name, $version, $iconUrl)
{
$this->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;
}
}

View File

@@ -0,0 +1,28 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Plugin;
interface PluginMetadataInterface
{
/**
* @return string
*/
public function getName();
/**
* @return string
*/
public function getVersion();
/**
* @return string
*/
public function getIconUrl();
}

View File

@@ -0,0 +1,15 @@
{% extends app['request'].isXmlHttpRequest ? "admin/common/ajax_wrap.html.twig" : "admin/common/iframe_wrap.html.twig" %}
{% block content %}
<div class="page-header">
<h1>{% trans 'admin::plugins: plugins' %}</h1>
</div>
<div id="plugin_list">
{% for pluginKey in plugins.keys() %}
{% set plugin = plugins[pluginKey] %}
<div>{{ plugin.name }}</div>
{% endfor %}
</div>
{% endblock %}

View File

@@ -69,6 +69,13 @@
</li>
{% endif %}
<li>
<a target="right" href="{{ path('admin_plugins_list') }}" class="ajax">
<img src="/skins/admin/plugin.png" />
<span>{% trans 'admin::plugins: plugins' %}</span>
</a>
</li>
<li class="open">
<div class="{% if feature == 'bases' %}selected{% endif %}" style="padding:0 0 2px 0;">
<a id="TREE_DATABASES" target="right" href="{{ path('admin_databases') }}" class="ajax">