Merge pull request #1500 from bburnichon/mapping-subdefs-PLUG-7

Mapping subdefs
This commit is contained in:
Benoît Burnichon
2015-09-08 20:58:55 +02:00
10 changed files with 541 additions and 567 deletions

View File

@@ -19,19 +19,23 @@ class BasePluginMetadata implements PluginMetadataInterface
private $iconUrl;
/** @var string */
private $localeTextDomain;
/** @var string[] */
private $configurationTabServiceIds;
/**
* @param string $name
* @param string $version
* @param string $iconUrl
* @param string $localeTextDomain
* @param string $name
* @param string $version
* @param string $iconUrl
* @param string $localeTextDomain
* @param string[] $configurationTabServiceIds
*/
public function __construct($name, $version, $iconUrl, $localeTextDomain)
public function __construct($name, $version, $iconUrl, $localeTextDomain, array $configurationTabServiceIds = [])
{
$this->name = $name;
$this->version = $version;
$this->iconUrl = $iconUrl;
$this->localeTextDomain = $localeTextDomain;
$this->configurationTabServiceIds = $configurationTabServiceIds;
}
/**
@@ -65,4 +69,12 @@ class BasePluginMetadata implements PluginMetadataInterface
{
return $this->localeTextDomain;
}
/**
* @return string[]
*/
public function getConfigurationTabServiceIds()
{
return $this->configurationTabServiceIds;
}
}

View File

@@ -0,0 +1,27 @@
<?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 ConfigurationTabInterface
{
/**
* Get the title translation key in plugin domain
*
* @return string
*/
public function getTitle();
/**
* Get the url where configuration tab can be retrieved
*
* @return string
*/
public function getUrl();
}

View File

@@ -25,4 +25,16 @@ interface PluginMetadataInterface
* @return string
*/
public function getIconUrl();
/**
* @return string
*/
public function getLocaleTextDomain();
/**
* Names of all configuration tabs service.
*
* @return array<string>
*/
public function getConfigurationTabServiceIds();
}

View File

@@ -55,6 +55,10 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
return $this->AvSubdefs;
}
/**
* @param string $searchGroup
* @return databox_subdef[]
*/
public function getSubdefGroup($searchGroup)
{
$searchGroup = strtolower($searchGroup);

View File

@@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-06-12 13:37+0100\n"
"PO-Revision-Date: 2015-09-03 16:46+0200\n"
"PO-Revision-Date: 2015-09-04 14:56+0200\n"
"Last-Translator: Benoît Burnichon <bburnichon@alchemy.fr>\n"
"Language-Team: \n"
"Language: en_GB\n"
@@ -11662,6 +11662,9 @@ msgstr "Name: "
msgid "admin::plugins: version"
msgstr "Version: "
msgid "admin::plugins: retrieveConfigurationError"
msgstr "An error occurred while fetching configuration content."
#~ msgid "report:: questions"
#~ msgstr "Questions"

File diff suppressed because it is too large Load Diff

View File

@@ -11438,3 +11438,7 @@ msgstr ""
msgid "admin::plugins: version"
msgstr ""
msgid "admin::plugins: retrieveConfigurationError"
msgstr ""

View File

@@ -6,15 +6,56 @@
<h1>{% trans 'plugin.name' plugin.localeTextDomain %}</h1>
</div>
{{ block('about') }}
{% endblock %}
{% block about %}
<h1>{% trans 'admin::plugins: about' %}</h1>
<ul>
<li>{{ 'admin::plugins: name'|trans }}{{ plugin.name }}</li>
<li>{{ 'admin::plugins: version'|trans }}{{ plugin.version }}</li>
</ul>
<div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="configurationTabs">
{% for divId, configurationTabServiceId in plugin.configurationTabServiceIds %}
{% set configurationTab = app[configurationTabServiceId] %}
{% set tabTitle = configurationTab.title %}
<li role="presentation"><a href="#{{ divId }}" aria-controls="{{ divId }}" role="tab" data-toggle="tab" data-url="{{ configurationTab.url }}">{% trans tabTitle plugin.localeTextDomain %}</a></li>
{% endfor %}
<li role="presentation" class="active"><a href="#about" aria-controls="about" role="tab" data-toggle="tab">{% trans 'admin::plugins: about' %}</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
{% for divId, configurationTabServiceId in plugin.configurationTabServiceIds %}
<div role="tabpanel" class="tab-pane fade" id="{{ divId }}"></div>
{% endfor %}
<div role="tabpanel" class="tab-pane fade in active" id="about">
<ul>
<li>{{ 'admin::plugins: name'|trans }}{{ plugin.name }}</li>
<li>{{ 'admin::plugins: version'|trans }}{{ plugin.version }}</li>
</ul>
</div>
</div>
</div>
<script type="text/javascript">
var contentsDownloaded = {};
var remoteContent = function(url) {
return $.get(url);
};
var tabs = $('#configurationTabs a[data-toggle="tab"]');
tabs.on('show', function (e) {
if (e.target.hash != '#about' && contentsDownloaded[e.target.hash] === undefined) {
$(e.target.hash).empty().html('<img src="/skins/icons/main-loader.gif" alt="loading"/>');
}
});
tabs.on('shown', function (e) {
if (e.target.hash != '#about' && contentsDownloaded[e.target.hash] === undefined) {
var targetDiv = $(e.target.hash);
remoteContent($(e.target).attr('data-url')).then(function(response) {
targetDiv.empty().html(response);
contentsDownloaded[e.target.hash] = true;
}, function(error) {
console.log(error);
targetDiv.empty().html('<i class="icon-fire">{% trans 'admin::plugins: retrieveConfigurationError' %}</i>');
});
}
});
</script>
{% endblock %}