本文整理汇总了PHP中Validate::isLocalizationPackSelection方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isLocalizationPackSelection方法的具体用法?PHP Validate::isLocalizationPackSelection怎么用?PHP Validate::isLocalizationPackSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::isLocalizationPackSelection方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
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();
}
示例2: loadLocalisationPack
public function loadLocalisationPack($file, $selection, $install_mode = false)
{
if (!($xml = simplexml_load_string($file))) {
return false;
}
$mainAttributes = $xml->attributes();
$this->name = strval($mainAttributes['name']);
$this->version = strval($mainAttributes['version']);
if (empty($selection)) {
$res = true;
$res &= $this->_installStates($xml);
$res &= $this->_installTaxes($xml);
$res &= $this->_installCurrencies($xml, $install_mode);
$res &= $this->_installUnits($xml);
if (!defined('_PS_MODE_DEV_') or !_PS_MODE_DEV_) {
$res &= $this->_installLanguages($xml, $install_mode);
}
if ($res and isset($this->iso_code_lang)) {
Configuration::updateValue('PS_LANG_DEFAULT', (int) Language::getIdByIso($this->iso_code_lang));
}
if ($install_mode and $res and isset($this->iso_currency)) {
$res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int) Currency::getIdByIsoCode($this->iso_currency));
Currency::refreshCurrencies();
}
return $res;
}
foreach ($selection as $selected) {
if (!Validate::isLocalizationPackSelection($selected) or !$this->{'_install' . ucfirst($selected)}($xml)) {
return false;
}
}
return true;
}
示例3: postProcess
public function postProcess()
{
if (Tools::isSubmit('submitLocalizationPack')) {
$version = str_replace('.', '', _PS_VERSION_);
$version = substr($version, 0, 2);
if (Validate::isFileName(Tools::getValue('iso_localization_pack'))) {
$pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . Tools::getValue('iso_localization_pack') . '.xml');
if (!$pack && !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) {
$this->errors[] = Tools::displayError('Cannot load the localization pack.');
}
if (!($selection = Tools::getValue('selection'))) {
$this->errors[] = Tools::displayError('Please select at least one item to import.');
} else {
foreach ($selection as $selected) {
if (!Validate::isLocalizationPackSelection($selected)) {
$this->errors[] = Tools::displayError('Invalid selection');
return;
}
}
$localization_pack = new LocalizationPack();
if (!$localization_pack->loadLocalisationPack($pack, $selection)) {
$this->errors = array_merge($this->errors, $localization_pack->getErrors());
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token);
}
}
}
}
// Remove the module list cache if the default country changed
if (Tools::isSubmit('submitOptionsconfiguration') && file_exists(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST)) {
@unlink(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
}
parent::postProcess();
}
示例4: postProcess
public function postProcess()
{
if (Tools::isSubmit('submitLocalizationPack')) {
$version = str_replace('.', '', _PS_VERSION_);
$version = substr($version, 0, 2);
if (Validate::isFileName(Tools::getValue('iso_localization_pack'))) {
$pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . Tools::getValue('iso_localization_pack') . '.xml');
if (!$pack && !($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")');
}
if (!($selection = Tools::getValue('selection'))) {
$this->errors[] = Tools::displayError('Please select at least one item to import.');
} else {
foreach ($selection as $selected) {
if (!Validate::isLocalizationPackSelection($selected)) {
$this->errors[] = Tools::displayError('Invalid selection');
return;
}
}
$localization_pack = new LocalizationPack();
if (!$localization_pack->loadLocalisationPack($pack, $selection)) {
$this->errors = array_merge($this->errors, $localization_pack->getErrors());
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token);
}
}
}
}
parent::postProcess();
}
示例5: loadLocalisationPack
public function loadLocalisationPack($file, $selection, $install_mode = false, $iso_localization_pack = null)
{
if (!($xml = @simplexml_load_string($file))) {
return false;
}
libxml_clear_errors();
$main_attributes = $xml->attributes();
$this->name = (string) $main_attributes['name'];
$this->version = (string) $main_attributes['version'];
if ($iso_localization_pack) {
$id_country = (int) Country::getByIso($iso_localization_pack);
if ($id_country) {
$country = new Country($id_country);
}
if (!$id_country || !Validate::isLoadedObject($country)) {
$this->_errors[] = Tools::displayError(sprintf('Cannot load country : %1d', $id_country));
return false;
}
if (!$country->active) {
$country->active = 1;
if (!$country->update()) {
$this->_errors[] = Tools::displayError(sprintf('Cannot enable the associated country: %1s', $country->name));
}
}
}
$res = true;
if (empty($selection)) {
$res &= $this->_installStates($xml);
$res &= $this->_installTaxes($xml);
$res &= $this->_installCurrencies($xml, $install_mode);
$res &= $this->installConfiguration($xml);
$res &= $this->installModules($xml);
$res &= $this->updateDefaultGroupDisplayMethod($xml);
if (($res || $install_mode) && isset($this->iso_code_lang)) {
if (!($id_lang = (int) Language::getIdByIso($this->iso_code_lang, true))) {
$id_lang = 1;
}
if (!$install_mode) {
Configuration::updateValue('PS_LANG_DEFAULT', $id_lang);
}
} elseif (!isset($this->iso_code_lang) && $install_mode) {
$id_lang = 1;
}
if (!Language::isInstalled(Language::getIsoById($id_lang))) {
$res &= $this->_installLanguages($xml, $install_mode);
$res &= $this->_installUnits($xml);
}
if ($install_mode && $res && isset($this->iso_currency)) {
Cache::clean('Currency::getIdByIsoCode_*');
$res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int) Currency::getIdByIsoCode($this->iso_currency));
Currency::refreshCurrencies();
}
} else {
foreach ($selection as $selected) {
// No need to specify the install_mode because if the selection mode is used, then it's not the install
$res &= Validate::isLocalizationPackSelection($selected) ? $this->{'_install' . $selected}($xml) : false;
}
}
return $res;
}
示例6: postProcess
public function postProcess()
{
if (_PS_MODE_DEMO_) {
$this->errors[] = $this->trans('This functionality has been disabled.', array(), 'Admin.Notifications.Error');
return;
}
if (!extension_loaded('openssl')) {
$this->displayWarning($this->l('Importing a new language may fail without the OpenSSL module. Please enable "openssl.so" on your server configuration.'));
}
if (Tools::isSubmit('submitLocalizationPack')) {
$version = str_replace('.', '', _PS_VERSION_);
$version = substr($version, 0, 2);
if (($iso_localization_pack = Tools::getValue('iso_localization_pack')) && Validate::isFileName($iso_localization_pack)) {
if (Tools::getValue('download_updated_pack') == '1' || defined('_PS_HOST_MODE_')) {
$pack = @Tools::file_get_contents(_PS_API_URL_ . '/localization/' . $version . '/' . $iso_localization_pack . '.xml');
} else {
$pack = false;
}
if (defined('_PS_HOST_MODE_')) {
$path = _PS_CORE_DIR_ . '/localization/' . $iso_localization_pack . '.xml';
} else {
$path = _PS_ROOT_DIR_ . '/localization/' . $iso_localization_pack . '.xml';
}
if (!$pack && !($pack = @Tools::file_get_contents($path))) {
$this->errors[] = $this->trans('Cannot load the localization pack.', array(), 'Admin.International.Notification');
}
if (!($selection = Tools::getValue('selection'))) {
$this->errors[] = $this->trans('Please select at least one item to import.', array(), 'Admin.International.Notification');
} else {
foreach ($selection as $selected) {
if (!Validate::isLocalizationPackSelection($selected)) {
$this->errors[] = $this->trans('Invalid selection', array(), 'Admin.Notifications.Error');
return;
}
}
$localization_pack = new LocalizationPack();
if (!$localization_pack->loadLocalisationPack($pack, $selection, false, $iso_localization_pack)) {
$this->errors = array_merge($this->errors, $localization_pack->getErrors());
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token);
}
}
}
}
// Remove the module list cache if the default country changed
if (Tools::isSubmit('submitOptionsconfiguration') && file_exists(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST)) {
@unlink(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
}
parent::postProcess();
}
示例7: loadLocalisationPack
public function loadLocalisationPack($file, $selection, $install_mode = false)
{
if (!($xml = simplexml_load_string($file))) {
return false;
}
$main_attributes = $xml->attributes();
$this->name = (string) $main_attributes['name'];
$this->version = (string) $main_attributes['version'];
if (empty($selection)) {
$res = true;
$res &= $this->_installStates($xml);
$res &= $this->_installTaxes($xml);
$res &= $this->_installCurrencies($xml, $install_mode);
$res &= $this->_installUnits($xml);
$res &= $this->installConfiguration($xml);
$res &= $this->installModules($xml);
$res &= $this->_installLanguages($xml, $install_mode);
if ($res && isset($this->iso_code_lang)) {
if (!($id_lang = (int) Language::getIdByIso($this->iso_code_lang))) {
$id_lang = 1;
}
if (!$install_mode) {
Configuration::updateValue('PS_LANG_DEFAULT', $id_lang);
}
}
if ($install_mode && $res && isset($this->iso_currency)) {
Cache::clean('Currency::getIdByIsoCode_*');
$res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int) Currency::getIdByIsoCode($this->iso_currency));
Currency::refreshCurrencies();
}
return $res;
}
foreach ($selection as $selected) {
if (strtolower((string) $selected) == 'currencies') {
if (!Validate::isLocalizationPackSelection($selected) || !$this->{'_install' . ucfirst($selected)}($xml, true)) {
return false;
}
} else {
if (!Validate::isLocalizationPackSelection($selected) || !$this->{'_install' . ucfirst($selected)}($xml)) {
return false;
}
}
}
return true;
}
示例8: loadLocalisationPack
public function loadLocalisationPack($file, $selection, $install_mode = false)
{
if (!($xml = simplexml_load_string($file))) {
return false;
}
$main_attributes = $xml->attributes();
$this->name = (string) $main_attributes['name'];
$this->version = (string) $main_attributes['version'];
$res = true;
if (empty($selection)) {
$res &= $this->_installStates($xml);
$res &= $this->_installTaxes($xml);
$res &= $this->_installCurrencies($xml, $install_mode);
$res &= $this->_installUnits($xml);
$res &= $this->installConfiguration($xml);
$res &= $this->installModules($xml);
$res &= $this->_installLanguages($xml, $install_mode);
$res &= $this->updateDefaultGroupDisplayMethod($xml);
if ($res && isset($this->iso_code_lang)) {
if (!($id_lang = (int) Language::getIdByIso($this->iso_code_lang))) {
$id_lang = 1;
}
if (!$install_mode) {
Configuration::updateValue('PS_LANG_DEFAULT', $id_lang);
}
}
if ($install_mode && $res && isset($this->iso_currency)) {
Cache::clean('Currency::getIdByIsoCode_*');
$res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int) Currency::getIdByIsoCode($this->iso_currency));
Currency::refreshCurrencies();
}
} else {
foreach ($selection as $selected) {
// No need to specify the install_mode because if the selection mode is used, then it's not the install
$res &= Validate::isLocalizationPackSelection($selected) ? $this->{'_install' . $selected}($xml) : false;
}
}
return $res;
}
示例9: import_language
public static function import_language($isoCode, $imports, $fromLocalPack = true)
{
//todo
// from localization directory; or from prestashop.com (api ?)
if ($imports == 'all') {
$selection = array('states', 'taxes', 'currencies', 'languages', 'units', 'groups');
} else {
$selection = split(',', $imports);
foreach ($selection as $selected) {
if (!Validate::isLocalizationPackSelection($selected)) {
echo "{$selected} is not a valid selection !\n";
return false;
}
}
}
if ($fromLocalPack) {
if (defined('_PS_HOST_MODE_')) {
$localizationPackFileName = _PS_CORE_DIR_ . '/localization/' . $isoCode . '.xml';
} else {
$localizationPackFileName = _PS_ROOT_DIR_ . '/localization/' . $isoCode . '.xml';
}
if (!is_readable($localizationPackFileName)) {
echo "Could not read localization pack !\n";
return false;
}
$pack = @Tools::file_get_contents($localizationPackFileName);
} else {
//todo: get content from prestashop servers
$pack = false;
}
//todo: IN PROGRESS seems this installs the language pack ?
$localizationPack = new LocalizationPack();
if (!$localizationPack->loadLocalisationPack($pack, $selection, false, $isoCode)) {
echo "Could not load localization pack\n";
return false;
}
// import lang pack
Language::checkAndAddLanguage($isoCode, $localizationPack, false, null);
}