[*] BO : reorganization of admin tabs

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13820 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2012-03-02 14:44:07 +00:00
parent a32fc0cc5b
commit 0f865fd2d6
74 changed files with 10384 additions and 11234 deletions
@@ -0,0 +1,206 @@
<?php
/*
* 2007-2012 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-2012 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 AdminAdminPreferencesControllerCore extends AdminController
{
public function __construct()
{
$this->className = 'Configuration';
$this->table = 'configuration';
parent::__construct();
// Upload quota
$max_upload = (int)ini_get('upload_max_filesize');
$max_post = (int)ini_get('post_max_size');
$upload_mb = min($max_upload, $max_post);
// Options list
$this->options = array(
'general' => array(
'title' => $this->l('General'),
'icon' => 'tab-preferences',
'fields' => array(
'PRESTASTORE_LIVE' => array(
'title' => $this->l('Automatically check for module updates'),
'desc' => $this->l('New modules and updates are displayed on the modules page'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'visibility' => Shop::CONTEXT_ALL
),
'PS_COOKIE_CHECKIP' => array(
'title' => $this->l('Check IP on the cookie'),
'desc' => $this->l('Check the IP address of the cookie in order to avoid your cookie being stolen'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'default' => '0',
'visibility' => Shop::CONTEXT_ALL
),
'PS_COOKIE_LIFETIME_FO' => array(
'title' => $this->l('Lifetime of the Front Office cookie'),
'desc' => $this->l('Indicate the number of hours'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'default' => '480',
'visibility' => Shop::CONTEXT_ALL
),
'PS_COOKIE_LIFETIME_BO' => array(
'title' => $this->l('Lifetime of the Back Office cookie'),
'desc' => $this->l('Indicate the number of hours'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'default' => '480',
'visibility' => Shop::CONTEXT_ALL
),
),
),
'upload' => array(
'title' => $this->l('Upload quota'),
'icon' => 'tab-preferences',
'fields' => array(
'PS_ATTACHMENT_MAXIMUM_SIZE' => array(
'title' => $this->l('Attachment maximum size'),
'desc' => $this->l('Set the maximum size of attachment files (in MegaBytes).').' '.$this->l('Maximum:').' '.
((int)str_replace('M', '', ini_get('post_max_size')) > (int)str_replace('M', '', ini_get('upload_max_filesize')) ? ini_get('upload_max_filesize') : ini_get('post_max_size')),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('Megabits'),
'default' => '2'
),
'PS_LIMIT_UPLOAD_FILE_VALUE' => array(
'title' => $this->l('Limit upload file value'),
'desc' => $this->l('Define the limit upload for a downloadable product, this value have to be inferior or egal to your server\'s maximum upload file ').sprintf('(%s MB).', $upload_mb),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('Megabits'),
'default' => '1'
),
'PS_LIMIT_UPLOAD_IMAGE_VALUE' => array(
'title' => $this->l('Limit upload image value'),
'desc' => $this->l('Define the limit upload for an image, this value have to be inferior or egal to your server\'s maximum upload file ').sprintf('(%s MB).', $upload_mb),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('Megabits'),
'default' => '1'
),
),
),
'help' => array(
'title' => $this->l('Help'),
'icon' => 'tab-preferences',
'fields' => array(
'PS_HELPBOX' => array(
'title' => $this->l('Back Office help boxes'),
'desc' => $this->l('Enable yellow help boxes which are displayed under form fields in the Back Office'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'visibility' => Shop::CONTEXT_ALL
),
'PS_HIDE_OPTIMIZATION_TIPS' => array(
'title' => $this->l('Hide optimization tips'),
'desc' => $this->l('Hide optimization tips on the back office homepage'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
),
),
'notifications' => array(
'title' => $this->l('Notifications'),
'icon' => 'tab-preferences',
'fields' => array(
'PS_SHOW_NEW_ORDERS' => array(
'title' => $this->l('Show notifications for new orders'),
'desc' => $this->l('This will display notifications when new orders will be made on your shop'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_SHOW_NEW_CUSTOMERS' => array(
'title' => $this->l('Show notifications for new customers'),
'desc' => $this->l('This will display notifications when new customers will register on your shop'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_SHOW_NEW_MESSAGES' => array(
'title' => $this->l('Show notifications for new messages'),
'desc' => $this->l('This will display notifications when new messages will be posted on your shop'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
),
),
);
}
public function postProcess()
{
$upload_max_size = (int)str_replace('M', '', ini_get('upload_max_filesize'));
$post_max_size = (int)str_replace('M', '', ini_get('post_max_size'));
$max_size = $upload_max_size < $post_max_size ? $upload_max_size : $post_max_size;
if (Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE') > $max_size || Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE') > $max_size)
{
$this->errors[] = Tools::displayError('The limit choosen is superior to the server\'s maximum upload file You need to improve the limit of your server.');
return;
}
if (Tools::getIsset('PS_LIMIT_UPLOAD_FILE_VALUE') && !Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE'))
$_POST['PS_LIMIT_UPLOAD_FILE_VALUE'] = 1;
if (Tools::getIsset('PS_LIMIT_UPLOAD_IMAGE_VALUE') && !Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE'))
$_POST['PS_LIMIT_UPLOAD_IMAGE_VALUE'] = 1;
parent::postProcess();
}
/**
* Update PS_ATTACHMENT_MAXIMUM_SIZE
*/
public function updateOptionPsAttachementMaximumSize($value)
{
if (!$value)
return;
$upload_max_size = (int)str_replace('M', '', ini_get('upload_max_filesize'));
$post_max_size = (int)str_replace('M', '', ini_get('post_max_size'));
$max_size = $upload_max_size < $post_max_size ? $upload_max_size : $post_max_size;
$value = ($max_size < Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE')) ? $max_size : Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE');
Configuration::updateValue('PS_ATTACHMENT_MAXIMUM_SIZE', $value);
}
}
@@ -1,124 +0,0 @@
<?php
/*
* 2007-2012 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-2012 PrestaShop SA
* @version Release: $Revision: 8971 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminAliasesControllerCore extends AdminController
{
public function __construct()
{
$this->table = 'alias';
$this->className = 'Alias';
$this->lang = false;
$this->requiredDatabase = true;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->context = Context::getContext();
if (!Tools::getValue('realedit'))
$this->deleted = false;
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->fieldsDisplay = array(
'alias' => array('title' => $this->l('Aliases'), 'width' => 'auto'),
'search' => array('title' => $this->l('Search'), 'width' => 100),
'active' => array('title' => $this->l('Status'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
);
parent::__construct();
}
public function renderForm()
{
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Aliases'),
'image' => '../img/admin/search.gif'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Alias:'),
'name' => 'alias',
'size' => 40,
'required' => true,
'desc' => array(
$this->l('Enter each alias separated by a comma (\',\') (e.g., \'prestshop,preztashop,prestasohp\')'),
$this->l('Forbidden characters: <>;=#{}')
)
),
array(
'type' => 'text',
'label' => $this->l('Result:'),
'name' => 'search',
'size' => 15,
'required' => true,
'desc' => $this->l('Search this word instead.')
)
),
'submit' => array(
'title' => $this->l(' Save '),
'class' => 'button'
)
);
$this->fields_value = array('alias' => $this->object->getAliases());
return parent::renderForm();
}
public function postProcess()
{
if (isset($_POST['submitAdd'.$this->table]))
{
$search = strval(Tools::getValue('search'));
$string = strval(Tools::getValue('alias'));
$aliases = explode(',', $string);
if (empty($search) || empty($string))
$this->errors[] = $this->l('aliases and result are both required');
if (!Validate::isValidSearch($search))
$this->errors[] = $search.' '.$this->l('is not a valid result');
foreach ($aliases as $alias)
if (!Validate::isValidSearch($alias))
$this->errors[] = $alias.' '.$this->l('is not a valid alias');
if (!count($this->errors))
{
foreach ($aliases as $alias)
{
$obj = new Alias(null, trim($alias), trim($search));
$obj->save();
}
}
}
else
parent::postProcess();
}
}
@@ -1,206 +0,0 @@
<?php
/*
* 2007-2012 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-2012 PrestaShop SA
* @version Release: $Revision: 7060 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminContactControllerCore extends AdminController
{
public function __construct()
{
$this->className = 'Configuration';
$this->table = 'configuration';
parent::__construct();
$temporyArrayFields = $this->_getDefaultFieldsContent();
$this->_buildOrderedFieldsShop($temporyArrayFields);
}
protected function _getDefaultFieldsContent()
{
$this->context = Context::getContext();
$countryList = array();
$countryList[] = array('id' => '0', 'name' => $this->l('Choose your country'));
foreach (Country::getCountries($this->context->language->id) as $country)
$countryList[] = array('id' => $country['id_country'], 'name' => $country['name']);
$stateList = array();
$stateList[] = array('id' => '0', 'name' => $this->l('Choose your state (if applicable)'));
foreach (State::getStates($this->context->language->id) as $state)
$stateList[] = array('id' => $state['id_state'], 'name' => $state['name']);
$formFields = array(
'PS_SHOP_NAME' => array(
'title' => $this->l('Shop name:'),
'desc' => $this->l('Displayed in e-mails and page titles'),
'validation' => 'isGenericName',
'required' => true,
'size' => 30,
'type' => 'text'
),
'PS_SHOP_EMAIL' => array('title' => $this->l('Shop e-mail:'),
'desc' => $this->l('Displayed in e-mails sent to customers'),
'validation' => 'isEmail',
'required' => true,
'size' => 30,
'type' => 'text'
),
'PS_SHOP_DETAILS' => array(
'title' => $this->l('Registration:'),
'desc' => $this->l('Shop registration information (e.g., SIRET or RCS)'),
'validation' => 'isGenericName',
'size' => 30,
'type' => 'textarea',
'cols' => 30,
'rows' => 5
),
'PS_SHOP_ADDR1' => array(
'title' => $this->l('Shop address line 1:'),
'validation' => 'isAddress',
'size' => 30,
'type' => 'text'
),
'PS_SHOP_ADDR2' => array(
'title' => 'Address line 2',
'validation' => 'isAddress',
'size' => 30,
'type' => 'text'
),
'PS_SHOP_CODE' => array(
'title' => $this->l('Post/Zip code:'),
'validation' => 'isGenericName',
'size' => 6,
'type' => 'text'
),
'PS_SHOP_CITY' => array(
'title' => $this->l('City:'),
'validation' => 'isGenericName',
'size' => 30,
'type' => 'text'),
'PS_SHOP_COUNTRY_ID' => array(
'title' => $this->l('Country:'),
'validation' => 'isInt',
'type' => 'select',
'list' => $countryList,
'identifier' => 'id',
'cast' => 'intval',
'defaultValue' => (int)$this->context->country->id
),
'PS_SHOP_STATE_ID' => array(
'title' => $this->l('State:'),
'validation' => 'isInt',
'type' => 'select',
'list' => $stateList,
'identifier' => 'id',
'cast' => 'intval'
),
'PS_SHOP_PHONE' => array(
'title' => $this->l('Phone:'),
'validation' => 'isGenericName',
'size' => 30,
'type' => 'text'
),
'PS_SHOP_FAX' => array(
'title' => $this->l('Fax:'),
'validation' => 'isGenericName',
'size' => 30,
'type' => 'text'
),
);
return $formFields;
}
protected function _buildOrderedFieldsShop($formFields)
{
$associatedOrderKey = array(
'PS_SHOP_NAME' => 'company',
'PS_SHOP_ADDR1' => 'address1',
'PS_SHOP_ADDR2' => 'address2',
'PS_SHOP_CITY' => 'city',
'PS_SHOP_STATE_ID' => 'State:name',
'PS_SHOP_CODE' => 'postcode',
'PS_SHOP_COUNTRY_ID' => 'Country:name',
'PS_SHOP_PHONE' => 'phone');
$fields = array();
$orderedFields = AddressFormat::getOrderedAddressFields(Configuration::get('PS_SHOP_COUNTRY_ID'), false, true);
foreach ($orderedFields as $lineFields)
if (($patterns = explode(' ', $lineFields)))
foreach ($patterns as $pattern)
if (($key = array_search($pattern, $associatedOrderKey)))
$fields[$key] = $formFields[$key];
foreach ($formFields as $key => $value)
if (!isset($fields[$key]))
$fields[$key] = $formFields[$key];
$this->options = array(
'general' => array(
'title' => $this->l('Contact details'),
'icon' => 'tab-contact',
'fields' => $fields,
'submit' => array('title' => $this->l(' Save '), 'class' => 'button')
),
);
}
public function beforeUpdateOptions()
{
if (isset($_POST['PS_SHOP_STATE_ID']) && $_POST['PS_SHOP_STATE_ID'] != '0')
{
$sql = 'SELECT `active` FROM `'._DB_PREFIX_.'state`
WHERE `id_country` = '.(int)Tools::getValue('PS_SHOP_COUNTRY_ID').'
AND `id_state` = '.(int)Tools::getValue('PS_SHOP_STATE_ID');
$isStateOk = Db::getInstance()->getValue($sql);
if ($isStateOk != 1)
$this->errors[] = Tools::displayError('This state is not in this country.');
}
}
public function updateOptionPsShopCountryId($value)
{
if (!$this->errors && $value)
{
$country = new Country($value, $this->context->language->id);
if ($country->id)
{
Configuration::updateValue('PS_SHOP_COUNTRY_ID', $value);
Configuration::updateValue('PS_SHOP_COUNTRY', pSQL($country->name));
}
}
}
public function updateOptionPsShopStateId($value)
{
if (!$this->errors && $value)
{
$state = new State($value);
if ($state->id)
{
Configuration::updateValue('PS_SHOP_STATE_ID', $value);
Configuration::updateValue('PS_SHOP_STATE', pSQL($state->name));
}
}
}
}
@@ -56,14 +56,6 @@ class AdminCountriesControllerCore extends AdminController
'general' => array(
'title' => $this->l('Countries options'),
'fields' => array(
'PS_COUNTRY_DEFAULT' => array(
'title' => $this->l('Default country:'),
'desc' => $this->l('The default country used in shop'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id_country',
'list' => Country::getCountries(Context::getContext()->language->id)
),
'PS_RESTRICT_DELIVERED_COUNTRIES' => array(
'title' => $this->l('Restrict countries in FO by those delivered by active carriers'),
'cast' => 'intval',
@@ -54,22 +54,6 @@ class AdminCurrenciesControllerCore extends AdminController
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->options = array(
'general' => array(
'title' => $this->l('Currencies options'),
'fields' => array(
'PS_CURRENCY_DEFAULT' => array(
'title' => $this->l('Default currency:'),
'desc' => $this->l('The default currency used in shop')
.'<div class="warn">'.
$this->l('If you change default currency, you will have to manually edit every product price.').'</div>',
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id_currency',
'list' => Currency::getCurrencies()
)
),
'submit' => array()
),
'change' => array(
'title' => $this->l('Currency rates'),
'image' => '../img/admin/exchangesrate.gif',
@@ -319,11 +303,5 @@ class AdminCurrenciesControllerCore extends AdminController
}
parent::initProcess();
}
public function updateOptionPsCurrencyDefault($value)
{
Configuration::updateValue('PS_CURRENCY_DEFAULT', $value);
Currency::refreshCurrencies();
}
}
@@ -0,0 +1,114 @@
<?php
/*
* 2007-2012 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-2012 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 AdminCustomerPreferencesControllerCore extends AdminController
{
public function __construct()
{
$this->className = 'Configuration';
$this->table = 'configuration';
parent::__construct();
$registration_process_type = array(
array(
'value' => PS_REGISTRATION_PROCESS_STANDARD,
'name' => $this->l('Only account creation')
),
array(
'value' => PS_REGISTRATION_PROCESS_AIO,
'name' => $this->l('Standard (account creation and address creation)')
)
);
$this->options = array(
'general' => array(
'title' => $this->l('General'),
'icon' => 'tab-preferences',
'fields' => array(
'PS_REGISTRATION_PROCESS_TYPE' => array(
'title' => $this->l('Registration process type'),
'desc' => $this->l('The "Only account creation" step register process allows the customer to register faster, and create his address later.'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'select',
'list' => $registration_process_type,
'identifier' => 'value'
),
'PS_CART_FOLLOWING' => array(
'title' => $this->l('Cart re-display at login'),
'desc' => $this->l('After customer logs in, recall and display contents of his/her last shopping cart'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_PASSWD_TIME_FRONT' => array(
'title' => $this->l('Regenerate password:'),
'desc' => $this->l('Security minimum time to wait to regenerate the password'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'size' => 5,
'type' => 'text',
'suffix' => $this->l('minutes')
),
'PS_B2B_ENABLE' => array(
'title' => $this->l('Enable B2B mode'),
'desc' => $this->l('Activate or deactivate B2B mode. When this option is enable some features about B2B appear.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
),
'submit' => array('title' => $this->l(' Save '), 'class' => 'button'),
),
);
}
/**
* Update PS_B2B_ENABLE and enables / disables the associated tabs
* @param $value integer Value of option
*/
public function updateOptionPsB2bEnable($value)
{
$value = (int)$value;
$tabs_class_name = array('AdminOutstanding');
if (!empty($tabs_class_name))
{
foreach ($tabs_class_name as $tab_class_name)
{
$tab = Tab::getInstanceFromClassName($tab_class_name);
if (Validate::isLoadedObject($tab))
{
$tab->active = $value;
$tab->save();
}
}
}
Configuration::updateValue('PS_B2B_ENABLE', $value);
}
}
@@ -138,24 +138,6 @@ class AdminCustomersControllerCore extends AdminController
$this->shopLinkType = 'shop';
$this->shopShareDatas = Shop::SHARE_CUSTOMER;
$this->options = array(
'general' => array(
'title' => $this->l('Customers options'),
'fields' => array(
'PS_PASSWD_TIME_FRONT' => array(
'title' => $this->l('Regenerate password:'),
'desc' => $this->l('Security minimum time to wait to regenerate the password'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'size' => 5,
'type' => 'text',
'suffix' => ' '.$this->l('minutes')
)
),
'submit' => array()
)
);
parent::__construct();
}
@@ -742,7 +724,6 @@ class AdminCustomersControllerCore extends AdminController
else
return false;
}
}
public function processUpdate($token)
-275
View File
@@ -1,275 +0,0 @@
<?php
/*
* 2007-2012 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-2012 PrestaShop SA
* @version Release: $Revision: 7465 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminDbControllerCore extends AdminController
{
public function __construct()
{
$this->className = 'Configuration';
$this->table = 'configuration';
parent::__construct();
$this->options = array(
'database' => array(
'title' => $this->l('Database'),
'icon' => 'database_gear',
'fields' => array(
'db_server' => array(
'title' => $this->l('Server:'),
'desc' => $this->l('IP or server name; \'localhost\' will work in most cases'),
'size' => 30,
'type' => 'text',
'required' => true,
'defaultValue' => _DB_SERVER_,
'visibility' => Shop::CONTEXT_ALL
),
'db_name' => array(
'title' => $this->l('Database:'),
'desc' => $this->l('Database name (e.g., \'prestashop\')'),
'size' => 30,
'type' => 'text',
'required' => true,
'defaultValue' => _DB_NAME_,
'visibility' => Shop::CONTEXT_ALL
),
'db_prefix' => array(
'title' => $this->l('Prefix:'),
'size' => 30,
'type' => 'text',
'defaultValue' => _DB_PREFIX_,
'visibility' => Shop::CONTEXT_ALL
),
'db_user' => array(
'title' => $this->l('User:'),
'size' => 30,
'type' => 'text',
'required' => true,
'defaultValue' => _DB_USER_,
'visibility' => Shop::CONTEXT_ALL
),
'db_passwd' => array(
'title' => $this->l('Password:'),
'size' => 30,
'type' => 'password',
'desc' => $this->l('Leave blank if no change'),
'defaultValue' => _DB_PASSWD_,
'visibility' => Shop::CONTEXT_ALL
)
),
'submit' => array()
)
);
$this->fieldsDisplay = array (
'table' => array(
'title' => $this->l('Table'),
'type' => 'string',
'width' => 120
),
'table_engine' => array(
'title' => $this->l('Table Engine'),
'type' => 'string',
'width' => 120
)
);
}
public function initContent()
{
$this->warnings[] = $this->l('Be VERY CAREFUL with these settings, as changes may cause your PrestaShop online store to malfunction. For all issues, check the config/settings.inc.php file.');
$this->display = 'options';
$this->initToolbar();
$this->content .= $this->renderOptions();
$this->content .= $this->renderForm();
$this->context->smarty->assign(array(
'content' => $this->content,
'url_post' => self::$currentIndex.'&token='.$this->token,
));
}
public function renderForm()
{
$engines = array();
$tab_engines = $this->getEngines();
foreach ($tab_engines as $key => $engine)
$engines[]['name'] = $engine;
$this->fields_form = array(
'legend' => array(
'title' => $this->l('MySQL Engine'),
'image' => '../img/admin/AdminBackup.gif'
),
'input' => array(
array(
'type' => 'table',
'name' => 'table'
),
array(
'type' => 'select',
'label' => $this->l('Change Engine to'),
'name' => 'engineType',
'options' => array(
'query' => $engines,
'id' => 'name',
'name' => 'name'
)
)
),
'submit' => array(
'title' => $this->l(' Save '),
'class' => 'button'
)
);
$table_status = $this->getTablesStatus();
foreach ($table_status as $key => $table)
if (!preg_match('#^'._DB_PREFIX_.'.*#Ui', $table['Name']))
unset($table_status[$key]);
$this->tpl_form_vars = array('table_status' => $table_status);
$this->show_toolbar = false;
return parent::renderForm();
}
/*
public function initContent()
{
$this->warnings[] = $this->l('Be VERY CAREFUL with these settings, as changes may cause your PrestaShop online store to malfunction.
For all issues, check the config/settings.inc.php file.');
$this->initToolbar();
$this->content .= $this->renderOptions();
$table_status = $this->getTablesStatus();
foreach ($table_status as $key => $table)
if (!preg_match('#^'._DB_PREFIX_.'.*#Ui', $table['Name']))
unset($table_status[$key]);
$this->context->smarty->assign(array(
'update_url' => self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token,
'table_status' => $table_status,
'engines' => $this->getEngines(),
'content' => $this->content,
));
}
*/
public function postProcess()
{
// PrestaShop demo mode
if (_PS_MODE_DEMO_)
{
$this->errors[] = Tools::displayError('This functionnality has been disabled.');
return;
}
if ($this->action == 'update_options')
{
foreach ($this->options['database']['fields'] as $field => $values)
if (isset($values['required']) && $values['required'])
if (($value = Tools::getValue($field)) == false && (string)$value != '0')
$this->errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is required.');
if (!count($this->errors))
{
/* Datas are not saved in database but in config/settings.inc.php */
$settings = array();
foreach ($this->options['database']['fields'] as $k => $data)
if ($value = Tools::getValue($k))
$settings['_'.Tools::strtoupper($k).'_'] = $value;
if (Db::checkConnection(
isset($settings['_DB_SERVER_']) ? $settings['_DB_SERVER_'] : _DB_SERVER_,
isset($settings['_DB_USER_']) ? $settings['_DB_USER_'] : _DB_USER_,
isset($settings['_DB_PASSWD_']) ? $settings['_DB_PASSWD_'] : _DB_PASSWD_,
isset($settings['_DB_NAME_']) ? $settings['_DB_NAME_'] : _DB_NAME_,
true
) == 0)
{
rewriteSettingsFile(null, null, $settings);
Tools::redirectAdmin(self::$currentIndex.'&conf=6'.'&token='.$this->token);
}
else
$this->errors[] = Tools::displayError('Unable to connect to a database with these identifiers.');
}
}
// Change engine
if ($this->action == 'save')
{
if (!isset($_POST['tablesBox']) || !count($_POST['tablesBox']))
$this->errors[] = Tools::displayError('You did not select any tables');
else
{
$available_engines = $this->getEngines();
$tables_status = $this->getTablesStatus();
$tables_engine = array();
foreach ($tables_status as $table)
$tables_engine[$table['Name']] = $table['Engine'];
$engine_type = pSQL(Tools::getValue('engineType'));
/* Datas are not saved in database but in config/settings.inc.php */
$settings = array('_MYSQL_ENGINE_' => $engine_type);
rewriteSettingsFile(null, null, $settings);
foreach ($_POST['tablesBox'] as $table)
{
if ($engine_type == $tables_engine[$table])
$this->errors[] = $table.' '.$this->l('is already in').' '.$engine_type;
else
if (!Db::getInstance()->execute('ALTER TABLE `'.bqSQL($table).'` ENGINE=`'.bqSQL($engine_type).'`'))
$this->errors[] = $this->l('Can\'t change engine for').' '.$table;
}
if (!count($this->errors))
Tools::redirectAdmin(self::$currentIndex.'&conf=4'.'&token='.$this->token);
}
}
}
public function getEngines()
{
$engines = Db::getInstance()->executeS('SHOW ENGINES');
$allowed_engines = array();
foreach ($engines as $engine)
if (in_array($engine['Engine'], array('InnoDB', 'MyISAM')) && in_array($engine['Support'], array('DEFAULT', 'YES')))
$allowed_engines[] = $engine['Engine'];
return $allowed_engines;
}
public function getTablesStatus()
{
return Db::getInstance()->executeS('SHOW TABLE STATUS');
}
}
@@ -1,181 +0,0 @@
<?php
/*
* 2007-2012 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-2012 PrestaShop SA
* @version Release: $Revision: 6844 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminGeneratorControllerCore extends AdminController
{
protected $options = array('array for auto display');
public function __construct()
{
$this->ht_file = _PS_ROOT_DIR_.'/.htaccess';
$this->rb_file = _PS_ROOT_DIR_.'/robots.txt';
$this->sm_file = _PS_ROOT_DIR_.'/sitemap.xml';
$this->rb_data = $this->getRobotsContent();
return parent::__construct();
}
public function initContent()
{
$this->tpl_option_vars['checkConfiguration_ht'] = $this->checkConfiguration($this->ht_file);
$this->tpl_option_vars['checkConfiguration_rb'] = $this->checkConfiguration($this->rb_file);
$this->tpl_option_vars['ps_htaccess_cache_control'] = Configuration::get('PS_HTACCESS_CACHE_CONTROL');
$this->tpl_option_vars['ps_rewriting_settings'] = Configuration::get('PS_REWRITING_SETTINGS');
$this->tpl_option_vars['mod_rewrite'] = Tools::modRewriteActive();
$this->tpl_option_vars['ps_htaccess_disable_multiviews'] = Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS');
parent::initContent();
}
public function checkConfiguration($file)
{
if (file_exists($file))
return is_writable($file);
return is_writable(dirname($file));
}
public function postProcess()
{
if (Tools::isSubmit('submitHtaccess'))
{
if ($this->tabAccess['edit'] === '1')
{
Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', (int)Tools::getValue('PS_HTACCESS_CACHE_CONTROL'));
Configuration::updateValue('PS_REWRITING_SETTINGS', (int)Tools::getValue('PS_REWRITING_SETTINGS'));
Configuration::updateValue('PS_HTACCESS_DISABLE_MULTIVIEWS', (int)Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS'));
if (Tools::generateHtaccess($this->ht_file, null, null, '', Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS')))
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
$this->errors[] = $this->l('Cannot write into file:').' <b>'.$this->ht_file.'</b><br />'.$this->l('Please check write permissions.');
}
else
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
}
if (Tools::isSubmit('submitRobots'))
{
if ($this->tabAccess['edit'] === '1')
{
if (!$write_fd = @fopen($this->rb_file, 'w'))
$this->errors[] = sprintf(Tools::displayError('Cannot write into file: %s. Please check write permissions.'), $this->rb_file);
else
{
// PS Comments
fwrite($write_fd, "# robots.txt automaticaly generated by PrestaShop e-commerce open-source solution\n");
fwrite($write_fd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n");
fwrite($write_fd, "# This file is to prevent the crawling and indexing of certain parts\n");
fwrite($write_fd, "# of your site by web crawlers and spiders run by sites like Yahoo!\n");
fwrite($write_fd, "# and Google. By telling these \"robots\" where not to go on your site,\n");
fwrite($write_fd, "# you save bandwidth and server resources.\n");
fwrite($write_fd, "# For more information about the robots.txt standard, see:\n");
fwrite($write_fd, "# http://www.robotstxt.org/wc/robots.html\n");
//GoogleBot specific
fwrite($write_fd, "# GoogleBot specific\n");
fwrite($write_fd, "User-agent: Googlebot\n");
foreach ($this->rb_data['GB'] as $gb)
fwrite($write_fd, 'Disallow: '.__PS_BASE_URI__.$gb."\n");
// User-Agent
fwrite($write_fd, "# All bots\n");
fwrite($write_fd, "User-agent: *\n");
// Directories
fwrite($write_fd, "# Directories\n");
foreach ($this->rb_data['Directories'] as $dir)
fwrite($write_fd, 'Disallow: '.__PS_BASE_URI__.$dir."\n");
// Files
fwrite($write_fd, "# Files\n");
foreach ($this->rb_data['Files'] as $file)
fwrite($write_fd, 'Disallow: '.__PS_BASE_URI__.$file."\n");
// Sitemap
fwrite($write_fd, "# Sitemap\n");
if (file_exists($this->sm_file))
if (filesize($this->sm_file))
fwrite(
$write_fd,
'Sitemap: '.(Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].__PS_BASE_URI__.'sitemap.xml'."\n"
);
fwrite($write_fd, "\n");
fclose($write_fd);
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
}
} else
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
}
}
public function getRobotsContent()
{
$tab = array();
// Directories
$tab['Directories'] = array('classes/', 'config/', 'download/', 'mails/', 'modules/', 'translations/', 'tools/');
// Files
$disallow_controllers = array(
'addresses', 'address', 'authentication', 'cart', 'discount', 'footer',
'get-file', 'header', 'history', 'identity', 'images.inc', 'init', 'my-account', 'order', 'order-opc',
'order-slip', 'order-detail', 'order-follow', 'order-return', 'order-confirmation', 'pagination', 'password',
'pdf-invoice', 'pdf-order-return', 'pdf-order-slip', 'product-sort', 'search', 'statistics','attachment', 'guest-tracking'
);
// Rewrite files
$tab['Files'] = array();
if (Configuration::get('PS_REWRITING_SETTINGS'))
{
$sql = 'SELECT ml.url_rewrite
FROM '._DB_PREFIX_.'meta m
INNER JOIN '._DB_PREFIX_.'meta_lang ml ON ml.id_meta = m.id_meta
WHERE m.page IN (\''.implode('\', \'', $disallow_controllers).'\')';
if ($results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))
foreach ($results as $row)
$tab['Files'][] = $row['url_rewrite'];
}
$tab['GB'] = array(
'*orderby=','*orderway=','*tag=','*id_currency=','*search_query=','*id_lang=','*back=','*utm_source=','*utm_medium=','*utm_campaign=','*n='
);
foreach ($disallow_controllers as $controller)
$tab['GB'][] = '*controller='.$controller;
return $tab;
}
/**
* @see AdminController::initToolbar()
*/
public function initToolbar()
{
parent::initToolbar();
unset($this->toolbar_btn['save']);
}
}
+2 -2
View File
@@ -105,7 +105,7 @@ class AdminHomeControllerCore extends AdminController
$this->context->smarty->assign('hide_tips', Configuration::get('PS_HIDE_OPTIMIZATION_TIPS'));
$opti_list[] = array(
'title' => $this->l('URL rewriting'),
'href' => $link->getAdminLink('AdminGenerator'),
'href' => $link->getAdminLink('AdminMeta'),
'color' => $lights[$rewrite]['color'],
'image' => $lights[$rewrite]['image'],
);
@@ -147,7 +147,7 @@ class AdminHomeControllerCore extends AdminController
$opti_list[] = array(
'title' => $this->l('.htaccess up-to-date'),
'href' => $link->getAdminLink('AdminGenerator'),
'href' => $link->getAdminLink('AdminMeta'),
'color' => $lights[$htaccessAfterUpdate]['color'],
'image' => $lights[$htaccessAfterUpdate]['image'],
);
+92 -4
View File
@@ -55,12 +55,100 @@ class AdminImagesControllerCore extends AdminController
'description' => $this->l('JPEG images have a small file size and standard quality. PNG images have a bigger file size, a higher quality and support transparency. Note that in all cases the image files will have the .jpg extension.').'
<br /><br />'.$this->l('WARNING: This feature may not be compatible with your theme or with some modules. In particular, PNG mode is not compatible with the Watermark module. If you encounter any issue, turn it off by selecting "Use JPEG".'),
'fields' => array(
'PS_IMAGE_QUALITY' => array('title' => $this->l('Image quality'), 'show' => true, 'required' => true, 'type' => 'radio', 'choices' => array('jpg' => $this->l('Use JPEG'), 'png' => $this->l('Use PNG only if the base image is in PNG format'), 'png_all' => $this->l('Use PNG for all images'))),
'PS_JPEG_QUALITY' => array('title' => $this->l('JPEG quality'), 'desc' => $this->l('Ranges from 0 (worst quality, smallest file) to 100 (best quality, biggest file)'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'),
'PS_PNG_QUALITY' => array('title' => $this->l('PNG quality'), 'desc' => $this->l('Ranges from 9 (worst quality, smallest file) to 0 (best quality, biggest file)'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'),
'PS_IMAGE_QUALITY' => array(
'title' => $this->l('Image quality'),
'show' => true,
'required' => true,
'type' => 'radio',
'choices' => array('jpg' => $this->l('Use JPEG'), 'png' => $this->l('Use PNG only if the base image is in PNG format'), 'png_all' => $this->l('Use PNG for all images'))
),
'PS_JPEG_QUALITY' => array(
'title' => $this->l('JPEG quality'),
'desc' => $this->l('Ranges from 0 (worst quality, smallest file) to 100 (best quality, biggest file)'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text'
),
'PS_PNG_QUALITY' => array(
'title' => $this->l('PNG quality'),
'desc' => $this->l('Ranges from 9 (worst quality, smallest file) to 0 (best quality, biggest file)'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text'
),
),
'submit' => array('name' => 'submitImagePreferences'),
)
),
'product_images' => array(
'title' => $this->l('Products images'),
'fields' => array(
'PS_IMAGE_GENERATION_METHOD' => array(
'title' => $this->l('Image generated by:'),
'validation' => 'isUnsignedId',
'required' => false,
'cast' => 'intval',
'type' => 'select',
'list' => array(
array(
'id' => '0',
'name' => $this->l('auto')
),
array(
'id' => '1',
'name' => $this->l('width')
),
array(
'id' => '2',
'name' => $this->l('height')
)
),
'identifier' => 'id',
'visibility' => Shop::CONTEXT_ALL
),
'PS_PRODUCT_PICTURE_MAX_SIZE' => array(
'title' => $this->l('Maximum size of product pictures:'),
'desc' => $this->l('The maximum size of pictures uploadable by customers (in Bytes)'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('bytes'),
'visibility' => Shop::CONTEXT_ALL
),
'PS_PRODUCT_PICTURE_WIDTH' => array(
'title' => $this->l('Product pictures width:'),
'desc' => $this->l('The maximum width of pictures uploadable by customers'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text',
'width' => 'px',
'visibility' => Shop::CONTEXT_ALL
),
'PS_PRODUCT_PICTURE_HEIGHT' => array(
'title' => $this->l('Product pictures height:'),
'desc' => $this->l('The maximum height of pictures uploadable by customers'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text',
'height' => 'px',
'visibility' => Shop::CONTEXT_ALL
),
'PS_LEGACY_IMAGES' => array(
'title' => $this->l('Use the legacy image filesystem:'),
'desc' => $this->l('This should be set to yes unless you successfully moved images in Preferences > Images tab'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool',
'visibility' => Shop::CONTEXT_ALL
),
),
'submit' => array('title' => $this->l(' Save '), 'class' => 'button'),
),
);
$this->fields_form = array(
+2 -4
View File
@@ -2156,16 +2156,14 @@ class AdminImportControllerCore extends AdminController
case UPLOAD_ERR_INI_SIZE:
$this->errors[] = Tools::displayError('The uploaded file exceeds the upload_max_filesize directive in php.ini.
If your server configuration allows it, you may add a directive in your .htaccess, for example:')
.'<br/><a href="?tab=AdminGenerator&amp;token='
.Tools::getAdminTokenLite('AdminGenerator').'" >
.'<br/><a href="'.$this->context->link->getAdminLink('AdminMeta').'" >
<code>php_value upload_max_filesize 20M</code> '.
Tools::displayError('(clic to open Generator tab)').'</a>';
break;
case UPLOAD_ERR_FORM_SIZE:
$this->errors[] = Tools::displayError('The uploaded file exceeds the post_max_size directive in php.ini.
If your server configuration allows it, you may add a directive in your .htaccess, for example:')
.'<br/><a href="?tab=AdminGenerator&amp;token='
.Tools::getAdminTokenLite('AdminGenerator').'" >
.'<br/><a href="'.$this->context->link->getAdminLink('AdminMeta').'" >
<code>php_value post_max_size 20M</code> '.
Tools::displayError('(clic to open Generator tab)').'</a>';
break;
@@ -37,11 +37,15 @@ class AdminInformationControllerCore extends AdminController
{
$this->tpl_view_vars = array(
'version' => array(
'mysql' => Db::getInstance()->getVersion(),
'php' => phpversion(),
'ps' => _PS_VERSION_,
'server' => $_SERVER['SERVER_SOFTWARE'],
),
'database' => array(
'version' => Db::getInstance()->getVersion(),
'prefix' => _DB_PREFIX_,
'engine' => _MYSQL_ENGINE_,
),
'uname' => function_exists('php_uname') ? php_uname('s').' '.php_uname('v').' '.php_uname('m') : '',
'apache_instaweb' => Tools::apacheModExists('mod_instaweb'),
'shop' => array(
@@ -94,22 +94,6 @@ class AdminLanguagesControllerCore extends AdminController
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->specificConfirmDelete = $this->l('When you delete a language, ALL RELATED TRANSLATIONS IN THE DATABASE WILL BE DELETED, are you sure you want to delete this language?');
$this->options = array(
'general' => array(
'title' => $this->l('Languages options'),
'fields' => array(
'PS_LANG_DEFAULT' => array(
'title' => $this->l('Default language:'),
'desc' => $this->l('The default language used in shop'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id_lang',
'list' => Language::getlanguages(false)
)
),
'submit' => array()
)
);
parent::__construct();
}
@@ -478,13 +462,6 @@ class AdminLanguagesControllerCore extends AdminController
parent::copyFromPost($object, $table);
}
public function beforeUpdateOptions()
{
$lang = new Language((int)Tools::getValue('PS_LANG_DEFAULT'));
if (!$lang->active)
$this->errors[] = Tools::displayError('You cannot set this language as default language because it\'s disabled');
}
public function ajaxProcessCheckLangPack()
{
$this->json = true;
@@ -32,7 +32,43 @@ class AdminLocalizationControllerCore extends AdminController
$this->className = 'Configuration';
$this->table = 'configuration';
parent::__construct();
$this->options = array(
'general' => array(
'title' => $this->l('Configuration'),
'fields' => array(
'PS_LANG_DEFAULT' => array(
'title' => $this->l('Default language:'),
'desc' => $this->l('The default language used in shop'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id_lang',
'list' => Language::getlanguages(false)
),
'PS_COUNTRY_DEFAULT' => array(
'title' => $this->l('Default country:'),
'desc' => $this->l('The default country used in shop'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id_country',
'list' => Country::getCountries($this->context->language->id)
),
'PS_CURRENCY_DEFAULT' => array(
'title' => $this->l('Default currency:'),
'desc' =>
$this->l('The default currency used in shop')
.'<div class="warn">'
.$this->l('If you change default currency, you will have to manually edit every product price.')
.'</div>',
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id_currency',
'list' => Currency::getCurrencies()
),
),
'submit' => array()
),
'localization' => array(
'title' => $this->l('Localization'),
'width' => 'width2',
@@ -88,11 +124,20 @@ class AdminLocalizationControllerCore extends AdminController
'type' => 'text',
'visibility' => Shop::CONTEXT_ALL
)
)
),
'submit' => array('title' => $this->l(' Save '), 'class' => 'button')
)
);
parent::__construct();
if (function_exists('date_default_timezone_set'))
$this->options['general']['fields']['PS_TIMEZONE'] = array(
'title' => $this->l('Time Zone:'),
'validation' => 'isAnything',
'type' => 'select',
'list' => Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT name FROM '._DB_PREFIX_.'timezone'),
'identifier' => 'name',
'visibility' => Shop::CONTEXT_ALL
);
}
public function postProcess()
@@ -231,18 +276,29 @@ class AdminLocalizationControllerCore extends AdminController
public function initContent()
{
// toolbar (save, cancel, new, ..)
$this->initToolbar();
$this->content .= $this->renderOptions();
if (!$this->loadObject(true))
return;
$this->content .= $this->renderForm();
// toolbar (save, cancel, new, ..)
$this->initToolbar();
$this->context->smarty->assign(array(
'content' => $this->content,
'localization_form' => $this->renderForm(),
'localization_options' => $this->renderOptions(),
'url_post' => self::$currentIndex.'&token='.$this->token,
));
}
public function beforeUpdateOptions()
{
$lang = new Language((int)Tools::getValue('PS_LANG_DEFAULT'));
if (!$lang->active)
$this->errors[] = Tools::displayError('You cannot set this language as default language because it\'s disabled');
}
public function updateOptionPsCurrencyDefault($value)
{
Configuration::updateValue('PS_CURRENCY_DEFAULT', $value);
Currency::refreshCurrencies();
}
}
@@ -0,0 +1,62 @@
<?php
/*
* 2007-2012 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-2012 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 AdminMaintenanceControllerCore extends AdminController
{
public function __construct()
{
$this->className = 'Configuration';
$this->table = 'configuration';
parent::__construct();
$this->options = array(
'general' => array(
'title' => $this->l('General'),
'icon' => 'tab-preferences',
'fields' => array(
'PS_SHOP_ENABLE' => array(
'title' => $this->l('Enable Shop'),
'desc' => $this->l('Activate or deactivate your shop. Deactivate your shop while you perform maintenance on it. Please note that the webservice will not be disabled'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_MAINTENANCE_IP' => array(
'title' => $this->l('Maintenance IP'),
'desc' => $this->l('IP addresses allowed to access the Front Office even if shop is disabled. Use a comma to separate them (e.g., 42.24.4.2,127.0.0.1,99.98.97.96)'),
'validation' => 'isGenericName',
'type' => 'maintenance_ip',
'size' => 30,
'default' => ''
),
),
'submit' => array('title' => $this->l(' Save '), 'class' => 'button'),
),
);
}
}
+163 -18
View File
@@ -36,6 +36,11 @@ class AdminMetaControllerCore extends AdminController
{
parent::__construct();
$this->ht_file = _PS_ROOT_DIR_.'/.htaccess';
$this->rb_file = _PS_ROOT_DIR_.'/robots.txt';
$this->sm_file = _PS_ROOT_DIR_.'/sitemap.xml';
$this->rb_data = $this->getRobotsContent();
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
@@ -49,28 +54,64 @@ class AdminMetaControllerCore extends AdminController
$this->_group = 'GROUP BY a.id_meta';
$mod_rewrite = Tools::modRewriteActive();
$general_fields = array(
'PS_REWRITING_SETTINGS' => array(
'title' => $this->l('Friendly URL'),
'desc' => ($mod_rewrite ? $this->l('Enable only if your server allows URL rewriting (recommended)') : ''),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'rewriting_settings',
'mod_rewrite' => $mod_rewrite
),
'PS_CANONICAL_REDIRECT' => array(
'title' => $this->l('Automatically redirect to Canonical url'),
'desc' => $this->l('Recommended but your theme must be compliant'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
);
if ($this->checkConfiguration($this->ht_file))
$general_fields['PS_HTACCESS_DISABLE_MULTIVIEWS'] = array(
'title' => $this->l('Disable apache multiviews'),
'desc' => $this->l('Enable this option only if you have problems with some pages URL rewriting.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
);
// Options to generate robot.txt
$robots_description = $this->l('Your file robots.txt MUST be in your website\'s root directory and nowhere else.');
$robots_description .= '<br />'.$this->l('eg: http://www.yoursite.com/robots.txt');
if ($this->checkConfiguration($this->rb_file))
{
$robots_description .= '<br />'.$this->l('Generate your "robots.txt" file by clicking on the following button (this will erase your old robots.txt file):');
$robots_submit = array('name' => 'submitRobots', 'title' => $this->l('Generate robots.txt file'));
}
else
{
$robots_description .= '<br />'.$this->l('Before being able to use this tool, you need to:');
$robots_description .= '<br />- '.$this->l('create a robots.txt blank file in your root dir');
$robots_description .= '<br />- '.$this->l(' give it write permissions (CHMOD 666 on Unix system)');
}
$robots_options = array(
'title' => $this->l('Robots file generation'),
'description' => $robots_description,
);
if (isset($robots_submit))
$robots_options['submit'] = $robots_submit;
// List of options
$this->options = array(
'general' => array(
'title' => $this->l('URLs Setup'),
'fields' => array(
'PS_REWRITING_SETTINGS' => array(
'title' => $this->l('Friendly URL'),
'desc' => ($mod_rewrite ? $this->l('Enable only if your server allows URL rewriting (recommended)') : ''),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'rewriting_settings',
'mod_rewrite' => $mod_rewrite
),
'PS_CANONICAL_REDIRECT' => array(
'title' => $this->l('Automatically redirect to Canonical url'),
'desc' => $this->l('Recommended but your theme must be compliant'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
),
'fields' => $general_fields,
'submit' => array()
),
'robots' => $robots_options,
'routes' => array(
'title' => $this->l('Schema of URLs'),
'description' => $this->l('You can change here the pattern of your links. There are some available keywords for each route listed below, keywords with * are required. To add a keyword in URL use {keyword} syntax. You can add some text before or after the keyword IF the keyword is not empty with syntax {prepend:keyword:append}, for example {-hey-:meta_title} will add "-hey-my-title" in URL if meta title is set, or nothing. Friendly URL and rewriting Apache option must be activated on your web server to use this functionality.'),
@@ -225,10 +266,63 @@ class AdminMetaControllerCore extends AdminController
}
Hook::exec('actionAdminMetaSave');
}
else if (Tools::isSubmit('submitRobots'))
$this->generateRobotsFile();
return parent::postProcess();
}
public function generateRobotsFile()
{
if (!$write_fd = @fopen($this->rb_file, 'w'))
$this->errors[] = sprintf(Tools::displayError('Cannot write into file: %s. Please check write permissions.'), $this->rb_file);
else
{
// PS Comments
fwrite($write_fd, "# robots.txt automaticaly generated by PrestaShop e-commerce open-source solution\n");
fwrite($write_fd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n");
fwrite($write_fd, "# This file is to prevent the crawling and indexing of certain parts\n");
fwrite($write_fd, "# of your site by web crawlers and spiders run by sites like Yahoo!\n");
fwrite($write_fd, "# and Google. By telling these \"robots\" where not to go on your site,\n");
fwrite($write_fd, "# you save bandwidth and server resources.\n");
fwrite($write_fd, "# For more information about the robots.txt standard, see:\n");
fwrite($write_fd, "# http://www.robotstxt.org/wc/robots.html\n");
//GoogleBot specific
fwrite($write_fd, "# GoogleBot specific\n");
fwrite($write_fd, "User-agent: Googlebot\n");
foreach ($this->rb_data['GB'] as $gb)
fwrite($write_fd, 'Disallow: '.__PS_BASE_URI__.$gb."\n");
// User-Agent
fwrite($write_fd, "# All bots\n");
fwrite($write_fd, "User-agent: *\n");
// Directories
fwrite($write_fd, "# Directories\n");
foreach ($this->rb_data['Directories'] as $dir)
fwrite($write_fd, 'Disallow: '.__PS_BASE_URI__.$dir."\n");
// Files
fwrite($write_fd, "# Files\n");
foreach ($this->rb_data['Files'] as $file)
fwrite($write_fd, 'Disallow: '.__PS_BASE_URI__.$file."\n");
// Sitemap
fwrite($write_fd, "# Sitemap\n");
if (file_exists($this->sm_file))
if (filesize($this->sm_file))
fwrite(
$write_fd,
'Sitemap: '.(Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].__PS_BASE_URI__.'sitemap.xml'."\n"
);
fwrite($write_fd, "\n");
fclose($write_fd);
$this->redirect_after = self::$currentIndex.'&conf=4&token='.$this->token;
}
}
public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $limit = null, $id_lang_shop = false)
{
parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, Context::getContext()->shop->id);
@@ -268,7 +362,7 @@ class AdminMetaControllerCore extends AdminController
public function updateOptionPsRewritingSettings()
{
Configuration::updateValue('PS_REWRITING_SETTINGS', (int)Tools::getValue('PS_REWRITING_SETTINGS'));
Tools::generateHtaccess();
Tools::generateHtaccess($this->ht_file, null, null, '', Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS'));
}
public function updateOptionPsRouteProductRule()
@@ -340,4 +434,55 @@ class AdminMetaControllerCore extends AdminController
$this->addFieldRoute('cms_category_rule', $this->l('Route to CMS category'));
$this->addFieldRoute('module', $this->l('Route to modules'));
}
/**
* Check if a file is writable
*
* @param string $file
* @return bool
*/
public function checkConfiguration($file)
{
if (file_exists($file))
return is_writable($file);
return is_writable(dirname($file));
}
public function getRobotsContent()
{
$tab = array();
// Directories
$tab['Directories'] = array('classes/', 'config/', 'download/', 'mails/', 'modules/', 'translations/', 'tools/');
// Files
$disallow_controllers = array(
'addresses', 'address', 'authentication', 'cart', 'discount', 'footer',
'get-file', 'header', 'history', 'identity', 'images.inc', 'init', 'my-account', 'order', 'order-opc',
'order-slip', 'order-detail', 'order-follow', 'order-return', 'order-confirmation', 'pagination', 'password',
'pdf-invoice', 'pdf-order-return', 'pdf-order-slip', 'product-sort', 'search', 'statistics','attachment', 'guest-tracking'
);
// Rewrite files
$tab['Files'] = array();
if (Configuration::get('PS_REWRITING_SETTINGS'))
{
$sql = 'SELECT ml.url_rewrite
FROM '._DB_PREFIX_.'meta m
INNER JOIN '._DB_PREFIX_.'meta_lang ml ON ml.id_meta = m.id_meta
WHERE m.page IN (\''.implode('\', \'', $disallow_controllers).'\')';
if ($results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))
foreach ($results as $row)
$tab['Files'][] = $row['url_rewrite'];
}
$tab['GB'] = array(
'*orderby=','*orderway=','*tag=','*id_currency=','*search_query=','*id_lang=','*back=','*utm_source=','*utm_medium=','*utm_campaign=','*n='
);
foreach ($disallow_controllers as $controller)
$tab['GB'][] = '*controller='.$controller;
return $tab;
}
}
@@ -0,0 +1,184 @@
<?php
/*
* 2007-2012 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-2012 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 AdminOrderPreferencesControllerCore extends AdminController
{
public function __construct()
{
$this->className = 'Configuration';
$this->table = 'configuration';
parent::__construct();
// List of CMS tabs
$cms_tab = array(0 => array(
'id' => 0,
'name' => $this->l('None')
));
foreach (CMS::listCms($this->context->language->id) as $cms_file)
$cms_tab[] = array('id' => $cms_file['id_cms'], 'name' => $cms_file['meta_title']);
// List of order process types
$order_process_type = array(
array(
'value' => PS_ORDER_PROCESS_STANDARD,
'name' => $this->l('Standard (5 steps)')
),
array(
'value' => PS_ORDER_PROCESS_OPC,
'name' => $this->l('One page checkout')
)
);
// Tax list
$taxes[] = array('id' => 0, 'name' => $this->l('None'));
foreach (Tax::getTaxes($this->context->language->id) as $tax)
$taxes[] = array('id' => $tax['id_tax'], 'name' => $tax['name']);
$this->options = array(
'general' => array(
'title' => $this->l('General'),
'icon' => 'tab-preferences',
'fields' => array(
'PS_ORDER_PROCESS_TYPE' => array(
'title' => $this->l('Order process type'),
'desc' => $this->l('You can choose the order process type as either standard (5 steps) or One Page Checkout'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'select',
'list' => $order_process_type,
'identifier' => 'value'
),
'PS_GUEST_CHECKOUT_ENABLED' => array(
'title' => $this->l('Enable guest checkout'),
'desc' => $this->l('Your guest can make an order without registering'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_PURCHASE_MINIMUM' => array(
'title' => $this->l('Minimum purchase total required in order to validate order:'),
'desc' => $this->l('Set to 0 to disable this feature'),
'validation' => 'isFloat',
'cast' => 'floatval',
'type' => 'price'
),
'PS_ALLOW_MULTISHIPPING' => array(
'title' => $this->l('Allow multi-shipping'),
'desc' => $this->l('Allow the customer to ship his order to multiple addresses. This option will transform the customer cart in one or more orders.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_SHIP_WHEN_AVAILABLE' => array(
'title' => $this->l('Delayed shipping'),
'desc' => $this->l('Allow the customer to split his order. One with the products "in stock", and an other with the other products. This option will transform the customer cart in two orders.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_CONDITIONS' => array(
'title' => $this->l('Terms of service'),
'desc' => $this->l('Require customers to accept or decline terms of service before processing the order'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'js' => array(
'on' => 'onchange="changeCMSActivationAuthorization()"',
'off' => 'onchange="changeCMSActivationAuthorization()"'
)
),
'PS_CONDITIONS_CMS_ID' => array(
'title' => $this->l('Conditions of use CMS page'),
'desc' => $this->l('Choose the Conditions of use CMS page'),
'validation' => 'isInt',
'type' => 'select',
'list' => $cms_tab,
'identifier' => 'id',
'cast' => 'intval'
),
),
'submit' => array('title' => $this->l(' Save '), 'class' => 'button'),
),
'gift' => array(
'title' => $this->l('Gift options'),
'icon' => 'tab-preferences',
'fields' => array(
'PS_GIFT_WRAPPING' => array(
'title' => $this->l('Offer gift-wrapping'),
'desc' => $this->l('Suggest gift-wrapping to customer and possibility of leaving a message'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_GIFT_WRAPPING_PRICE' => array(
'title' => $this->l('Gift-wrapping price'),
'desc' => $this->l('Set a price for gift-wrapping'),
'validation' => 'isPrice',
'cast' => 'floatval',
'type' => 'price'
),
'PS_GIFT_WRAPPING_TAX' => array(
'title' => $this->l('Gift-wrapping tax'),
'desc' => $this->l('Set a tax for gift-wrapping'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'select',
'list' => $taxes,
'identifier' => 'id'
),
'PS_RECYCLABLE_PACK' => array(
'title' => $this->l('Offer recycled packaging'),
'desc' => $this->l('Suggest recycled packaging to customer'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_GIFT_WRAPPING_ACCOUNT_NUMBER' => array(
'title' => $this->l('Gift-wrapping account number'),
'desc' => $this->l('Set an account number for your gift-wrapping (used for accounting)'),
'validation' => 'isString',
'type' => 'text',
'size' => 30,
),
),
'submit' => array('title' => $this->l(' Save '), 'class' => 'button'),
),
);
}
/**
* This method is called before we start to update options configuration
*/
public function beforeUpdateOptions()
{
$sql = 'SELECT `id_cms` FROM `'._DB_PREFIX_.'cms`
WHERE id_cms = '.(int)Tools::getValue('PS_CONDITIONS_CMS_ID');
if (Tools::getValue('PS_CONDITIONS') && (Tools::getValue('PS_CONDITIONS_CMS_ID') == 0 || !Db::getInstance()->getValue($sql)))
$this->errors[] = Tools::displayError('Assign a valid CMS page if you want it to be read.');
}
}
+61 -135
View File
@@ -35,6 +35,67 @@ class AdminPPreferencesControllerCore extends AdminController
parent::__construct();
$this->options = array(
'products' => array(
'title' => $this->l('Products (general)'),
'fields' => array(
'PS_CATALOG_MODE' => array(
'title' => $this->l('Catalog mode:'),
'desc' => $this->l('When active, all features for shopping will be disabled'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_COMPARATOR_MAX_ITEM' => array(
'title' => $this->l('Max items in the comparator:'),
'desc' => $this->l('Specify here the threshold from which be displayed a message announcing an upcoming out of stock.').' '.$this->l('Set to 0 to disable this feature'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text'
),
'PS_NB_DAYS_NEW_PRODUCT' => array(
'title' => $this->l('Number of days during which the product is considered \'new\':'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text'
),
'PS_CART_REDIRECT' => array(
'title' => $this->l('Re-direction after adding product to cart:'),
'desc' => $this->l('Concerns only the non-AJAX version of the cart'),
'cast' => 'intval',
'show' => true,
'required' => false,
'type' => 'radio',
'validation' => 'isBool',
'choices' => array(
0 => $this->l('previous page'),
1 => $this->l('cart summary')
)
),
'PS_PRODUCT_SHORT_DESC_LIMIT' => array(
'title' => $this->l('Short description max size'),
'desc' => $this->l('Set the maximum size of product short description'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('characters'),
),
'PS_QTY_DISCOUNT_ON_COMBINATION' => array(
'title' => $this->l('Quantity discounts based on:'),
'desc' => $this->l('How to calculate quantity discounts'),
'cast' => 'intval',
'show' => true,
'required' => false,
'type' => 'radio',
'validation' => 'isBool',
'choices' => array(
0 => $this->l('Products'),
1 => $this->l('Combinations')
)
)
),
),
'order_by_pagination' => array(
'title' => $this->l('Pagination'),
'fields' => array(
@@ -121,73 +182,6 @@ class AdminPPreferencesControllerCore extends AdminController
)
)
),
'product_images' => array(
'title' => $this->l('Products images'),
'fields' => array(
'PS_IMAGE_GENERATION_METHOD' => array(
'title' => $this->l('Image generated by:'),
'validation' => 'isUnsignedId',
'required' => false,
'cast' => 'intval',
'type' => 'select',
'list' => array(
array(
'id' => '0',
'name' => $this->l('auto')
),
array(
'id' => '1',
'name' => $this->l('width')
),
array(
'id' => '2',
'name' => $this->l('height')
)
),
'identifier' => 'id',
'visibility' => Shop::CONTEXT_ALL
),
'PS_PRODUCT_PICTURE_MAX_SIZE' => array(
'title' => $this->l('Maximum size of product pictures:'),
'desc' => $this->l('The maximum size of pictures uploadable by customers (in Bytes)'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('bytes'),
'visibility' => Shop::CONTEXT_ALL
),
'PS_PRODUCT_PICTURE_WIDTH' => array(
'title' => $this->l('Product pictures width:'),
'desc' => $this->l('The maximum width of pictures uploadable by customers'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text',
'suffix' => 'px',
'visibility' => Shop::CONTEXT_ALL
),
'PS_PRODUCT_PICTURE_HEIGHT' => array(
'title' => $this->l('Product pictures height:'),
'desc' => $this->l('The maximum height of pictures uploadable by customers'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text',
'suffix' => 'px',
'visibility' => Shop::CONTEXT_ALL
),
'PS_LEGACY_IMAGES' => array(
'title' => $this->l('Use the legacy image filesystem:'),
'desc' => $this->l('This should be set to yes unless you successfully moved images in Preferences > Images tab'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool',
'visibility' => Shop::CONTEXT_ALL
),
)
),
'stock' => array(
'title' => $this->l('Products stock'),
'fields' => array(
@@ -220,74 +214,6 @@ class AdminPPreferencesControllerCore extends AdminController
'type' => 'bool',
'visibility' => Shop::CONTEXT_ALL
),
)
),
'products' => array(
'title' => $this->l('Products (general)'),
'fields' => array(
'PS_CATALOG_MODE' => array(
'title' => $this->l('Catalog mode:'),
'desc' => $this->l('When active, all features for shopping will be disabled'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_COMPARATOR_MAX_ITEM' => array(
'title' => $this->l('Max items in the comparator:'),
'desc' => $this->l('Specify here the threshold from which be displayed a message announcing an upcoming out of stock.').' '.$this->l('Set to 0 to disable this feature'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text'
),
'PS_PURCHASE_MINIMUM' => array(
'title' => $this->l('Minimum purchase total required in order to validate order:'),
'desc' => $this->l('Set to 0 to disable this feature'),
'validation' => 'isFloat',
'cast' => 'floatval',
'type' => 'price'
),
'PS_NB_DAYS_NEW_PRODUCT' => array(
'title' => $this->l('Number of days during which the product is considered \'new\':'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text'
),
'PS_CART_REDIRECT' => array(
'title' => $this->l('Re-direction after adding product to cart:'),
'desc' => $this->l('Concerns only the non-AJAX version of the cart'),
'cast' => 'intval',
'show' => true,
'required' => false,
'type' => 'radio',
'validation' => 'isBool',
'choices' => array(
0 => $this->l('previous page'),
1 => $this->l('cart summary')
)
),
'PS_PRODUCT_SHORT_DESC_LIMIT' => array(
'title' => $this->l('Short description max size'),
'desc' => $this->l('Set the maximum size of product short description'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('characters')
),
'PS_QTY_DISCOUNT_ON_COMBINATION' => array(
'title' => $this->l('Quantity discounts based on:'),
'desc' => $this->l('How to calculate quantity discounts'),
'cast' => 'intval',
'show' => true,
'required' => false,
'type' => 'radio',
'validation' => 'isBool',
'choices' => array(
0 => $this->l('Products'),
1 => $this->l('Combinations')
)
)
),
'bottom' => '<script type="text/javascript">stockManagementActivationAuthorization();</script>',
'submit' => array()
@@ -192,7 +192,7 @@ class AdminPerformanceControllerCore extends AdminController
'input' => array(
array(
'type' => 'hidden',
'name' => 'ccc_up'
'name' => 'ccc_up',
),
array(
'type' => 'radio',
@@ -288,6 +288,26 @@ class AdminPerformanceControllerCore extends AdminController
'label' => $this->l('Keep W3C validation')
)
)
),
array(
'type' => 'radio',
'label' => $this->l('Apache optimization'),
'name' => 'PS_HTACCESS_CACHE_CONTROL',
'class' => 't',
'desc' => $this->l('This will add directives to your .htaccess file which should improve caching and compression.'),
'is_bool' => true,
'values' => array(
array(
'id' => 'PS_HTACCESS_CACHE_CONTROL_1',
'value' => 1,
'label' => $this->l('Yes'),
),
array(
'id' => 'PS_HTACCESS_CACHE_CONTROL_0',
'value' => 0,
'label' => $this->l('No'),
),
),
)
)
);
@@ -297,6 +317,8 @@ class AdminPerformanceControllerCore extends AdminController
$this->fields_value['PS_HTML_THEME_COMPRESSION'] = Configuration::get('PS_HTML_THEME_COMPRESSION');
$this->fields_value['PS_JS_HTML_THEME_COMPRESSION'] = Configuration::get('PS_JS_HTML_THEME_COMPRESSION');
$this->fields_value['PS_HIGH_HTML_THEME_COMPRESSION'] = Configuration::get('PS_HIGH_HTML_THEME_COMPRESSION');
$this->fields_value['PS_HTACCESS_CACHE_CONTROL'] = Configuration::get('PS_HTACCESS_CACHE_CONTROL');
$this->fields_value['ccc_up'] = 1;
}
public function initFieldsetMediaServer()
@@ -585,10 +607,15 @@ class AdminPerformanceControllerCore extends AdminController
!Configuration::updateValue('PS_JS_THEME_CACHE', (int)Tools::getValue('PS_JS_THEME_CACHE')) ||
!Configuration::updateValue('PS_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_HTML_THEME_COMPRESSION')) ||
!Configuration::updateValue('PS_JS_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_JS_HTML_THEME_COMPRESSION')) ||
!Configuration::updateValue('PS_HIGH_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_HIGH_HTML_THEME_COMPRESSION')))
!Configuration::updateValue('PS_HIGH_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_HIGH_HTML_THEME_COMPRESSION')) ||
!Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', (int)Tools::getValue('PS_HTACCESS_CACHE_CONTROL')))
$this->errors[] = Tools::displayError('Unknown error.');
else
{
$redirecAdmin = true;
if (Configuration::get('PS_HTACCESS_CACHE_CONTROL'))
Tools::generateHtaccess();
}
}
else
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
@@ -34,40 +34,11 @@ class AdminPreferencesControllerCore extends AdminController
$this->className = 'Configuration';
$this->table = 'configuration';
$max_upload = (int)ini_get('upload_max_filesize');
$max_post = (int)ini_get('post_max_size');
$upload_mb = min($max_upload, $max_post);
// Prevent classes which extend AdminPreferences to load useless data
if (get_class($this) == 'AdminPreferencesController')
{
$timezones = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT name FROM '._DB_PREFIX_.'timezone');
$taxes[] = array('id' => 0, 'name' => $this->l('None'));
foreach (Tax::getTaxes($this->context->language->id) as $tax)
$taxes[] = array('id' => $tax['id_tax'], 'name' => $tax['name']);
$order_process_type = array(
array(
'value' => PS_ORDER_PROCESS_STANDARD,
'name' => $this->l('Standard (5 steps)')
),
array(
'value' => PS_ORDER_PROCESS_OPC,
'name' => $this->l('One page checkout')
)
);
$registration_process_type = array(
array(
'value' => PS_REGISTRATION_PROCESS_STANDARD,
'name' => $this->l('Only account creation')
),
array(
'value' => PS_REGISTRATION_PROCESS_AIO,
'name' => $this->l('Standard (account creation and address creation)')
)
);
$round_mode = array(
array(
'value' => PS_ROUND_UP,
@@ -83,31 +54,7 @@ class AdminPreferencesControllerCore extends AdminController
)
);
$cms_tab = array(0 =>
array(
'id' => 0,
'name' => $this->l('None')
)
);
foreach (CMS::listCms($this->context->language->id) as $cms_file)
$cms_tab[] = array('id' => $cms_file['id_cms'], 'name' => $cms_file['meta_title']);
$fields = array(
'PS_SHOP_ENABLE' => array(
'title' => $this->l('Enable Shop'),
'desc' => $this->l('Activate or deactivate your shop. Deactivate your shop while you perform maintenance on it. Please note that the webservice will not be disabled'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_MAINTENANCE_IP' => array(
'title' => $this->l('Maintenance IP'),
'desc' => $this->l('IP addresses allowed to access the Front Office even if shop is disabled. Use a comma to separate them (e.g., 42.24.4.2,127.0.0.1,99.98.97.96)'),
'validation' => 'isGenericName',
'type' => 'maintenance_ip',
'size' => 30,
'default' => ''
),
'PS_SSL_ENABLED' => array(
'title' => $this->l('Enable SSL'),
'desc' => $this->l('If your hosting provider allows SSL, you can activate SSL encryption (https://) for customer account identification and order processing'),
@@ -116,15 +63,6 @@ class AdminPreferencesControllerCore extends AdminController
'type' => 'bool',
'default' => '0'
),
'PS_COOKIE_CHECKIP' => array(
'title' => $this->l('Check IP on the cookie'),
'desc' => $this->l('Check the IP address of the cookie in order to avoid your cookie being stolen'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'default' => '0',
'visibility' => Shop::CONTEXT_ALL
),
'PS_TOKEN_ENABLE' => array(
'title' => $this->l('Increase Front Office security'),
'desc' => $this->l('Enable or disable token on the Front Office in order to improve PrestaShop security'),
@@ -134,152 +72,6 @@ class AdminPreferencesControllerCore extends AdminController
'default' => '0',
'visibility' => Shop::CONTEXT_ALL
),
'PS_HELPBOX' => array(
'title' => $this->l('Back Office help boxes'),
'desc' => $this->l('Enable yellow help boxes which are displayed under form fields in the Back Office'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'visibility' => Shop::CONTEXT_ALL
),
'PS_COOKIE_LIFETIME_FO' => array(
'title' => $this->l('Lifetime of the Front Office cookie'),
'desc' => $this->l('Indicate the number of hours'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'default' => '480',
'visibility' => Shop::CONTEXT_ALL
),
'PS_COOKIE_LIFETIME_BO' => array(
'title' => $this->l('Lifetime of the Back Office cookie'),
'desc' => $this->l('Indicate the number of hours'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'default' => '480',
'visibility' => Shop::CONTEXT_ALL
),
'PS_B2B_ENABLE' => array(
'title' => $this->l('Enable B2B mode'),
'desc' => $this->l('Activate or deactivate B2B mode. When this option is enable some features about B2B appear.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_ORDER_PROCESS_TYPE' => array(
'title' => $this->l('Order process type'),
'desc' => $this->l('You can choose the order process type as either standard (5 steps) or One Page Checkout'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'select',
'list' => $order_process_type,
'identifier' => 'value'
),
'PS_ALLOW_MULTISHIPPING' => array(
'title' => $this->l('Allow multi-shipping'),
'desc' => $this->l('Allow the customer to ship his order to multiple addresses. This option will transform the customer cart in one or more orders.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_SHIP_WHEN_AVAILABLE' => array(
'title' => $this->l('Delayed shipping'),
'desc' => $this->l('Allow the customer to split his order. One with the products "in stock", and an other with the other products. This option will transform the customer cart in two orders.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_REGISTRATION_PROCESS_TYPE' => array(
'title' => $this->l('Registration process type'),
'desc' => $this->l('The "Only account creation" step register process allows the customer to register faster, and create his address later.'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'select',
'list' => $registration_process_type,
'identifier' => 'value'
),
'PS_GUEST_CHECKOUT_ENABLED' => array(
'title' => $this->l('Enable guest checkout'),
'desc' => $this->l('Your guest can make an order without registering'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_CONDITIONS' => array(
'title' => $this->l('Terms of service'),
'desc' => $this->l('Require customers to accept or decline terms of service before processing the order'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'js' => array(
'on' => 'onchange="changeCMSActivationAuthorization()"',
'off' => 'onchange="changeCMSActivationAuthorization()"'
)
),
'PS_CONDITIONS_CMS_ID' => array(
'title' => $this->l('Conditions of use CMS page'),
'desc' => $this->l('Choose the Conditions of use CMS page'),
'validation' => 'isInt',
'type' => 'select',
'list' => $cms_tab,
'identifier' => 'id',
'cast' => 'intval'
),
'PS_GIFT_WRAPPING' => array(
'title' => $this->l('Offer gift-wrapping'),
'desc' => $this->l('Suggest gift-wrapping to customer and possibility of leaving a message'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_GIFT_WRAPPING_PRICE' => array(
'title' => $this->l('Gift-wrapping price'),
'desc' => $this->l('Set a price for gift-wrapping'),
'validation' => 'isPrice',
'cast' => 'floatval',
'type' => 'price'
),
'PS_GIFT_WRAPPING_TAX' => array(
'title' => $this->l('Gift-wrapping tax'),
'desc' => $this->l('Set a tax for gift-wrapping'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'select',
'list' => $taxes,
'identifier' => 'id'
),
'PS_GIFT_WRAPPING_ACCOUNT_NUMBER' => array(
'title' => $this->l('Gift-wrapping account number'),
'desc' => $this->l('Set an account number for your gift-wrapping (used for accounting)'),
'validation' => 'isString',
'type' => 'text',
'size' => 30,
),
'PS_ATTACHMENT_MAXIMUM_SIZE' => array(
'title' => $this->l('Attachment maximum size'),
'desc' => $this->l('Set the maximum size of attachment files (in MegaBytes).').' '.$this->l('Maximum:').' '.
((int)str_replace('M', '', ini_get('post_max_size')) > (int)str_replace('M', '', ini_get('upload_max_filesize')) ? ini_get('upload_max_filesize') : ini_get('post_max_size')),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'default' => '2'
),
'PS_RECYCLABLE_PACK' => array(
'title' => $this->l('Offer recycled packaging'),
'desc' => $this->l('Suggest recycled packaging to customer'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_CART_FOLLOWING' => array(
'title' => $this->l('Cart re-display at login'),
'desc' => $this->l('After customer logs in, recall and display contents of his/her last shopping cart'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_PRICE_ROUND_MODE' => array(
'title' => $this->l('Round mode'),
'desc' => $this->l('You can choose how to round prices: always round superior; always round inferior, or classic rounding'),
@@ -289,21 +81,6 @@ class AdminPreferencesControllerCore extends AdminController
'list' => $round_mode,
'identifier' => 'value'
),
'PRESTASTORE_LIVE' => array(
'title' => $this->l('Automatically check for module updates'),
'desc' => $this->l('New modules and updates are displayed on the modules page'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'visibility' => Shop::CONTEXT_ALL
),
'PS_HIDE_OPTIMIZATION_TIPS' => array(
'title' => $this->l('Hide optimization tips'),
'desc' => $this->l('Hide optimization tips on the back office homepage'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_DISPLAY_SUPPLIERS' => array(
'title' => $this->l('Display suppliers and manufacturers'),
'desc' => $this->l('Display manufacturers and suppliers list even if corresponding blocks are disabled'),
@@ -311,57 +88,8 @@ class AdminPreferencesControllerCore extends AdminController
'cast' => 'intval',
'type' => 'bool'
),
'PS_SHOW_NEW_ORDERS' => array(
'title' => $this->l('Show notifications for new orders'),
'desc' => $this->l('This will display notifications when new orders will be made on your shop'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_SHOW_NEW_CUSTOMERS' => array(
'title' => $this->l('Show notifications for new customers'),
'desc' => $this->l('This will display notifications when new customers will register on your shop'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_SHOW_NEW_MESSAGES' => array(
'title' => $this->l('Show notifications for new messages'),
'desc' => $this->l('This will display notifications when new messages will be posted on your shop'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_LIMIT_UPLOAD_FILE_VALUE' => array(
'title' => $this->l('Limit upload file value'),
'desc' => $this->l('Define the limit upload for a downloadable product, this value have to be inferior or egal to your server\'s maximum upload file ').sprintf('(%s MB).', $upload_mb),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('Megabits'),
'default' => '1'
),
'PS_LIMIT_UPLOAD_IMAGE_VALUE' => array(
'title' => $this->l('Limit upload image value'),
'desc' => $this->l('Define the limit upload for an image, this value have to be inferior or egal to your server\'s maximum upload file ').sprintf('(%s MB).', $upload_mb),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('Megabits'),
'default' => '1'
),
);
if (function_exists('date_default_timezone_set'))
$fields['PS_TIMEZONE'] = array(
'title' => $this->l('Time Zone:'),
'validation' => 'isAnything',
'type' => 'select',
'list' => $timezones,
'identifier' => 'name',
'visibility' => Shop::CONTEXT_ALL
);
// No HTTPS activation if you haven't already.
if (!Tools::usingSecureMode())
{
@@ -376,95 +104,10 @@ class AdminPreferencesControllerCore extends AdminController
'icon' => 'tab-preferences',
'fields' => $fields,
'submit' => array('title' => $this->l(' Save '), 'class' => 'button'),
),
);
}
parent::__construct();
}
public function postProcess()
{
$upload_max_size = (int)str_replace('M', '', ini_get('upload_max_filesize'));
$post_max_size = (int)str_replace('M', '', ini_get('post_max_size'));
$max_size = $upload_max_size < $post_max_size ? $upload_max_size : $post_max_size;
if (Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE') > $max_size || Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE') > $max_size)
{
$this->errors[] = Tools::displayError('The limit choosen is superior to the server\'s maximum upload file You need to improve the limit of your server.');
return;
}
if (Tools::getIsset('PS_LIMIT_UPLOAD_FILE_VALUE') && !Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE'))
$_POST['PS_LIMIT_UPLOAD_FILE_VALUE'] = 1;
if (Tools::getIsset('PS_LIMIT_UPLOAD_IMAGE_VALUE') && !Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE'))
$_POST['PS_LIMIT_UPLOAD_IMAGE_VALUE'] = 1;
Tools::clearCache($this->context->smarty);
parent::postProcess();
}
protected function getConf($fields, $languages)
{
$tab['_MEDIA_SERVER_1_'] = _MEDIA_SERVER_1_;
$tab['_MEDIA_SERVER_2_'] = _MEDIA_SERVER_2_;
$tab['_MEDIA_SERVER_3_'] = _MEDIA_SERVER_3_;
return $tab;
}
/**
* This method is called before we start to update options configuration
*/
public function beforeUpdateOptions()
{
if (get_class($this) != 'AdminPreferences')
return;
$sql = 'SELECT `id_cms` FROM `'._DB_PREFIX_.'cms`
WHERE id_cms = '.(int)Tools::getValue('PS_CONDITIONS_CMS_ID');
if (Tools::getValue('PS_CONDITIONS') && (Tools::getValue('PS_CONDITIONS_CMS_ID') == 0 || !Db::getInstance()->getValue($sql)))
$this->errors[] = Tools::displayError('Assign a valid CMS page if you want it to be read.');
}
/**
* Update PS_ATTACHMENT_MAXIMUM_SIZE
*/
public function updateOptionPsAttachementMaximumSize($value)
{
if (!$value)
return;
$upload_max_size = (int)str_replace('M', '', ini_get('upload_max_filesize'));
$post_max_size = (int)str_replace('M', '', ini_get('post_max_size'));
$max_size = $upload_max_size < $post_max_size ? $upload_max_size : $post_max_size;
$value = ($max_size < Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE')) ? $max_size : Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE');
Configuration::update('PS_ATTACHMENT_MAXIMUM_SIZE', $value);
}
/**
* Update PS_B2B_ENABLE and enables / disables the associated tabs
* @param $value integer Value of option
*/
public function updateOptionPsB2bEnable($value)
{
$value = (int)$value;
$tabs_class_name = array('AdminOutstanding');
if (!empty($tabs_class_name))
{
foreach ($tabs_class_name as $tab_class_name)
{
$tab = Tab::getInstanceFromClassName($tab_class_name);
if (Validate::isLoadedObject($tab))
{
$tab->active = $value;
$tab->save();
}
}
}
Configuration::updateValue('PS_B2B_ENABLE', $value);
}
}
+117 -2
View File
@@ -27,13 +27,33 @@
class AdminSearchConfControllerCore extends AdminController
{
protected $toolbar_scroll = false;
public function __construct()
{
$this->className = 'Configuration';
$this->table = 'configuration';
$this->table = 'alias';
$this->className = 'Alias';
$this->lang = false;
$this->requiredDatabase = true;
parent::__construct();
// Alias fields
$this->addRowAction('edit');
$this->addRowAction('delete');
if (!Tools::getValue('realedit'))
$this->deleted = false;
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->fieldsDisplay = array(
'alias' => array('title' => $this->l('Aliases'), 'width' => 'auto'),
'search' => array('title' => $this->l('Search'), 'width' => 100),
'active' => array('title' => $this->l('Status'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
);
// Search options
$current_file_name = array_reverse(explode('/', $_SERVER['SCRIPT_NAME']));
$cron_url = Tools::getHttpHost(true, true).__PS_BASE_URI__.
substr($_SERVER['SCRIPT_NAME'], strlen(__PS_BASE_URI__), -strlen($current_file_name['0'])).
@@ -167,4 +187,99 @@ class AdminSearchConfControllerCore extends AdminController
),
);
}
public function initProcess()
{
parent::initProcess();
// This is a composite page, we don't want the "options" display mode
if ($this->display == 'options')
$this->display = '';
}
/**
* Function used to render the options for this controller
*/
public function renderOptions()
{
if ($this->options && is_array($this->options))
{
$helper = new HelperOptions($this);
$this->setHelperDisplay($helper);
$helper->toolbar_scroll = true;
$helper->toolbar_btn = array('save' => array(
'href' => '#',
'desc' => $this->l('Save')
));
$helper->id = $this->id;
$helper->tpl_vars = $this->tpl_option_vars;
$options = $helper->generateOptions($this->options);
return $options;
}
}
public function renderForm()
{
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Aliases'),
'image' => '../img/admin/search.gif'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Alias:'),
'name' => 'alias',
'size' => 40,
'required' => true,
'desc' => array(
$this->l('Enter each alias separated by a comma (\',\') (e.g., \'prestshop,preztashop,prestasohp\')'),
$this->l('Forbidden characters: <>;=#{}')
)
),
array(
'type' => 'text',
'label' => $this->l('Result:'),
'name' => 'search',
'size' => 15,
'required' => true,
'desc' => $this->l('Search this word instead.')
)
),
'submit' => array(
'title' => $this->l(' Save '),
'class' => 'button'
)
);
$this->fields_value = array('alias' => $this->object->getAliases());
return parent::renderForm();
}
public function processSave($token)
{
$search = strval(Tools::getValue('search'));
$string = strval(Tools::getValue('alias'));
$aliases = explode(',', $string);
if (empty($search) || empty($string))
$this->errors[] = $this->l('aliases and result are both required');
if (!Validate::isValidSearch($search))
$this->errors[] = $search.' '.$this->l('is not a valid result');
foreach ($aliases as $alias)
if (!Validate::isValidSearch($alias))
$this->errors[] = $alias.' '.$this->l('is not a valid alias');
if (!count($this->errors))
{
foreach ($aliases as $alias)
{
$obj = new Alias(null, trim($alias), trim($search));
$obj->save();
}
}
if (empty($this->errors))
$this->confirmations[] = $this->l('Creation successfull');
}
}
+165 -1
View File
@@ -112,6 +112,8 @@ class AdminStoresControllerCore extends AdminController
);
parent::__construct();
$this->_buildOrderedFieldsShop($this->_getDefaultFieldsContent());
}
public function renderList()
@@ -386,6 +388,168 @@ class AdminStoresControllerCore extends AdminController
return $ret;
}
}
protected function _getDefaultFieldsContent()
{
$this->context = Context::getContext();
$countryList = array();
$countryList[] = array('id' => '0', 'name' => $this->l('Choose your country'));
foreach (Country::getCountries($this->context->language->id) as $country)
$countryList[] = array('id' => $country['id_country'], 'name' => $country['name']);
$stateList = array();
$stateList[] = array('id' => '0', 'name' => $this->l('Choose your state (if applicable)'));
foreach (State::getStates($this->context->language->id) as $state)
$stateList[] = array('id' => $state['id_state'], 'name' => $state['name']);
$formFields = array(
'PS_SHOP_NAME' => array(
'title' => $this->l('Shop name:'),
'desc' => $this->l('Displayed in e-mails and page titles'),
'validation' => 'isGenericName',
'required' => true,
'size' => 30,
'type' => 'text'
),
'PS_SHOP_EMAIL' => array('title' => $this->l('Shop e-mail:'),
'desc' => $this->l('Displayed in e-mails sent to customers'),
'validation' => 'isEmail',
'required' => true,
'size' => 30,
'type' => 'text'
),
'PS_SHOP_DETAILS' => array(
'title' => $this->l('Registration:'),
'desc' => $this->l('Shop registration information (e.g., SIRET or RCS)'),
'validation' => 'isGenericName',
'size' => 30,
'type' => 'textarea',
'cols' => 30,
'rows' => 5
),
'PS_SHOP_ADDR1' => array(
'title' => $this->l('Shop address line 1:'),
'validation' => 'isAddress',
'size' => 30,
'type' => 'text'
),
'PS_SHOP_ADDR2' => array(
'title' => 'Address line 2',
'validation' => 'isAddress',
'size' => 30,
'type' => 'text'
),
'PS_SHOP_CODE' => array(
'title' => $this->l('Post/Zip code:'),
'validation' => 'isGenericName',
'size' => 6,
'type' => 'text'
),
'PS_SHOP_CITY' => array(
'title' => $this->l('City:'),
'validation' => 'isGenericName',
'size' => 30,
'type' => 'text'
),
'PS_SHOP_COUNTRY_ID' => array(
'title' => $this->l('Country:'),
'validation' => 'isInt',
'type' => 'select',
'list' => $countryList,
'identifier' => 'id',
'cast' => 'intval',
'defaultValue' => (int)$this->context->country->id
),
'PS_SHOP_STATE_ID' => array(
'title' => $this->l('State:'),
'validation' => 'isInt',
'type' => 'select',
'list' => $stateList,
'identifier' => 'id',
'cast' => 'intval'
),
'PS_SHOP_PHONE' => array(
'title' => $this->l('Phone:'),
'validation' => 'isGenericName',
'size' => 30,
'type' => 'text'
),
'PS_SHOP_FAX' => array(
'title' => $this->l('Fax:'),
'validation' => 'isGenericName',
'size' => 30,
'type' => 'text'
),
);
return $formFields;
}
protected function _buildOrderedFieldsShop($formFields)
{
$associatedOrderKey = array(
'PS_SHOP_NAME' => 'company',
'PS_SHOP_ADDR1' => 'address1',
'PS_SHOP_ADDR2' => 'address2',
'PS_SHOP_CITY' => 'city',
'PS_SHOP_STATE_ID' => 'State:name',
'PS_SHOP_CODE' => 'postcode',
'PS_SHOP_COUNTRY_ID' => 'Country:name',
'PS_SHOP_PHONE' => 'phone');
$fields = array();
$orderedFields = AddressFormat::getOrderedAddressFields(Configuration::get('PS_SHOP_COUNTRY_ID'), false, true);
foreach ($orderedFields as $lineFields)
if (($patterns = explode(' ', $lineFields)))
foreach ($patterns as $pattern)
if (($key = array_search($pattern, $associatedOrderKey)))
$fields[$key] = $formFields[$key];
foreach ($formFields as $key => $value)
if (!isset($fields[$key]))
$fields[$key] = $formFields[$key];
$this->options['contact'] = array(
'title' => $this->l('Contact details'),
'icon' => 'tab-contact',
'fields' => $fields,
'submit' => array('title' => $this->l(' Save '), 'class' => 'button')
);
}
public function beforeUpdateOptions()
{
if (isset($_POST['PS_SHOP_STATE_ID']) && $_POST['PS_SHOP_STATE_ID'] != '0')
{
$sql = 'SELECT `active` FROM `'._DB_PREFIX_.'state`
WHERE `id_country` = '.(int)Tools::getValue('PS_SHOP_COUNTRY_ID').'
AND `id_state` = '.(int)Tools::getValue('PS_SHOP_STATE_ID');
$isStateOk = Db::getInstance()->getValue($sql);
if ($isStateOk != 1)
$this->errors[] = Tools::displayError('This state is not in this country.');
}
}
public function updateOptionPsShopCountryId($value)
{
if (!$this->errors && $value)
{
$country = new Country($value, $this->context->language->id);
if ($country->id)
{
Configuration::updateValue('PS_SHOP_COUNTRY_ID', $value);
Configuration::updateValue('PS_SHOP_COUNTRY', pSQL($country->name));
}
}
}
public function updateOptionPsShopStateId($value)
{
if (!$this->errors && $value)
{
$state = new State($value);
if ($state->id)
{
Configuration::updateValue('PS_SHOP_STATE_ID', $value);
Configuration::updateValue('PS_SHOP_STATE', pSQL($state->name));
}
}
}
}