diff --git a/admin-dev/tabs/AdminGeolocation.php b/admin-dev/tabs/AdminGeolocation.php
deleted file mode 100755
index 995acff10..000000000
--- a/admin-dev/tabs/AdminGeolocation.php
+++ /dev/null
@@ -1,187 +0,0 @@
-
-* @copyright 2007-2011 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 AdminGeolocation extends AdminTab
-{
- public function display()
- {
- $this->context = Context::getContext();
- echo '
-
'.$this->l('Geolocation').'
- ';
-
- if (!$this->_isGeoLiteCityAvailable())
- $this->displayWarning($this->l('In order to use Geolocation, please download').' '.$this->l('this file').' '.$this->l('and decompress it into tools/geoip/ directory'));
-
- echo '
-
- ';
- $allowedCountries = explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'));
- echo '
-
-
-
- ';
- }
-
- public function postProcess()
- {
- if (Tools::isSubmit('submitGeolocationConfiguration'))
- {
- if ($this->_isGeoLiteCityAvailable())
- {
- Configuration::updateValue('PS_GEOLOCATION_ENABLED', intval(Tools::getValue('PS_GEOLOCATION_ENABLED')));
- Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
- }
- else
- $this->_errors[] = Tools::displayError('Geolocation database is unavailable.');
- }
-
- if (Tools::isSubmit('submitGeolocationCountries'))
- {
- if (!is_array(Tools::getValue('countries')) OR !sizeof(Tools::getValue('countries')))
- $this->_errors[] = Tools::displayError('Country selection is invalid');
- else
- {
- Configuration::updateValue('PS_GEOLOCATION_BEHAVIOR', (!(int)(Tools::getValue('PS_GEOLOCATION_BEHAVIOR')) ? _PS_GEOLOCATION_NO_CATALOG_ : _PS_GEOLOCATION_NO_ORDER_));
- Configuration::updateValue('PS_GEOLOCATION_NA_BEHAVIOR', (int)Tools::getValue('PS_GEOLOCATION_NA_BEHAVIOR'));
- Configuration::updateValue('PS_ALLOWED_COUNTRIES', implode(';', Tools::getValue('countries')));
- Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
- }
- }
-
- if (Tools::isSubmit('submitGeolocationWhitelist'))
- {
- if (!Validate::isCleanHtml(Tools::getValue('PS_GEOLOCATION_WHITELIST')))
- $this->_errors[] = Tools::displayError('Invalid whitelist');
- else
- {
- Configuration::updateValue('PS_GEOLOCATION_WHITELIST', str_replace("\n", ';', str_replace("\r", '', Tools::getValue('PS_GEOLOCATION_WHITELIST'))));
- Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
- }
- }
-
- return parent::postProcess();
- }
-
- private function _isGeoLiteCityAvailable()
- {
- if (file_exists(_PS_GEOIP_DIR_.'GeoLiteCity.dat'))
- return true;
- return false;
- }
-}
-
diff --git a/admin-dev/themes/template/options.tpl b/admin-dev/themes/template/options.tpl
index 1bc4b78ab..2cdb05b77 100644
--- a/admin-dev/themes/template/options.tpl
+++ b/admin-dev/themes/template/options.tpl
@@ -46,6 +46,7 @@
{/if}
{foreach $categoryData['fields'] AS $key => $field}
+
{if $field['type'] == 'hidden'}
{else}
@@ -57,8 +58,9 @@
{/if}
{$field['title']}
{/if}
-
+ {block name="end_field_block"}{/block}
{/if}
{/foreach}
{if isset($categoryData['submit'])}
diff --git a/classes/AdminController.php b/classes/AdminController.php
index a6c6c77d9..60a703574 100644
--- a/classes/AdminController.php
+++ b/classes/AdminController.php
@@ -1157,6 +1157,9 @@ class AdminControllerCore extends Controller
if ($this->options && is_array($this->options))
{
$helper = new HelperOptions();
+ // Check if form template has been overriden
+ if (file_exists($this->context->smarty->template_dir[0].'/'.$this->tpl_folder.'options.tpl'))
+ $helper->tpl = $this->tpl_folder.'options.tpl';
$helper->id = $this->id;
$helper->token = $this->token;
$helper->table = $this->table;
diff --git a/controllers/admin/AdminCountriesController.php b/controllers/admin/AdminCountriesController.php
index 37443e041..83eb4aad4 100644
--- a/controllers/admin/AdminCountriesController.php
+++ b/controllers/admin/AdminCountriesController.php
@@ -48,6 +48,29 @@ class AdminCountriesControllerCore extends AdminController
'dir' => 'st'
);
+ $this->options = array(
+ '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',
+ 'type' => 'bool',
+ 'default' => '0'
+ )
+ ),
+ 'submit' => array()
+ )
+ );
+
$this->fieldsDisplay = array(
'id_country' => array(
'title' => $this->l('ID'),
@@ -85,29 +108,6 @@ class AdminCountriesControllerCore extends AdminController
)
);
- $this->options = array(
- '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',
- 'type' => 'bool',
- 'default' => '0'
- )
- ),
- 'submit' => array()
- )
- );
-
parent::__construct();
}
@@ -168,7 +168,7 @@ class AdminCountriesControllerCore extends AdminController
'maxlength' => 3,
'class' => 'uppercase',
'required' => true,
- 'p' => $this->l('2- or 3-letter ISO code, e.g., FR for France').'.
+ 'p' => $this->l('2- or 3-letter ISO code, e.g., FR for France').'.
'.
$this->l('Official list here').'
.'
@@ -234,7 +234,7 @@ class AdminCountriesControllerCore extends AdminController
'name' => 'zip_code_format',
'class' => 'uppercase',
'required' => true,
- 'p' => $this->l('National zip code (L for a letter, N for a number and C for the Iso code), e.g., NNNNN for France.
+ 'p' => $this->l('National zip code (L for a letter, N for a number and C for the Iso code), e.g., NNNNN for France.
No verification if undefined')
),
array(
diff --git a/controllers/admin/AdminGeolocationController.php b/controllers/admin/AdminGeolocationController.php
new file mode 100755
index 000000000..d9d822886
--- /dev/null
+++ b/controllers/admin/AdminGeolocationController.php
@@ -0,0 +1,146 @@
+
+* @copyright 2007-2011 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 AdminGeolocationControllerCore extends AdminController
+{
+ public function __construct()
+ {
+ parent::__construct();
+
+ $this->options = array(
+ 'geolocationConfiguration' => array(
+ 'title' => $this->l('Geolocation by IP:'),
+ 'icon' => 'world',
+ 'class' => 'width3',
+ 'fields' => array(
+ 'PS_GEOLOCATION_ENABLED' => array('title' => $this->l('Geolocation by IP:'), 'desc' => $this->l('This option allows you, among other things, to restrict access to your shop for many countries. See below.'), 'validation' => 'isUnsignedId', 'cast' => 'intval', 'type' => 'bool'),
+ ),
+ 'submit' => array(),
+ ),
+ 'geolocationCountries' => array(
+ 'title' => $this->l('Options'),
+ 'icon' => 'world',
+ 'class' => 'width4',
+ 'description' => $this->l('The following features are only available if you enable the Geolocation by IP feature.'),
+ 'fields' => array(
+ 'PS_GEOLOCATION_BEHAVIOR' => array(
+ 'title' => $this->l('Geolocation behavior for restricted countries:'),
+ 'type' => 'select',
+ 'identifier' => 'key',
+ 'list' => array(array('key' => _PS_GEOLOCATION_NO_CATALOG_, 'name' => $this->l('Visitors can\'t see your catalog')),
+ array('key' => _PS_GEOLOCATION_NO_ORDER_, 'name' => $this->l('Visitors can see your catalog but can\'t make an order'))),
+ ),
+ 'PS_GEOLOCATION_NA_BEHAVIOR' => array(
+ 'title' => $this->l('Geolocation behavior for undefined countries:'),
+ 'type' => 'select',
+ 'identifier' => 'key',
+ 'list' => array(array('key' => '-1', 'name' => $this->l('All features are available')),
+ array('key' => _PS_GEOLOCATION_NO_CATALOG_, 'name' => $this->l('Visitors can\'t see your catalog')),
+ array('key' => _PS_GEOLOCATION_NO_ORDER_, 'name' => $this->l('Visitors can see your catalog but can\'t make an order')))
+ ),
+ 'countries' => array(
+ 'title' => $this->l('Select countries that can access your store:'),
+ 'type' => 'checkbox_table',
+ 'identifier' => 'iso_code',
+ 'list' => Country::getCountries($this->context->language->id)
+ ),
+ ),
+ 'submit' => array(),
+ ),
+ 'geolocationWhitelist' => array(
+ 'title' => $this->l('Whitelist of IP addresses'),
+ 'icon' => 'world',
+ 'class' => 'width3',
+ 'description' => $this->l('You can add many IP addresses, these addresses will always be allowed to access your shop (e.g. Google bots IP).'),
+ 'fields' => array(
+ 'PS_GEOLOCATION_WHITELIST' => array('title' => $this->l('Allowed IP addresses:'), 'type' => 'textarea_newlines', 'cols' => 80, 'rows' => 30),
+ ),
+ 'submit' => array(),
+ ),
+ );
+ }
+
+ public function postProcess()
+ {
+ if (Tools::isSubmit('submitGeolocationConfiguration'))
+ {
+ if ($this->_isGeoLiteCityAvailable())
+ {
+ Configuration::updateValue('PS_GEOLOCATION_ENABLED', intval(Tools::getValue('PS_GEOLOCATION_ENABLED')));
+ Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
+ }
+ else
+ $this->_errors[] = Tools::displayError('Geolocation database is unavailable.');
+ }
+
+ if (Tools::isSubmit('submitGeolocationCountries'))
+ {
+ if (!is_array(Tools::getValue('countries')) OR !sizeof(Tools::getValue('countries')))
+ $this->_errors[] = Tools::displayError('Country selection is invalid');
+ else
+ {
+ Configuration::updateValue('PS_GEOLOCATION_BEHAVIOR', (!(int)(Tools::getValue('PS_GEOLOCATION_BEHAVIOR')) ? _PS_GEOLOCATION_NO_CATALOG_ : _PS_GEOLOCATION_NO_ORDER_));
+ Configuration::updateValue('PS_GEOLOCATION_NA_BEHAVIOR', (int)Tools::getValue('PS_GEOLOCATION_NA_BEHAVIOR'));
+ Configuration::updateValue('PS_ALLOWED_COUNTRIES', implode(';', Tools::getValue('countries')));
+ Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
+ }
+ }
+
+ if (Tools::isSubmit('submitGeolocationWhitelist'))
+ {
+ if (!Validate::isCleanHtml(Tools::getValue('PS_GEOLOCATION_WHITELIST')))
+ $this->_errors[] = Tools::displayError('Invalid whitelist');
+ else
+ {
+ Configuration::updateValue('PS_GEOLOCATION_WHITELIST', str_replace("\n", ';', str_replace("\r", '', Tools::getValue('PS_GEOLOCATION_WHITELIST'))));
+ Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
+ }
+ }
+
+ return parent::postProcess();
+ }
+
+ public function initContent()
+ {
+ if (!$this->_isGeoLiteCityAvailable())
+ $this->displayWarning($this->l('In order to use Geolocation, please download').' '.$this->l('this file').' '.$this->l('and decompress it into tools/geoip/ directory'));
+
+ $this->context->smarty->assign(array(
+ 'allowed_countries' => explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')),
+ 'url_countries' => self::$currentIndex.'&token='.Tools::getValue('token'),
+ ));
+ parent::initContent();
+ }
+
+ private function _isGeoLiteCityAvailable()
+ {
+ if (file_exists(_PS_GEOIP_DIR_.'GeoLiteCity.dat'))
+ return true;
+ return false;
+ }
+}
+