New installer

This commit is contained in:
Romain Neutron
2013-04-19 17:59:27 +02:00
parent ec5a4f730b
commit 3b5be74d99
19 changed files with 392 additions and 583 deletions

View File

@@ -40,6 +40,8 @@ rewrite ^/prod/export/.*$ /index.php last;
rewrite ^/prod/record/preview/.*$ /index.php last;
rewrite ^/prod/notifications/.*$ /index.php last;
rewrite ^/prod/share/.*$ /index.php last;
rewrite ^/setup/.*$ /index.php last;
rewrite ^/setup.*$ /index.php last;
rewrite ^/user/preferences/.*$ /index.php last;
rewrite ^/user/notifications/.*$ /index.php last;
@@ -55,6 +57,3 @@ rewrite ^/client/baskets.*$ /index.php last;
rewrite ^/api/v1/.*$ /api/v1/index.php last;
rewrite ^/api/oauthv2/.*$ /api/oauthv2/index.php last;
rewrite ^/api/.*$ /api/index.php last;
rewrite ^/setup/.*$ /setup/installer.php last;

View File

@@ -65,6 +65,7 @@ use Alchemy\Phrasea\Controller\Root\Developers;
use Alchemy\Phrasea\Controller\Root\Login;
use Alchemy\Phrasea\Controller\Root\RSSFeeds;
use Alchemy\Phrasea\Controller\Root\Session;
use Alchemy\Phrasea\Controller\Setup as SetupController;
use Alchemy\Phrasea\Controller\Thesaurus\Thesaurus;
use Alchemy\Phrasea\Controller\Thesaurus\Xmlhttp as ThesaurusXMLHttp;
use Alchemy\Phrasea\Controller\Utils\ConnectionTest;
@@ -79,6 +80,7 @@ use Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider;
use Alchemy\Phrasea\Core\Provider\ConfigurationTesterServiceProvider;
use Alchemy\Phrasea\Core\Provider\FtpServiceProvider;
use Alchemy\Phrasea\Core\Provider\GeonamesServiceProvider;
use Alchemy\Phrasea\Core\Provider\InstallerServiceProvider;
use Alchemy\Phrasea\Core\Provider\NotificationDelivererServiceProvider;
use Alchemy\Phrasea\Core\Provider\ORMServiceProvider;
use Alchemy\Phrasea\Core\Provider\PhraseanetServiceProvider;
@@ -217,6 +219,7 @@ class Application extends SilexApplication
$this->register(new MP4BoxServiceProvider());
$this->register(new NotificationDelivererServiceProvider());
$this->register(new ORMServiceProvider());
$this->register(new InstallerServiceProvider());
$this->register(new PhraseanetServiceProvider());
$this->register(new PhraseaVersionServiceProvider());
$this->register(new PhraseaLocaleServiceProvider());
@@ -593,6 +596,10 @@ class Application extends SilexApplication
return new Response($buffer, 200, array('Content-Type' => 'text/plain'));
})->bind('robots');
$this->mount('/setup/test', new PathFileTest());
$this->mount('/setup/connection_test', new ConnectionTest());
$this->mount('/setup', new SetupController());
$this->mount('/feeds/', new RSSFeeds());
$this->mount('/account/', new Account());
$this->mount('/login/', new Login());

View File

@@ -21,8 +21,14 @@ return call_user_func(function($environment = null) {
$app = new PhraseaApplication($environment);
$app->before(function () use ($app) {
$app['firewall']->requireSetup();
$app->before(function (Request $request) use ($app) {
if (0 === strpos($request->getPathInfo(), '/setup')) {
if (!$app['phraseanet.configuration-tester']->isBlank()) {
return $app->redirect('/login/');
}
} else {
$app['firewall']->requireSetup();
}
});
$app->before(function(Request $request) use ($app) {

View File

@@ -1,57 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Controller\Setup\Installer;
use Alchemy\Phrasea\Controller\Utils\ConnectionTest;
use Alchemy\Phrasea\Controller\Utils\PathFileTest;
use Silex\Application as SilexApplication;
use Symfony\Component\HttpFoundation\Response;
return call_user_func(function() {
$app = new SilexApplication();
$app['debug'] = true;
$app['twig'] = $app->share(function (SilexApplication $app) {
$ld_path = array(__DIR__ . '/../../../../templates/web');
$loader = new \Twig_Loader_Filesystem($ld_path);
$twig = new \Twig_Environment($loader);
$twig->addExtension(new \Twig_Extensions_Extension_I18n());
return $twig;
});
$app->get('/', function(SilexApplication $app) {
if (!$app['phraseanet.configuration-tester']->isBlank()) {
return $app->redirect('/login/');
}
return $app->redirect('/setup/installer/');
});
$app->mount('/installer/', new Installer());
$app->mount('/test', new PathFileTest());
$app->mount('/connection_test', new ConnectionTest());
$app->error(function($e) use ($app) {
if ($e instanceof \Exception_Setup_PhraseaAlreadyInstalled) {
return $app->redirect('/login/');
}
return new Response('Internal Server Error', 500, array('X-Status-Code' => 500));
});
return $app;
});

View File

@@ -12,12 +12,8 @@
namespace Alchemy\Phrasea\Command\Setup;
use Alchemy\Phrasea\Command\Command;
use Alchemy\Phrasea\Setup\Installer;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\ExecutableFinder;
use Symfony\Component\Console\Helper\DialogHelper;
use Alchemy\Phrasea\Setup\Requirements\BinariesRequirements;
use Alchemy\Phrasea\Setup\Requirements\FilesystemRequirements;
use Alchemy\Phrasea\Setup\Requirements\LocalesRequirements;

View File

@@ -9,51 +9,50 @@
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Controller\Setup;
namespace Alchemy\Phrasea\Controller;
use Silex\Application;
use Alchemy\Phrasea\Application;
use Silex\ControllerProviderInterface;
use Silex\Application as SilexApplication;
use Symfony\Component\HttpFoundation\Request;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Installer implements ControllerProviderInterface
{
public function connect(Application $app)
class Setup implements ControllerProviderInterface
{
public function connect(SilexApplication $app)
{
$controllers = $app['controllers_factory'];
$controllers->get('/', $this->call('rootInstaller'));
$controllers->get('/', function(Application $app) {
return $app->redirect('/setup/installer/');
});
$controllers->get('/step2/', $this->call('getInstallForm'));
$controllers->get('/installer/', $this->call('rootInstaller'))
->bind('install_root');
$controllers->post('/install/', $this->call('doInstall'));
$controllers->get('/installer/step2/', $this->call('getInstallForm'))
->bind('install_step2');
$controllers->post('/installer/install/', $this->call('doInstall'));
return $controllers;
}
public function rootInstaller(Application $app, Request $request)
{
// $php_constraint = \setup::check_php_version();
// $writability_constraints = \setup::check_writability(new \Setup_Registry());
// $extension_constraints = \setup::check_php_extension();
// $opcode_constraints = \setup::check_cache_opcode();
// $php_conf_constraints = \setup::check_php_configuration();
// $locales_constraints = \setup::check_system_locales($app);
//
// $constraints_coll = array(
// 'php_constraint' => $php_constraint
// , 'writability_constraints' => $writability_constraints
// , 'extension_constraints' => $extension_constraints
// , 'opcode_constraints' => $opcode_constraints
// , 'php_conf_constraints' => $php_conf_constraints
// , 'locales_constraints' => $locales_constraints
// );
$constraints_coll = array(
$requirementsCollection = $this->getRequirementsCollection();
return $app['twig']->render('/setup/index.html.twig', array(
'locale' => $app['locale'],
'available_locales' => \Alchemy\Phrasea\Application::getAvailableLanguages(),
'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/',
'requirementsCollection' => $requirementsCollection,
));
}
private function getRequirementsCollection()
{
return array(
new \Alchemy\Phrasea\Setup\Requirements\BinariesRequirements(),
new \Alchemy\Phrasea\Setup\Requirements\FilesystemRequirements(),
new \Alchemy\Phrasea\Setup\Requirements\LocalesRequirements(),
@@ -61,33 +60,6 @@ class Installer implements ControllerProviderInterface
new \Alchemy\Phrasea\Setup\Requirements\PhraseaRequirements(),
new \Alchemy\Phrasea\Setup\Requirements\SystemRequirements(),
);
// $redirect = true;
// foreach ($constraints_coll as $key => $constraints) {
// $unset = true;
// foreach ($constraints as $constraint) {
// if (!$constraint->is_ok() && $constraint->is_blocker())
// $redirect = $unset = false;
// }
// if ($unset === true) {
// unset($constraints_coll[$key]);
// }
// }
// if ($redirect) {
// return $app->redirect('/setup/installer/step2/');
// }
// $app['twig.loader.filesystem']->setPaths(array(
// __DIR__ . '/../../../../../templates/web'
// ));
return $app['twig']->render('/setup/index.html.twig', array(
'locale' => $app['locale'],
'available_locales' => $app->getAvailableLanguages(),
'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/',
'constraints' => $constraints_coll,
));
}
public function getInstallForm(Application $app, Request $request)
@@ -96,27 +68,12 @@ class Installer implements ControllerProviderInterface
$warnings = array();
$php_constraint = \setup::check_php_version();
$writability_constraints = \setup::check_writability(new \Setup_Registry());
$extension_constraints = \setup::check_php_extension();
$opcode_constraints = \setup::check_cache_opcode();
$php_conf_constraints = \setup::check_php_configuration();
$locales_constraints = \setup::check_system_locales($app);
$requirementsCollection = $this->getRequirementsCollection();
$constraints_coll = array(
'php_constraint' => $php_constraint
, 'writability_constraints' => $writability_constraints
, 'extension_constraints' => $extension_constraints
, 'opcode_constraints' => $opcode_constraints
, 'php_conf_constraints' => $php_conf_constraints
, 'locales_constraints' => $locales_constraints
);
foreach ($constraints_coll as $key => $constraints) {
$unset = true;
foreach ($constraints as $constraint) {
if (!$constraint->is_ok() && !$constraint->is_blocker()) {
$warnings[] = $constraint->get_message();
foreach($requirementsCollection as $requirements) {
foreach($requirements->getRequirements() as $requirement) {
if (!$requirement->isFulfilled() && !$requirement->isOptional()) {
$warnings[] = $requirement->getTestMessage();
}
}
}
@@ -129,7 +86,7 @@ class Installer implements ControllerProviderInterface
'/setup/step2.html.twig'
, array(
'locale' => $app['locale']
, 'available_locales' => $app->getAvailableLanguages()
, 'available_locales' => Application::getAvailableLanguages()
, 'available_templates' => array('en', 'fr')
, 'version_number' => $app['phraseanet.version']->getNumber()
, 'version_name' => $app['phraseanet.version']->getName()
@@ -144,6 +101,7 @@ class Installer implements ControllerProviderInterface
public function doInstall(Application $app, Request $request)
{
set_time_limit(360);
\phrasea::use_i18n($app['locale']);
$servername = $request->getScheme() . '://' . $request->getHttpHost() . '/';
@@ -179,33 +137,36 @@ class Installer implements ControllerProviderInterface
$dataPath = $request->request->get('datapath_noweb');
try {
$installer = new \Alchemy\Phrasea\Setup\Installer($app, $email, $password, $abConn, $servername, $dataPath, $dbConn, $template);
$installer = $app['phraseanet.installer'];
$installer->setPhraseaIndexerPath($request->request->get('binary_phraseanet_indexer'));
$binaryData = array();
foreach (array(
'php_binary' => $request->request->get('binary_php'),
'convert_binary' => $request->request->get('binary_convert'),
'composite_binary' => $request->request->get('binary_composite'),
'swf_extract_binary' => $request->request->get('binary_swfextract'),
'pdf2swf_binary' => $request->request->get('binary_pdf2swf'),
'swf_render_binary' => $request->request->get('binary_swfrender'),
'unoconv_binary' => $request->request->get('binary_unoconv'),
'ffmpeg_binary' => $request->request->get('binary_ffmpeg'),
'mp4box_binary' => $request->request->get('binary_MP4Box'),
'pdftotext_binary' => $request->request->get('binary_xpdf'),
'php_binary' => $request->request->get('binary_php'),
'convert_binary' => $request->request->get('binary_convert'),
'composite_binary' => $request->request->get('binary_composite'),
'swf_extract_binary' => $request->request->get('binary_swfextract'),
'pdf2swf_binary' => $request->request->get('binary_pdf2swf'),
'swf_render_binary' => $request->request->get('binary_swfrender'),
'unoconv_binary' => $request->request->get('binary_unoconv'),
'ffmpeg_binary' => $request->request->get('binary_ffmpeg'),
'mp4box_binary' => $request->request->get('binary_MP4Box'),
'pdftotext_binary' => $request->request->get('binary_xpdf'),
) as $key => $path) {
$installer->addBinaryData($key, $path);
$binaryData[$key] = $path;
}
$installer->install();
$user = $installer->install($email, $password, $abConn, $servername, $dataPath, $dbConn, $template, $binaryData);
$app->openAccount(new \Session_Authentication_None($user));
//exit;
$redirection = '/admin/?section=taskmanager&notice=install_success';
return $app->redirect($redirection);
} catch (\Exception $e) {
}
var_dump($e->getMessage(), $e->getFile(), $e->getLine());
return $app->redirect('/setup/installer/step2/?error=' . sprintf(_('an error occured : %s'), $e->getMessage()));
}

View File

@@ -0,0 +1,30 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Provider;
use Silex\Application;
use Silex\ServiceProviderInterface;
use Alchemy\Phrasea\Setup\Installer;
class InstallerServiceProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
$app['phraseanet.installer'] = $app->share(function (Application $app) {
return new Installer($app);
});
}
public function boot(Application $app)
{
}
}

View File

@@ -1,5 +1,14 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Provider;
use Silex\Application;
@@ -54,14 +63,17 @@ class PhraseaLocaleServiceProvider implements ServiceProviderInterface
);
$this->app['locale'] = $this->locale = $this->app->share(function(Application $app) use ($event) {
$event->getRequest()->setDefaultLocale(
$app['phraseanet.registry']->get('GV_default_lng', 'en_GB')
);
$event->getRequest()->setLocale(
$app['phraseanet.registry']->get('GV_default_lng', 'en_GB')
);
$languages = $app->getAvailableLanguages();
if (isset($app['phraseanet.registry'])) {
$event->getRequest()->setDefaultLocale(
$app['phraseanet.registry']->get('GV_default_lng', 'en_GB')
);
$event->getRequest()->setLocale(
$app['phraseanet.registry']->get('GV_default_lng', 'en_GB')
);
}
$languages = \Alchemy\Phrasea\Application::getAvailableLanguages();
if ($event->getRequest()->cookies->has('locale')
&& isset($languages[$event->getRequest()->cookies->get('locale')])) {
$event->getRequest()->setLocale($event->getRequest()->cookies->get('locale'));

View File

@@ -16,52 +16,33 @@ use Doctrine\ORM\Tools\SchemaTool;
class Installer
{
private $email;
private $password;
private $abConn;
private $dbConn;
private $template;
private $app;
private $phraseaIndexer;
private $serverName;
private $dataPath;
private $binaryData = array();
public function __construct(Application $app, $email, $password, \connection_interface $abConn, $serverName, $dataPath, \connection_interface $dbConn = null, $template = null)
public function __construct(Application $app)
{
$this->app = $app;
$this->email = $email;
$this->password = $password;
$this->abConn = $abConn;
$this->dbConn = $dbConn;
$this->template = $template;
$this->serverName = $serverName;
$this->dataPath = $dataPath;
}
public function addBinaryData($key, $path)
public function install($email, $password, \connection_interface $abConn, $serverName, $dataPath, \connection_interface $dbConn = null, $template = null, array $binaryData = array())
{
if ($path) {
$this->binaryData[$key] = $path;
}
}
public function install()
{
$this->rollbackInstall();
$this->rollbackInstall($abConn, $dbConn);
try {
$this->createConfigFile();
$this->createConfigFile($abConn, $serverName, $binaryData);
$this->createAB();
$this->populateRegistryData();
$this->createUser();
if ($this->dbConn) {
$this->createDB();
$this->populateRegistryData($serverName, $dataPath, $binaryData);
$user = $this->createUser($email, $password);
if (null !== $dbConn) {
$this->createDB($dbConn, $template);
}
} catch (\Exception $e) {
$this->rollbackInstall();
$this->rollbackInstall($abConn, $dbConn);
throw $e;
}
return $user;
}
public function setPhraseaIndexerPath($path)
@@ -69,13 +50,13 @@ class Installer
$this->phraseaIndexer = $path;
}
private function populateRegistryData()
private function populateRegistryData($serverName, $dataPath, $binaryData)
{
$this->app['phraseanet.registry']->set('GV_base_datapath_noweb', $this->dataPath, \registry::TYPE_STRING);
$this->app['phraseanet.registry']->set('GV_ServerName', $this->serverName, \registry::TYPE_STRING);
$this->app['phraseanet.registry']->set('GV_base_datapath_noweb', $dataPath, \registry::TYPE_STRING);
$this->app['phraseanet.registry']->set('GV_ServerName', $serverName, \registry::TYPE_STRING);
foreach ($this->binaryData as $key => $value) {
foreach ($binaryData as $key => $value) {
$this->app['phraseanet.registry']->set($key, $value, \registry::TYPE_STRING);
}
@@ -92,10 +73,10 @@ class Installer
}
}
private function createDB()
private function createDB(\connection_interface $dbConn = null, $template)
{
$template = new \SplFileInfo(__DIR__ . '/../../../conf.d/data_templates/' . $this->template . '-simple.xml');
$databox = \databox::create($this->app, $this->dbConn, $template, $this->app['phraseanet.registry']);
$template = new \SplFileInfo(__DIR__ . '/../../../conf.d/data_templates/' . $template . '-simple.xml');
$databox = \databox::create($this->app, $dbConn, $template, $this->app['phraseanet.registry']);
$this->app['phraseanet.user']->ACL()
->give_access_to_sbas(array($databox->get_sbas_id()))
->update_rights_to_sbas(
@@ -145,14 +126,16 @@ class Installer
}
}
private function createUser()
private function createUser($email, $password)
{
$user = \User_Adapter::create($this->app, $this->email, $this->password, $this->email, true);
$user = \User_Adapter::create($this->app, $email, $password, $email, true);
$this->app['session']->set('usr_id', $user->get_id());
return $user;
}
private function rollbackInstall()
private function rollbackInstall(\connection_interface $abConn, \connection_interface $dbConn = null)
{
$structure = simplexml_load_file(__DIR__ . "/../../../conf.d/bases_structure.xml");
@@ -166,18 +149,18 @@ class Installer
foreach ($appbox->tables->table as $table) {
try {
$sql = 'DROP TABLE `' . $table['name'] . '`';
$stmt = $this->abConn->prepare($sql);
$stmt = $abConn->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
} catch (\PDOException $e) {
}
}
if ($this->dbConn) {
if (null !== $dbConn) {
foreach ($databox->tables->table as $table) {
try {
$sql = 'DROP TABLE `' . $table['name'] . '`';
$stmt = $this->dbConn->prepare($sql);
$stmt = $dbConn->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
} catch (\PDOException $e) {
@@ -208,13 +191,13 @@ class Installer
$this->app['phraseanet.registry'] = new \registry($this->app);
}
private function createConfigFile()
private function createConfigFile($abConn, $serverName, $binaryData)
{
$this->app['phraseanet.configuration']->initialize();
$connexionINI = array();
foreach ($this->abConn->get_credentials() as $key => $value) {
foreach ($abConn->get_credentials() as $key => $value) {
$key = $key == 'hostname' ? 'host' : $key;
$connexionINI[$key] = (string) $value;
}
@@ -222,8 +205,6 @@ class Installer
$connexionINI['driver'] = 'pdo_mysql';
$connexionINI['charset'] = 'UTF8';
$serverName = $this->serverName;
$connexion = array(
'main_connexion' => $connexionINI,
'test_connexion' => array(
@@ -267,6 +248,6 @@ class Installer
}
$this->app['phraseanet.configuration']->setConfigurations($arrayConf, $arrayConf['environment']);
$this->app['phraseanet.configuration']->setBinaries(array('binaries' => $this->binaryData));
$this->app['phraseanet.configuration']->setBinaries(array('binaries' => $binaryData));
}
}

View File

@@ -14,65 +14,85 @@
{% block content %}
<div class="steps" style="min-height:450px;">
<h2>
INSTALL
</h2>
<p>
You MUST resolve these problems to continue
</p>
<table style="width:100%;">
<tr>
<td>
{% if php_constraints is defined %}
<h2>PHP Version</h2>
<ul class="setup">
{%for constraint in php_constraints %}
{{ _self.constraint_format(constraint) }}
{% endfor %}
</ul>
{% endif %}
{% if writability_constraints is defined %}
<h2>Filesystem configuration</h2>
<ul class="setup">
{%for constraint in writability_constraints %}
{{ _self.constraint_format(constraint) }}
{% endfor %}
</ul>
{% endif %}
{% if extension_constraints is defined %}
<h3>PHP extensions</h3>
<ul class="setup">
{%for constraint in extension_constraints %}
{{ _self.constraint_format(constraint) }}
{% endfor %}
</ul>
{% endif %}
</td>
<td>
{% if opcode_constraints is defined %}
<h2>PHP Cache System</h2>
<ul class="setup">
{%for constraint in opcode_constraints %}
{{ _self.constraint_format(constraint) }}
{% endfor %}
</ul>
{% endif %}
{% if php_conf_constraints is defined %}
<h2>PHP configuration</h2>
<ul class="setup">
{%for constraint in php_conf_constraints %}
{{ _self.constraint_format(constraint) }}
{% endfor %}
</ul>
{% endif %}
{% if locales_constraints is defined %}
<h2>Locales Support</h2>
<ul class="setup">
{%for constraint in locales_constraints %}
{{ _self.constraint_format(constraint) }}
{% endfor %}
</ul>
{% endif %}
<div style="height:400px;overflow:auto;">
<h2>
INSTALL
</h2>
<p>
Please have a look a this recommendations
</p>
<table>
{% for requirements in requirementsCollection %}
<tr>
<td colspan="2">
<h3> {{ requirements.getName() }} requirements </h3>
</td>
</tr>
{% for requirement in requirements.getRequirements() %}
<tr>
<td>
{% if requirement.isFulfilled() %}
<span style="color:green">OK</span>
{% elseif requirement.isOptional() %}
<span style="color:orange">WARNING</span>
{% else %}
<span style="color:red">ERROR</span>
{% endif %}
</td>
<td>
{{ requirement.getTestMessage }}
{% if not requirement.isFulfilled() %}
{{ requirement.getHelpText() }}
{% endif %}
</td>
</tr>
{% endfor %}
<tr>
<td colspan="2">
<h3> {{ requirements.getName() }} recommendations </h3>
</td>
</tr>
{% for requirement in requirements.getRecommendations() %}
<tr>
<td>
{% if requirement.isFulfilled() %}
<span style="color:green">OK</span>
{% elseif requirement.isOptional() %}
<span style="color:orange">WARNING</span>
{% else %}
<span style="color:red">ERROR</span>
{% endif %}
</td>
<td>
{{ requirement.getTestMessage }}
{% if not requirement.isFulfilled() %}
{{ requirement.getHelpText() }}
{% endif %}
</td>
</tr>
{% endfor %}
{% endfor %}
</table>
</div>
<div>
<table style="width:100%;">
<tr>
<td style="text-align:right;">
<a href="{{ path('install_step2') }}">Continue Install</a>
</td>
</tr>
</table>
</div>
</div>
</td>
</tr>
</table>

View File

@@ -334,6 +334,13 @@
</td>
</tr>
{% endfor %}
{% if warnings is not empty %}
<tr>
<td>
<a href="{{ path('install_root') }}">{% trans 'Review system configuration' %}</a>
</td>
</tr>
{% endif %}
</table>
</td>
</tr>

View File

@@ -1,199 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Application;
class ApplicationSetupTest extends \PhraseanetWebTestCaseAbstract
{
protected $client;
protected $root;
/**
*
* @var \appbox
*/
protected $appbox;
/**
*
* @var \connection_pdo
*/
protected $connection;
protected $registry = array();
public function setUp()
{
$this->markTestSkipped('To review');
parent::setUp();
$this->root = __DIR__ . '/../../../../../';
$this->temporaryUnInstall();
$this->connection = self::$DI['app']['phraseanet.appbox']->get_connection();
$this->registry = array();
$params = array(
'GV_base_datapath_noweb',
'GV_ServerName',
'php_binary',
'convert_binary',
'composite_binary',
'swf_extract_binary',
'pdf2swf_binary',
'swf_render_binary',
'unoconv_binary',
'ffmpeg_binary',
'mp4box_binary',
'pdftotext_binary',
);
foreach ($params as $param) {
$this->registry[$param] = self::$DI['app']['phraseanet.registry']->get($param);
}
}
public function tearDown()
{
$this->temporaryReInstall();
self::$DI['app']['phraseanet.appbox']->set_connection($this->connection);
foreach ($this->registry as $param => $value) {
self::$DI['app']['phraseanet.registry']->set($param, $value, \registry::TYPE_STRING);
}
parent::tearDown();
}
/**
* @covers Alchemy\Phrasea\Controller\Setup\Installer::connect
*/
public function testRouteSlash()
{
$crawler = self::$DI['client']->request('GET', '/');
$response = self::$DI['client']->getResponse();
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals('/setup/installer/', $response->headers->get('location'));
$this->temporaryReInstall();
$crawler = self::$DI['client']->request('GET', '/');
$response = self::$DI['client']->getResponse();
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals('/login/', $response->headers->get('location'));
}
/**
* @covers Alchemy\Phrasea\Controller\Setup\Installer::connect
*/
public function testRouteSetupInstaller()
{
$crawler = self::$DI['client']->request('GET', '/installer/');
$response = self::$DI['client']->getResponse();
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals('/setup/installer/step2/', $response->headers->get('location'));
}
/**
* @covers Alchemy\Phrasea\Controller\Setup\Installer::connect
*/
public function testRouteSetupInstallerStep2()
{
$crawler = self::$DI['client']->request('GET', '/installer/step2/');
$response = self::$DI['client']->getResponse();
$this->assertEquals(200, $response->getStatusCode());
}
/**
* @covers Alchemy\Phrasea\Controller\Setup\Installer::connect
*/
public function testRouteSetupInstallerInstall()
{
$settings = Symfony\Component\Yaml\Yaml::parse(file_get_contents($this->root . 'hudson/InstallDBs.yml'));
$settings = $settings['database'];
$host = isset($settings['host']) ? $settings['host'] : 'localhost';
$port = isset($settings['port']) ? $settings['port'] : '3306';
$MySQLuser = isset($settings['user']) ? $settings['user'] : 'root';
$MySQLpassword = isset($settings['password']) ? $settings['password'] : '';
$abName = isset($settings['applicationBox']) ? $settings['applicationBox'] : null;
$dbName = isset($settings['dataBox']) ? $settings['dataBox'] : null;
$connection = new connection_pdo('unitTestsAB', $host, $port, $MySQLuser, $MySQLpassword, $abName, array(), false);
self::$DI['app']['phraseanet.appbox']->set_connection($connection);
$dataDir = sys_get_temp_dir() . '/datainstall/';
$params = array(
'email' => 'user@example.org',
'password' => 'prètty%%password',
'binary_xpdf' => '/path/to/xpdf',
'binary_mplayer' => '/path/to/mplayer',
'binary_MP4Box' => '/path/to/MP4Box',
'binary_ffmpeg' => '/path/to/ffmpeg',
'binary_unoconv' => '/path/to/unoconv',
'binary_swfrender' => '/path/to/swfrender',
'binary_pdf2swf' => '/path/to/pdf2swf',
'binary_swfextract' => '/path/to/swfextract',
'binary_exiftool' => '/path/to/exiftool',
'binary_composite' => '/path/to/composite',
'binary_convert' => '/path/to/convert',
'binary_php' => '/path/to/php',
'datapath_noweb' => $dataDir . 'noweb',
'ab_hostname' => $host,
'ab_port' => $port,
'ab_user' => $MySQLuser,
'ab_password' => $MySQLpassword,
'ab_name' => $abName,
'db_name' => $dbName,
'db_template' => 'en-simple',
'create_task' => array(),
'binary_phraseanet_indexer' => '/path/to/phraseanet_indexer',
);
$crawler = self::$DI['client']->request('POST', '/installer/install/', $params);
$response = self::$DI['client']->getResponse();
$this->assertEquals(302, $response->getStatusCode());
$this->assertTrue(false === strpos($response->headers->get('location'), '/setup/installer/'));
}
public function temporaryUnInstall()
{
if (file_exists($this->root . 'config/config.yml')) {
rename($this->root . 'config/config.yml', $this->root . 'config/config.yml.unitTests');
}
if (file_exists($this->root . 'config/services.yml')) {
rename($this->root . 'config/services.yml', $this->root . 'config/services.yml.unitTests');
}
if (file_exists($this->root . 'config/connexions.yml')) {
rename($this->root . 'config/connexions.yml', $this->root . 'config/connexions.yml.unitTests');
}
}
public function temporaryReInstall()
{
if (file_exists($this->root . 'config/config.yml.unitTests')) {
if (file_exists($this->root . 'config/config.yml')) {
unlink($this->root . 'config/config.yml');
}
rename($this->root . 'config/config.yml.unitTests', $this->root . 'config/config.yml');
}
if (file_exists($this->root . 'config/services.yml.unitTests')) {
if (file_exists($this->root . 'config/services.yml')) {
unlink($this->root . 'config/services.yml');
}
rename($this->root . 'config/services.yml.unitTests', $this->root . 'config/services.yml');
}
if (file_exists($this->root . 'config/connexions.yml.unitTests')) {
if (file_exists($this->root . 'config/connexions.yml')) {
unlink($this->root . 'config/connexions.yml');
}
rename($this->root . 'config/connexions.yml.unitTests', $this->root . 'config/connexions.yml');
}
}
}

View File

@@ -1,28 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Controller\Setup;
use Alchemy\Phrasea\Application as PhraseaApplication;
use Alchemy\Phrasea\Controller\Setup\Installer;
use Alchemy\Phrasea\Controller\Utils\PathFileTest;
use Alchemy\Phrasea\Controller\Utils\ConnectionTest;
return call_user_func(function() {
$app = new PhraseaApplication('test');
$app['install'] = true;
$app->get('/', function() use ($app) {
return $app->redirect('/setup/installer/');
});
$app->mount('/installer/', new Installer());
$app->mount('/test', new PathFileTest());
$app->mount('/connection_test', new ConnectionTest());
$app->error(function($e) {
});
return $app;
});

View File

@@ -1,51 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Controller\Setup;
class InstallerTest extends \PhraseanetWebTestCaseAbstract
{
public function setUp()
{
parent::setUp();
$environment = 'test';
return self::$DI['app'] = require __DIR__ . '/FakeSetupApplication.inc';
}
/**
* Default route test
*/
public function testRouteSlash()
{
self::$DI['client']->request('GET', '/');
$response = self::$DI['client']->getResponse();
/* @var $response \Symfony\Component\HttpFoundation\Response */
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals('/setup/installer/', $response->headers->get('location'));
}
public function testRouteInstaller()
{
self::$DI['client']->request('GET', '/installer/');
$response = self::$DI['client']->getResponse();
/* @var $response \Symfony\Component\HttpFoundation\Response */
$this->assertEquals(302, $response->getStatusCode(), "test that response is a redirection " . self::$DI['client']->getResponse()->getContent());
$this->assertEquals('/setup/installer/step2/', $response->headers->get('location'));
}
public function testRouteInstallerStep2()
{
self::$DI['client']->request('GET', '/installer/step2/');
$response = self::$DI['client']->getResponse();
/* @var $response \Symfony\Component\HttpFoundation\Response */
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->isOk());
}
}

View File

@@ -0,0 +1,158 @@
<?php
namespace Alchemy\Tests\Phrasea\Controller;
use Symfony\Component\Yaml\Yaml;
class SetupTest extends \Silex\WebTestCase
{
protected $app;
public function createApplication()
{
return $this->app;
}
public function setUp()
{
// set test environment
$environment = 'test';
$this->app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Root.php';
$this->app['phraseanet.configuration-tester'] = $this->getMockBuilder('Alchemy\Phrasea\Setup\ConfigurationTester')
->disableOriginalConstructor()
->getMock();
}
public function testRouteSlash()
{
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isBlank')
->will($this->returnValue(true));
$client = $this->createClient();
$crawler = $client->request('GET', '/setup/');
$response = $client->getResponse();
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals('/setup/installer/', $response->headers->get('location'));
}
public function testRouteSlashWhenInstalled()
{
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isBlank')
->will($this->returnValue(false));
$client = $this->createClient();
$crawler = $client->request('GET', '/setup/');
$response = $client->getResponse();
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals('/login/', $response->headers->get('location'));
}
public function testRouteSetupInstaller()
{
$client = $this->createClient();
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isBlank')
->will($this->returnValue(true));
$crawler = $client->request('GET', '/setup/installer/');
$response = $client->getResponse();
$this->assertEquals(200, $response->getStatusCode());
}
public function testRouteSetupInstallerStep2()
{
$client = $this->createClient();
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isBlank')
->will($this->returnValue(true));
$crawler = $client->request('GET', '/setup/installer/step2/');
$response = $client->getResponse();
$this->assertEquals(200, $response->getStatusCode());
}
public function testRouteSetupInstallerInstall()
{
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isBlank')
->will($this->returnValue(true));
$this->app['phraseanet.installer'] = $this->getMockBuilder('Alchemy\Phrasea\Setup\Installer')
->disableOriginalConstructor()
->getMock();
$user = $this->getMockBuilder('User_Adapter')
->disableOriginalConstructor()
->getMock();
$user->expects($this->exactly(2))
->method('get_id')
->will($this->returnValue(4));
$acl = $this->getMockBuilder('ACL')
->disableOriginalConstructor()
->getMock();
$acl->expects($this->once())
->method('get_granted_sbas')
->will($this->returnValue(array()));
$user->expects($this->once())
->method('ACL')
->will($this->returnValue($acl));
$this->app['phraseanet.installer']->expects($this->once())
->method('install')
->will($this->returnValue($user));
$client = $this->createClient();
$settings = Yaml::parse(file_get_contents(__DIR__ . '/../../../../../hudson/InstallDBs.yml'));
$settings = $settings['database'];
$host = isset($settings['host']) ? $settings['host'] : 'localhost';
$port = isset($settings['port']) ? $settings['port'] : '3306';
$MySQLuser = isset($settings['user']) ? $settings['user'] : 'root';
$MySQLpassword = isset($settings['password']) ? $settings['password'] : '';
$abName = isset($settings['applicationBox']) ? $settings['applicationBox'] : null;
$dbName = isset($settings['dataBox']) ? $settings['dataBox'] : null;
$dataDir = sys_get_temp_dir() . '/datainstall/';
$params = array(
'email' => 'user@example.org',
'password' => 'prètty%%password',
'binary_xpdf' => '/path/to/xpdf',
'binary_mplayer' => '/path/to/mplayer',
'binary_MP4Box' => '/path/to/MP4Box',
'binary_ffmpeg' => '/path/to/ffmpeg',
'binary_unoconv' => '/path/to/unoconv',
'binary_swfrender' => '/path/to/swfrender',
'binary_pdf2swf' => '/path/to/pdf2swf',
'binary_swfextract' => '/path/to/swfextract',
'binary_exiftool' => '/path/to/exiftool',
'binary_composite' => '/path/to/composite',
'binary_convert' => '/path/to/convert',
'binary_php' => '/path/to/php',
'datapath_noweb' => $dataDir . 'noweb',
'ab_hostname' => $host,
'ab_port' => $port,
'ab_user' => $MySQLuser,
'ab_password' => $MySQLpassword,
'ab_name' => $abName,
'db_name' => $dbName,
'db_template' => 'en-simple',
'create_task' => array(),
'binary_phraseanet_indexer' => '/path/to/phraseanet_indexer',
);
$crawler = $client->request('POST', '/setup/installer/install/', $params);
$response = $client->getResponse();
$this->assertEquals(302, $response->getStatusCode());
$this->assertTrue(false === strpos($response->headers->get('location'), '/setup/installer/'));
}
}

View File

@@ -52,8 +52,8 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
$template = 'en';
$dataPath = __DIR__ . '/../../../../../datas/';
$installer = new Installer($app, 'admin@example.com', 'sdfsdsd', $abConn, 'http://local.phrasea.test.installer/', $dataPath, $dbConn, $template);
$installer->install();
$installer = new Installer($app);
$installer->install('admin@example.com', 'sdfsdsd', $abConn, 'http://local.phrasea.test.installer/', $dataPath, $dbConn, $template);
\User_Adapter::unsetInstances();

View File

@@ -60,9 +60,6 @@
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/.*$ /api/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^setup/.*$ /setup/installer.php [L]
RewriteRule ^admin/test-rewrite$ admin/adminFeedback.php?action=APACHE&test=success [L]
<IfModule mod_xsendfile.c>

View File

@@ -1,7 +0,0 @@
<html>
<head></head>
<body>
<div>french : Vous devez activer le mod_rewrite de votre serveur web</div>
<div>english : You must activate mod_rewrite on your web server</div>
</body>
</html>

View File

@@ -1,23 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @todo write tests
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
require_once __DIR__ . "/../../vendor/autoload.php";
$app = require __DIR__ . '/../../lib/Alchemy/Phrasea/Application/Setup.php';
$app->run();