当前位置: 首页>>代码示例>>PHP>>正文


PHP Validate::isLanguageIsoCode方法代码示例

本文整理汇总了PHP中Validate::isLanguageIsoCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isLanguageIsoCode方法的具体用法?PHP Validate::isLanguageIsoCode怎么用?PHP Validate::isLanguageIsoCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validate的用法示例。


在下文中一共展示了Validate::isLanguageIsoCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 public function postProcess()
 {
     if (isset($_GET['delete' . $this->table]) || Tools::getValue('submitDel' . $this->table)) {
         $this->_errors[] = Tools::displayError('You cannot delete a country. If you do not want it available for customers, please disable it.');
     } elseif (Tools::getValue('submitAdd' . $this->table)) {
         if (!Tools::getValue('id_' . $this->table)) {
             if (Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Country::getByIso(Tools::getValue('iso_code'))) {
                 $this->_errors[] = Tools::displayError('This ISO code already exists, you cannot create two country with the same ISO code');
             }
         } else {
             if (Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
                 $id_country = Country::getByIso(Tools::getValue('iso_code'));
                 if (!is_null($id_country) && $id_country != Tools::getValue('id_' . $this->table)) {
                     $this->_errors[] = Tools::displayError('This ISO code already exists, you cannot create two country with the same ISO code');
                 }
             }
         }
         if (Tools::isSubmit('standardization')) {
             Configuration::updateValue('PS_TAASC', (bool) Tools::getValue('standardization', false));
         }
         if (isset($this->_errors) && count($this->_errors)) {
             return false;
         }
     }
     return parent::postProcess();
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:26,代码来源:AdminCountries.php

示例2: createAddress

 /**
  * @param $address
  * @param $customer
  * @return int
  * @throws ShopgateLibraryException
  */
 public function createAddress(ShopgateAddress $address, $customer)
 {
     /** @var AddressCore | Address $addressModel */
     $addressItem = new Address();
     $addressItem->id_customer = $customer->id;
     $addressItem->lastname = $address->getLastName();
     $addressItem->firstname = $address->getFirstName();
     if ($address->getCompany()) {
         $addressItem->company = $address->getCompany();
     }
     $addressItem->address1 = $address->getStreet1();
     if ($address->getStreet2()) {
         $addressItem->address2 = $address->getStreet2();
     }
     $addressItem->city = $address->getCity();
     $addressItem->postcode = $address->getZipcode();
     if (!Validate::isLanguageIsoCode($address->getCountry())) {
         $customer->delete();
         throw new ShopgateLibraryException(ShopgateLibraryException::REGISTER_FAILED_TO_ADD_USER, 'invalid country code: ' . $address->getCountry(), true);
     }
     $addressItem->id_country = Country::getByIso($address->getCountry());
     /**
      * prepare states
      */
     $stateParts = explode('-', $address->getState());
     if (count($stateParts) == 2) {
         $address->setState($stateParts[1]);
     }
     if ($address->getState() && !Validate::isStateIsoCode($address->getState())) {
         $customer->delete();
         throw new ShopgateLibraryException(ShopgateLibraryException::REGISTER_FAILED_TO_ADD_USER, 'invalid state code: ' . $address->getState(), true);
     } else {
         $addressItem->id_state = State::getIdByIso($address->getState());
     }
     $addressItem->alias = $address->getIsDeliveryAddress() ? $this->getModule()->l('Default delivery address') : $this->getModule()->l('Default');
     $addressItem->alias = $address->getIsInvoiceAddress() ? $this->getModule()->l('Default invoice address') : $this->getModule()->l('Default');
     $addressItem->phone = $address->getPhone();
     $addressItem->phone_mobile = $address->getMobile();
     $shopgateCustomFieldsHelper = new ShopgateCustomFieldsHelper();
     $shopgateCustomFieldsHelper->saveCustomFields($addressItem, $address->getCustomFields());
     $validateMessage = $addressItem->validateFields(false, true);
     if ($validateMessage !== true) {
         $customer->delete();
         throw new ShopgateLibraryException(ShopgateLibraryException::REGISTER_FAILED_TO_ADD_USER, $validateMessage, true);
     }
     $addressItem->save();
     return $addressItem->id;
 }
开发者ID:pankajshoffex,项目名称:shoffex_prestashop,代码行数:54,代码来源:Json.php

示例3: ajaxProcessCheckLangPack

 public function ajaxProcessCheckLangPack()
 {
     $this->json = true;
     if (!Tools::getValue('iso_lang') || !Validate::isLanguageIsoCode(Tools::getValue('iso_lang'))) {
         $this->status = 'error';
         $this->errors[] = $this->l('Iso code is not valid');
         return;
     }
     if (!Tools::getValue('ps_version') || !Validate::isPrestaShopVersion(Tools::getValue('ps_version'))) {
         $this->status = 'error';
         $this->errors[] = $this->l('Technical Error: ps_version is not valid');
         return;
     }
     // Get all iso code available
     if ($lang_packs = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . Tools::getValue('ps_version') . '&iso_lang=' . Tools::strtolower(Tools::getValue('iso_lang')))) {
         $result = Tools::jsonDecode($lang_packs);
         if ($lang_packs !== '' && $result && !isset($result->error)) {
             $this->status = 'ok';
             $this->content = $lang_packs;
         } else {
             $this->status = 'error';
             $this->errors[] = $this->l('Wrong ISO code, or the selected language pack is unavailable.');
         }
     } else {
         $this->status = 'error';
         $this->errors[] = $this->l('Technical Error: translation server unreachable.');
     }
 }
开发者ID:ortegon000,项目名称:tienda,代码行数:28,代码来源:AdminLanguagesController.php

示例4: postProcess

 public function postProcess()
 {
     if (!Tools::getValue('id_' . $this->table)) {
         if (Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Country::getByIso(Tools::getValue('iso_code'))) {
             $this->errors[] = Tools::displayError('This ISO code already exists.You cannot create two countries with the same ISO code.');
         }
     } else {
         if (Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
             $id_country = Country::getByIso(Tools::getValue('iso_code'));
             if (!is_null($id_country) && $id_country != Tools::getValue('id_' . $this->table)) {
                 $this->errors[] = Tools::displayError('This ISO code already exists.You cannot create two countries with the same ISO code.');
             }
         }
     }
     return parent::postProcess();
 }
开发者ID:AmineBENCHEIKHBRAHIM,项目名称:LnsTech-Prestashop-WebSite,代码行数:16,代码来源:AdminCountriesController.php

示例5: die

/* Theme is missing or maintenance */
if (!is_dir(dirname(__FILE__) . '/themes/' . _THEME_NAME_)) {
    die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.'));
} elseif (basename($_SERVER['PHP_SELF']) != 'disabled.php' and !intval(Configuration::get('PS_SHOP_ENABLE'))) {
    $maintenance = true;
}
ob_start();
global $cart, $cookie, $_CONF, $link;
/* get page name to display it in body id */
$pathinfo = pathinfo(__FILE__);
$page_name = basename($_SERVER['PHP_SELF'], '.' . $pathinfo['extension']);
$page_name = preg_match('/^[0-9]/', $page_name) ? 'page_' . $page_name : $page_name;
// Init Cookie
$cookie = new Cookie('ps');
// Switch language if needed and init cookie language
if ($iso = Tools::getValue('isolang') and Validate::isLanguageIsoCode($iso) and $id_lang = intval(Language::getIdByIso($iso))) {
    $_GET['id_lang'] = $id_lang;
}
Tools::switchLanguage();
Tools::setCookieLanguage();
/* attribute id_lang is often needed, so we create a constant for performance reasons */
define('_USER_ID_LANG_', intval($cookie->id_lang));
if (isset($_GET['logout']) or $cookie->logged and Customer::isBanned(intval($cookie->id_customer))) {
    $cookie->logout();
    Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL);
} elseif (isset($_GET['mylogout'])) {
    $cookie->mylogout();
    Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL);
}
$iso = strtolower(Language::getIsoById($cookie->id_lang ? intval($cookie->id_lang) : 1));
@(include _PS_TRANSLATIONS_DIR_ . $iso . '/fields.php');
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:31,代码来源:init.php

示例6: switchLanguage

 /**
  * Set cookie id_lang
  */
 public static function switchLanguage(Context $context = null)
 {
     if (!$context) {
         $context = Context::getContext();
     }
     // Install call the dispatcher and so the switchLanguage
     // Stop this method by checking the cookie
     if (!isset($context->cookie)) {
         return;
     }
     if (($iso = Tools::getValue('isolang')) && Validate::isLanguageIsoCode($iso) && ($id_lang = (int) Language::getIdByIso($iso))) {
         $_GET['id_lang'] = $id_lang;
     }
     // update language only if new id is different from old id
     // or if default language changed
     $cookie_id_lang = $context->cookie->id_lang;
     $configuration_id_lang = Configuration::get('PS_LANG_DEFAULT');
     if (($id_lang = (int) Tools::getValue('id_lang')) && Validate::isUnsignedId($id_lang) && $cookie_id_lang != (int) $id_lang || $id_lang == $configuration_id_lang && Validate::isUnsignedId($id_lang) && $id_lang != $cookie_id_lang) {
         $context->cookie->id_lang = $id_lang;
         $language = new Language($id_lang);
         if (Validate::isLoadedObject($language) && $language->active) {
             $context->language = $language;
         }
         $params = $_GET;
         if (Configuration::get('PS_REWRITING_SETTINGS') || !Language::isMultiLanguageActivated()) {
             unset($params['id_lang']);
         }
     }
 }
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:32,代码来源:Tools.php

示例7: getCountry

 public static function getCountry($address = null)
 {
     if ($id_country = Tools::getValue('id_country')) {
     } elseif (isset($address) && isset($address->id_country) && $address->id_country) {
         $id_country = $address->id_country;
     } elseif (Configuration::get('PS_DETECT_COUNTRY') && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         preg_match('#(?<=-)\\w\\w|\\w\\w(?!-)#', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $array);
         if (is_array($array) && isset($array[0]) && Validate::isLanguageIsoCode($array[0])) {
             $id_country = Country::getByIso($array[0], true);
         }
     }
     if (!isset($id_country) || !$id_country) {
         $id_country = Configuration::get('PS_COUNTRY_DEFAULT');
     }
     return (int) $id_country;
 }
开发者ID:evgrishin,项目名称:mh16014,代码行数:16,代码来源:Tools.php

示例8: postProcess

 public function postProcess()
 {
     global $currentIndex;
     /* PrestaShop demo mode */
     if (_PS_MODE_DEMO_) {
         $this->_errors[] = Tools::displayError('This functionnality has been disabled.');
         return;
     }
     /* PrestaShop demo mode*/
     if (Tools::isSubmit('submitCopyLang')) {
         if ($this->tabAccess['add'] === '1') {
             $this->submitCopyLang();
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to add here.');
         }
     } elseif (Tools::isSubmit('submitExport')) {
         if ($this->tabAccess['add'] === '1') {
             $this->submitExportLang();
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to add here.');
         }
     } elseif (Tools::isSubmit('submitImport')) {
         if ($this->tabAccess['add'] === '1') {
             $this->submitImportLang();
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to add here.');
         }
     } elseif (Tools::isSubmit('submitAddLanguage')) {
         if ($this->tabAccess['add'] === '1') {
             $this->submitAddLang();
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to add here.');
         }
     } elseif (Tools::isSubmit('submitTranslationsFront')) {
         if ($this->tabAccess['edit'] === '1') {
             if (!Validate::isLanguageIsoCode(Tools::strtolower(Tools::getValue('lang')))) {
                 die(Tools::displayError());
             }
             $this->writeTranslationFile('Front', _PS_THEME_DIR_ . 'lang/' . Tools::strtolower(Tools::getValue('lang')) . '.php');
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (Tools::isSubmit('submitTranslationsPDF')) {
         if ($this->tabAccess['edit'] === '1') {
             if (!Validate::isLanguageIsoCode(Tools::strtolower(Tools::getValue('lang')))) {
                 die(Tools::displayError());
             }
             $this->writeTranslationFile('PDF', _PS_TRANSLATIONS_DIR_ . Tools::strtolower(Tools::getValue('lang')) . '/pdf.php', 'PDF');
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (Tools::isSubmit('submitTranslationsBack')) {
         if ($this->tabAccess['edit'] === '1') {
             if (!Validate::isLanguageIsoCode(Tools::strtolower(Tools::getValue('lang')))) {
                 die(Tools::displayError());
             }
             $this->writeTranslationFile('Back', _PS_TRANSLATIONS_DIR_ . Tools::strtolower(Tools::getValue('lang')) . '/admin.php', 'ADM');
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (Tools::isSubmit('submitTranslationsErrors')) {
         if ($this->tabAccess['edit'] === '1') {
             if (!Validate::isLanguageIsoCode(Tools::strtolower(Tools::getValue('lang')))) {
                 die(Tools::displayError());
             }
             $this->writeTranslationFile('Errors', _PS_TRANSLATIONS_DIR_ . Tools::strtolower(Tools::getValue('lang')) . '/errors.php', false, 'ERRORS');
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (Tools::isSubmit('submitTranslationsFields')) {
         if ($this->tabAccess['edit'] === '1') {
             if (!Validate::isLanguageIsoCode(Tools::strtolower(Tools::getValue('lang')))) {
                 die(Tools::displayError());
             }
             $this->writeTranslationFile('Fields', _PS_TRANSLATIONS_DIR_ . Tools::strtolower(Tools::getValue('lang')) . '/fields.php', false, 'FIELDS');
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (Tools::isSubmit('submitTranslationsMails') || Tools::isSubmit('submitTranslationsMailsAndStay')) {
         if ($this->tabAccess['edit'] === '1' && ($id_lang = Language::getIdByIso(Tools::getValue('lang'))) > 0) {
             $this->submitTranslationsMails($id_lang);
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (Tools::isSubmit('submitTranslationsModules')) {
         if ($this->tabAccess['edit'] === '1') {
             $array_lang_src = Language::getLanguages(false);
             foreach ($array_lang_src as $language) {
                 $this->all_iso_lang[] = $language['iso_code'];
             }
             $lang = Tools::strtolower($_POST['lang']);
             if (!Validate::isLanguageIsoCode($lang)) {
                 die(Tools::displayError());
             }
             if (!($modules = scandir(_PS_MODULE_DIR_))) {
                 $this->displayWarning(Tools::displayError('There are no modules in your copy of PrestaShop. Use the Modules tab to activate them or go to our Website to download additional Modules.'));
             } else {
                 $arr_find_and_write = array();
                 $arr_files = $this->getAllModuleFiles($modules, _PS_MODULE_DIR_, $lang, true);
                 $arr_find_and_write = array_merge($arr_find_and_write, $arr_files);
//.........这里部分代码省略.........
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:101,代码来源:AdminTranslations.php

示例9: postProcess

 public function postProcess()
 {
     global $currentIndex, $cookie;
     if (isset($_GET['delete' . $this->table])) {
         if ($this->tabAccess['delete'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject()) and isset($this->fieldImageSettings)) {
                 // English is needed by the system (ex. translations)
                 if ($object->id == Language::getIdByIso('en')) {
                     $this->_errors[] = $this->l('You cannot delete the English language as it is a system requirement, you can only deactivate it.');
                 }
                 if ($object->id == Configuration::get('PS_LANG_DEFAULT')) {
                     $this->_errors[] = $this->l('you cannot delete the default language');
                 } elseif ($object->id == $cookie->id_lang) {
                     $this->_errors[] = $this->l('You cannot delete the language currently in use. Please change languages before deleting.');
                 } elseif ($this->deleteNoPictureImages((int) Tools::getValue('id_lang')) and $object->delete()) {
                     Tools::redirectAdmin($currentIndex . '&conf=1' . '&token=' . $this->token);
                 }
             } else {
                 $this->_errors[] = Tools::displayError('An error occurred while deleting object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } elseif (Tools::getValue('submitDel' . $this->table) and isset($_POST[$this->table . 'Box'])) {
         if ($this->tabAccess['delete'] === '1') {
             if (in_array(Configuration::get('PS_LANG_DEFAULT'), $_POST[$this->table . 'Box'])) {
                 $this->_errors[] = $this->l('you cannot delete the default language');
             } elseif (in_array($cookie->id_lang, $_POST[$this->table . 'Box'])) {
                 $this->_errors[] = $this->l('you cannot delete the language currently in use, please change languages before deleting');
             } else {
                 foreach ($_POST[$this->table . 'Box'] as $language) {
                     $this->deleteNoPictureImages($language);
                 }
                 parent::postProcess();
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } elseif (Tools::isSubmit('submitAddlang')) {
         /* New language */
         if ((int) Tools::getValue('id_' . $this->table) == 0) {
             if ($this->tabAccess['add'] === '1') {
                 if (isset($_POST['iso_code']) and !empty($_POST['iso_code']) and Validate::isLanguageIsoCode(Tools::getValue('iso_code')) and Language::getIdByIso($_POST['iso_code'])) {
                     $this->_errors[] = Tools::displayError('This ISO code is already linked to another language.');
                 }
                 if ((!empty($_FILES['no-picture']['tmp_name']) or !empty($_FILES['flag']['tmp_name'])) and Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
                     if ($_FILES['no-picture']['error'] == UPLOAD_ERR_OK) {
                         $this->copyNoPictureImage(strtolower(Tools::getValue('iso_code')));
                     }
                     // class AdminTab deal with every $_FILES content, don't do that for no-picture
                     unset($_FILES['no-picture']);
                     parent::postProcess();
                 } else {
                     $this->validateRules();
                     $this->_errors[] = Tools::displayError('Flag and No-Picture image fields are required.');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('You do not have permission to add here.');
             }
         } else {
             if ($this->tabAccess['edit'] === '1') {
                 if ((isset($_FILES['no-picture']) and !$_FILES['no-picture']['error'] or isset($_FILES['flag']) and !$_FILES['flag']['error']) and Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
                     if ($_FILES['no-picture']['error'] == UPLOAD_ERR_OK) {
                         $this->copyNoPictureImage(strtolower(Tools::getValue('iso_code')));
                     }
                     // class AdminTab deal with every $_FILES content, don't do that for no-picture
                     unset($_FILES['no-picture']);
                     parent::postProcess();
                 }
                 if (!Validate::isLoadedObject($object = $this->loadObject())) {
                     die(Tools::displayError());
                 }
                 if ((int) $object->id == (int) Configuration::get('PS_LANG_DEFAULT') and (int) $_POST['active'] != (int) $object->active) {
                     $this->_errors[] = Tools::displayError('You cannot change the status of the default language.');
                 } else {
                     parent::postProcess();
                 }
                 $this->validateRules();
             } else {
                 $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
             }
         }
     } elseif (isset($_GET['status']) and isset($_GET['id_lang'])) {
         if ($this->tabAccess['edit'] === '1') {
             if (!Validate::isLoadedObject($object = $this->loadObject())) {
                 die(Tools::displayError());
             }
             if ((int) $object->id == (int) Configuration::get('PS_LANG_DEFAULT')) {
                 $this->_errors[] = Tools::displayError('You cannot change the status of the default language.');
             } else {
                 return parent::postProcess();
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (Tools::isSubmit('submitOptions' . $this->table)) {
         $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');
         } else {
//.........这里部分代码省略.........
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:101,代码来源:AdminLanguages.php

示例10: getMailFiles

 /**
  * Get each informations for each mails founded in the folder $dir.
  *
  * @since 1.4.0.14
  * @param string $dir
  * @param string $group_name
  * @return array : list of mails
  */
 public function getMailFiles($dir, $group_name = 'mail')
 {
     $arr_return = array();
     if (Language::getIdByIso('en')) {
         $default_language = 'en';
     } else {
         $default_language = Language::getIsoById((int) Configuration::get('PS_LANG_DEFAULT'));
     }
     if (!$default_language || !Validate::isLanguageIsoCode($default_language)) {
         return false;
     }
     // Very usefull to name input and textarea fields
     $arr_return['group_name'] = $group_name;
     $arr_return['empty_values'] = 0;
     $arr_return['total_filled'] = 0;
     $arr_return['directory'] = $dir;
     // Get path for english mail directory
     $dir_en = str_replace('/' . $this->lang_selected->iso_code . '/', '/' . $default_language . '/', $dir);
     if (Tools::file_exists_cache($dir_en)) {
         // Get all english files to compare with the language to translate
         foreach (scandir($dir_en) as $email_file) {
             if (strripos($email_file, '.html') > 0 || strripos($email_file, '.txt') > 0) {
                 $email_name = substr($email_file, 0, strripos($email_file, '.'));
                 $type = substr($email_file, strripos($email_file, '.') + 1);
                 if (!isset($arr_return['files'][$email_name])) {
                     $arr_return['files'][$email_name] = array();
                 }
                 // $email_file is from scandir ($dir), so we already know that file exists
                 $arr_return['files'][$email_name][$type]['en'] = $this->getMailContent($dir_en, $email_file);
                 // check if the file exists in the language to translate
                 if (Tools::file_exists_cache($dir . '/' . $email_file)) {
                     $arr_return['files'][$email_name][$type][$this->lang_selected->iso_code] = $this->getMailContent($dir, $email_file);
                     $this->total_expression++;
                 } else {
                     $arr_return['files'][$email_name][$type][$this->lang_selected->iso_code] = '';
                 }
                 if ($arr_return['files'][$email_name][$type][$this->lang_selected->iso_code] == '') {
                     $arr_return['empty_values']++;
                 } else {
                     $arr_return['total_filled']++;
                 }
             }
         }
     } else {
         $this->warnings[] = sprintf(Tools::displayError('A mail directory exists for %1$s but not for English in %2$s'), $this->lang_selected->iso_code, str_replace(_PS_ROOT_DIR_, '', $dir));
     }
     return $arr_return;
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:56,代码来源:AdminTranslationsController.php

示例11: process

 public function process()
 {
     parent::process();
     /* Secure restriction for guest */
     if (self::$cookie->is_guest) {
         Tools::redirect('addresses.php');
     }
     if (Tools::isSubmit('id_country') and Tools::getValue('id_country') != NULL and is_numeric(Tools::getValue('id_country'))) {
         $selectedCountry = (int) Tools::getValue('id_country');
     } elseif (isset($this->_address) and isset($this->_address->id_country) and !empty($this->_address->id_country) and is_numeric($this->_address->id_country)) {
         $selectedCountry = (int) $this->_address->id_country;
     } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $array = preg_split('/,|-/', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         if (!Validate::isLanguageIsoCode($array[0]) or !($selectedCountry = Country::getByIso($array[0]))) {
             $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
         }
     } else {
         $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
     }
     $countries = Country::getCountries((int) self::$cookie->id_lang, true);
     $countriesList = '';
     foreach ($countries as $country) {
         $countriesList .= '<option value="' . (int) $country['id_country'] . '" ' . ($country['id_country'] == $selectedCountry ? 'selected="selected"' : '') . '>' . htmlentities($country['name'], ENT_COMPAT, 'UTF-8') . '</option>';
     }
     if ((Configuration::get('VATNUMBER_MANAGEMENT') and file_exists(_PS_MODULE_DIR_ . 'vatnumber/vatnumber.php')) && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT'))) {
         self::$smarty->assign('vat_display', 2);
     } else {
         if (Configuration::get('VATNUMBER_MANAGEMENT')) {
             self::$smarty->assign('vat_display', 1);
         } else {
             self::$smarty->assign('vat_display', 0);
         }
     }
     self::$smarty->assign('ajaxurl', _MODULE_DIR_);
     self::$smarty->assign(array('countries_list' => $countriesList, 'countries' => $countries, 'errors' => $this->errors, 'token' => Tools::getToken(false), 'select_address' => (int) Tools::getValue('select_address')));
 }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:36,代码来源:AddressController.php

示例12: getByIso

    /**
     * Get a country ID with its iso code
     *
     * @param string $iso_code Country iso code
     * @param bool $active return only active coutries
     * @return int Country ID
     */
    public static function getByIso($iso_code, $active = false)
    {
        if (!Validate::isLanguageIsoCode($iso_code)) {
            die(Tools::displayError());
        }
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT `id_country`
			FROM `' . _DB_PREFIX_ . 'country`
			WHERE `iso_code` = \'' . pSQL(strtoupper($iso_code)) . '\'' . ($active ? ' AND active = 1' : ''));
        if (isset($result['id_country'])) {
            return (int) $result['id_country'];
        }
        return false;
    }
开发者ID:jpodracky,项目名称:dogs,代码行数:21,代码来源:Country.php

示例13: getContent

 public function getContent()
 {
     include_once dirname(__FILE__) . '/backward_compatibility/backward.php';
     $output = '';
     $shopgateConfig = new ShopgateConfigPresta();
     $bools = array('true' => true, 'false' => false);
     if (Tools::isSubmit('saveConfigurations')) {
         $configs = Tools::getValue('configs', array());
         foreach ($configs as $name => $value) {
             if (isset($bools[$value])) {
                 $configs[$name] = $bools[$value];
             }
             $configs[$name] = htmlentities($configs[$name]);
         }
         $configs['use_stock'] = !(bool) Configuration::get('PS_ORDER_OUT_OF_STOCK');
         $settings = Tools::getValue('settings', array());
         foreach ($settings as $key => $value) {
             if (in_array($key, array('SHOPGATE_SHIPPING_SERVICE', 'SHOPGATE_MIN_QUANTITY_CHECK', 'SHOPGATE_MIN_QUANTITY_CHECK', 'SHOPGATE_OUT_OF_STOCK_CHECK', 'SHOPGATE_OUT_OF_STOCK_CHECK'))) {
                 Configuration::updateValue($key, htmlentities($value, ENT_QUOTES));
             }
         }
         $languageID = Configuration::get('PS_LANG_DEFAULT');
         if (Validate::isLanguageIsoCode($configs["language"])) {
             $languageID = Language::getIdByIso($configs["language"]);
         }
         Configuration::updateValue('SHOPGATE_LANGUAGE_ID', $languageID);
         try {
             $shopgateConfig->loadArray($configs);
             $shopgateConfig->saveFile(array_keys($configs));
             $output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('Confirmation') . '" />' . $this->l('Configurations updated') . '</div>';
         } catch (ShopgateLibraryException $e) {
             $output .= '<div class="conf error"><img src="../img/admin/error.png" alt="' . $this->l('Error') . '" />' . $this->l('Error') . ': ' . $e->getAdditionalInformation() . '</div>';
         }
     }
     $langs = array();
     foreach (Language::getLanguages() as $id => $l) {
         $langs[strtoupper($l['iso_code'])] = $l['name'];
     }
     $servers = array('live' => $this->l('Live'), 'pg' => $this->l('Playground'), 'custom' => $this->l('Custom'));
     $enables = array();
     $settings = Configuration::getMultiple(array('SHOPGATE_SHIPPING_SERVICE', 'SHOPGATE_MIN_QUANTITY_CHECK', 'SHOPGATE_OUT_OF_STOCK_CHECK'));
     $shopgateConfig = new ShopgateConfigPresta();
     $configs = $shopgateConfig->toArray();
     $this->context->smarty->assign('settings', $settings);
     $this->context->smarty->assign('shipping_service_list', $this->shipping_service_list);
     $this->context->smarty->assign('langs', $langs);
     $this->context->smarty->assign('currencies', Currency::getCurrencies());
     $this->context->smarty->assign('servers', $servers);
     $this->context->smarty->assign('enables', $enables);
     $this->context->smarty->assign('configs', $configs);
     $this->context->smarty->assign('mod_dir', $this->_path);
     $this->context->smarty->assign('api_url', Tools::getHttpHost(true, true) . $this->_path . 'api.php');
     $this->context->smarty->assign('shopgate_offer_url', $this->_getOfferLink(Context::getContext()->language->language_code));
     return $output . $this->display(__FILE__, 'views/templates/admin/configurations.tpl');
 }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:55,代码来源:shopgate.php

示例14: init

 public function init()
 {
     global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files;
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     // If current URL use SSL, set it true (used a lot for module redirect)
     if (Tools::usingSecureMode()) {
         $useSSL = $this->ssl = true;
     }
     $css_files = array();
     $js_files = array();
     if ($this->ssl && !Tools::usingSecureMode() && _PS_SSL_ENABLED_) {
         header('HTTP/1.1 301 Moved Permanently');
         header('Cache-Control: no-cache');
         header('Location: ' . Tools::getShopDomainSsl(true) . $_SERVER['REQUEST_URI']);
         exit;
     } elseif (_PS_SSL_ENABLED_ && Tools::usingSecureMode() && !$this->ssl) {
         header('HTTP/1.1 301 Moved Permanently');
         header('Cache-Control: no-cache');
         header('Location: ' . Tools::getShopDomain(true) . $_SERVER['REQUEST_URI']);
         exit;
     }
     ob_start();
     /* Loading default country */
     $defaultCountry = new Country((int) _PS_COUNTRY_DEFAULT_, (int) _PS_LANG_DEFAULT_);
     $cookie = new Cookie('ps', '', time() + ((int) Configuration::get('PS_COOKIE_LIFETIME_FO') > 0 ? (int) Configuration::get('PS_COOKIE_LIFETIME_FO') : 1) * 3600);
     $link = new Link();
     if ($this->auth && !$cookie->isLogged($this->guestAllowed)) {
         Tools::redirect('authentication.php' . ($this->authRedirection ? '?back=' . $this->authRedirection : ''));
     }
     /* Theme is missing or maintenance */
     if (!file_exists(_PS_THEME_DIR_)) {
         die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.'));
     } elseif (basename($_SERVER['PHP_SELF']) != 'disabled.php' && !(int) Configuration::get('PS_SHOP_ENABLE')) {
         $this->maintenance = true;
     } elseif (_PS_GEOLOCATION_ENABLED_) {
         $this->geolocationManagement();
     }
     // Switch language if needed and init cookie language
     $iso = Tools::getValue('isolang');
     if ($iso && Validate::isLanguageIsoCode($iso)) {
         $id_lang = (int) Language::getIdByIso($iso);
         if ($id_lang) {
             $_GET['id_lang'] = $id_lang;
         }
     }
     Tools::switchLanguage();
     Tools::setCookieLanguage();
     /* attribute id_lang is often needed, so we create a constant for performance reasons */
     if (!defined('_USER_ID_LANG_')) {
         define('_USER_ID_LANG_', (int) $cookie->id_lang);
     }
     if (isset($_GET['logout']) || $cookie->logged && Customer::isBanned((int) $cookie->id_customer)) {
         $cookie->logout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     } elseif (isset($_GET['mylogout'])) {
         $cookie->mylogout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     }
     global $currency;
     $currency = Tools::setCurrency();
     /* Cart already exists */
     if ((int) $cookie->id_cart) {
         $cart = new Cart((int) $cookie->id_cart);
         if ($cart->OrderExists()) {
             unset($cookie->id_cart, $cart, $cookie->checkedTOS);
         } elseif (_PS_GEOLOCATION_ENABLED_ && !in_array(strtoupper($cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && $cart->nbProducts() && (int) Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') != -1 && !self::isInWhitelistForGeolocation()) {
             unset($cookie->id_cart, $cart);
         } elseif ($cookie->id_customer != $cart->id_customer || $cookie->id_lang != $cart->id_lang || $cookie->id_currency != $cart->id_currency) {
             if ($cookie->id_customer) {
                 $cart->id_customer = (int) $cookie->id_customer;
             }
             $cart->id_lang = (int) $cookie->id_lang;
             $cart->id_currency = (int) $cookie->id_currency;
             $cart->update();
         }
         /* Select an address if not set */
         if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 || !isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $cookie->id_customer) {
             $to_update = false;
             if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) {
                 $to_update = true;
                 $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             }
             if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) {
                 $to_update = true;
                 $cart->id_address_invoice = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             }
             if ($to_update) {
                 $cart->update();
             }
         }
     }
     if (!isset($cart) || !$cart->id) {
         $cart = new Cart();
         $cart->id_lang = (int) $cookie->id_lang;
         $cart->id_currency = (int) $cookie->id_currency;
         $cart->id_guest = (int) $cookie->id_guest;
         if ($cookie->id_customer) {
//.........这里部分代码省略.........
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:101,代码来源:FrontController.php

示例15: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->context->smarty->assign('genders', Gender::getGenders());
     $this->assignDate();
     $this->assignCountries();
     $this->context->smarty->assign('newsletter', 1);
     $back = Tools::getValue('back');
     $key = Tools::safeOutput(Tools::getValue('key'));
     if (!empty($key)) {
         $back .= (strpos($back, '?') !== false ? '&' : '?') . 'key=' . $key;
     }
     if ($back == Tools::secureReferrer(Tools::getValue('back'))) {
         $this->context->smarty->assign('back', html_entity_decode($back));
     } else {
         $this->context->smarty->assign('back', Tools::safeOutput($back));
     }
     if (Tools::getValue('display_guest_checkout')) {
         if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
             $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
         } else {
             $countries = Country::getCountries($this->context->language->id, true);
         }
         if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
             // get all countries as language (xy) or language-country (wz-XY)
             $array = array();
             preg_match("#(?<=-)\\w\\w|\\w\\w(?!-)#", $_SERVER['HTTP_ACCEPT_LANGUAGE'], $array);
             if (!Validate::isLanguageIsoCode($array[0]) || !($sl_country = Country::getByIso($array[0]))) {
                 $sl_country = (int) Configuration::get('PS_COUNTRY_DEFAULT');
             }
         } else {
             $sl_country = (int) Tools::getValue('id_country', Configuration::get('PS_COUNTRY_DEFAULT'));
         }
         $this->context->smarty->assign(array('inOrderProcess' => true, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'sl_country' => (int) $sl_country, 'countries' => $countries));
     }
     if (Tools::getValue('create_account')) {
         $this->context->smarty->assign('email_create', 1);
     }
     if (Tools::getValue('multi-shipping') == 1) {
         $this->context->smarty->assign('multi_shipping', true);
     } else {
         $this->context->smarty->assign('multi_shipping', false);
     }
     $this->assignAddressFormat();
     // Call a hook to display more information on form
     $this->context->smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop')));
     // Just set $this->template value here in case it's used by Ajax
     $this->setTemplate(_PS_THEME_DIR_ . 'authentication.tpl');
     if ($this->ajax) {
         // Call a hook to display more information on form
         $this->context->smarty->assign(array('PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'genders' => Gender::getGenders()));
         $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'page' => $this->context->smarty->fetch($this->template), 'token' => Tools::getToken(false));
         die(Tools::jsonEncode($return));
     }
 }
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:59,代码来源:AuthController.php


注:本文中的Validate::isLanguageIsoCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。