From b6bc6994fc007254bd8a9b64456a24471244303e Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 10:53:15 +0200 Subject: [PATCH 1/9] WIP : Install wizard --- .../Controller/Install/InstallController.php | 3 ++- core/lib/Thelia/Install/CheckPermission.php | 25 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/core/lib/Thelia/Controller/Install/InstallController.php b/core/lib/Thelia/Controller/Install/InstallController.php index 40e6643db..75594868a 100644 --- a/core/lib/Thelia/Controller/Install/InstallController.php +++ b/core/lib/Thelia/Controller/Install/InstallController.php @@ -42,9 +42,10 @@ class InstallController extends BaseInstallController public function checkPermission() { + var_dump('step2'); //$this->verifyStep(2); - //$permission = new CheckPermission(); + $permission = new CheckPermission(); $this->getSession()->set("step", 2); return $this->render("step-2.html"); diff --git a/core/lib/Thelia/Install/CheckPermission.php b/core/lib/Thelia/Install/CheckPermission.php index db73330cf..e57185c36 100644 --- a/core/lib/Thelia/Install/CheckPermission.php +++ b/core/lib/Thelia/Install/CheckPermission.php @@ -31,9 +31,10 @@ namespace Thelia\Install; */ class CheckPermission extends BaseInstall { - const CONF = "const"; - const LOG = "log"; - const CACHE = "cache"; + + const DIR_CONF = 'local/config'; + const DIR_LOG = 'log'; + const DIR_CACHE = 'cache'; private $directories = array(); private $validation = array(); @@ -44,22 +45,22 @@ class CheckPermission extends BaseInstall $this->directories = array( - self::CONF => THELIA_ROOT . "local/config", - self::LOG => THELIA_ROOT . "log", - self::CACHE => THELIA_ROOT . "cache" + self::DIR_CONF => THELIA_ROOT . 'local/config', + self::DIR_LOG => THELIA_ROOT . 'DIR_LOG', + self::DIR_CACHE => THELIA_ROOT . 'DIR_CACHE' ); $this->validation = array( - self::CONF => array( - "text" => sprintf("config directory(%s)...", $this->directories[self::CONF]), + self::DIR_CONF => array( + "text" => sprintf("config directory(%s)...", $this->directories[self::DIR_CONF]), "status" => true ), - self::LOG => array( - "text" => sprintf("cache directory(%s)...", $this->directories[self::LOG]), + self::DIR_LOG => array( + "text" => sprintf("DIR_CACHE directory(%s)...", $this->directories[self::DIR_LOG]), "status" => true ), - self::CACHE => array( - "text" => sprintf("log directory(%s)...", $this->directories[self::CACHE]), + self::DIR_CACHE => array( + "text" => sprintf("DIR_LOG directory(%s)...", $this->directories[self::DIR_CACHE]), "status" => true ) ); From b151325e572c9c23a1940e9565462c2abe29ee6f Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 15:07:41 +0200 Subject: [PATCH 2/9] WIP : Install wizard : step 2 file permission --- .../Controller/Install/InstallController.php | 70 ++++++- core/lib/Thelia/Install/BaseInstall.php | 15 +- core/lib/Thelia/Install/CheckPermission.php | 183 ++++++++++++++---- templates/install/layout.tpl | 1 - templates/install/step-2.html | 15 +- 5 files changed, 232 insertions(+), 52 deletions(-) diff --git a/core/lib/Thelia/Controller/Install/InstallController.php b/core/lib/Thelia/Controller/Install/InstallController.php index 75594868a..648ae843e 100644 --- a/core/lib/Thelia/Controller/Install/InstallController.php +++ b/core/lib/Thelia/Controller/Install/InstallController.php @@ -26,12 +26,14 @@ use Thelia\Install\CheckPermission; /** * Class InstallController + * * @package Thelia\Controller\Install - * @author Manuel Raynaud + * @author Manuel Raynaud + * @author Guillaume MOREL */ class InstallController extends BaseInstallController { - public function index() + public function indexAction() { //$this->verifyStep(1); @@ -40,57 +42,109 @@ class InstallController extends BaseInstallController return $this->render("index.html"); } - public function checkPermission() + /** + * Integration tests + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function checkPermissionAction() { + $args = array(); var_dump('step2'); //$this->verifyStep(2); - $permission = new CheckPermission(); + $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"); + + 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 + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function databaseConnectionAction() + { + var_dump('step 3'); + exit(); //$this->verifyStep(2); //$permission = new CheckPermission(); $this->getSession()->set("step", 3); + return $this->render("step-3.html"); } - public function databaseSelection() + /** + * Database selection + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function databaseSelectionAction() { //$this->verifyStep(2); //$permission = new CheckPermission(); $this->getSession()->set("step", 4); + return $this->render("step-4.html"); } - public function generalInformation() + /** + * Set general informations + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function generalInformationAction() { //$this->verifyStep(2); //$permission = new CheckPermission(); $this->getSession()->set("step", 5); + return $this->render("step-5.html"); } - public function thanks() + /** + * Display Thanks page + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function thanksAction() { //$this->verifyStep(2); //$permission = new CheckPermission(); $this->getSession()->set("step", 6); + return $this->render("thanks.html"); } + /** + * Verify each steps and redirect if one step has already been passed + * + * @param int $step Step number + * + * @return bool + */ protected function verifyStep($step) { $session = $this->getSession(); diff --git a/core/lib/Thelia/Install/BaseInstall.php b/core/lib/Thelia/Install/BaseInstall.php index 11b8d0999..86928236a 100644 --- a/core/lib/Thelia/Install/BaseInstall.php +++ b/core/lib/Thelia/Install/BaseInstall.php @@ -25,15 +25,28 @@ use Thelia\Install\Exception\AlreadyInstallException; /** * Class BaseInstall + * * @author Manuel Raynaud */ abstract class BaseInstall { + /** @var bool If Installation wizard is launched by CLI */ + protected $isConsoleMode = true; + /** - * Verify if an installation already exists + * Constructor + * + * @param bool $verifyInstall Verify if an installation already exists */ public function __construct($verifyInstall = true) { + + // Check if install wizard is launched via CLI + if (php_sapi_name() == 'cli') { + $this->isConsoleMode = true; + } else { + $this->isConsoleMode = false; + } /* TODO : activate this part if (file_exists(THELIA_ROOT . '/local/config/database.yml') && $verifyInstall) { throw new AlreadyInstallException("Thelia is already installed"); diff --git a/core/lib/Thelia/Install/CheckPermission.php b/core/lib/Thelia/Install/CheckPermission.php index e57185c36..d924bac35 100644 --- a/core/lib/Thelia/Install/CheckPermission.php +++ b/core/lib/Thelia/Install/CheckPermission.php @@ -23,57 +23,172 @@ namespace Thelia\Install; +use RecursiveDirectoryIterator; +use RecursiveIteratorIterator; +use Symfony\Component\Translation\TranslatorInterface; +use Thelia\Core\Translation\Translator; + /** * Class CheckPermission + * + * Take care of integration tests (files permissions) + * * @package Thelia\Install - * @author Manuel Raynaud + * @author Manuel Raynaud + * @author Guillaume MOREL */ class CheckPermission extends BaseInstall { - const DIR_CONF = 'local/config'; - const DIR_LOG = 'log'; - const DIR_CACHE = 'cache'; + const DIR_CONF = 'local/config'; + const DIR_LOG = 'log'; + const DIR_CACHE = 'cache'; - private $directories = array(); - private $validation = array(); - private $valid = true; + /** @var array Directory needed to be writable */ + protected $directoriesToBeWritable = array( + self::DIR_CONF, + self::DIR_LOG, + self::DIR_CACHE, + ); - public function __construct($verifyInstall = true) + protected $validationMessages = array(); + + /** @var bool If permissions are OK */ + protected $isValid = true; + + /** @var TranslatorInterface Translator Service */ + protected $translator = null; + + /** + * Constructor + * + * @param bool $verifyInstall If verify install + * @param Translator $translator Translator Service + * necessary for install wizard + */ + public function __construct($verifyInstall = true, Translator $translator = null) { + $this->translator = $translator; - - $this->directories = array( - self::DIR_CONF => THELIA_ROOT . 'local/config', - self::DIR_LOG => THELIA_ROOT . 'DIR_LOG', - self::DIR_CACHE => THELIA_ROOT . 'DIR_CACHE' - ); - - $this->validation = array( - self::DIR_CONF => array( - "text" => sprintf("config directory(%s)...", $this->directories[self::DIR_CONF]), - "status" => true - ), - self::DIR_LOG => array( - "text" => sprintf("DIR_CACHE directory(%s)...", $this->directories[self::DIR_LOG]), - "status" => true - ), - self::DIR_CACHE => array( - "text" => sprintf("DIR_LOG directory(%s)...", $this->directories[self::DIR_CACHE]), - "status" => true - ) - ); + foreach ($this->directoriesToBeWritable as $directory) { + $this->validationMessages[$directory] = array( + 'text' => '', + 'hint' => '', + 'status' => true + ); + } parent::__construct($verifyInstall); } + /** + * Perform file permission check + * + * @return bool + */ public function exec() { - foreach ($this->directories as $key => $directory) { - if(is_writable($directory) === false) { - $this->valid = false; - $this->validation[$key]["status"] = false; + foreach ($this->directoriesToBeWritable as $directory) { + $fullDirectory = THELIA_ROOT . $directory; + $this->validationMessages[$directory]['text'] = $this->getI18nText($fullDirectory, true); + if (is_writable($fullDirectory) === false) { + if (!$this->makeDirectoryWritable($fullDirectory)) { + $this->isValid = false; + $this->validationMessages[$directory]['status'] = false; + $this->validationMessages[$directory]['text'] = $this->getI18nText($fullDirectory, false); + $this->validationMessages[$directory]['hint'] = $this->getI18nHint($fullDirectory); + } } } + + return $this->isValid; } -} \ No newline at end of file + + /** + * Get validation messages + * + * @return array + */ + public function getValidationMessages() + { + return $this->validationMessages; + } + + /** + * Make a directory writable (recursively) + * + * @param string $directory path to directory + * + * @return bool + */ + protected function makeDirectoryWritable($directory) + { + chmod($directory, 0777); + $iterator = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($directory) + ); + foreach ($iterator as $item) { + chmod($item, 0777); + } + + return (is_writable(THELIA_ROOT . $directory) === true); + } + + + + /** + * Get Translated text about the directory state + * + * @param string $directory Directory being checked + * @param bool $isValid If directory permission is valid + * + * @return string + */ + protected function getI18nText($directory, $isValid) + { + if ($this->translator !== null) { + if ($isValid) { + $sentence = 'Your directory %directory% is writable'; + } else { + $sentence = 'Your directory %directory% is not writable'; + } + + $translatedText = $this->translator->trans( + $sentence, + array( + '%directory%' => $directory + ), + 'install-wizard' + ); + } else { + $translatedText = sprintf('Your directory %s needs to be writable', $directory); + } + + return $translatedText; + } + + /** + * Get Translated hint about the directory state + * + * @param string $directory Directory being checked + * + * @return string + */ + protected function getI18nHint($directory) + { + if ($this->translator !== null) { + $sentence = 'chmod 777 %directory% on your server with admin rights could help'; + $translatedText = $this->translator->trans( + $sentence, + array( + '%directory%' => $directory + ), + 'install-wizard' + ); + } else { + $translatedText = sprintf('chmod 777 %s on your server with admin rights could help', $directory); + } + + return $translatedText; + } +} diff --git a/templates/install/layout.tpl b/templates/install/layout.tpl index 4539ce32f..6b38292e2 100644 --- a/templates/install/layout.tpl +++ b/templates/install/layout.tpl @@ -38,7 +38,6 @@ - {intl l='Édité par OpenStudio'} - {intl l='Forum Thelia'} - {intl l='Contributions Thelia'} - {intl l='interface par Steaw-Webdesign'}

{module_include location='in_footer'} diff --git a/templates/install/step-2.html b/templates/install/step-2.html index fc24d25cb..a05267c7c 100644 --- a/templates/install/step-2.html +++ b/templates/install/step-2.html @@ -24,15 +24,14 @@
-

We will check some rights to files and directories...

+

{intl l="Checking directory permissions ..."}

    -
  • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
  • -
  • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
  • -
  • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
  • -
  • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
  • -
  • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
  • -
  • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
  • -
  • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
  • + {foreach from=$validationMessages item=validationMessage} +
  • + {$validationMessage.text nofilter} + {if !$validationMessage.status} - {$validationMessage.hint nofilter}{/if} +
  • + {/foreach}
From bca2b58e416c9fb1d01aa55f9165d7f3151657bb Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 15:07:58 +0200 Subject: [PATCH 3/9] Merge master --- local/modules/Colissimo/Colissimo.php | 0 local/modules/Colissimo/Config/config.xml | 0 local/modules/Colissimo/Config/plugin.xml | 0 local/modules/Colissimo/Config/schema.xml | 0 local/modules/DebugBar/Config/config.xml | 0 local/modules/DebugBar/Config/plugin.xml | 0 local/modules/DebugBar/Config/schema.xml | 0 local/modules/DebugBar/DataCollector/PropelCollector.php | 0 local/modules/DebugBar/DebugBar.php | 0 local/modules/DebugBar/Listeners/DebugBarListeners.php | 0 local/modules/DebugBar/Smarty/Plugin/DebugBar.php | 0 11 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 local/modules/Colissimo/Colissimo.php mode change 100644 => 100755 local/modules/Colissimo/Config/config.xml mode change 100644 => 100755 local/modules/Colissimo/Config/plugin.xml mode change 100644 => 100755 local/modules/Colissimo/Config/schema.xml mode change 100644 => 100755 local/modules/DebugBar/Config/config.xml mode change 100644 => 100755 local/modules/DebugBar/Config/plugin.xml mode change 100644 => 100755 local/modules/DebugBar/Config/schema.xml mode change 100644 => 100755 local/modules/DebugBar/DataCollector/PropelCollector.php mode change 100644 => 100755 local/modules/DebugBar/DebugBar.php mode change 100644 => 100755 local/modules/DebugBar/Listeners/DebugBarListeners.php mode change 100644 => 100755 local/modules/DebugBar/Smarty/Plugin/DebugBar.php diff --git a/local/modules/Colissimo/Colissimo.php b/local/modules/Colissimo/Colissimo.php old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/config.xml b/local/modules/Colissimo/Config/config.xml old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/plugin.xml b/local/modules/Colissimo/Config/plugin.xml old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/schema.xml b/local/modules/Colissimo/Config/schema.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Config/config.xml b/local/modules/DebugBar/Config/config.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Config/plugin.xml b/local/modules/DebugBar/Config/plugin.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Config/schema.xml b/local/modules/DebugBar/Config/schema.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/DataCollector/PropelCollector.php b/local/modules/DebugBar/DataCollector/PropelCollector.php old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/DebugBar.php b/local/modules/DebugBar/DebugBar.php old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Listeners/DebugBarListeners.php b/local/modules/DebugBar/Listeners/DebugBarListeners.php old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Smarty/Plugin/DebugBar.php b/local/modules/DebugBar/Smarty/Plugin/DebugBar.php old mode 100644 new mode 100755 From cfc52c4e7fade57c5d5f5f157eab6a3c84de5cc9 Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 18:15:09 +0200 Subject: [PATCH 4/9] Working : install wizard : type inference --- core/lib/Thelia/Controller/BaseController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 19e62a400..d5c54e991 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -31,6 +31,7 @@ use Symfony\Component\Routing\Exception\MissingMandatoryParametersException; use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Router; use Thelia\Core\Security\SecurityContext; +use Thelia\Core\Translation\Translator; use Thelia\Tools\URL; use Thelia\Tools\Redirect; use Thelia\Core\Template\ParserContext; @@ -89,7 +90,7 @@ class BaseController extends ContainerAware * * return the Translator * - * @return mixed \Thelia\Core\Translation\Translator + * @return Translator */ public function getTranslator() { From 63472b9f80e1be15a736bd38a1bc921f7ec515f4 Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 19:00:28 +0200 Subject: [PATCH 5/9] WIP : install wizard : step 1, 2, 3 --- core/lib/Thelia/Config/Resources/config.xml | 2 + .../Config/Resources/routing/install.xml | 12 +- .../Controller/Install/InstallController.php | 162 +++++++++++--- core/lib/Thelia/Form/InstallStep3Form.php | 111 ++++++++++ core/lib/Thelia/Install/BaseInstall.php | 5 +- .../Install/CheckDatabaseConnection.php | 100 +++++++++ core/lib/Thelia/Install/CheckPermission.php | 202 +++++++++++++++++- templates/install/index.html | 2 +- templates/install/layout.tpl | 6 +- templates/install/step-2.html | 4 +- templates/install/step-3.html | 74 +++++-- 11 files changed, 612 insertions(+), 68 deletions(-) create mode 100755 core/lib/Thelia/Form/InstallStep3Form.php create mode 100644 core/lib/Thelia/Install/CheckDatabaseConnection.php diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 691cf2198..b90ca3e45 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -40,6 +40,8 @@ +
+ diff --git a/core/lib/Thelia/Config/Resources/routing/install.xml b/core/lib/Thelia/Config/Resources/routing/install.xml index 37ddde487..720761b40 100644 --- a/core/lib/Thelia/Config/Resources/routing/install.xml +++ b/core/lib/Thelia/Config/Resources/routing/install.xml @@ -5,27 +5,27 @@ xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - Thelia\Controller\Install\InstallController::index + Thelia\Controller\Install\InstallController::indexAction - Thelia\Controller\Install\InstallController::checkPermission + Thelia\Controller\Install\InstallController::checkPermissionAction - Thelia\Controller\Install\InstallController::databaseConnection + Thelia\Controller\Install\InstallController::databaseConnectionAction - Thelia\Controller\Install\InstallController::databaseSelection + Thelia\Controller\Install\InstallController::databaseSelectionAction - Thelia\Controller\Install\InstallController::generalInformation + Thelia\Controller\Install\InstallController::generalInformationAction - Thelia\Controller\Install\InstallController::thanks + Thelia\Controller\Install\InstallController::thanksAction diff --git a/core/lib/Thelia/Controller/Install/InstallController.php b/core/lib/Thelia/Controller/Install/InstallController.php index 648ae843e..a6b0d975d 100644 --- a/core/lib/Thelia/Controller/Install/InstallController.php +++ b/core/lib/Thelia/Controller/Install/InstallController.php @@ -22,7 +22,12 @@ /*************************************************************************************/ namespace Thelia\Controller\Install; +use Thelia\Form\Exception\FormValidationException; +use Thelia\Form\InstallStep3Form; +use Thelia\Install\CheckDatabaseConnection; use Thelia\Install\CheckPermission; +use Thelia\Install\Exception\AlreadyInstallException; +use Thelia\Install\Exception\InstallException; /** * Class InstallController @@ -35,9 +40,14 @@ class InstallController extends BaseInstallController { 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"); } @@ -49,29 +59,22 @@ class InstallController extends BaseInstallController */ 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(); - 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); } - /** - * Database connexion tests - * - * @return \Symfony\Component\HttpFoundation\Response - */ - public function databaseConnection() - { - var_dump('step 3 bis'); - } - /** * Database connexion tests * @@ -79,15 +82,95 @@ class InstallController extends BaseInstallController */ public function databaseConnectionAction() { - var_dump('step 3'); - exit(); - //$this->verifyStep(2); + $args = array(); - //$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() { - //$this->verifyStep(2); + $args = array(); + try { + + } catch (AlreadyInstallException $e) { + $args['isAlreadyInstalled'] = true; + } + + //$this->verifyStep(2); // @todo implement //$permission = new CheckPermission(); @@ -107,13 +197,19 @@ class InstallController extends BaseInstallController } /** - * Set general informations + * Set general information * * @return \Symfony\Component\HttpFoundation\Response */ public function generalInformationAction() { - //$this->verifyStep(2); + $args = array(); + try { + + } catch (AlreadyInstallException $e) { + $args['isAlreadyInstalled'] = true; + } + //$this->verifyStep(2); // @todo implement //$permission = new CheckPermission(); @@ -129,7 +225,13 @@ class InstallController extends BaseInstallController */ public function thanksAction() { - //$this->verifyStep(2); + $args = array(); + try { + + } catch (AlreadyInstallException $e) { + $args['isAlreadyInstalled'] = true; + } + //$this->verifyStep(2); // @todo implement //$permission = new CheckPermission(); @@ -162,5 +264,7 @@ class InstallController extends BaseInstallController } break; } + + return true; } } diff --git a/core/lib/Thelia/Form/InstallStep3Form.php b/core/lib/Thelia/Form/InstallStep3Form.php new file mode 100755 index 000000000..9388f14db --- /dev/null +++ b/core/lib/Thelia/Form/InstallStep3Form.php @@ -0,0 +1,111 @@ +. */ +/* */ +/**********************************************************************************/ + +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 + * + */ +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'; + } +} diff --git a/core/lib/Thelia/Install/BaseInstall.php b/core/lib/Thelia/Install/BaseInstall.php index 86928236a..aa41140dd 100644 --- a/core/lib/Thelia/Install/BaseInstall.php +++ b/core/lib/Thelia/Install/BaseInstall.php @@ -37,6 +37,8 @@ abstract class BaseInstall * Constructor * * @param bool $verifyInstall Verify if an installation already exists + * + * @throws Exception\AlreadyInstallException */ public function __construct($verifyInstall = true) { @@ -47,10 +49,9 @@ abstract class BaseInstall } else { $this->isConsoleMode = false; } - /* TODO : activate this part if (file_exists(THELIA_ROOT . '/local/config/database.yml') && $verifyInstall) { throw new AlreadyInstallException("Thelia is already installed"); - }*/ + } $this->exec(); diff --git a/core/lib/Thelia/Install/CheckDatabaseConnection.php b/core/lib/Thelia/Install/CheckDatabaseConnection.php new file mode 100644 index 000000000..50c117d22 --- /dev/null +++ b/core/lib/Thelia/Install/CheckDatabaseConnection.php @@ -0,0 +1,100 @@ +. */ +/* */ +/*************************************************************************************/ + +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 + * @author Guillaume MOREL + */ +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); + } + +} diff --git a/core/lib/Thelia/Install/CheckPermission.php b/core/lib/Thelia/Install/CheckPermission.php index d924bac35..d07b8ed83 100644 --- a/core/lib/Thelia/Install/CheckPermission.php +++ b/core/lib/Thelia/Install/CheckPermission.php @@ -52,6 +52,13 @@ class CheckPermission extends BaseInstall 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(); /** @var bool If permissions are OK */ @@ -71,6 +78,12 @@ class CheckPermission extends BaseInstall { $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) { $this->validationMessages[$directory] = array( 'text' => '', @@ -78,6 +91,14 @@ class CheckPermission extends BaseInstall 'status' => true ); } + foreach ($this->minServerConfigurationNecessary as $key => $value) { + $this->validationMessages[$key] = array( + 'text' => '', + 'hint' => $this->getI18nConfigHint(), + 'status' => true + ); + } + parent::__construct($verifyInstall); } @@ -88,19 +109,35 @@ class CheckPermission extends BaseInstall */ public function exec() { + if (version_compare(phpversion(), '5.4', '<')) { + $this->validationMessages['php_version'] = $this->getI18nPhpVersionText('5.4', phpversion(), false); + } + foreach ($this->directoriesToBeWritable as $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 (!$this->makeDirectoryWritable($fullDirectory)) { $this->isValid = false; $this->validationMessages[$directory]['status'] = false; - $this->validationMessages[$directory]['text'] = $this->getI18nText($fullDirectory, false); - $this->validationMessages[$directory]['hint'] = $this->getI18nHint($fullDirectory); + $this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, false); + $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; } @@ -144,7 +181,7 @@ class CheckPermission extends BaseInstall * * @return string */ - protected function getI18nText($directory, $isValid) + protected function getI18nDirectoryText($directory, $isValid) { if ($this->translator !== null) { if ($isValid) { @@ -174,7 +211,7 @@ class CheckPermission extends BaseInstall * * @return string */ - protected function getI18nHint($directory) + protected function getI18nDirectoryHint($directory) { if ($this->translator !== null) { $sentence = 'chmod 777 %directory% on your server with admin rights could help'; @@ -191,4 +228,159 @@ class CheckPermission extends BaseInstall 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 %key% server configuration (currently %currentValue%) is well enough to run Thelia2 (%expectedValue% needed)'; + } else { + $sentence = 'Your %key% 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 php.ini 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 %currentValue% is well enough to run Thelia2 (%expectedValue% needed)'; + } else { + $sentence = 'Your PHP version %currentValue% 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)]; + } } diff --git a/templates/install/index.html b/templates/install/index.html index dd1d5f62b..b7843d528 100644 --- a/templates/install/index.html +++ b/templates/install/index.html @@ -34,7 +34,7 @@ diff --git a/templates/install/layout.tpl b/templates/install/layout.tpl index 6b38292e2..1497d7ea5 100644 --- a/templates/install/layout.tpl +++ b/templates/install/layout.tpl @@ -26,8 +26,12 @@ {* -- Main page content section ----------------------------------------- *} + {if $isAlreadyInstalled} +
{intl l='Thelia is already installed'}
+ {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 ---------------------------------------------------- *} diff --git a/templates/install/step-2.html b/templates/install/step-2.html index a05267c7c..fbd34ddb5 100644 --- a/templates/install/step-2.html +++ b/templates/install/step-2.html @@ -37,8 +37,8 @@ diff --git a/templates/install/step-3.html b/templates/install/step-3.html index cb4157dd7..f93b0182b 100644 --- a/templates/install/step-3.html +++ b/templates/install/step-3.html @@ -23,29 +23,59 @@ -
- - -
- - -
-
- - -
-
- - -
- + {form name="thelia.install.step3"} +
+ {if ! empty($general_error) } +
{$general_error}
+ {/if} -
- - + {form_hidden_fields form=$form} + + {form_field form=$form field='locale'} + + {/form_field} + +
+ {form_field form=$form field='host'} +
+ + + {if $error}{$message}{/if} +
+ {/form_field} + + {form_field form=$form field='user'} +
+ + + {if $error}{$message}{/if} +
+ {/form_field} + + {form_field form=$form field='password'} +
+ + + {if $error}{$message}{/if} +
+ {/form_field} + + {form_field form=$form field='port'} +
+ + + {if $error}{$message}{/if} +
+ {/form_field} +
+ + + + + + + \ No newline at end of file diff --git a/web/install/fd33fd0-6fda040.ico b/web/install/fd33fd0-6fda040.ico new file mode 100644 index 0000000000000000000000000000000000000000..24c27fefda083bbb0c2e15292e4bfdb6ce1dfbd4 GIT binary patch literal 3447 zcmV--4T$oIP)4Tx07wm;mUmPX*B8g%%xo{TU6vwc>AklFq%OTkl_mFQv@x1^BM1TV}0C2duqR=S6Xn?LjUp6xrb&~O43j*Nv zEr418u3H3zGns$s|L;SQD-ufpfWpxLJ03rmi*g~#S@{x?OrJ!Vo{}kJ7$ajbnjp%m zGEV!%=70KpVow?KvV}a4moSaFCQKV= zXBIPnpP$8-NG!rR+)R#`$7JVZi#Wn10DSspSrkx`)s~4C+0n+?(b2-z5-tDd^^cpM zz5W?wz5V3zGUCskL5!X++LzcbT23thtSPiMTfS&1I{|204}j|3FPi>70OSh+Xzlyz zdl<5LNtZ}OE>>3g`T3RtKG#xK(9i3CI(+v0d-&=+OWAp!Ysd8Ar*foO5~i%E+?=c& zshF87;&Ay)i~kOm zCIB-Z!^JGdti+UJsxgN!t(Y#%b<8kk67vyD#cE*9urAm@Y#cTXn~yERR$}Y1E!Yd# zo7hq8Ya9;8z!~A3Z~?e@Tn26#t`xT$*Ni)h>&K1Yrto;Y8r}@=h7ZGY@Dh9xekcA2 z{tSKqKZ<`tAQQ9+wgf*y0zpVvOQ<9qCY&Y=5XJ~ILHOG0j2XwBQ%7jM`P2tv~{#P+6CGu9Y;5!2hua>CG_v;z4S?CC1rc%807-x z8s$^ULkxsr$OvR)G0GUn7`GVjR5Vq*RQM{JRGL%DRgX~5SKp(4L49HleU9rK?wsN|$L8GCfHh1tA~lw29MI^|n9|hJ z^w$(=?$kW5IibbS^3=-Es?a*EHLgw5cGnhYS7@Kne#%s4dNH$@Rm?8tq>hG8fR0pW zzfP~tjINRHeBHIW&AJctNO~;2RJ{tlPQ6KeZT(RF<@$~KcMXUJEQ54|9R}S7(}qTd zv4$HA+YFx=sTu_uEj4O1x^GN1_Ap*-Tx)#81ZToB$u!w*a?KPrbudjgtugI0gUuYx z1ZKO<`pvQC&gMe%TJu2*iiMX&o<*a@uqDGX#B!}=o8@yWeX9hktybMuAFUm%v#jf^ z@7XBX1lg>$>9G0T*3_13TVs2}j%w#;x5}>F?uEUXJ>Pzh{cQ)DL#V?BhfaqNj!uqZ z$0o;dCw-@6r(I5iEIKQkRm!^LjCJ;QUgdn!`K^nii^S!a%Wtk0u9>cfU7yS~n#-SC zH+RHM*Nx-0-)+d9>7MMq&wa>4$AjZh>+#4_&y(j_?>XjW;+5fb#Ot}YwYS*2#e16V z!d}5X>x20C`xN{1`YQR(_pSDQ=%?$K=GW*q>F?mb%>QfvHXt})YrtTjW*|4PA#gIt zDQHDdS1=_wD!4lMQHW`XIHV&K4h;(37J7f4!93x-wlEMD7`83!LAX));_x3Ma1r4V zH4%>^Z6cRPc1O{olA;bry^i*dE{nc5-*~=serJq)Okzw!%yg_zYWi`#ol25V;v^kU#wN!mA5MPH z3FFjqrcwe^cBM>m+1wr6XFN|{1#g`1#xLiOrMjh-r#?w@OWT$Wgg6&&5F%x&L(6hXP*!%2{VOVIa)adIsGCtQITk9vCHD^izmgw;`&@D zcVTY3gpU49^+=7S>!rha?s+wNZ}MaEj~6Hw2n%|am@e70WNfM5(r=exmT{MLF4tMU zX8G_6uNC`OLMu~NcCOM}Rk&(&wg2ivYe;J{*Zj2BdTsgISLt?eJQu}$~QLORDCnMIdyYynPb_W zEx0YhEw{FMY&}%2SiZD;WLxOA)(U1tamB0cN!u@1+E?z~LE0hRF;o>&)xJ}I=a!xC ztJAA*)_B)6@6y<{Y1i~_-tK`to_m`1YVIxB`);3L-|hYW`&(-bYby`n4&)tpTo+T< z{VnU;hI;k-lKKw^g$IWYMIP#EaB65ctZ}%k5pI+=jvq-pa_u{x@7kLzn)Wv{noEv? zqtc^Kzfb=D*0JDYoyS?nn|?6(VOI;SrMMMpUD7()mfkkh9^c-7BIrbChiga6kCs0k zJgIZC=9KcOveTr~g{NoFEIl)IR&;jaT-v#j&ZN$J=i|=b=!)p-y%2oi(nY_E=exbS z&s=i5bn>#xz3Ke>~2=f&N;yEFGz-^boBexUH6@}b7V+Mi8+ZXR+R zIyLMw-18{v(Y+Dw$g^K^e|bMz_?Y^*a!h-y;fd{&ljDBl*PbqTI{HlXY-Xb9SH)j< zJvV;-!*8Cy^-RW1j=m7TnEk!oscC6Ok(H4{Y6aD%MK}gQxhM)oT1U9I2r9_uLny69 zB(%sspv4G51`@SMsGU|&DT#tDG!zw|)9_~A%)9q=?wg!kb>Q;O=kJ~KyXOKTLgi#Y zRP^osiVh6>`}y`91GZ$eTRaLKU;~bJcZ+l; z6Xr6F24QhV7KYoKNmpVRJ}lPtbqq}mfWyiF8$-#924~|jVq_tk zm}{9j+=;InAza@qu7tmgLYxRN-^7=s$Kxc5cV`Wams0w@LhC@IgldI~0#_UUzy5-ANpqN4lx z3xE=5{31d_Ea1nga#wWV;_$dXG5--~*LgZ4r}+q7m`hD>(?Dj^ytbZ)kE=Q9x}KD7UMYPxJf*y%QgoHFSRx{c z5nWT+#1KS-{gvf=M_L8vI|KS-MfB5CCFWy9OlJ4|NI!eO{O>92J0ifTo>S)b=lXvg Z*dOOSw(A)Zay0+|002ovPDHLkV1k~6kmmpZ literal 0 HcmV?d00001 diff --git a/web/install/footer.php b/web/install/footer.php new file mode 100644 index 000000000..2dbe991d4 --- /dev/null +++ b/web/install/footer.php @@ -0,0 +1,42 @@ +. */ +/* */ +/*************************************************************************************/ +?> + + + + + +
+ + + + + \ No newline at end of file diff --git a/web/install/header.php b/web/install/header.php new file mode 100644 index 000000000..983fa51ce --- /dev/null +++ b/web/install/header.php @@ -0,0 +1,59 @@ +. */ +/* */ +/*************************************************************************************/ +session_start(); +include 'bootstrap.php'; +?> + + + + Installation + + + + + +
+
+
+
+
Version undefined
+
+
+
+
+
+
+
+
+
+

Thelia installation wizard

+
+
    +
  • 1Welcome
  • +
  • 2Checking permissions
  • +
  • 3Database connection
  • +
  • 4Database selection
  • +
  • 5General information
  • +
  • 6Thanks
  • +
+
\ No newline at end of file diff --git a/web/install/index.php b/web/install/index.php new file mode 100644 index 000000000..884ca11b7 --- /dev/null +++ b/web/install/index.php @@ -0,0 +1,39 @@ +. */ +/* */ +/*************************************************************************************/ +?> + +
+

+Welcome in the Thelia installation wizard. +

+

+We will guide you throughout this process to install any application on your system. +

+
+ + \ No newline at end of file diff --git a/web/install/permission.php b/web/install/permission.php new file mode 100644 index 000000000..fca995457 --- /dev/null +++ b/web/install/permission.php @@ -0,0 +1,56 @@ +. */ +/* */ +/*************************************************************************************/ +?> +getContainer()->get('thelia.translator')); +$isValid = $checkPermission->exec(); +$validationMessage = $checkPermission->getValidationMessages(); +$_SESSION['install']['return_step'] = 'permission.php'; +$_SESSION['install']['continue'] = $isValid; +$_SESSION['install']['current_step'] = 'permission.php'; +$_SESSION['install']['step'] = 2; +?> +
+

Checking permissions

+
    + $data): ?> +
  • + + +
  • + +
+ +
+
+ + Continue + + refresh + +
+ \ No newline at end of file diff --git a/web/install/script.js b/web/install/script.js new file mode 100644 index 000000000..b26e7612e --- /dev/null +++ b/web/install/script.js @@ -0,0 +1,1999 @@ +/** + * bootstrap.js v3.0.0 by @fat and @mdo + * Copyright 2013 Twitter Inc. + * http://www.apache.org/licenses/LICENSE-2.0 + */ +if (!jQuery) { throw new Error("Bootstrap requires jQuery") } + +/* ======================================================================== + * Bootstrap: transition.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#transitions + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) + // ============================================================ + + function transitionEnd() { + var el = document.createElement('bootstrap') + + var transEndEventNames = { + 'WebkitTransition' : 'webkitTransitionEnd' + , 'MozTransition' : 'transitionend' + , 'OTransition' : 'oTransitionEnd otransitionend' + , 'transition' : 'transitionend' + } + + for (var name in transEndEventNames) { + if (el.style[name] !== undefined) { + return { end: transEndEventNames[name] } + } + } + } + + // http://blog.alexmaccaw.com/css-transitions + $.fn.emulateTransitionEnd = function (duration) { + var called = false, $el = this + $(this).one($.support.transition.end, function () { called = true }) + var callback = function () { if (!called) $($el).trigger($.support.transition.end) } + setTimeout(callback, duration) + return this + } + + $(function () { + $.support.transition = transitionEnd() + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: alert.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#alerts + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // ALERT CLASS DEFINITION + // ====================== + + var dismiss = '[data-dismiss="alert"]' + var Alert = function (el) { + $(el).on('click', dismiss, this.close) + } + + Alert.prototype.close = function (e) { + var $this = $(this) + var selector = $this.attr('data-target') + + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 + } + + var $parent = $(selector) + + if (e) e.preventDefault() + + if (!$parent.length) { + $parent = $this.hasClass('alert') ? $this : $this.parent() + } + + $parent.trigger(e = $.Event('close.bs.alert')) + + if (e.isDefaultPrevented()) return + + $parent.removeClass('in') + + function removeElement() { + $parent.trigger('closed.bs.alert').remove() + } + + $.support.transition && $parent.hasClass('fade') ? + $parent + .one($.support.transition.end, removeElement) + .emulateTransitionEnd(150) : + removeElement() + } + + + // ALERT PLUGIN DEFINITION + // ======================= + + var old = $.fn.alert + + $.fn.alert = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.alert') + + if (!data) $this.data('bs.alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.alert.Constructor = Alert + + + // ALERT NO CONFLICT + // ================= + + $.fn.alert.noConflict = function () { + $.fn.alert = old + return this + } + + + // ALERT DATA-API + // ============== + + $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: button.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#buttons + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // BUTTON PUBLIC CLASS DEFINITION + // ============================== + + var Button = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Button.DEFAULTS, options) + } + + Button.DEFAULTS = { + loadingText: 'loading...' + } + + Button.prototype.setState = function (state) { + var d = 'disabled' + var $el = this.$element + var val = $el.is('input') ? 'val' : 'html' + var data = $el.data() + + state = state + 'Text' + + if (!data.resetText) $el.data('resetText', $el[val]()) + + $el[val](data[state] || this.options[state]) + + // push to event loop to allow forms to submit + setTimeout(function () { + state == 'loadingText' ? + $el.addClass(d).attr(d, d) : + $el.removeClass(d).removeAttr(d); + }, 0) + } + + Button.prototype.toggle = function () { + var $parent = this.$element.closest('[data-toggle="buttons"]') + + if ($parent.length) { + var $input = this.$element.find('input') + .prop('checked', !this.$element.hasClass('active')) + .trigger('change') + if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') + } + + this.$element.toggleClass('active') + } + + + // BUTTON PLUGIN DEFINITION + // ======================== + + var old = $.fn.button + + $.fn.button = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.button') + var options = typeof option == 'object' && option + + if (!data) $this.data('bs.button', (data = new Button(this, options))) + + if (option == 'toggle') data.toggle() + else if (option) data.setState(option) + }) + } + + $.fn.button.Constructor = Button + + + // BUTTON NO CONFLICT + // ================== + + $.fn.button.noConflict = function () { + $.fn.button = old + return this + } + + + // BUTTON DATA-API + // =============== + + $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + $btn.button('toggle') + e.preventDefault() + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: carousel.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#carousel + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // CAROUSEL CLASS DEFINITION + // ========================= + + var Carousel = function (element, options) { + this.$element = $(element) + this.$indicators = this.$element.find('.carousel-indicators') + this.options = options + this.paused = + this.sliding = + this.interval = + this.$active = + this.$items = null + + this.options.pause == 'hover' && this.$element + .on('mouseenter', $.proxy(this.pause, this)) + .on('mouseleave', $.proxy(this.cycle, this)) + } + + Carousel.DEFAULTS = { + interval: 5000 + , pause: 'hover' + , wrap: true + } + + Carousel.prototype.cycle = function (e) { + e || (this.paused = false) + + this.interval && clearInterval(this.interval) + + this.options.interval + && !this.paused + && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) + + return this + } + + Carousel.prototype.getActiveIndex = function () { + this.$active = this.$element.find('.item.active') + this.$items = this.$active.parent().children() + + return this.$items.index(this.$active) + } + + Carousel.prototype.to = function (pos) { + var that = this + var activeIndex = this.getActiveIndex() + + if (pos > (this.$items.length - 1) || pos < 0) return + + if (this.sliding) return this.$element.one('slid', function () { that.to(pos) }) + if (activeIndex == pos) return this.pause().cycle() + + return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) + } + + Carousel.prototype.pause = function (e) { + e || (this.paused = true) + + if (this.$element.find('.next, .prev').length && $.support.transition.end) { + this.$element.trigger($.support.transition.end) + this.cycle(true) + } + + this.interval = clearInterval(this.interval) + + return this + } + + Carousel.prototype.next = function () { + if (this.sliding) return + return this.slide('next') + } + + Carousel.prototype.prev = function () { + if (this.sliding) return + return this.slide('prev') + } + + Carousel.prototype.slide = function (type, next) { + var $active = this.$element.find('.item.active') + var $next = next || $active[type]() + var isCycling = this.interval + var direction = type == 'next' ? 'left' : 'right' + var fallback = type == 'next' ? 'first' : 'last' + var that = this + + if (!$next.length) { + if (!this.options.wrap) return + $next = this.$element.find('.item')[fallback]() + } + + this.sliding = true + + isCycling && this.pause() + + var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) + + if ($next.hasClass('active')) return + + if (this.$indicators.length) { + this.$indicators.find('.active').removeClass('active') + this.$element.one('slid', function () { + var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) + $nextIndicator && $nextIndicator.addClass('active') + }) + } + + if ($.support.transition && this.$element.hasClass('slide')) { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $next.addClass(type) + $next[0].offsetWidth // force reflow + $active.addClass(direction) + $next.addClass(direction) + $active + .one($.support.transition.end, function () { + $next.removeClass([type, direction].join(' ')).addClass('active') + $active.removeClass(['active', direction].join(' ')) + that.sliding = false + setTimeout(function () { that.$element.trigger('slid') }, 0) + }) + .emulateTransitionEnd(600) + } else { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $active.removeClass('active') + $next.addClass('active') + this.sliding = false + this.$element.trigger('slid') + } + + isCycling && this.cycle() + + return this + } + + + // CAROUSEL PLUGIN DEFINITION + // ========================== + + var old = $.fn.carousel + + $.fn.carousel = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.carousel') + var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) + var action = typeof option == 'string' ? option : options.slide + + if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) + if (typeof option == 'number') data.to(option) + else if (action) data[action]() + else if (options.interval) data.pause().cycle() + }) + } + + $.fn.carousel.Constructor = Carousel + + + // CAROUSEL NO CONFLICT + // ==================== + + $.fn.carousel.noConflict = function () { + $.fn.carousel = old + return this + } + + + // CAROUSEL DATA-API + // ================= + + $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { + var $this = $(this), href + var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + var options = $.extend({}, $target.data(), $this.data()) + var slideIndex = $this.attr('data-slide-to') + if (slideIndex) options.interval = false + + $target.carousel(options) + + if (slideIndex = $this.attr('data-slide-to')) { + $target.data('bs.carousel').to(slideIndex) + } + + e.preventDefault() + }) + + $(window).on('load', function () { + $('[data-ride="carousel"]').each(function () { + var $carousel = $(this) + $carousel.carousel($carousel.data()) + }) + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: collapse.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#collapse + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // COLLAPSE PUBLIC CLASS DEFINITION + // ================================ + + var Collapse = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Collapse.DEFAULTS, options) + this.transitioning = null + + if (this.options.parent) this.$parent = $(this.options.parent) + if (this.options.toggle) this.toggle() + } + + Collapse.DEFAULTS = { + toggle: true + } + + Collapse.prototype.dimension = function () { + var hasWidth = this.$element.hasClass('width') + return hasWidth ? 'width' : 'height' + } + + Collapse.prototype.show = function () { + if (this.transitioning || this.$element.hasClass('in')) return + + var startEvent = $.Event('show.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var actives = this.$parent && this.$parent.find('> .panel > .in') + + if (actives && actives.length) { + var hasData = actives.data('bs.collapse') + if (hasData && hasData.transitioning) return + actives.collapse('hide') + hasData || actives.data('bs.collapse', null) + } + + var dimension = this.dimension() + + this.$element + .removeClass('collapse') + .addClass('collapsing') + [dimension](0) + + this.transitioning = 1 + + var complete = function () { + this.$element + .removeClass('collapsing') + .addClass('in') + [dimension]('auto') + this.transitioning = 0 + this.$element.trigger('shown.bs.collapse') + } + + if (!$.support.transition) return complete.call(this) + + var scrollSize = $.camelCase(['scroll', dimension].join('-')) + + this.$element + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + [dimension](this.$element[0][scrollSize]) + } + + Collapse.prototype.hide = function () { + if (this.transitioning || !this.$element.hasClass('in')) return + + var startEvent = $.Event('hide.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var dimension = this.dimension() + + this.$element + [dimension](this.$element[dimension]()) + [0].offsetHeight + + this.$element + .addClass('collapsing') + .removeClass('collapse') + .removeClass('in') + + this.transitioning = 1 + + var complete = function () { + this.transitioning = 0 + this.$element + .trigger('hidden.bs.collapse') + .removeClass('collapsing') + .addClass('collapse') + } + + if (!$.support.transition) return complete.call(this) + + this.$element + [dimension](0) + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + } + + Collapse.prototype.toggle = function () { + this[this.$element.hasClass('in') ? 'hide' : 'show']() + } + + + // COLLAPSE PLUGIN DEFINITION + // ========================== + + var old = $.fn.collapse + + $.fn.collapse = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.collapse') + var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) + + if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.collapse.Constructor = Collapse + + + // COLLAPSE NO CONFLICT + // ==================== + + $.fn.collapse.noConflict = function () { + $.fn.collapse = old + return this + } + + + // COLLAPSE DATA-API + // ================= + + $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) { + var $this = $(this), href + var target = $this.attr('data-target') + || e.preventDefault() + || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 + var $target = $(target) + var data = $target.data('bs.collapse') + var option = data ? 'toggle' : $this.data() + var parent = $this.attr('data-parent') + var $parent = parent && $(parent) + + if (!data || !data.transitioning) { + if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed') + $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') + } + + $target.collapse(option) + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: dropdown.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#dropdowns + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // DROPDOWN CLASS DEFINITION + // ========================= + + var backdrop = '.dropdown-backdrop' + var toggle = '[data-toggle=dropdown]' + var Dropdown = function (element) { + var $el = $(element).on('click.bs.dropdown', this.toggle) + } + + Dropdown.prototype.toggle = function (e) { + var $this = $(this) + + if ($this.is('.disabled, :disabled')) return + + var $parent = getParent($this) + var isActive = $parent.hasClass('open') + + clearMenus() + + if (!isActive) { + if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { + // if mobile we we use a backdrop because click events don't delegate + $(' -
+
From 072dec5cc93b010beedf91b13052f7a2ccc0e84c Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 17 Sep 2013 15:43:15 +0200 Subject: [PATCH 9/9] nstall step Please enter the commit message for your changes. Lines starting --- core/lib/Thelia/Core/Thelia.php | 39 ++++++++---------- core/lib/Thelia/Install/Database.php | 2 +- core/lib/Thelia/Model/Admin.php | 2 - install/thelia.sqlite | Bin 262144 -> 0 bytes web/install/config.php | 22 +++++------ web/install/end.php | 57 +++++++++++++++++++++++++++ web/install/footer.php | 1 - 7 files changed, 85 insertions(+), 38 deletions(-) delete mode 100644 install/thelia.sqlite create mode 100644 web/install/end.php diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index b446af221..dbfe48e17 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -69,29 +69,22 @@ class Thelia extends Kernel protected function initPropel() { - if (defined('THELIA_INSTALL_MODE') === true) { - $serviceContainer = Propel::getServiceContainer(); - $serviceContainer->setAdapterClass('thelia', 'sqlite'); - $manager = new ConnectionManagerSingle(); - $manager->setConfiguration(array( - "classname" => "\Propel\Runtime\Connection\PropelPDO", - "dsn" => "sqlite:".THELIA_ROOT . "/install/thelia.sqlite" - )); - $serviceContainer->setConnectionManager('thelia', $manager); - } else { - $definePropel = new DefinePropel(new DatabaseConfiguration(), - Yaml::parse(THELIA_ROOT . '/local/config/database.yml')); - $serviceContainer = Propel::getServiceContainer(); - $serviceContainer->setAdapterClass('thelia', 'mysql'); - $manager = new ConnectionManagerSingle(); - $manager->setConfiguration($definePropel->getConfig()); - $serviceContainer->setConnectionManager('thelia', $manager); - $con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME); - $con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true); - if ($this->isDebug()) { - $serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance()); - $con->useDebug(true); - } + if (file_exists(THELIA_ROOT . '/local/config/database.yml') === false) { + return ; + } + + $definePropel = new DefinePropel(new DatabaseConfiguration(), + Yaml::parse(THELIA_ROOT . '/local/config/database.yml')); + $serviceContainer = Propel::getServiceContainer(); + $serviceContainer->setAdapterClass('thelia', 'mysql'); + $manager = new ConnectionManagerSingle(); + $manager->setConfiguration($definePropel->getConfig()); + $serviceContainer->setConnectionManager('thelia', $manager); + $con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME); + $con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true); + if ($this->isDebug()) { + $serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance()); + $con->useDebug(true); } diff --git a/core/lib/Thelia/Install/Database.php b/core/lib/Thelia/Install/Database.php index 34ca97dae..648a6431a 100644 --- a/core/lib/Thelia/Install/Database.php +++ b/core/lib/Thelia/Install/Database.php @@ -93,7 +93,7 @@ class Database */ public function createDatabase($dbName) { - $this->connection->query( + $this->connection->exec( sprintf( "CREATE DATABASE IF NOT EXISTS %s CHARACTER SET utf8", $dbName diff --git a/core/lib/Thelia/Model/Admin.php b/core/lib/Thelia/Model/Admin.php index 67f6a5928..2712eb95c 100755 --- a/core/lib/Thelia/Model/Admin.php +++ b/core/lib/Thelia/Model/Admin.php @@ -34,8 +34,6 @@ class Admin extends BaseAdmin implements UserInterface public function setPassword($password) { - \Thelia\Log\Tlog::getInstance()->debug($password); - if ($this->isNew() && ($password === null || trim($password) == "")) { throw new \InvalidArgumentException("customer password is mandatory on creation"); } diff --git a/install/thelia.sqlite b/install/thelia.sqlite deleted file mode 100644 index 65d4cb6a9fb8af1ef1ccd4edbb66f4072e3e8d00..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 262144 zcmeI*&u=4F9RTpL_eXw+DE*; zVeaw2gQ@+`f=~bU>2H4im!Hi%{?GnrkAHtzhiSEM%U%Kd3)!$BkjH7k3)_wbtFYI};aEOO>cpjlyc_hpSOI z(KK6_4U?nQ3|Gq4=-sFime;Fcd2@Aj@wlPgZPeRw_(7?%^j@h_xK|ACN6V$n)oQp9 zcWRp(3m5u#>bqyXzkRPb8s$M{Wvx`%3V#%Bg@smgaWv{l-JlNR<|==veB3i_iN2~yFP3W!s<$SD_PEy z-|EFle6yCk)w{Z~7Hw2ZYY#>(!@cHHEwjZZA6}oz-MW?e<%`D@?Rw`?`nfSdkkb@RViPJF|N8-gv8}Db-HiVm{urry+yZ?&XbXdBgPdrvRbV5d9m*E`Mrmvw56#_2yDe%Ts6d&L{ixw5}_>)KTA&YjHB zYokrx?QFLmjh+@~#p@I6oNt`9R?_Zz*| zUb=D5S2uR*d)<6kjecBBqLM@hqi)09QDyN#_Ga$YS2J73b3VDV`|-!a7-;%1q^6c_s7Y;GDxK(d@(sC)r<2{QS)wPTbw$1WNjYqa?z{PTcrO zVX(g!cee}qMX=e==Aorh-4Mw};Q}J!-koy`MhrE2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5V+z3U&~&*ooNhvy|~lZ&rWBq-O9A%Lf|{u7lLoRmzT97sEH-&b$zO^E7TciCgZ~JAeFbz183DZTD)+ zmCGXMlDxAAe+~}*o}3&62oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkL{ zY6*NjI}^M-Kb4sdg3XQl-}?SP3jh4WuRkhg=QBzD%QG`GK@e?LK0o^1T$=ac)kgetConnection(); $connection->exec("SET NAMES UTF8"); @@ -41,10 +41,6 @@ if (!$err) { $database->createDatabase($_SESSION['install']['database']); } - if (!$connection->exec(sprintf('use %s', $_SESSION['install']['database']))) { - header('location: bdd.php?err=1'); - } - $database->insertSql($_SESSION['install']['database']); if(!file_exists(THELIA_ROOT . "/local/config/database.yml")) { @@ -75,6 +71,8 @@ if (!$err) { } } +$_SESSION['install']['step'] = $step; + ?>
@@ -98,13 +96,15 @@ if (!$err) {
-
- - +
+
+ +
+
- -
+ + diff --git a/web/install/end.php b/web/install/end.php new file mode 100644 index 000000000..a86c2d903 --- /dev/null +++ b/web/install/end.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ +$step=6; +include "header.php"; + +if($_SESSION['install']['step'] != $step && (empty($_POST['admin_login']) || empty($_POST['admin_password']) || ($_POST['admin_password'] != $_POST['admin_password_verif']))) { + header('location: config.php?err=1'); +} + +if($_SESSION['install']['step'] == 5) { + $admin = new \Thelia\Model\Admin(); + $admin->setLogin($_POST['admin_login']) + ->setPassword($_POST['admin_password']) + ->setFirstname('admin') + ->setLastname('admin') + ->save(); + + $config = new \Thelia\Model\Config(); + $config->setName('contact_email') + ->setValue($_POST['email_contact']) + ->save(); + ; +} + +$_SESSION['install']['step'] = $step; +?> + +
+

+ Thank you have installed Thelia +

+

+ Don't forget to delete the web/install directory. +

+ +
+ \ No newline at end of file diff --git a/web/install/footer.php b/web/install/footer.php index 2dbe991d4..29e87f2c2 100644 --- a/web/install/footer.php +++ b/web/install/footer.php @@ -37,6 +37,5 @@
- \ No newline at end of file