diff --git a/cache/.gitkeep b/cache/.gitkeep
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/lib/Alchemy/Phrasea/Command/Setup/Install.php b/lib/Alchemy/Phrasea/Command/Setup/Install.php
index f5a7ccf817..071baf5bb2 100644
--- a/lib/Alchemy/Phrasea/Command/Setup/Install.php
+++ b/lib/Alchemy/Phrasea/Command/Setup/Install.php
@@ -176,6 +176,7 @@ class Install extends Command
private function getDBConn(InputInterface $input, OutputInterface $output, Connection $abConn, DialogHelper $dialog)
{
$dbConn = $template = $info = null;
+ $templates = $this->container['phraseanet.structure-template']->getAvailable();
if (!$input->getOption('databox')) {
do {
$retry = false;
@@ -196,8 +197,9 @@ class Install extends Command
$output->writeln("\n\tData-Box : Connection successful !\n");
do {
- $template = $dialog->ask($output, 'Choose a language template for metadata structure, available are fr (french) and en (english) (en) : ', 'en');
- } while (!in_array($template, ['en', 'fr']));
+ $template = $dialog->ask($output, "Choose a language template for metadata structure, available are {$templates->__toString()} : ", 'en');
+ }
+ while (!in_array($template, array_keys($templates->getTemplates())));
$output->writeln("\n\tLanguage selected is '$template'\n");
} catch (\Exception $e) {
diff --git a/lib/Alchemy/Phrasea/Controller/SetupController.php b/lib/Alchemy/Phrasea/Controller/SetupController.php
index b18dd7965b..36eaaae141 100644
--- a/lib/Alchemy/Phrasea/Controller/SetupController.php
+++ b/lib/Alchemy/Phrasea/Controller/SetupController.php
@@ -77,7 +77,7 @@ class SetupController extends Controller
return $this->render('/setup/step2.html.twig', [
'locale' => $this->app['locale'],
'available_locales' => Application::getAvailableLanguages(),
- 'available_templates' => ['en', 'fr'],
+ 'available_templates' => $this->app['phraseanet.structure-template']->getAvailable()->getTemplates(),
'warnings' => $warnings,
'error' => $request->query->get('error'),
'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/',
diff --git a/lib/Alchemy/Phrasea/Core/Configuration/StructureTemplate.php b/lib/Alchemy/Phrasea/Core/Configuration/StructureTemplate.php
new file mode 100644
index 0000000000..727cdd0bce
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Core/Configuration/StructureTemplate.php
@@ -0,0 +1,93 @@
+app = $app;
+ }
+ /**
+ * @return $this
+ * @throws \Exception
+ */
+ public function getAvailable()
+ {
+ $templateList = new \DirectoryIterator($this->app['root.path'] . '/lib/conf.d/data_templates');
+ if(empty($templateList)) throw new \Exception('No available structure template');
+ $templates = [];
+ $abbreviationLength = 2;
+ foreach ($templateList as $template)
+ {
+ if($template->isDot()
+ || !$template->isFile()
+ || $template->getExtension() !== self::TEMPLATE_EXTENSION) continue;
+ $name = $template->getFilename();
+ $abbreviation = strtolower(substr($name,0,$abbreviationLength));
+ if(array_key_exists($abbreviation,$templates) ){
+ $abbreviation = strtolower(substr($name,0,++$abbreviationLength));
+ }
+ $templates[$abbreviation] = $template->getBasename('.'.self::TEMPLATE_EXTENSION);
+ }
+ $this->templates = $templates;
+ return $this;
+ }
+ /**
+ * @return string
+ */
+ public function __toString()
+ {
+ if(!$this->templates){
+ return '';
+ }
+ $templateToString = '';
+ $cpt = 1;
+ $templateLength = count($this->templates);
+ foreach ($this->templates as $key => $value){
+ if (($templateLength - 1) == $cpt) {
+ $separator = ' and ';
+ }elseif(end($this->templates) == $value){
+ $separator = '';
+ }else{
+ $separator = ', ';
+ }
+ $templateToString .= $key.' ('.$value.')'. $separator;
+ $cpt++;
+ }
+ return $templateToString;
+ }
+ /**
+ * @param $template
+ * @return mixed
+ * @throws \Exception
+ */
+ public function getTemplateName($template = 'en'){
+ if(!array_key_exists($template,$this->templates)){
+ throw new \Exception('Not found template : '.$template);
+ }
+ return $this->templates[$template];
+ }
+ /**
+ * @return mixed
+ */
+ public function getTemplates()
+ {
+ return $this->templates;
+ }
+}
\ No newline at end of file
diff --git a/lib/Alchemy/Phrasea/Core/Provider/ConfigurationServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ConfigurationServiceProvider.php
index 55623e0081..c7cec0227e 100644
--- a/lib/Alchemy/Phrasea/Core/Provider/ConfigurationServiceProvider.php
+++ b/lib/Alchemy/Phrasea/Core/Provider/ConfigurationServiceProvider.php
@@ -11,6 +11,8 @@
namespace Alchemy\Phrasea\Core\Provider;
+use Alchemy\Phrasea\Application;
+use Alchemy\Phrasea\Core\Configuration\StructureTemplate;
use Alchemy\Phrasea\Core\Configuration\AccessRestriction;
use Alchemy\Phrasea\Core\Configuration\Configuration;
use Alchemy\Phrasea\Core\Configuration\DisplaySettingService;
@@ -71,6 +73,10 @@ class ConfigurationServiceProvider implements ServiceProviderInterface
$app['conf.restrictions'] = $app->share(function (SilexApplication $app) {
return new AccessRestriction($app['conf'], $app->getApplicationBox(), $app['monolog']);
});
+
+ $app['phraseanet.structure-template'] = $app->share(function (Application $app) {
+ return new StructureTemplate($app);
+ });
}
/**
diff --git a/lib/Alchemy/Phrasea/Setup/Installer.php b/lib/Alchemy/Phrasea/Setup/Installer.php
index 2868f79835..0700eb1907 100644
--- a/lib/Alchemy/Phrasea/Setup/Installer.php
+++ b/lib/Alchemy/Phrasea/Setup/Installer.php
@@ -53,7 +53,7 @@ class Installer
private function createDB(Connection $dbConn = null, $template, User $admin)
{
- $template = new \SplFileInfo(__DIR__ . '/../../../conf.d/data_templates/' . $template . '-simple.xml');
+ $template = new \SplFileInfo(__DIR__ . '/../../../conf.d/data_templates/' . $this->app['phraseanet.structure-template']->getAvailable()->getTemplateName($template) . '.xml');
$databox = \databox::create($this->app, $dbConn, $template);
$this->app->getAclForUser($admin)
diff --git a/templates/web/setup/step2.html.twig b/templates/web/setup/step2.html.twig
index 3984f7fd27..83f3329ef8 100644
--- a/templates/web/setup/step2.html.twig
+++ b/templates/web/setup/step2.html.twig
@@ -738,8 +738,8 @@
|
|