mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
Add basic template and hooks in Admin
This commit is contained in:
@@ -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',
|
||||
|
57
lib/Alchemy/Phrasea/Controller/Admin/PluginsController.php
Normal file
57
lib/Alchemy/Phrasea/Controller/Admin/PluginsController.php
Normal 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;
|
||||
}
|
||||
}
|
52
lib/Alchemy/Phrasea/ControllerProvider/Admin/Plugins.php
Normal file
52
lib/Alchemy/Phrasea/ControllerProvider/Admin/Plugins.php
Normal 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;
|
||||
}
|
||||
}
|
@@ -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();
|
||||
});
|
||||
|
56
lib/Alchemy/Phrasea/Plugin/BasePluginMetadata.php
Normal file
56
lib/Alchemy/Phrasea/Plugin/BasePluginMetadata.php
Normal 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;
|
||||
}
|
||||
}
|
28
lib/Alchemy/Phrasea/Plugin/PluginMetadataInterface.php
Normal file
28
lib/Alchemy/Phrasea/Plugin/PluginMetadataInterface.php
Normal 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();
|
||||
}
|
15
templates/web/admin/plugins/index.html.twig
Normal file
15
templates/web/admin/plugins/index.html.twig
Normal 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 %}
|
@@ -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">
|
||||
|
Reference in New Issue
Block a user