WIP : install wizard : step 1, 2, 3
This commit is contained in:
@@ -40,6 +40,8 @@
|
|||||||
</loops>
|
</loops>
|
||||||
|
|
||||||
<forms>
|
<forms>
|
||||||
|
<form name="thelia.install.step3" class="Thelia\Form\InstallStep3Form"/>
|
||||||
|
|
||||||
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
|
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
|
||||||
<form name="thelia.customer.modification" class="Thelia\Form\CustomerModification"/>
|
<form name="thelia.customer.modification" class="Thelia\Form\CustomerModification"/>
|
||||||
<form name="thelia.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
|
<form name="thelia.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
|
||||||
|
|||||||
@@ -5,27 +5,27 @@
|
|||||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||||
|
|
||||||
<route id="install.step1" path="/install" >
|
<route id="install.step1" path="/install" >
|
||||||
<default key="_controller">Thelia\Controller\Install\InstallController::index</default>
|
<default key="_controller">Thelia\Controller\Install\InstallController::indexAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="install.step2" path="/install/step/2" >
|
<route id="install.step2" path="/install/step/2" >
|
||||||
<default key="_controller">Thelia\Controller\Install\InstallController::checkPermission</default>
|
<default key="_controller">Thelia\Controller\Install\InstallController::checkPermissionAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="install.step3" path="/install/step/3" >
|
<route id="install.step3" path="/install/step/3" >
|
||||||
<default key="_controller">Thelia\Controller\Install\InstallController::databaseConnection</default>
|
<default key="_controller">Thelia\Controller\Install\InstallController::databaseConnectionAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="install.step4" path="/install/step/4" >
|
<route id="install.step4" path="/install/step/4" >
|
||||||
<default key="_controller">Thelia\Controller\Install\InstallController::databaseSelection</default>
|
<default key="_controller">Thelia\Controller\Install\InstallController::databaseSelectionAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="install.step5" path="/install/step/5" >
|
<route id="install.step5" path="/install/step/5" >
|
||||||
<default key="_controller">Thelia\Controller\Install\InstallController::generalInformation</default>
|
<default key="_controller">Thelia\Controller\Install\InstallController::generalInformationAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="install.step6" path="/install/thanks" >
|
<route id="install.step6" path="/install/thanks" >
|
||||||
<default key="_controller">Thelia\Controller\Install\InstallController::thanks</default>
|
<default key="_controller">Thelia\Controller\Install\InstallController::thanksAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
</routes>
|
</routes>
|
||||||
|
|||||||
@@ -22,7 +22,12 @@
|
|||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Controller\Install;
|
namespace Thelia\Controller\Install;
|
||||||
|
use Thelia\Form\Exception\FormValidationException;
|
||||||
|
use Thelia\Form\InstallStep3Form;
|
||||||
|
use Thelia\Install\CheckDatabaseConnection;
|
||||||
use Thelia\Install\CheckPermission;
|
use Thelia\Install\CheckPermission;
|
||||||
|
use Thelia\Install\Exception\AlreadyInstallException;
|
||||||
|
use Thelia\Install\Exception\InstallException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class InstallController
|
* Class InstallController
|
||||||
@@ -35,9 +40,14 @@ class InstallController extends BaseInstallController
|
|||||||
{
|
{
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
//$this->verifyStep(1);
|
$args = array();
|
||||||
|
try {
|
||||||
|
//$this->verifyStep(1); // @todo implement
|
||||||
|
$this->getSession()->set("step", 1);
|
||||||
|
} catch (AlreadyInstallException $e) {
|
||||||
|
$args['isAlreadyInstalled'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
$this->getSession()->set("step", 1);
|
|
||||||
|
|
||||||
return $this->render("index.html");
|
return $this->render("index.html");
|
||||||
}
|
}
|
||||||
@@ -49,29 +59,22 @@ class InstallController extends BaseInstallController
|
|||||||
*/
|
*/
|
||||||
public function checkPermissionAction()
|
public function checkPermissionAction()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
|
//$this->verifyStep(2); // @todo implement
|
||||||
|
$checkPermission = new CheckPermission(true, $this->getTranslator());
|
||||||
|
$args['isValid'] = $isValid = $checkPermission->exec();
|
||||||
|
$args['validationMessages'] = $checkPermission->getValidationMessages();
|
||||||
|
|
||||||
|
$this->getSession()->set("step", 2);
|
||||||
|
} catch (AlreadyInstallException $e) {
|
||||||
|
$args['isAlreadyInstalled'] = true;
|
||||||
|
}
|
||||||
$args = array();
|
$args = array();
|
||||||
var_dump('step2');
|
|
||||||
//$this->verifyStep(2);
|
|
||||||
|
|
||||||
$checkPermission = new CheckPermission(true, $this->getTranslator());
|
|
||||||
$args['isValid'] = $isValid = $checkPermission->exec();
|
|
||||||
$args['validationMessages'] = $checkPermission->getValidationMessages();
|
|
||||||
|
|
||||||
$this->getSession()->set("step", 2);
|
|
||||||
|
|
||||||
return $this->render("step-2.html", $args);
|
return $this->render("step-2.html", $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Database connexion tests
|
|
||||||
*
|
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
|
||||||
*/
|
|
||||||
public function databaseConnection()
|
|
||||||
{
|
|
||||||
var_dump('step 3 bis');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database connexion tests
|
* Database connexion tests
|
||||||
*
|
*
|
||||||
@@ -79,15 +82,95 @@ class InstallController extends BaseInstallController
|
|||||||
*/
|
*/
|
||||||
public function databaseConnectionAction()
|
public function databaseConnectionAction()
|
||||||
{
|
{
|
||||||
var_dump('step 3');
|
$args = array();
|
||||||
exit();
|
|
||||||
//$this->verifyStep(2);
|
|
||||||
|
|
||||||
//$permission = new CheckPermission();
|
try {
|
||||||
|
//$this->verifyStep(2); // @todo implement
|
||||||
|
|
||||||
$this->getSession()->set("step", 3);
|
if ($this->getRequest()->isMethod('POST')) {
|
||||||
|
// Create the form from the request
|
||||||
|
$step3Form = new InstallStep3Form($this->getRequest());
|
||||||
|
|
||||||
return $this->render("step-3.html");
|
$message = false;
|
||||||
|
try {
|
||||||
|
// Check the form against constraints violations
|
||||||
|
$form = $this->validateForm($step3Form, 'POST');
|
||||||
|
|
||||||
|
// Get the form field values
|
||||||
|
$data = $form->getData();
|
||||||
|
var_dump('data', $data);
|
||||||
|
|
||||||
|
// @todo implement tests
|
||||||
|
try {
|
||||||
|
new CheckDatabaseConnection(
|
||||||
|
$data['host'],
|
||||||
|
$data['user'],
|
||||||
|
$data['password'],
|
||||||
|
$data['port'],
|
||||||
|
true,
|
||||||
|
$this->getTranslator()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->getSession()->set('install', array(
|
||||||
|
'host' =>$data['host'],
|
||||||
|
'user' => $data['user'],
|
||||||
|
'password' => $data['password'],
|
||||||
|
'port' => $data['port']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} catch (InstallException $e) {
|
||||||
|
$message = $this->getTranslator()->trans(
|
||||||
|
'Can\'t connect with these credentials to this server',
|
||||||
|
array(),
|
||||||
|
'install-wizard'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// $this->redirect(
|
||||||
|
// str_replace(
|
||||||
|
// '{id}',
|
||||||
|
// $couponEvent->getCoupon()->getId(),
|
||||||
|
// $creationForm->getSuccessUrl()
|
||||||
|
// )
|
||||||
|
// );
|
||||||
|
} catch (FormValidationException $e) {
|
||||||
|
// Invalid data entered
|
||||||
|
$message = $this->getTranslator()->trans(
|
||||||
|
'Please check your input:',
|
||||||
|
array(),
|
||||||
|
'install-wizard'
|
||||||
|
);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Any other error
|
||||||
|
$message = $this->getTranslator()->trans(
|
||||||
|
'Sorry, an error occurred:',
|
||||||
|
array(),
|
||||||
|
'install-wizard'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($message !== false) {
|
||||||
|
// Mark the form as with error
|
||||||
|
$step3Form->setErrorMessage($message);
|
||||||
|
|
||||||
|
// Send the form and the error to the parser
|
||||||
|
$this->getParserContext()
|
||||||
|
->addForm($step3Form)
|
||||||
|
->setGeneralError($message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getSession()->set("step", 3);
|
||||||
|
|
||||||
|
$args['edit_language_locale'] = $this->getSession()->getLang()->getLocale();
|
||||||
|
$args['formAction'] = 'install/step/3';
|
||||||
|
|
||||||
|
} catch (AlreadyInstallException $e) {
|
||||||
|
$args['isAlreadyInstalled'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('step-3.html', $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,7 +180,14 @@ class InstallController extends BaseInstallController
|
|||||||
*/
|
*/
|
||||||
public function databaseSelectionAction()
|
public function databaseSelectionAction()
|
||||||
{
|
{
|
||||||
//$this->verifyStep(2);
|
$args = array();
|
||||||
|
try {
|
||||||
|
|
||||||
|
} catch (AlreadyInstallException $e) {
|
||||||
|
$args['isAlreadyInstalled'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//$this->verifyStep(2); // @todo implement
|
||||||
|
|
||||||
//$permission = new CheckPermission();
|
//$permission = new CheckPermission();
|
||||||
|
|
||||||
@@ -107,13 +197,19 @@ class InstallController extends BaseInstallController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set general informations
|
* Set general information
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function generalInformationAction()
|
public function generalInformationAction()
|
||||||
{
|
{
|
||||||
//$this->verifyStep(2);
|
$args = array();
|
||||||
|
try {
|
||||||
|
|
||||||
|
} catch (AlreadyInstallException $e) {
|
||||||
|
$args['isAlreadyInstalled'] = true;
|
||||||
|
}
|
||||||
|
//$this->verifyStep(2); // @todo implement
|
||||||
|
|
||||||
//$permission = new CheckPermission();
|
//$permission = new CheckPermission();
|
||||||
|
|
||||||
@@ -129,7 +225,13 @@ class InstallController extends BaseInstallController
|
|||||||
*/
|
*/
|
||||||
public function thanksAction()
|
public function thanksAction()
|
||||||
{
|
{
|
||||||
//$this->verifyStep(2);
|
$args = array();
|
||||||
|
try {
|
||||||
|
|
||||||
|
} catch (AlreadyInstallException $e) {
|
||||||
|
$args['isAlreadyInstalled'] = true;
|
||||||
|
}
|
||||||
|
//$this->verifyStep(2); // @todo implement
|
||||||
|
|
||||||
//$permission = new CheckPermission();
|
//$permission = new CheckPermission();
|
||||||
|
|
||||||
@@ -162,5 +264,7 @@ class InstallController extends BaseInstallController
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
111
core/lib/Thelia/Form/InstallStep3Form.php
Executable file
111
core/lib/Thelia/Form/InstallStep3Form.php
Executable file
@@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
/**********************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/**********************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Form;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||||
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by JetBrains PhpStorm.
|
||||||
|
* Date: 8/29/13
|
||||||
|
* Time: 3:45 PM
|
||||||
|
*
|
||||||
|
* Allow to build a form Install Step 3 Database connection
|
||||||
|
*
|
||||||
|
* @package Coupon
|
||||||
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class InstallStep3Form extends BaseForm
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Build Coupon form
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function buildForm()
|
||||||
|
{
|
||||||
|
$this->formBuilder
|
||||||
|
->add(
|
||||||
|
'host',
|
||||||
|
'text',
|
||||||
|
array(
|
||||||
|
'constraints' => array(
|
||||||
|
new NotBlank()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->add(
|
||||||
|
'user',
|
||||||
|
'text',
|
||||||
|
array(
|
||||||
|
'constraints' => array(
|
||||||
|
new NotBlank()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->add(
|
||||||
|
'password',
|
||||||
|
'text',
|
||||||
|
array(
|
||||||
|
'constraints' => array(
|
||||||
|
new NotBlank()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->add(
|
||||||
|
'port',
|
||||||
|
'text',
|
||||||
|
array(
|
||||||
|
'constraints' => array(
|
||||||
|
new NotBlank(),
|
||||||
|
new GreaterThan(
|
||||||
|
array(
|
||||||
|
'value' => 0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->add(
|
||||||
|
'locale',
|
||||||
|
'hidden',
|
||||||
|
array(
|
||||||
|
'constraints' => array(
|
||||||
|
new NotBlank()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get form name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'thelia_install_step3';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,8 @@ abstract class BaseInstall
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param bool $verifyInstall Verify if an installation already exists
|
* @param bool $verifyInstall Verify if an installation already exists
|
||||||
|
*
|
||||||
|
* @throws Exception\AlreadyInstallException
|
||||||
*/
|
*/
|
||||||
public function __construct($verifyInstall = true)
|
public function __construct($verifyInstall = true)
|
||||||
{
|
{
|
||||||
@@ -47,10 +49,9 @@ abstract class BaseInstall
|
|||||||
} else {
|
} else {
|
||||||
$this->isConsoleMode = false;
|
$this->isConsoleMode = false;
|
||||||
}
|
}
|
||||||
/* TODO : activate this part
|
|
||||||
if (file_exists(THELIA_ROOT . '/local/config/database.yml') && $verifyInstall) {
|
if (file_exists(THELIA_ROOT . '/local/config/database.yml') && $verifyInstall) {
|
||||||
throw new AlreadyInstallException("Thelia is already installed");
|
throw new AlreadyInstallException("Thelia is already installed");
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->exec();
|
$this->exec();
|
||||||
|
|||||||
100
core/lib/Thelia/Install/CheckDatabaseConnection.php
Normal file
100
core/lib/Thelia/Install/CheckDatabaseConnection.php
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Install;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
use RecursiveDirectoryIterator;
|
||||||
|
use RecursiveIteratorIterator;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
use Thelia\Core\Translation\Translator;
|
||||||
|
use Thelia\Install\Exception\InstallException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CheckDatabaseConnection
|
||||||
|
*
|
||||||
|
* Take care of integration tests (database connection)
|
||||||
|
*
|
||||||
|
* @package Thelia\Install
|
||||||
|
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||||
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
|
*/
|
||||||
|
class CheckDatabaseConnection extends BaseInstall
|
||||||
|
{
|
||||||
|
protected $validationMessages = array();
|
||||||
|
|
||||||
|
/** @var bool If permissions are OK */
|
||||||
|
protected $isValid = true;
|
||||||
|
|
||||||
|
/** @var TranslatorInterface Translator Service */
|
||||||
|
protected $translator = null;
|
||||||
|
|
||||||
|
/** @var string Database host information */
|
||||||
|
protected $host = null;
|
||||||
|
|
||||||
|
/** @var string Database user information */
|
||||||
|
protected $user = null;
|
||||||
|
|
||||||
|
/** @var string Database password information */
|
||||||
|
protected $password = null;
|
||||||
|
|
||||||
|
/** @var int Database port information */
|
||||||
|
protected $port = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param string $host Database host information
|
||||||
|
* @param string $user Database user information
|
||||||
|
* @param string $password Database password information
|
||||||
|
* @param int $port Database port information
|
||||||
|
* @param bool $verifyInstall If verify install
|
||||||
|
* @param Translator $translator Translator Service
|
||||||
|
* necessary for install wizard
|
||||||
|
*/
|
||||||
|
public function __construct($host, $user, $password, $port, $verifyInstall = true, Translator $translator = null)
|
||||||
|
{
|
||||||
|
$this->host = $host;
|
||||||
|
$this->user = $user;
|
||||||
|
$this->password = $password;
|
||||||
|
$this->port = $port;
|
||||||
|
|
||||||
|
parent::__construct($verifyInstall);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform database connection check
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function exec()
|
||||||
|
{
|
||||||
|
$link = mysql_connect($this->host . ':' . $this->port, $this->user, $this->password);
|
||||||
|
if (!$link) {
|
||||||
|
throw new InstallException('Can\'t connect to the given credentials');
|
||||||
|
}
|
||||||
|
mysql_close($link);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -52,6 +52,13 @@ class CheckPermission extends BaseInstall
|
|||||||
self::DIR_CACHE,
|
self::DIR_CACHE,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/** @var array Minimum server configuration necessary */
|
||||||
|
protected $minServerConfigurationNecessary = array(
|
||||||
|
'memory_limit' => 134217728,
|
||||||
|
'post_max_size' => 20971520,
|
||||||
|
'upload_max_filesize' => 2097152
|
||||||
|
);
|
||||||
|
|
||||||
protected $validationMessages = array();
|
protected $validationMessages = array();
|
||||||
|
|
||||||
/** @var bool If permissions are OK */
|
/** @var bool If permissions are OK */
|
||||||
@@ -71,6 +78,12 @@ class CheckPermission extends BaseInstall
|
|||||||
{
|
{
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
|
|
||||||
|
$this->validationMessages['php_version'] = array(
|
||||||
|
'text' => $this->getI18nPhpVersionText('5.4', phpversion(), true),
|
||||||
|
'hint' => $this->getI18nPhpVersionHint(),
|
||||||
|
'status' => true
|
||||||
|
);
|
||||||
|
|
||||||
foreach ($this->directoriesToBeWritable as $directory) {
|
foreach ($this->directoriesToBeWritable as $directory) {
|
||||||
$this->validationMessages[$directory] = array(
|
$this->validationMessages[$directory] = array(
|
||||||
'text' => '',
|
'text' => '',
|
||||||
@@ -78,6 +91,14 @@ class CheckPermission extends BaseInstall
|
|||||||
'status' => true
|
'status' => true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
foreach ($this->minServerConfigurationNecessary as $key => $value) {
|
||||||
|
$this->validationMessages[$key] = array(
|
||||||
|
'text' => '',
|
||||||
|
'hint' => $this->getI18nConfigHint(),
|
||||||
|
'status' => true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
parent::__construct($verifyInstall);
|
parent::__construct($verifyInstall);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,19 +109,35 @@ class CheckPermission extends BaseInstall
|
|||||||
*/
|
*/
|
||||||
public function exec()
|
public function exec()
|
||||||
{
|
{
|
||||||
|
if (version_compare(phpversion(), '5.4', '<')) {
|
||||||
|
$this->validationMessages['php_version'] = $this->getI18nPhpVersionText('5.4', phpversion(), false);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->directoriesToBeWritable as $directory) {
|
foreach ($this->directoriesToBeWritable as $directory) {
|
||||||
$fullDirectory = THELIA_ROOT . $directory;
|
$fullDirectory = THELIA_ROOT . $directory;
|
||||||
$this->validationMessages[$directory]['text'] = $this->getI18nText($fullDirectory, true);
|
$this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, true);
|
||||||
if (is_writable($fullDirectory) === false) {
|
if (is_writable($fullDirectory) === false) {
|
||||||
if (!$this->makeDirectoryWritable($fullDirectory)) {
|
if (!$this->makeDirectoryWritable($fullDirectory)) {
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
$this->validationMessages[$directory]['status'] = false;
|
$this->validationMessages[$directory]['status'] = false;
|
||||||
$this->validationMessages[$directory]['text'] = $this->getI18nText($fullDirectory, false);
|
$this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, false);
|
||||||
$this->validationMessages[$directory]['hint'] = $this->getI18nHint($fullDirectory);
|
$this->validationMessages[$directory]['hint'] = $this->getI18nDirectoryHint($fullDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($this->minServerConfigurationNecessary as $key => $value) {
|
||||||
|
$this->validationMessages[$key]['text'] = $this->getI18nConfigText($key, $this->formatBytes($value), ini_get($key), true);
|
||||||
|
if (!$this->verifyServerMemoryValues($key, $value)) {
|
||||||
|
$this->isValid = false;
|
||||||
|
$this->validationMessages[$key]['status'] = false;
|
||||||
|
$this->validationMessages[$key]['text'] = $this->getI18nConfigText($key, $this->formatBytes($value), ini_get($key), false);;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $this->isValid;
|
return $this->isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +181,7 @@ class CheckPermission extends BaseInstall
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getI18nText($directory, $isValid)
|
protected function getI18nDirectoryText($directory, $isValid)
|
||||||
{
|
{
|
||||||
if ($this->translator !== null) {
|
if ($this->translator !== null) {
|
||||||
if ($isValid) {
|
if ($isValid) {
|
||||||
@@ -174,7 +211,7 @@ class CheckPermission extends BaseInstall
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getI18nHint($directory)
|
protected function getI18nDirectoryHint($directory)
|
||||||
{
|
{
|
||||||
if ($this->translator !== null) {
|
if ($this->translator !== null) {
|
||||||
$sentence = '<span class="label label-primary">chmod 777 %directory%</span> on your server with admin rights could help';
|
$sentence = '<span class="label label-primary">chmod 777 %directory%</span> on your server with admin rights could help';
|
||||||
@@ -191,4 +228,159 @@ class CheckPermission extends BaseInstall
|
|||||||
|
|
||||||
return $translatedText;
|
return $translatedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Translated text about the directory state
|
||||||
|
* Not usable with CLI
|
||||||
|
*
|
||||||
|
* @param string $key .ini file key
|
||||||
|
* @param string $expectedValue Expected server value
|
||||||
|
* @param string $currentValue Actual server value
|
||||||
|
* @param bool $isValid If server configuration is valid
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getI18nConfigText($key, $expectedValue, $currentValue, $isValid)
|
||||||
|
{
|
||||||
|
if ($isValid) {
|
||||||
|
$sentence = 'Your <span class="label label-primary">%key%</span> server configuration (currently %currentValue%) is well enough to run Thelia2 (%expectedValue% needed)';
|
||||||
|
} else {
|
||||||
|
$sentence = 'Your <span class="label label-primary">%key%</span> server configuration (currently %currentValue%) is not sufficient enough in order to run Thelia2 (%expectedValue% needed)';
|
||||||
|
}
|
||||||
|
|
||||||
|
$translatedText = $this->translator->trans(
|
||||||
|
$sentence,
|
||||||
|
array(
|
||||||
|
'%key%' => $key,
|
||||||
|
'%expectedValue%' => $expectedValue,
|
||||||
|
'%currentValue%' => $currentValue,
|
||||||
|
),
|
||||||
|
'install-wizard'
|
||||||
|
);
|
||||||
|
|
||||||
|
return $translatedText;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Translated hint about the config requirement issue
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getI18nConfigHint()
|
||||||
|
{
|
||||||
|
$sentence = 'Modifying this value on your server <span class="label label-primary">php.ini</span> file with admin rights could help';
|
||||||
|
$translatedText = $this->translator->trans(
|
||||||
|
$sentence,
|
||||||
|
array(),
|
||||||
|
'install-wizard'
|
||||||
|
);
|
||||||
|
|
||||||
|
return $translatedText;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Translated hint about the PHP version requirement issue
|
||||||
|
*
|
||||||
|
* @param string $expectedValue
|
||||||
|
* @param string $currentValue
|
||||||
|
* @param bool $isValid
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getI18nPhpVersionText($expectedValue, $currentValue, $isValid)
|
||||||
|
{
|
||||||
|
if ($this->translator !== null) {
|
||||||
|
if ($isValid) {
|
||||||
|
$sentence = 'Your PHP version <span class="label label-primary">%currentValue%</span> is well enough to run Thelia2 (%expectedValue% needed)';
|
||||||
|
} else {
|
||||||
|
$sentence = 'Your PHP version <span class="label label-primary">%currentValue%</span> is not sufficient enough to run Thelia2 (%expectedValue% needed)';
|
||||||
|
}
|
||||||
|
|
||||||
|
$translatedText = $this->translator->trans(
|
||||||
|
$sentence,
|
||||||
|
array(
|
||||||
|
'%expectedValue%' => $expectedValue,
|
||||||
|
'%currentValue%' => $currentValue,
|
||||||
|
),
|
||||||
|
'install-wizard'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$translatedText = sprintf('Thelia needs at least PHP %s (%s currently)', $expectedValue, $currentValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $translatedText;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Translated hint about the config requirement issue
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getI18nPhpVersionHint()
|
||||||
|
{
|
||||||
|
$sentence = 'Upgrading your version of PHP with admin rights could help';
|
||||||
|
$translatedText = $this->translator->trans(
|
||||||
|
$sentence,
|
||||||
|
array(),
|
||||||
|
'install-wizard'
|
||||||
|
);
|
||||||
|
|
||||||
|
return $translatedText;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a server memory value is met or not
|
||||||
|
*
|
||||||
|
* @param string $key .ini file key
|
||||||
|
* @param int $necessaryValueInBytes Expected value in bytes
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function verifyServerMemoryValues($key, $necessaryValueInBytes)
|
||||||
|
{
|
||||||
|
$serverValueInBytes = $this->returnBytes(ini_get($key));
|
||||||
|
|
||||||
|
return ($serverValueInBytes >= $necessaryValueInBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return bytes from memory .ini value
|
||||||
|
*
|
||||||
|
* @param string $val .ini value
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected function returnBytes($val)
|
||||||
|
{
|
||||||
|
$val = trim($val);
|
||||||
|
$last = strtolower($val[strlen($val)-1]);
|
||||||
|
switch($last) {
|
||||||
|
// The 'G' modifier is available since PHP 5.1.0
|
||||||
|
case 'g':
|
||||||
|
$val *= 1024;
|
||||||
|
case 'm':
|
||||||
|
$val *= 1024;
|
||||||
|
case 'k':
|
||||||
|
$val *= 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert bytes to readable string
|
||||||
|
*
|
||||||
|
* @param int $bytes bytes
|
||||||
|
* @param int $precision conversion precision
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function formatBytes($bytes, $precision = 2)
|
||||||
|
{
|
||||||
|
$base = log($bytes) / log(1024);
|
||||||
|
$suffixes = array('', 'k', 'M', 'G', 'T');
|
||||||
|
|
||||||
|
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<a href="install/step/2" class="pull-right btn btn-default btn-primary"><span class="glyphicon glyphicon-chevron-right"></span> {intl l="Continue"}</a>
|
<a href="{url path='/install/step/2'}" class="pull-right btn btn-default btn-primary"><span class="glyphicon glyphicon-chevron-right"></span> {intl l="Continue"}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -26,8 +26,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{* -- Main page content section ----------------------------------------- *}
|
{* -- Main page content section ----------------------------------------- *}
|
||||||
|
{if $isAlreadyInstalled}
|
||||||
|
<div>{intl l='Thelia is already installed'}</div>
|
||||||
|
{else}
|
||||||
|
{block name="main-content"}Put here the content of the template{/block}
|
||||||
|
{/if}
|
||||||
|
|
||||||
{block name="main-content"}Put here the content of the template{/block}
|
|
||||||
|
|
||||||
{* -- Footer section ---------------------------------------------------- *}
|
{* -- Footer section ---------------------------------------------------- *}
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<a href="install" class="pull-left btn btn-default"><span class="glyphicon glyphicon-chevron-left"></span> {intl l="Return"}</a>
|
<a href="{url path='/install'}" class="pull-left btn btn-default"><span class="glyphicon glyphicon-chevron-left"></span> {intl l="Return"}</a>
|
||||||
<a href="install/step/3" class="pull-right btn btn-default btn-primary"><span class="glyphicon glyphicon-chevron-right"></span> {intl l="Continue"}</a>
|
<a href="{url path='/install/step/3'}" class="pull-right btn btn-default btn-primary"><span class="glyphicon glyphicon-chevron-right"></span> {intl l="Continue"}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,29 +23,59 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="well">
|
{form name="thelia.install.step3"}
|
||||||
|
<form action="{url path=$formAction}" {form_enctype form=$form} method="POST" >
|
||||||
<form action="">
|
{if ! empty($general_error) }
|
||||||
<div class="form-group">
|
<div class="alert alert-danger">{$general_error}</div>
|
||||||
<label for="">{intl l="Host"} :</label>
|
{/if}
|
||||||
<input id="" type="text" class="form-control">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="">{intl l="Login"} :</label>
|
|
||||||
<input id="" type="text" class="form-control">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="">{intl l="Password"} :</label>
|
|
||||||
<input id="" type="password" class="form-control">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</div>
|
{form_hidden_fields form=$form}
|
||||||
|
|
||||||
<div class="clearfix">
|
{form_field form=$form field='locale'}
|
||||||
<a href="install/step/2" class="pull-left btn btn-default"><span class="glyphicon glyphicon-chevron-left"></span> {intl l="Return"}</a>
|
<input type="hidden" name="{$name}" value="{if $value}{$value}{else}{$edit_language_locale}{/if}" />
|
||||||
<a href="install/step/4" class="pull-right btn btn-default btn-primary"><span class="glyphicon glyphicon-chevron-right"></span> {intl l="Continue"}</a>
|
{/form_field}
|
||||||
</div>
|
|
||||||
|
<div class="well">
|
||||||
|
{form_field form=$form field='host'}
|
||||||
|
<div class="form-group{if $error} has-error{/if}">
|
||||||
|
<label for="host">{intl l="Host"} :</label>
|
||||||
|
<input id="host" class="form-control" type="text" name="{$name}" value="{$value}" placeholder="localhost">
|
||||||
|
{if $error}{$message}{/if}
|
||||||
|
</div>
|
||||||
|
{/form_field}
|
||||||
|
|
||||||
|
{form_field form=$form field='user'}
|
||||||
|
<div class="form-group{if $error} has-error{/if}">
|
||||||
|
<label for="user">{intl l="User"} :</label>
|
||||||
|
<input id="user" type="text" class="form-control" name="{$name}" value="{$value}" >
|
||||||
|
{if $error}{$message}{/if}
|
||||||
|
</div>
|
||||||
|
{/form_field}
|
||||||
|
|
||||||
|
{form_field form=$form field='password'}
|
||||||
|
<div class="form-group{if $error} has-error{/if}">
|
||||||
|
<label for="password">{intl l="Password"} :</label>
|
||||||
|
<input id="password" type="password" class="form-control" name="{$name}" value="{$value}" >
|
||||||
|
{if $error}{$message}{/if}
|
||||||
|
</div>
|
||||||
|
{/form_field}
|
||||||
|
|
||||||
|
{form_field form=$form field='port'}
|
||||||
|
<div class="form-group{if $error} has-error{/if}">
|
||||||
|
<label for="port">{intl l="Port"} :</label>
|
||||||
|
<input id="port" type="text" class="form-control" name="{$name}" value="{if value}{$value}{else}3306{/if}">
|
||||||
|
{if $error}{$message}{/if}
|
||||||
|
</div>
|
||||||
|
{/form_field}
|
||||||
|
</div>
|
||||||
|
<button type="submit" value="{intl l="Continue"}" />
|
||||||
|
<div class="clearfix">
|
||||||
|
|
||||||
|
<a href="install/step/2" class="pull-left btn btn-default"><span class="glyphicon glyphicon-chevron-left"></span> {intl l="Return"}</a>
|
||||||
|
<a href="install/step/4" class="pull-right btn btn-default btn-primary"><span class="glyphicon glyphicon-chevron-right"></span> {intl l="Continue"}</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{/form}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user