[+] Install: new installer reworked from scratch

This commit is contained in:
rMalie
2011-11-10 17:32:47 +00:00
parent a2c3001445
commit 122b163553
867 changed files with 39069 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
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 license@prestashop.com 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 <contact@prestashop.com>
@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 =
==========================
+410
View File
@@ -0,0 +1,410 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @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);
return $flip[$step];
}
/**
* Make a HTTP redirection to a step
*
* @param string $step
*/
public function redirect($step)
{
header('location: index.php?step='.$step);
exit;
}
/**
* Get translated string
*
* @param string $str String to translate
* @param ... All other params will be used with sprintf
* @return string
*/
public function l($str)
{
return call_user_func_array(array($this->language, 'l'), func_get_args());
}
/**
* Find previous step
*
* @param string $step
*/
public function findPreviousStep()
{
return (isset(self::$steps[$this->getStepOffset($this->step) - 1])) ? self::$steps[$this->getStepOffset($this->step) - 1] : false;
}
/**
* Find next step
*
* @param string $step
*/
public function findNextStep()
{
return (isset(self::$steps[$this->getStepOffset($this->step) + 1])) ? self::$steps[$this->getStepOffset($this->step) + 1] : false;
}
/**
* Check if current step is first step in list of steps
*
* @return bool
*/
public function isFirstStep()
{
return self::getStepOffset($this->step) == 0;
}
/**
* Check if current step is last step in list of steps
*
* @return bool
*/
public function isLastStep()
{
return self::getStepOffset($this->step) == (count(self::$steps) - 1);
}
/**
* Check is given step is already finished
*
* @param string $step
* @return bool
*/
public function isStepFinished($step)
{
return self::getStepOffset($step) < self::getStepOffset($this->getLastStep());
}
/**
* Get telephone used for this language
*
* @return string
*/
public function getPhone()
{
return $this->language->getInformation('phone', false);
}
/**
* Get link to documentation for this language
*
* Enter description here ...
*/
public function getDocumentationLink()
{
return $this->language->getInformation('documentation');
}
/**
* Get link to forum for this language
*
* Enter description here ...
*/
public function getForumLink()
{
return $this->language->getInformation('forum');
}
/**
* Get link to blog for this language
*
* Enter description here ...
*/
public function getBlogLink()
{
return $this->language->getInformation('blog');
}
/**
* Get link to support for this language
*
* Enter description here ...
*/
public function getSupportLink()
{
return $this->language->getInformation('support');
}
/**
* Send AJAX response in JSON format {success: bool, message: string}
*
* @param bool $success
* @param string $message
*/
public function ajaxJsonAnswer($success, $message = '')
{
die(Tools::jsonEncode(array(
'success' => (bool)$success,
'message' => $message,
)));
}
/**
* Display a template
*
* @param string $template Template name
* @param bool $get_output Is true, return template html
* @return string
*/
public function displayTemplate($template, $get_output = false, $path = null)
{
if (!$path)
$path = _PS_INSTALL_PATH_.'theme/views/';
if (!file_exists($path.$template.'.phtml'))
throw new PrestashopInstallerException("Template '{$template}.phtml' not found");
if ($get_output)
ob_start();
include($path.$template.'.phtml');
if ($get_output)
{
$content = ob_get_contents();
ob_end_clean();
return $content;
}
}
public function &__get($varname)
{
if (isset($this->__vars[$varname]))
$ref = &$this->__vars[$varname];
else
{
$null = null;
$ref = &$null;
}
return $ref;
}
public function __set($varname, $value)
{
$this->__vars[$varname] = $value;
}
public function __isset($varname)
{
return isset($this->__vars[$varname]);
}
public function __unset($varname)
{
unset($this->__vars[$varname]);
}
}
+30
View File
@@ -0,0 +1,30 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @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
*/
class PrestashopInstallerException extends PrestashopException
{
}
File diff suppressed because it is too large Load Diff
+122
View File
@@ -0,0 +1,122 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @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
*/
class InstallLanguage
{
/**
* @var string Current language folder
*/
protected $path;
/**
* @var string Current language iso
*/
protected $iso;
/**
* @var array Cache list of installer translations for this language
*/
protected $data;
protected $fixtures_data;
/**
* @var array Cache list of informations in language.xml file
*/
protected $meta;
/**
* @var array Cache list of countries for this language
*/
protected $countries;
public function __construct($iso)
{
$this->path = _PS_INSTALL_LANGS_PATH_.$iso.'/';
$this->iso = $iso;
}
/**
* Get iso for current language
*
* @return string
*/
public function getIso()
{
return $this->iso;
}
/**
* Get an information from language.xml file (E.g. $this->getMetaInformation('name'))
*
* @param string $key
* @return string
*/
public function getMetaInformation($key)
{
if (!is_array($this->meta))
{
$this->meta = array();
$xml = simplexml_load_file($this->path.'language.xml');
foreach ($xml->children() as $node)
$this->meta[$node->getName()] = (string)$node;
}
return isset($this->meta[$key]) ? $this->meta[$key] : null;
}
public function getTranslation($key, $type = 'translations')
{
if (!is_array($this->data))
$this->data = file_exists($this->path.'install.php') ? include($this->path.'install.php') : array();
return isset($this->data[$type][$key]) ? $this->data[$type][$key] : null;
}
public function getFixtureTranslation($key)
{
if (!is_array($this->fixtures_data))
$this->fixtures_data = file_exists(_PS_INSTALL_FIXTURES_PATH_.'apple/langs/'.$this->iso.'/fixtures.php') ? include(_PS_INSTALL_FIXTURES_PATH_.'apple/langs/'.$this->iso.'/fixtures.php') : array();
return isset($this->fixtures_data[$key]) ? $this->fixtures_data[$key] : null;
}
public function getCountries()
{
if (!is_array($this->countries))
{
$this->countries = array();
if (file_exists($this->path.'data/country.xml'))
{
if ($xml = simplexml_load_file($this->path.'data/country.xml'))
foreach ($xml->country as $country)
$this->countries[strtolower((string)$country['id'])] = (string)$country->name;
}
}
return $this->countries;
}
}
+188
View File
@@ -0,0 +1,188 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @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
*/
class InstallLanguages
{
const DEFAULT_ISO = 'en';
/**
* @var array List of available languages
*/
protected $languages;
/**
* @var string Current language
*/
protected $language;
/**
* @var InstallLanguage Default language (english)
*/
protected $default;
protected static $_instance;
public static function getInstance()
{
if (!self::$_instance)
self::$_instance = new self();
return self::$_instance;
}
public function __construct()
{
// English language is required
if (!file_exists(_PS_INSTALL_LANGS_PATH_.'en/language.xml'))
throw new PrestashopInstallerException('English language is missing');
$this->languages = array(
self::DEFAULT_ISO => new InstallLanguage(self::DEFAULT_ISO),
);
// Load other languages
foreach (scandir(_PS_INSTALL_LANGS_PATH_) as $lang)
if ($lang[0] != '.' && is_dir(_PS_INSTALL_LANGS_PATH_.$lang) && $lang != self::DEFAULT_ISO)
$this->languages[$lang] = new InstallLanguage($lang);
}
/**
* Set current language
*
* @param string $iso Language iso
*/
public function setLanguage($iso)
{
if (!in_array($iso, $this->getIsoList()))
throw new PrestashopInstallerException('Language '.$iso.' not found');
$this->language = $iso;
}
/**
* Get current language
*
* @return string
*/
public function getLanguageIso()
{
return $this->language;
}
/**
* Get current language
*
* @return InstallLanguage
*/
public function getLanguage($iso = null)
{
if (!$iso)
$iso = $this->language;
return $this->languages[$iso];
}
public function getIsoList()
{
return array_keys($this->languages);
}
/**
* Get list of languages iso supported by installer
*
* @return array
*/
public function getLanguages()
{
return $this->languages;
}
/**
* Get translated string
*
* @param string $str String to translate
* @param ... All other params will be used with sprintf
* @return string
*/
public function l($str)
{
$args = func_get_args();
$translation = $this->getLanguage()->getTranslation($args[0]);
if (is_null($translation))
{
$translation = $this->getLanguage(self::DEFAULT_ISO)->getTranslation($args[0]);
if (is_null($translation))
$translation = $args[0];
}
$args[0] = $translation;
return call_user_func_array('sprintf', $args);
}
/**
* Get an information from language (phone, links, etc.)
*
* @param string $key Information identifier
*/
public function getInformation($key, $with_default = true)
{
$information = $this->getLanguage()->getTranslation($key, 'informations');
if (is_null($information) && $with_default)
return $this->getLanguage(self::DEFAULT_ISO)->getTranslation($key, 'informations');
return false;
}
/**
* Get list of countries for current language
*
* @return array
*/
public function getCountries()
{
static $countries = null;
if (is_null($countries))
{
$countries = array();
$countries_lang = $this->getLanguage()->getCountries();
$countries_default = $this->getLanguage(self::DEFAULT_ISO)->getCountries();
$xml = simplexml_load_file(_PS_INSTALL_DATA_PATH_.'xml/country.xml');
foreach ($xml->entities->country as $country)
{
$iso = strtolower((string)$country['iso_code']);
$countries[$iso] = isset($countries_lang[$iso]) ? $countries_lang[$iso] : $countries_default[$iso];
}
}
return $countries;
}
public function getFixtureTranslation($iso, $key)
{
$translation = $this->getLanguage($iso)->getFixtureTranslation($key);
if (is_null($translation))
$translation = $this->getLanguage(self::DEFAULT_ISO)->getFixtureTranslation($key);
return $translation;
}
}
+58
View File
@@ -0,0 +1,58 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @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 InstallAbstractModel
{
/**
* @var InstallLanguages
*/
public $language;
/**
* @var array List of errors
*/
protected $errors = array();
public function __construct()
{
$this->language = InstallLanguages::getInstance();
}
public function setError($errors)
{
if (!is_array($errors))
$errors = array($errors);
foreach ($errors as $error)
$this->errors[] = $error;
}
public function getErrors()
{
return $this->errors;
}
}
+66
View File
@@ -0,0 +1,66 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @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
*/
/**
* Manage session for install script
*/
class InstallSession
{
protected static $_instance;
public static function getInstance()
{
if (!self::$_instance)
self::$_instance = new self();
return self::$_instance;
}
public function __construct()
{
session_start();
}
public function __get($varname)
{
return isset($_SESSION[$varname]) ? $_SESSION[$varname] : null;
}
public function __set($varname, $value)
{
$_SESSION[$varname] = $value;
}
public function __isset($varname)
{
return isset($_SESSION[$varname]);
}
public function __unset($varname)
{
unset($_SESSION[$varname]);
}
}
+123
View File
@@ -0,0 +1,123 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @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
*/
class InstallSqlLoader
{
/**
* @var Db
*/
protected $db;
/**
* @var array List of keywords which will be replaced in queries
*/
protected $metadata = array();
/**
* @var array List of errors during last parsing
*/
protected $errors = array();
/**
* @param Db $db
*/
public function __construct(Db $db = null)
{
if (is_null($db))
$db = Db::getInstance();
$this->db = $db;
}
/**
* Set a list of keywords which will be replaced in queries
*
* @param array $data
*/
public function setMetaData(array $data)
{
foreach ($data as $k => $v)
$this->metadata[$k] = $v;
}
/**
* Parse a SQL file and execute queries
*
* @param string $filename
* @param bool $stop_when_fail
*/
public function parse_file($filename, $stop_when_fail = true)
{
if (!file_exists($filename))
throw new PrestashopInstallerException("File $filename not found");
return $this->parse(file_get_contents($filename), $stop_when_fail);
}
/**
* Parse and execute a list of SQL queries
*
* @param string $content
* @param bool $stop_when_fail
*/
public function parse($content, $stop_when_fail = true)
{
$this->errors = array();
$content = str_replace(array_keys($this->metadata), array_values($this->metadata), $content);
$queries = preg_split('#;\s*[\r\n]+#', $content);
foreach ($queries as $query)
{
$query = trim($query);
if (!$query)
continue;
if (!$this->db->execute($query))
{
$this->errors[] = array(
'errno' => $this->db->getNumberError(),
'error' => $this->db->getMsgError(),
'query' => $query,
);
if ($stop_when_fail)
return false;
}
}
return count($this->errors) ? false : true;
}
/**
* Get list of errors from last parsing
*
* @return array
*/
public function getErrors()
{
return $this->errors;
}
}
File diff suppressed because it is too large Load Diff
+438
View File
@@ -0,0 +1,438 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @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
*/
/**
* Step 4 : configure the shop, admin access and modules preactivations
*/
class InstallControllerHttpConfigure extends InstallControllerHttp
{
/**
* @see InstallAbstractModel::processNextStep()
*/
public function processNextStep()
{
// Save shop configuration
$this->session->shop_name = trim(Tools::getValue('shop_name'));
$this->session->shop_activity = Tools::getValue('shop_activity');
$this->session->shop_country = Tools::getValue('shop_country');
$this->session->shop_timezone = Tools::getValue('shop_timezone');
// Save admin configuration
$this->session->admin_firstname = trim(Tools::getValue('admin_firstname'));
$this->session->admin_lastname = trim(Tools::getValue('admin_lastname'));
$this->session->admin_email = trim(Tools::getValue('admin_email'));
$this->session->send_informations = Tools::getValue('send_informations');
// If password fields are empty, but are already stored in session, do not fill them again
if (!$this->session->admin_password || trim(Tools::getValue('admin_password')))
$this->session->admin_password = trim(Tools::getValue('admin_password'));
if (!$this->session->admin_password_confirm || trim(Tools::getValue('admin_password_confirm')))
$this->session->admin_password_confirm = trim(Tools::getValue('admin_password_confirm'));
// Save partners preactivation configuration
$this->session->partners = array();
$partners = Tools::getValue('partner');
if (is_array($partners))
{
// Check all selected partners and store their fields
$session_partners = array();
foreach ($partners as $partner_id => $state)
$session_partners[$partner_id] = (isset($_POST['partner_fields'][$partner_id])) ? $_POST['partner_fields'][$partner_id] : array();
$this->session->partners = $session_partners;
}
}
/**
* @see InstallAbstractModel::validate()
*/
public function validate()
{
// List of required fields
$required_fields = array('shop_name', 'shop_country', 'shop_timezone', 'admin_firstname', 'admin_lastname', 'admin_email', 'admin_password');
foreach ($required_fields as $field)
if (!$this->session->$field)
$this->errors[$field] = $this->l('Field required');
// Check shop name
if ($this->session->shop_name && !Validate::isGenericName($this->session->shop_name))
$this->errors['shop_name'] = $this->l('Invalid shop name');
// Check admin name
if ($this->session->admin_firstname && !Validate::isGenericName($this->session->admin_firstname))
$this->errors['admin_firstname'] = $this->l('Your firstname contains some invalid characters');
if ($this->session->admin_lastname && !Validate::isGenericName($this->session->admin_lastname))
$this->errors['admin_lastname'] = $this->l('Your lastname contains some invalid characters');
// Check passwords
if ($this->session->admin_password)
{
if (!Validate::isPasswdAdmin($this->session->admin_password))
$this->errors['admin_password'] = $this->l('The password is incorrect (alphanumeric string at least 8 characters)');
else if ($this->session->admin_password != $this->session->admin_password_confirm)
$this->errors['admin_password'] = $this->l('Password and its confirmation are different');
}
// Check email
if ($this->session->admin_email && !Validate::isEmail($this->session->admin_email))
$this->errors['admin_email'] = $this->l('This e-mail address is invalid');
return count($this->errors) ? false : true;
}
public function process()
{
if (Tools::getValue('uploadLogo'))
$this->processUploadLogo();
else if (Tools::getValue('timezoneByIso'))
$this->processTimezoneByIso();
else if (Tools::getValue('getPartners'))
$this->processGetPartners();
else if (Tools::getValue('getPartnersFields'))
$this->processGetPartnersFields();
}
/**
* Process the upload of new logo
*/
public function processUploadLogo()
{
$error = '';
if (isset($_FILES['fileToUpload']))
{
$file = $_FILES['fileToUpload'];
// If error code is not 0, an error occured during upload
if ($file['error'] != 0)
{
$upload_errors = array(
1 => $this->l('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
2 => $this->l('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
3 => $this->l('The uploaded file was only partially uploaded'),
4 => $this->l('No file was uploaded'),
6 => $this->l('Missing a temporary folder'),
7 => $this->l('Failed to write file to disk'),
8 => $this->l('File upload stopped by extension'),
);
if (isset($upload_errors[$file['error']]))
$error = $upload_errors[$file['error']];
else
$error = $this->l('No error code available');
}
// Check if no error during creation of tmp file
else if (!$file['tmp_name'] || $file['tmp_name'] == 'none')
{
$error = $this->l('Missing a temporary folder');
}
// No error, let's update the file
else
{
list($width, $height, $type) = getimagesize($file['tmp_name']);
// Check if this is really an image
if ($height == 0)
$error = $this->l('This is not a valid image file');
// Resize image
else
{
$newheight = ($height > 500) ? 500 : $height;
$percent = $newheight / $height;
$newwidth = $width * $percent;
$newheight = $height * $percent;
$thumb = imagecreatetruecolor($newwidth, $newheight);
switch ($type)
{
case 1:
$source = imagecreatefromgif($file['tmp_name']);
break;
case 2:
$source = imagecreatefromjpeg($file['tmp_name']);
break;
case 3:
$source = imagecreatefrompng($file['tmp_name']);
break;
default:
$error = $this->l('Image type is not supported');
}
if (!$error)
{
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
if (!is_writable(_PS_ROOT_DIR_.'/img/logo.jpg'))
$error = $this->l('Image folder is not writable');
else if (!imagejpeg($thumb, _PS_ROOT_DIR_.'/img/logo.jpg', 90))
$error = $this->l('Cannot upload the file');
}
}
}
}
$this->ajaxJsonAnswer(($error) ? false : true, $error);
}
/**
* Obtain the timezone associated to an iso
*/
public function processTimezoneByIso()
{
$timezone = $this->getTimezoneByIso(Tools::getValue('iso'));
$this->ajaxJsonAnswer(($timezone) ? true : false, $timezone);
}
/**
* Obtain a translation from presintall XML file
*
* @param SimplexmlElement $xml
* @param string $xpath
* @return string
*/
public function getPreinstallXmlLang(SimplexmlElement $xml, $xpath)
{
$lang = $this->language->getLanguageIso();
$translation = $xml->xpath($xpath.'[@iso="'.$lang.'"]');
if (!$translation && $lang != 'en')
$translation = $xml->xpath($xpath.'[@iso="en"]');
if (!$translation)
$translation = $xml->xpath($xpath);
return ($translation) ? (string)$translation[0] : '';
}
/**
* Get list of partners from PrestaShop website
*/
public function processGetPartners()
{
$this->iso = Tools::getValue('iso');
if (!$this->iso)
$this->ajaxJsonAnswer(false);
// Load partners XML file from prestashop.com
$stream_context = @stream_context_create(array('http' => array('method'=> 'GET', 'timeout' => 3)));
$content = @file_get_contents('http://www.prestashop.com/partner/preactivation/partners.php?version=1.1', false, $stream_context);
if (!$xml = @simplexml_load_string($content))
$this->ajaxJsonAnswer(false, $this->l('Cannot load partners from PrestaShop website'));
// Browse all partners
$partners = array();
foreach ($xml->partner as $partner)
{
// Partner available for current language ?
if (!$partner->xpath('countries[country="'.$this->iso.'"]'))
continue;
$partner_id = (string)$partner->key;
if (!isset($this->session->shop_name))
$checked = ($partner->prechecked) ? true : false;
else
$checked = (isset($this->session->partners[$partner_id])) ? true : false;
$partners[$partner_id] = array(
'name' => (string)$partner->name,
'label' => $this->getPreinstallXmlLang($partner, 'labels/label'),
'description' => $this->getPreinstallXmlLang($partner, 'descriptions/description'),
'logo' => $partner->logo_medium,
'checked' => $checked,
);
}
// If no partners, don't displayany preactivation HTML
if (!$partners)
$this->ajaxJsonAnswer(false);
// Render partners
$this->partners = $partners;
$html = $this->displayTemplate('partners', true);
$this->ajaxJsonAnswer(true, $html);
}
/**
* Get fields of a partner for a country as HTML
*/
public function processGetPartnersFields()
{
$this->partner_id = Tools::getValue('partner_id');
$this->iso = Tools::getValue('iso');
if (!$this->partner_id || !$this->iso)
$this->ajaxJsonAnswer(false);
$this->fields = $this->getPartnersFields($this->partner_id, $this->iso);
if (!$this->fields)
$this->ajaxJsonAnswer(false);
// Render fields
$html = $this->displayTemplate('partners_fields', true);
$this->ajaxJsonAnswer(true, $html);
}
/**
* Get list of fields of a partner for a country
*
* @param string $partner_id
* @param string $iso
* @return array
*/
public function getPartnersFields($partner_id, $iso)
{
// Load partners fields XML file from prestashop.com
$stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 5)));
$content = @file_get_contents('http://www.prestashop.com/partner/preactivation/fields.php?version=1.1&partner='.$partner_id.'&country_iso_code='.$iso, false, $stream_context);
if (!$xml = @simplexml_load_string($content))
$this->ajaxJsonAnswer(false, $this->l('Cannot load partners fields from PrestaShop website'));
// Browse all fields
$fields = array();
foreach ($xml->field as $field)
{
$key = (string)$field->key;
$data = array(
'type' => (string)$field->type,
'label' => $this->getPreinstallXmlLang($field, 'labels/label'),
'help' => $this->getPreinstallXmlLang($field, 'helps/help'),
'value' => (isset($this->session->partners[$partner_id][$key])) ? $this->session->partners[$partner_id][$key] : (string)$field->default,
);
switch ($data['type'])
{
case 'text' :
case 'password' :
$data['size'] = (string)$field->size;
break;
case 'radio' :
case 'select' :
$data['list'] = array();
foreach ($field->values as $value)
$data['list'][(string)$value->value] = $this->getPreinstallXmlLang($value, 'labels/label');
break;
case 'date' :
if (!is_array($data['value']))
$data['value'] = array(
'year' => 0,
'month' => 0,
'day' => 0,
);
break;
}
$fields[$key] = $data;
}
return $fields;
}
/**
* Get list of timezones
*
* @return array
*/
public function getTimezones()
{
if (!is_null($this->cache_timezones))
return;
if (!file_exists(_PS_INSTALL_DATA_PATH_.'xml/timezone.xml'))
return array();
$xml = simplexml_load_file(_PS_INSTALL_DATA_PATH_.'xml/timezone.xml');
$timezones = array();
foreach ($xml->entities->timezone as $timezone)
$timezones[] = (string)$timezone['name'];
return $timezones;
}
/**
* Get a timezone associated to an iso
*
* @param string $iso
* @return string
*/
public function getTimezoneByIso($iso)
{
if (!file_exists(_PS_INSTALL_DATA_PATH_.'iso_to_timezone.xml'))
return '';
$xml = simplexml_load_file(_PS_INSTALL_DATA_PATH_.'iso_to_timezone.xml');
$timezones = array();
foreach ($xml->relation as $relation)
$timezones[(string)$relation['iso']] = (string)$relation['zone'];
return isset($timezones[$iso]) ? $timezones[$iso] : '';
}
/**
* @see InstallAbstractModel::display()
*/
public function display()
{
// List of activities
$list_activities = array(
$this->l('Lingerie and Adult'),
$this->l('Animals and Pets'),
$this->l('Art and Culture'),
$this->l('Babies'),
$this->l('Beauty and Personal Care'),
$this->l('Cars'),
$this->l('Computer Hardware and Software'),
$this->l('Download'),
$this->l('Fashion and accessories'),
$this->l('Flowers, Gifts and Crafts'),
$this->l('Food and beverage'),
$this->l('HiFi, Photo and Video'),
$this->l('Home and Garden'),
$this->l('Home Appliances'),
$this->l('Jewelry'),
$this->l('Mobile and Telecom'),
$this->l('Services'),
$this->l('Shoes and accessories'),
$this->l('Sports and Entertainment'),
$this->l('Travel'),
);
sort($list_activities);
$this->list_activities = $list_activities;
$this->displayTemplate('configure');
}
/**
* Helper to display error for a field
*
* @param unknown_type $field
*/
public function displayError($field)
{
if (!isset($this->errors[$field]))
return;
return '<span class="result aligned errorTxt">'.$this->errors[$field].'</span>';
}
}
+202
View File
@@ -0,0 +1,202 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @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
*/
/**
* Step 3 : configure database and email connection
*/
class InstallControllerHttpDatabase extends InstallControllerHttp
{
/**
* @var InstallModelDatabase
*/
public $model_database;
/**
* @var InstallModelMail
*/
public $model_mail;
public function init()
{
require_once _PS_INSTALL_MODELS_PATH_.'database.php';
$this->model_database = new InstallModelDatabase();
require_once _PS_INSTALL_MODELS_PATH_.'mail.php';
$this->model_mail = new InstallModelMail();
}
/**
* @see InstallAbstractModel::processNextStep()
*/
public function processNextStep()
{
$this->session->install_type = Tools::getValue('db_mode');
// Save database config
$this->session->database_server = trim(Tools::getValue('dbServer'));
$this->session->database_name = trim(Tools::getValue('dbName'));
$this->session->database_login = trim(Tools::getValue('dbLogin'));
$this->session->database_password = trim(Tools::getValue('dbPassword'));
$this->session->database_prefix = trim(Tools::getValue('db_prefix'));
$this->session->database_engine = Tools::getValue('dbEngine');
$this->session->database_clear = Tools::getValue('database_clear');
// Save email config
$this->session->use_smtp = (bool)Tools::getValue('smtpChecked');
$this->session->smtp_server = trim(Tools::getValue('smtpSrv'));
$this->session->smtp_encryption = Tools::getValue('smtpEnc');
$this->session->smtp_port = (int)Tools::getValue('smtpPort');
$this->session->smtp_login = trim(Tools::getValue('smtpLogin'));
$this->session->smtp_password = trim(Tools::getValue('smtpPassword'));
}
/**
* Database configuration must be valid to validate this step
*
* @see InstallAbstractModel::validate()
*/
public function validate()
{
$this->errors = $this->model_database->testDatabaseSettings(
$this->session->database_server,
$this->session->database_name,
$this->session->database_login,
$this->session->database_password,
$this->session->database_prefix,
$this->session->database_engine
);
return count($this->errors) ? false : true;
}
public function process()
{
if (Tools::getValue('checkDb'))
$this->processCheckDb();
else if (Tools::getValue('sendMail'))
$this->processSendMail();
}
/**
* Check if a connection to database is possible with these data
*/
public function processCheckDb()
{
$server = Tools::getValue('dbServer');
$database = Tools::getValue('dbName');
$login = Tools::getValue('dbLogin');
$password = Tools::getValue('dbPassword');
$prefix = Tools::getValue('db_prefix');
$engine = Tools::getValue('dbEngine');
$errors = $this->model_database->testDatabaseSettings($server, $database, $login, $password, $prefix, $engine);
$this->ajaxJsonAnswer(
(count($errors)) ? false : true,
(count($errors)) ? implode('<br />', $errors) : $this->l('Database is connected')
);
}
/**
* Send a test email
*/
public function processSendMail()
{
$smtp_checked = (Tools::getValue('smtpChecked') == 'true');
$server = Tools::getValue('smtpSrv');
$encryption = Tools::getValue('smtpEnc');
$port = Tools::getValue('smtpPort');
$login = Tools::getValue('smtpLogin');
$password = Tools::getValue('smtpPassword');
$email = Tools::getValue('testEmail');
$result = $this->model_mail->sendTestMail($smtp_checked, $server, $login, $password, $port, $encryption, $email);
$this->ajaxJsonAnswer(
(bool)$result,
($result) ? $this->l('A test e-mail has been sent to %s', $email) : $this->l('An error occurred while sending email, please verify your parameters')
);
}
/**
* @see InstallAbstractModel::display()
*/
public function display()
{
if (!$this->session->install_type)
{
if (file_exists(_PS_ROOT_DIR_.'/config/settings.inc.php'))
{
include_once _PS_ROOT_DIR_.'/config/settings.inc.php';
$this->database_server = _DB_SERVER_;
$this->database_name = _DB_NAME_;
$this->database_login = _DB_USER_;
$this->database_password = _DB_PASSWD_;
$this->database_engine = _MYSQL_ENGINE_;
$this->database_prefix = _DB_PREFIX_;
}
else
{
$this->database_server = 'localhost';
$this->database_name = 'prestashop';
$this->database_login = 'root';
$this->database_password = '';
$this->database_engine = 'InnoDB';
$this->database_prefix = 'ps_';
}
$this->database_clear = true;
$this->install_type = 'full';
$this->use_smtp = false;
$this->smtp_server = 'smtp.';
$this->smtp_encryption = 'off';
$this->smtp_port = 25;
$this->smtp_login = '';
$this->smtp_password = '';
}
else
{
$this->database_server = $this->session->database_server;
$this->database_name = $this->session->database_name;
$this->database_login = $this->session->database_login;
$this->database_password = $this->session->database_password;
$this->database_engine = $this->session->database_engine;
$this->database_prefix = $this->session->database_prefix;
$this->database_clear = $this->session->database_clear;
$this->install_type = $this->session->install_type;
$this->use_smtp = $this->session->use_smtp;
$this->smtp_server = $this->session->smtp_server;
$this->smtp_encryption = $this->session->smtp_encryption;
$this->smtp_port = $this->session->smtp_port;
$this->smtp_login = $this->session->smtp_login;
$this->smtp_password = $this->session->smtp_password;
}
$this->displayTemplate('database');
}
}
+219
View File
@@ -0,0 +1,219 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @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
*/
class InstallControllerHttpProcess extends InstallControllerHttp
{
const SETTINGS_FILE = 'config/settings.inc.php';
public function init()
{
require_once _PS_INSTALL_MODELS_PATH_.'install.php';
$this->model_install = new InstallModelInstall();
}
/**
* @see InstallAbstractModel::processNextStep()
*/
public function processNextStep()
{
}
/**
* @see InstallAbstractModel::validate()
*/
public function validate()
{
return false;
}
public function process()
{
if (file_exists(_PS_ROOT_DIR_.'/'.self::SETTINGS_FILE))
require_once _PS_ROOT_DIR_.'/'.self::SETTINGS_FILE;
if (Tools::getValue('installDatabase'))
$this->processInstallDatabase();
else if (Tools::getValue('populateDatabase'))
$this->processPopulateDatabase();
else if (Tools::getValue('configureShop'))
$this->processConfigureShop();
else if (Tools::getValue('installModules'))
$this->processInstallModules();
else if (Tools::getValue('installFixtures'))
$this->processInstallFixtures();
else if (Tools::getValue('preactivation'))
$this->processPreactivation();
}
/**
* PROCESS : installDatabase
* Generate settings file and create database structure
*/
public function processInstallDatabase()
{
$success = $this->model_install->installDatabase(
$this->session->database_server,
$this->session->database_login,
$this->session->database_password,
$this->session->database_name,
$this->session->database_prefix,
$this->session->database_engine,
$this->session->database_clear
);
if (!$success || $this->model_install->getErrors())
$this->ajaxJsonAnswer(false, $this->model_install->getErrors());
$this->ajaxJsonAnswer(true);
}
/**
* PROCESS : populateDatabase
* Populate database with default data
*/
public function processPopulateDatabase()
{
$this->initializeContext();
if (!$this->model_install->populateDatabase(true) || $this->model_install->getErrors())
$this->ajaxJsonAnswer(false, $this->model_install->getErrors());
$this->session->xml_loader_ids = $this->model_install->xml_loader_ids;
$this->ajaxJsonAnswer(true);
}
/**
* PROCESS : configureShop
* Set default shop configuration
*/
public function processConfigureShop()
{
$this->initializeContext();
$success = $this->model_install->configureShop(array(
'shop_name' => $this->session->shop_name,
'shop_activity' => $this->session->shop_activity,
'shop_country' => $this->session->shop_country,
'shop_timezone' => $this->session->shop_timezone,
'use_smtp' => $this->session->use_smtp,
'smtp_server' => $this->session->smtp_server,
'smtp_login' => $this->session->smtp_login,
'smtp_password' => $this->session->smtp_password,
'smtp_encryption' =>$this->session->smtp_encryption,
'smtp_port' => $this->session->smtp_port,
'admin_firstname' =>$this->session->admin_firstname,
'admin_lastname' => $this->session->admin_lastname,
'admin_password' => $this->session->admin_password,
'admin_email' => $this->session->admin_email,
));
if (!$success || $this->model_install->getErrors())
$this->ajaxJsonAnswer(false, $this->model_install->getErrors());
$this->ajaxJsonAnswer(true);
}
public function initializeContext()
{
global $smarty;
Context::getContext()->shop = new Shop(1);
Configuration::loadConfiguration();
Context::getContext()->language = new Language(Configuration::get('PS_LANG_DEFAULT'));
require_once _PS_ROOT_DIR_.'/config/smarty.config.inc.php';
Context::getContext()->smarty = $smarty;
}
/**
* PROCESS : installModules
* Install all modules in ~/modules/ directory
*/
public function processInstallModules()
{
$this->initializeContext();
// Remove all modules from module table, just in case
Db::getInstance()->delete(_DB_PREFIX_.'module');
if (!$this->model_install->installModules() || $this->model_install->getErrors())
$this->ajaxJsonAnswer(false, $this->model_install->getErrors());
$this->ajaxJsonAnswer(true);
}
/**
* PROCESS : installFixtures
* Install fixtures (E.g. demo products)
*/
public function processInstallFixtures()
{
$this->initializeContext();
$this->model_install->xml_loader_ids = $this->session->xml_loader_ids;
if (!$this->model_install->installFixtures() || $this->model_install->getErrors())
$this->ajaxJsonAnswer(false, $this->model_install->getErrors());
$this->ajaxJsonAnswer(true);
}
/**
* PROCESS : preactivation
* (currently not used)
*/
public function processPreactivation()
{
foreach ($this->session->partners as $partner => $data)
{
/*$stream_context = @stream_context_create(array('http' => array('method'=> 'GET', 'timeout' => 5)));
$url = 'http://www.prestashop.com/partner/preactivation/actions.php?version=1.0&partner='.addslashes($_GET['partner']);
// Protect fields
foreach ($_GET as $key => $value)
$_GET[$key] = strip_tags(str_replace(array('\'', '"'), '', trim($value)));
// Encore Get, Send It and Get Answers
@require_once('../config/settings.inc.php');
foreach ($_GET as $key => $val)
$url .= '&'.$key.'='.urlencode($val);
$url .= '&security='.md5($_GET['email']._COOKIE_IV_);*/
}
$this->ajaxJsonAnswer(true);
}
/**
* @see InstallAbstractModel::display()
*/
public function display()
{
$this->process_steps = array(
'installDatabase',
'populateDatabase',
'configureShop',
'installModules',
'installFixtures',
//'preactivation',
);
$this->displayTemplate('process');
}
}
+132
View File
@@ -0,0 +1,132 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @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
*/
/**
* Step 2 : check system configuration (permissions on folders, PHP version, etc.)
*/
class InstallControllerHttpSystem extends InstallControllerHttp
{
public $tests = array();
/**
* @var InstallModelSystem
*/
public $model_system;
/**
* @see InstallAbstractModel::init()
*/
public function init()
{
require_once _PS_INSTALL_MODELS_PATH_.'system.php';
$this->model_system = new InstallModelSystem();
}
/**
* @see InstallAbstractModel::processNextStep()
*/
public function processNextStep()
{
}
/**
* Required tests must be passed to validate this step
*
* @see InstallAbstractModel::validate()
*/
public function validate()
{
$this->tests['required'] = $this->model_system->checkRequiredTests();
return $this->tests['required']['success'];
}
/**
* Display system step
*/
public function display()
{
if (!isset($this->tests['required']))
$this->tests['required'] = $this->model_system->checkRequiredTests();
if (!isset($this->tests['optional']))
$this->tests['optional'] = $this->model_system->checkOptionalTests();
// Generate display array
$this->tests_render = array(
'required' => array(
array(
'title' => $this->l('PHP parameters:'),
'checks' => array(
'phpversion' => $this->l('Is PHP 5.1.0 or later installed ?'),
'upload' => $this->l('Can upload files allowed ?'),
'system' => $this->l('Can create new files and folders ?'),
'gd' => $this->l('Is GD Library installed ?'),
'mysql_support' => $this->l('Is MySQL support is on ?'),
)
),
array(
'title' => $this->l('Write permissions on files:'),
'checks' => array(
'config_dir' => '~/config/',
'cache_dir' => '~/cache/',
'log_dir' => '~/log/',
'img_dir' => '~/img/',
'mails_dir' => '~/mails/',
'module_dir' => '~/modules/',
'theme_lang_dir' => '~/themes/prestashop/lang/',
'theme_cache_dir' => '~/themes/prestashop/cache/',
'translations_dir' => '~/translations/',
'customizable_products_dir' => '~/upload/',
'virtual_products_dir' => '~/download/',
'sitemap' => '~/sitemap.xml',
)
),
),
'optional' => array(
array(
'title' => $this->l('PHP parameters:'),
'checks' => array(
'fopen' => $this->l('Can open external URLs ?'),
'register_globals' => $this->l('Is PHP register global option desactivated (recommended) ?'),
'gz' => $this->l('Is GZIP compression activated (recommended) ?'),
'mcrypt' => $this->l('Is Mcrypt extension available (recommended) ?'),
'magicquotes' => $this->l('Is PHP magic quotes option desactivated (recommended) ?'),
'dom' => $this->l('Is Dom extension loaded ?'),
'pdo_mysql' => $this->l('Is PDO MySQL extension loaded ?'),
)
),
),
);
// If required tests failed, disable next button
if (!$this->tests['required']['success'])
$this->next_button = false;
$this->displayTemplate('system');
}
}
+73
View File
@@ -0,0 +1,73 @@
<?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 license@prestashop.com 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 <contact@prestashop.com>
* @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
*/
/**
* Step 1 : display agrement form
*/
class InstallControllerHttpWelcome extends InstallControllerHttp
{
/**
* Process welcome form
*
* @see InstallAbstractModel::process()
*/
public function processNextStep()
{
$this->session->licence_agrement = Tools::getValue('licence_agrement');
$this->session->configuration_agrement = Tools::getValue('configuration_agrement');
}
/**
* Licence agrement must be checked to validate this step
*
* @see InstallAbstractModel::validate()
*/
public function validate()
{
return $this->session->licence_agrement;
}
/**
* Change language
*/
public function process()
{
if (Tools::getValue('language'))
{
$this->session->lang = Tools::getValue('language');
$this->redirect('welcome');
}
}
/**
* Display welcome step
*/
public function display()
{
$this->displayTemplate('welcome');
}
}
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 980 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 976 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1019 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1000 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1022 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1004 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 991 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 959 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 991 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1013 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1010 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Some files were not shown because too many files have changed in this diff Show More