Commit 122b1635 authored by rMalie's avatar rMalie

[+] Install: new installer reworked from scratch

parent a2c30014
2007-2011 PrestaShop
NOTICE OF LICENSE
This source file is subject to the Open Software License (OSL 3.0)
that is bundled with this package in the file LICENSE.txt.
It is also available through the world-wide-web at this URL:
http://opensource.org/licenses/osl-3.0.php
If you did not receive a copy of the license and are unable to
obtain it through the world-wide-web, please send an email
to [email protected] so we can send you a copy immediately.
DISCLAIMER
Do not edit or add to this file if you wish to upgrade PrestaShop to newer
versions in the future. If you wish to customize PrestaShop for your
needs please refer to http://www.prestashop.com for more information.
@author PrestaShop SA <[email protected]>
@copyright 2007-2011 PrestaShop SA
@license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
International Registered Trademark & Property of PrestaShop SA
PREPARATION
===========
To install PrestaShop, you need a remote web server or on your computer (MAMP), with access to a database like MySQL.
You'll need access to phpMyAdmin to create a database and to indicate the information in the database in the installer.
If you do not host and unable to create your store, we offer a turnkey store, which lets you create your online store in less than 10 minutes without any technical knowledge.
We invite you to visit:
http://www.prestabox.com/
INSTALLATION
============
Simply go to your PrestaShop web directory and use installer :-)
If you have any PHP error, perhaps you don't have PHP5 or you need to activate it on your web host.
Please go to our forum to find pre-installation settings (PHP 5, htaccess) for certain hosting services (1&1, Free, Lycos, OVH, Infomaniak, Amen, GoDaddy, etc).
English webhost specifics settings :
http://www.prestashop.com/forums/viewthread/2946/installation_configuration___upgrade/preinstallation_settings_php_5_htaccess_for_certain_hosting_services
If you don't find any solution to launch installer, please post on our forum :
http://www.prestashop.com/forums/viewforum/7/installation_configuration___upgrade
There are always solutions for your issues ;-)
DOCUMENTATION
=============
For any extra documentation (how-to), please read our wiki :
http://www.prestashop.com/wiki/
FORUMS
======
You can also discute, help and contribute with PrestaShop community on our forums :
http://www.prestashop.com/forums/
Thanks for downloading and using PrestaShop e-commerce open-source solution !
==========================
= The PrestaTeam' =
= www.PrestaShop.com =
==========================
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
abstract class InstallControllerHttp
{
/**
* @var array List of installer steps
*/
protected static $steps = array('welcome', 'system', 'database', 'configure', 'process');
protected static $instances = array();
/**
* @var string Current step
*/
public $step;
/**
* @var array List of errors
*/
public $errors = array();
/**
* @var InstallController
*/
public $controller;
/**
* @var InstallSession
*/
public $session;
/**
* @var InstallLanguages
*/
public $language;
/**
* @var bool If false, disable next button access
*/
public $next_button = true;
/**
* @var InstallAbstractModel
*/
public $model;
/**
* @var array Magic vars
*/
protected $__vars = array();
/**
* Process form to go to next step
*/
abstract public function processNextStep();
/**
* Validate current step
*/
abstract public function validate();
/**
* Display current step view
*/
abstract public function display();
final public static function execute()
{
// Include all controllers
foreach (self::$steps as $step)
{
if (!file_exists(_PS_INSTALL_CONTROLLERS_PATH_.'http/'.$step.'.php'))
throw new PrestashopInstallerException("Controller file 'http/{$step}.php' not found");
require_once _PS_INSTALL_CONTROLLERS_PATH_.'http/'.$step.'.php';
$classname = 'InstallControllerHttp'.$step;
self::$instances[$step] = new $classname($step);
}
$session = InstallSession::getInstance();
if (!$session->last_step || !in_array($session->last_step, self::$steps))
$session->last_step = self::$steps[0];
// Get current step (check first if step is changed, then take it from session)
if (Tools::getValue('step'))
{
$current_step = Tools::getValue('step');
$session->step = $current_step;
}
else
$current_step = (isset($session->step)) ? $session->step : self::$steps[0];
if (!in_array($current_step, self::$steps))
$current_step = self::$steps[0];
// Validate all steps until current step. If a step is not valid, use it as current step.
foreach (self::$steps as $check_step)
{
// Do not validate current step
if ($check_step == $current_step)
break;
if (!self::$instances[$check_step]->validate())
{
$current_step = $check_step;
$session->step = $current_step;
$session->last_step = $current_step;
break;
}
}
// Submit form to go to next step
if (Tools::getValue('submitNext'))
{
self::$instances[$current_step]->processNextStep();
// If current step is validated, let's go to next step
if (self::$instances[$current_step]->validate())
$current_step = self::$instances[$current_step]->findNextStep();
$session->step = $current_step;
// Change last step
if (self::getStepOffset($current_step) > self::getStepOffset($session->last_step))
$session->last_step = $current_step;
}
// Go to previous step
else if (Tools::getValue('submitPrevious') && $current_step != self::$steps[0])
{
$current_step = self::$instances[$current_step]->findPreviousStep($current_step);
$session->step = $current_step;
}
self::$instances[$current_step]->process();
self::$instances[$current_step]->display();
}
final public function __construct($step)
{
$this->step = $step;
$this->session = InstallSession::getInstance();
// Set current language
$this->language = InstallLanguages::getInstance();
$lang = (isset($this->session->lang)) ? $this->session->lang : 'en';
if (!in_array($lang, $this->language->getIsoList()))
$lang = 'en';
$this->language->setLanguage($lang);
$this->init();
}
/**
* Initialize model
*/
public function init()
{
}
public function process()
{
}
/**
* Get steps list
*
* @return array
*/
public function getSteps()
{
return self::$steps;
}
public function getLastStep()
{
return $this->session->last_step;
}
/**
* Find offset of a step by name
*
* @param string $step Step name
* @return int
*/
static public function getStepOffset($step)
{
static $flip = null;
if (is_null($flip))
$flip = array_flip(self::$steps);