* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7610 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php'); class AdminLocalization extends AdminPreferences { public function __construct() { global $cookie; $lang = strtoupper(Language::getIsoById($cookie->id_lang)); $this->className = 'Configuration'; $this->table = 'configuration'; $this->_fieldsLocalization = array( 'PS_WEIGHT_UNIT' => array('title' => $this->l('Weight unit:'), 'desc' => $this->l('The weight unit of your shop (eg. kg or lbs)'), 'validation' => 'isWeightUnit', 'required' => true, 'type' => 'text'), 'PS_DISTANCE_UNIT' => array('title' => $this->l('Distance unit:'), 'desc' => $this->l('The distance unit of your shop (eg. km or mi)'), 'validation' => 'isDistanceUnit', 'required' => true, 'type' => 'text'), 'PS_VOLUME_UNIT' => array('title' => $this->l('Volume unit:'), 'desc' => $this->l('The volume unit of your shop'), 'validation' => 'isWeightUnit', 'required' => true, 'type' => 'text'), 'PS_DIMENSION_UNIT' => array('title' => $this->l('Dimension unit:'), 'desc' => $this->l('The dimension unit of your shop (eg. cm or in)'), 'validation' => 'isDistanceUnit', 'required' => true, 'type' => 'text')); $this->_fieldsOptions = array( 'PS_LOCALE_LANGUAGE' => array('title' => $this->l('Language locale:'), 'desc' => $this->l('Your server\'s language locale.'), 'validation' => 'isLanguageIsoCode', 'type' => 'text'), 'PS_LOCALE_COUNTRY' => array('title' => $this->l('Country locale:'), 'desc' => $this->l('Your server\'s country locale.'), 'validation' => 'isLanguageIsoCode', 'type' => 'text') ); parent::__construct(); } public function postProcess() { global $currentIndex; if (isset($_POST['submitLocalization'.$this->table])) { if ($this->tabAccess['edit'] === '1') $this->_postConfig($this->_fieldsLocalization); else $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } elseif (Tools::isSubmit('submitLocalizationPack')) { if (!$pack = @Tools::file_get_contents('http://www.prestashop.com/download/localization/'.Tools::getValue('iso_localization_pack').'.xml') AND !$pack = @Tools::file_get_contents(dirname(__FILE__).'/../../localization/'.Tools::getValue('iso_localization_pack').'.xml')) $this->_errors[] = Tools::displayError('Cannot load localization pack (from prestashop.com and from your local folder "localization")'); elseif (!$selection = Tools::getValue('selection')) $this->_errors[] = Tools::displayError('Please select at least one content item to import.'); else { foreach ($selection AS $selected) if (!Validate::isLocalizationPackSelection($selected)) { $this->_errors[] = Tools::displayError('Invalid selection'); return ; } $localizationPack = new LocalizationPack(); if (!$localizationPack->loadLocalisationPack($pack, $selection)) $this->_errors = array_merge($this->_errors, $localizationPack->getErrors()); else Tools::redirectAdmin($currentIndex.'&conf=23&token='.$this->token); } } parent::postProcess(); } public function display() { global $currentIndex; $this->_displayForm('localization', $this->_fieldsLocalization, $this->l('Localization'), 'width2', 'localization'); echo '
'.$this->l('Localization pack import').'

'.$this->l('States').'
'.$this->l('Taxes').'
'.$this->l('Currencies').'
'.$this->l('Languages').'
'.$this->l('Units (e.g., weight, volume, distance)').'

'; $this->_displayForm('options', $this->_fieldsOptions, $this->l('Advanced'), 'width2', 'localization'); } }