// install-new renamed to install-dev

This commit is contained in:
mMarinetti
2012-01-26 17:35:54 +00:00
parent 554e7ce7d7
commit c6376aa861
924 changed files with 0 additions and 0 deletions
+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://api.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://api.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>';
}
}
+204
View File
@@ -0,0 +1,204 @@
<?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,
$this->session->database_clear
);
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');
$clear = Tools::getValue('clear');
$errors = $this->model_database->testDatabaseSettings($server, $database, $login, $password, $prefix, $engine, $clear);
$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');
}
}
+247
View File
@@ -0,0 +1,247 @@
<?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';
/**
* @var InstallModelInstall
*/
protected $model_install;
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('installTheme'))
$this->processInstallTheme();
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();
// @todo remove true in populateDatabase for 1.5.0 RC version
$result = $this->model_install->populateDatabase(true, array(
'shop_name' => $this->session->shop_name
));
if (!$result || $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'));
Context::getContext()->country = new Country('PS_COUNTRY_DEFAULT');
Context::getContext()->cart = new Cart();
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 : installTheme
* Install theme
*/
public function processInstallTheme()
{
$this->initializeContext();
$this->model_install->installTheme();
if ($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://api.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(
array('key' => 'installDatabase', 'lang' => $this->l('Create database tables')),
array('key' => 'populateDatabase', 'lang' => $this->l('Populate database tables')),
array('key' => 'configureShop', 'lang' => $this->l('Configure shop informations')),
array('key' => 'installModules', 'lang' => $this->l('Install modules')),
array('key' => 'installFixtures', 'lang' => $this->l('Install demonstration data')),
array('key' => 'installTheme', 'lang' => $this->l('Install theme')),
);
$this->displayTemplate('process');
}
}
+134
View File
@@ -0,0 +1,134 @@
<?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();
//d($this->tests);
// 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_pdf_lang_dir' => '~/themes/prestashop/pdf/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 deactivated (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 deactivated (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');
}
}