mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
Merge pull request #2373 from falylala/PHRAS-1717-PORT_Install_show_available_documentary
PHRAS-1717- PORT_1296_Show all available structure for install CLI/Graphic mode
This commit is contained in:
0
cache/.gitkeep
vendored
0
cache/.gitkeep
vendored
@@ -176,6 +176,7 @@ class Install extends Command
|
|||||||
private function getDBConn(InputInterface $input, OutputInterface $output, Connection $abConn, DialogHelper $dialog)
|
private function getDBConn(InputInterface $input, OutputInterface $output, Connection $abConn, DialogHelper $dialog)
|
||||||
{
|
{
|
||||||
$dbConn = $template = $info = null;
|
$dbConn = $template = $info = null;
|
||||||
|
$templates = $this->container['phraseanet.structure-template']->getAvailable();
|
||||||
if (!$input->getOption('databox')) {
|
if (!$input->getOption('databox')) {
|
||||||
do {
|
do {
|
||||||
$retry = false;
|
$retry = false;
|
||||||
@@ -196,8 +197,9 @@ class Install extends Command
|
|||||||
$output->writeln("\n\t<info>Data-Box : Connection successful !</info>\n");
|
$output->writeln("\n\t<info>Data-Box : Connection successful !</info>\n");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$template = $dialog->ask($output, 'Choose a language template for metadata structure, available are fr (french) and en (english) (en) : ', 'en');
|
$template = $dialog->ask($output, "Choose a language template for metadata structure, available are {$templates->__toString()} : ", 'en');
|
||||||
} while (!in_array($template, ['en', 'fr']));
|
}
|
||||||
|
while (!in_array($template, array_keys($templates->getTemplates())));
|
||||||
|
|
||||||
$output->writeln("\n\tLanguage selected is <info>'$template'</info>\n");
|
$output->writeln("\n\tLanguage selected is <info>'$template'</info>\n");
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@@ -77,7 +77,7 @@ class SetupController extends Controller
|
|||||||
return $this->render('/setup/step2.html.twig', [
|
return $this->render('/setup/step2.html.twig', [
|
||||||
'locale' => $this->app['locale'],
|
'locale' => $this->app['locale'],
|
||||||
'available_locales' => Application::getAvailableLanguages(),
|
'available_locales' => Application::getAvailableLanguages(),
|
||||||
'available_templates' => ['en', 'fr'],
|
'available_templates' => $this->app['phraseanet.structure-template']->getAvailable()->getTemplates(),
|
||||||
'warnings' => $warnings,
|
'warnings' => $warnings,
|
||||||
'error' => $request->query->get('error'),
|
'error' => $request->query->get('error'),
|
||||||
'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/',
|
'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/',
|
||||||
|
93
lib/Alchemy/Phrasea/Core/Configuration/StructureTemplate.php
Normal file
93
lib/Alchemy/Phrasea/Core/Configuration/StructureTemplate.php
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2016 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
namespace Alchemy\Phrasea\Core\Configuration;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
/**
|
||||||
|
* Class StructureTemplate
|
||||||
|
* @package Alchemy\Phrasea\Core\Configuration
|
||||||
|
*/
|
||||||
|
class StructureTemplate
|
||||||
|
{
|
||||||
|
const TEMPLATE_EXTENSION = 'xml';
|
||||||
|
private $templates;
|
||||||
|
|
||||||
|
public function __construct(Application $app)
|
||||||
|
{
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
}
|
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Core\Provider;
|
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\AccessRestriction;
|
||||||
use Alchemy\Phrasea\Core\Configuration\Configuration;
|
use Alchemy\Phrasea\Core\Configuration\Configuration;
|
||||||
use Alchemy\Phrasea\Core\Configuration\DisplaySettingService;
|
use Alchemy\Phrasea\Core\Configuration\DisplaySettingService;
|
||||||
@@ -71,6 +73,10 @@ class ConfigurationServiceProvider implements ServiceProviderInterface
|
|||||||
$app['conf.restrictions'] = $app->share(function (SilexApplication $app) {
|
$app['conf.restrictions'] = $app->share(function (SilexApplication $app) {
|
||||||
return new AccessRestriction($app['conf'], $app->getApplicationBox(), $app['monolog']);
|
return new AccessRestriction($app['conf'], $app->getApplicationBox(), $app['monolog']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$app['phraseanet.structure-template'] = $app->share(function (Application $app) {
|
||||||
|
return new StructureTemplate($app);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -53,7 +53,7 @@ class Installer
|
|||||||
|
|
||||||
private function createDB(Connection $dbConn = null, $template, User $admin)
|
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);
|
$databox = \databox::create($this->app, $dbConn, $template);
|
||||||
|
|
||||||
$this->app->getAclForUser($admin)
|
$this->app->getAclForUser($admin)
|
||||||
|
@@ -738,8 +738,8 @@
|
|||||||
<td><label>{{ 'Modele de donnees' | trans }}</label></td>
|
<td><label>{{ 'Modele de donnees' | trans }}</label></td>
|
||||||
<td>
|
<td>
|
||||||
<select name="db_template" class="databox_creation_input">
|
<select name="db_template" class="databox_creation_input">
|
||||||
{% for template in available_templates %}
|
{% for key,template in available_templates %}
|
||||||
<option value="{{ template }}">{{ template }}</option>
|
<option value="{{ key }}">{{ template }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
Reference in New Issue
Block a user