本文整理汇总了PHP中Language::getIdByIso方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::getIdByIso方法的具体用法?PHP Language::getIdByIso怎么用?PHP Language::getIdByIso使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::getIdByIso方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAlertsInformations
private static function getAlertsInformations($iso)
{
$id_lang = Language::getIdByIso($iso);
$cert = Configuration::get(TSCommon::PREFIX_TABLE . 'CERTIFICATE_' . Tools::strtoupper($iso));
if ($cert != false) {
$certificate = (array) Tools::jsonDecode(Tools::htmlentitiesDecodeUTF8($cert));
if (trim($certificate['tsID']) != '') {
$query = '
SELECT
a.id_alert,
a.`iso`,
c.`email`,
o.`id_order`,
o.`id_lang`
FROM `' . _DB_PREFIX_ . self::TABLE_NAME . '` a
LEFT JOIN ' . _DB_PREFIX_ . 'orders o ON (a.id_order = o.id_order)
LEFT JOIN ' . _DB_PREFIX_ . 'customer c ON (c.id_customer = o.id_customer)
WHERE
o.`id_lang`=' . (int) $id_lang . '
AND
DATE_ADD(
o.`date_add`, INTERVAL ' . (int) $certificate['send_seperate_mail_delay'] . ' DAY
) <= NOW()';
return Db::getInstance()->ExecuteS($query);
}
}
return false;
}
示例2: __construct
public function __construct()
{
global $cookie;
$this->name = 'ebay';
$this->tab = 'market_place';
$this->version = '1.3.1';
$this->author = 'PrestaShop';
parent::__construct();
$this->displayName = $this->l('eBay');
$this->description = $this->l('Open your shop on the eBay market place !');
$this->id_lang = Language::getIdByIso('fr');
// Check the country and ask the bypass if not 'fr'
if (strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))) != 'fr' && !isset($cookie->ebay_country_default_fr)) {
$this->warning = $this->l('eBay module currently works only for eBay.fr');
return false;
}
// Checking Extension
if (!extension_loaded('curl') || !ini_get('allow_url_fopen')) {
if (!extension_loaded('curl') && !ini_get('allow_url_fopen')) {
$this->warning = $this->l('You must enable cURL extension and allow_url_fopen option on your server if you want to use this module.');
} elseif (!extension_loaded('curl')) {
$this->warning = $this->l('You must enable cURL extension on your server if you want to use this module.');
} elseif (!ini_get('allow_url_fopen')) {
$this->warning = $this->l('You must enable allow_url_fopen option on your server if you want to use this module.');
}
return false;
}
// Checking compatibility with older PrestaShop and fixing it
if (!Configuration::get('PS_SHOP_DOMAIN')) {
Configuration::updateValue('PS_SHOP_DOMAIN', $_SERVER['HTTP_HOST']);
}
// Generate eBay Security Token if not exists
if (!Configuration::get('EBAY_SECURITY_TOKEN')) {
Configuration::updateValue('EBAY_SECURITY_TOKEN', Tools::passwdGen(30));
}
/* For 1.4.3 and less compatibility */
$updateConfig = array('PS_OS_CHEQUE', 'PS_OS_PAYMENT', 'PS_OS_PREPARATION', 'PS_OS_SHIPPING', 'PS_OS_CANCELED', 'PS_OS_REFUND', 'PS_OS_ERROR', 'PS_OS_OUTOFSTOCK', 'PS_OS_BANKWIRE', 'PS_OS_PAYPAL', 'PS_OS_WS_PAYMENT');
if (!Configuration::get('PS_OS_PAYMENT')) {
foreach ($updateConfig as $u) {
if (!Configuration::get($u) && defined('_' . $u . '_')) {
Configuration::updateValue($u, constant('_' . $u . '_'));
}
}
}
// Check if installed
if (self::isInstalled($this->name)) {
// Upgrade eBay module
if (Configuration::get('EBAY_VERSION') != $this->version) {
$this->upgrade();
}
// Generate warnings
if (!Configuration::get('EBAY_API_TOKEN')) {
$this->warning = $this->l('You must register your module on eBay.');
}
// Loading Shipping Method
$this->loadShippingMethod();
// Warning uninstall
$this->confirmUninstall = $this->l('Are you sure you want uninstall this module ? All your configuration will be lost.');
}
}
示例3: submitCopyLang
public function submitCopyLang()
{
global $currentIndex;
if (!($fromLang = strval(Tools::getValue('fromLang'))) or !($toLang = strval(Tools::getValue('toLang')))) {
$this->_errors[] = $this->l('you must select 2 languages in order to copy data from one to another');
} elseif (!($fromTheme = strval(Tools::getValue('fromTheme'))) or !($toTheme = strval(Tools::getValue('toTheme')))) {
$this->_errors[] = $this->l('you must select 2 themes in order to copy data from one to another');
} elseif (!Language::copyLanguageData(Language::getIdByIso($fromLang), Language::getIdByIso($toLang))) {
$this->_errors[] = $this->l('an error occurred while copying data');
} elseif ($fromLang == $toLang and $fromTheme == $toTheme) {
$this->_errors[] = $this->l('nothing to copy! (same language and theme)');
}
if (sizeof($this->_errors)) {
return;
}
$bool = true;
$items = Language::getFilesList($fromLang, $fromTheme, $toLang, $toTheme, false, false, true);
foreach ($items as $source => $dest) {
$bool &= $this->checkDirAndCreate($dest);
$bool &= @copy($source, $dest);
}
if ($bool) {
Tools::redirectLink($currentIndex . '&conf=14&token=' . $this->token);
}
$this->_errors[] = $this->l('a part of the data has been copied but some language files could not be found or copied');
}
示例4: loadRoutes
/**
* Load default routes group by languages
*/
protected function loadRoutes($id_shop = null)
{
$context = Context::getContext();
// Load custom routes from modules
$modules_routes = Hook::exec('moduleRoutes', array('id_shop' => $id_shop), null, true, false);
if (is_array($modules_routes) && count($modules_routes)) {
foreach ($modules_routes as $module_route) {
if (is_array($module_route) && count($module_route)) {
foreach ($module_route as $route => $route_details) {
if (array_key_exists('controller', $route_details) && array_key_exists('rule', $route_details) && array_key_exists('keywords', $route_details) && array_key_exists('params', $route_details)) {
if (!isset($this->default_routes[$route])) {
$this->default_routes[$route] = array();
$this->default_routes[$route] = array_merge($this->default_routes[$route], $route_details);
}
}
}
}
}
}
// Set default routes
//new edit by Ha!*!*y :: Select only active languages
foreach (Language::getLanguages(TRUE) as $lang) {
foreach ($this->default_routes as $id => $route) {
$this->addRoute($id, $route['rule'], $route['controller'], $lang['id_lang'], $route['keywords'], isset($route['params']) ? $route['params'] : array(), $id_shop);
}
}
if ($this->use_routes) {
// Get iso lang
$iso_lang = Tools::getValue('isolang');
$id_lang = $context->language->id;
if (!empty($iso_lang)) {
$id_lang = Language::getIdByIso($iso_lang);
}
// Load routes from meta table
$sql = 'SELECT m.page, ml.url_rewrite, ml.id_lang
FROM `' . _DB_PREFIX_ . 'meta` m
LEFT JOIN `' . _DB_PREFIX_ . 'meta_lang` ml ON (m.id_meta = ml.id_meta' . Shop::addSqlRestrictionOnLang('ml', $id_shop) . ')
ORDER BY LENGTH(ml.url_rewrite) DESC';
if ($results = Db::getInstance()->executeS($sql)) {
foreach ($results as $row) {
if ($row['url_rewrite']) {
$this->addRoute($row['page'], $row['url_rewrite'], $row['page'], $row['id_lang'], array(), array(), $id_shop);
}
}
}
// Set default empty route if no empty route (that's weird I know)
if (!$this->empty_route) {
$this->empty_route = array('routeID' => 'index', 'rule' => '', 'controller' => 'index');
}
// Load custom routes
foreach ($this->default_routes as $route_id => $route_data) {
if ($custom_route = Configuration::get('PS_ROUTE_' . $route_id, null, null, $id_shop)) {
foreach (Language::getLanguages() as $lang) {
$this->addRoute($route_id, $custom_route, $route_data['controller'], $lang['id_lang'], $route_data['keywords'], isset($route_data['params']) ? $route_data['params'] : array(), $id_shop);
}
}
}
}
}
示例5: install
function install()
{
if (!parent::install()) {
return false;
}
$this->installModuleTab('AdminCache', array(Language::getIdByIso('fr') => 'Quadra Gestion Cache', Language::getIdByIso('en') => 'Quadra Cache Admin'), '8');
Configuration::updateValue('PS_QUADRA_CACHE_ACTIVE', 0);
}
示例6: getIdLang
public function getIdLang()
{
$id_lang = Language::getIdByIso($this->getIsoCode());
if (!$id_lang) {
//Fix for UK
$id_lang = Configuration::get('PS_LANG_DEFAULT');
}
return (int) $id_lang;
}
示例7: initContent
public function initContent()
{
Configuration::updateValue('SEGMENT_CUSTOMER_TOKEN', Tools::getValue('token'));
if (version_compare(_PS_VERSION_, '1.5', '>=')) {
Context::getContext()->controller->addJqueryUI('ui.datepicker');
}
$this->clearCacheLang();
$this->initLang();
Context::getContext()->smarty->assign(array('mj__PS_BASE_URI__' => __PS_BASE_URI__, 'mj_PS_JS_DIR_' => _PS_JS_DIR_, 'mj_MODULE_DIR_' => _MODULE_DIR_, 'mj_hint_fieldset' => array($this->l('This module enables you to create segments of customers according to any criteria you think of. You can then either display and export the selected customers or associate them to an existing customer group.', 'mailjet'), $this->l('These segments are particularly useful to create special offers associated with customer groups (e.g., send a coupon to the customers interested in some products)', 'mailjet'), $this->l('Create an infinite number of filters corresponding to your needs!', 'mailjet')), 'mj_datePickerJsFormat' => Context::getContext()->cookie->id_lang == Language::getIdByIso('fr') ? 'dd-mm-yy' : 'yy-mm-dd', 'mj_datepickerPersonnalized' => version_compare(_PS_VERSION_, '1.5', '<') ? '<script type="text/javascript" src="' . _PS_JS_DIR_ . 'jquery/datepicker/jquery-ui-personalized-1.6rc4.packed.js"></script>' : '', 'mj_token' => Tools::getValue('token'), 'mj_ajaxFile' => _MODULE_DIR_ . 'mailjet/ajax/ajax.php', 'mj_ajaxSyncFile' => _MODULE_DIR_ . 'mailjet/ajax/sync.php', 'mj_ajaxBundle' => _MODULE_DIR_ . 'mailjet/ajax/bundlejs_prestashop.php', 'mj_id_employee' => (int) Context::getContext()->cookie->id_employee, 'mj_lblMan' => stripReturn($this->ll(20)), 'mj_lblWoman' => stripReturn($this->ll(21)), 'mj_lblUnknown' => stripReturn($this->ll(43)), 'mj_trads' => array_map('stripReturn', $this->trad), 'mj_groups' => Group::getGroups((int) Context::getContext()->cookie->id_lang), 'mj_filter_list' => Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'mj_filter`'), 'mj_base_select' => Db::getInstance()->ExecuteS('SELECT id_basecondition, label FROM `' . _DB_PREFIX_ . 'mj_basecondition`')));
return '';
}
示例8: uninstall
public function uninstall()
{
foreach ($this->available_languages as $language) {
Configuration::deleteByName('TS_TAB0_ID_' . (int) Language::getIdByIso($language));
Configuration::deleteByName('TS_TAB0_ID_ACTIVE_' . (int) Language::getIdByIso($language));
}
Configuration::deleteByName('TS_TAB0_DISPLAY_IN_SHOP');
Configuration::deleteByName('TS_TAB0_DISPLAY_RATING_FRONT_END');
Configuration::deleteByName('TS_TAB0_DISPLAY_RATING_OC');
Configuration::deleteByName('TS_TAB0_SEND_RATING');
Configuration::deleteByName('TS_TAB0_SEND_SEPERATE_MAIL');
Configuration::deleteByName('TS_TAB0_SEND_SEPERATE_MAIL_DELAY');
Configuration::deleteByName('PS_TS_TAB0_SECURE_KEY');
return RatingAlert::dropTable();
}
示例9: __construct
public function __construct()
{
global $cookie;
$this->name = 'ebay';
$this->tab = 'market_place';
$this->version = '1.1';
parent::__construct();
$this->displayName = $this->l('eBay');
$this->description = $this->l('Open your shop on the eBay market place !');
$this->id_lang = Language::getIdByIso('fr');
// Check the country and ask the bypass if not 'fr'
if (strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))) != 'fr' && !isset($cookie->ebay_country_default_fr)) {
$this->warning = $this->l('eBay module currently works only for eBay.fr');
return false;
}
// Checking Extension
if (!extension_loaded('curl') || !ini_get('allow_url_fopen')) {
if (!extension_loaded('curl') && !ini_get('allow_url_fopen')) {
$this->warning = $this->l('You must enable cURL extension and allow_url_fopen option on your server if you want to use this module.');
} else {
if (!extension_loaded('curl')) {
$this->warning = $this->l('You must enable cURL extension on your server if you want to use this module.');
} else {
if (!ini_get('allow_url_fopen')) {
$this->warning = $this->l('You must enable allow_url_fopen option on your server if you want to use this module.');
}
}
}
return false;
}
// Checking compatibility with older PrestaShop and fixing it
if (!Configuration::get('PS_SHOP_DOMAIN')) {
Configuration::updateValue('PS_SHOP_DOMAIN', $_SERVER['HTTP_HOST']);
}
// Generate eBay Security Token if not exists
if (!Configuration::get('EBAY_SECURITY_TOKEN')) {
Configuration::updateValue('EBAY_SECURITY_TOKEN', Tools::passwdGen(30));
}
// Check if installed
if (self::isInstalled($this->name)) {
// Generate warnings
if (!Configuration::get('EBAY_API_TOKEN')) {
$this->warning = $this->l('You must register your module on eBay.');
}
// Shipping methods
$this->_shippingMethod = array(7104 => array('description' => 'Colissimo', 'shippingService' => 'FR_ColiposteColissimo', 'shippingServiceID' => '7104'), 7112 => array('description' => 'Ecopli', 'shippingService' => 'FR_Ecopli', 'shippingServiceID' => '7112'), 57104 => array('description' => 'La Poste - Courrier International Prioritaire', 'shippingService' => 'FR_LaPosteInternationalPriorityCourier', 'shippingServiceID' => '57104'), 7101 => array('description' => 'Lettre', 'shippingService' => 'FR_PostOfficeLetter', 'shippingServiceID' => '7101'), 57105 => array('description' => 'La Poste - Courrier International Economique', 'shippingService' => 'FR_LaPosteInternationalEconomyCourier', 'shippingServiceID' => '57105'), 57106 => array('description' => 'La Poste - Colissimo International', 'shippingService' => 'FR_LaPosteColissimoInternational', 'shippingServiceID' => '57106'), 7102 => array('description' => 'Lettre avec suivi', 'shippingService' => 'FR_PostOfficeLetterFollowed', 'shippingServiceID' => '7102'), 57107 => array('description' => 'La Poste - Colis Economique International', 'shippingService' => 'FR_LaPosteColisEconomiqueInternational', 'shippingServiceID' => '57107'), 7103 => array('description' => 'Lettre recommandée', 'shippingService' => 'FR_PostOfficeLetterRecommended', 'shippingServiceID' => '7103'), 7121 => array('description' => 'Lettre Max', 'shippingService' => 'FR_LaPosteLetterMax', 'shippingServiceID' => '7121'), 7113 => array('description' => 'Coliéco', 'shippingService' => 'FR_Colieco', 'shippingServiceID' => '7113'), 57108 => array('description' => 'La Poste - Colissimo Emballage International', 'shippingService' => 'FR_LaPosteColissimoEmballageInternational', 'shippingServiceID' => '57108'), 57114 => array('description' => 'Chronopost Express International', 'shippingService' => 'FR_ChronopostExpressInternational', 'shippingServiceID' => '57114'), 7106 => array('description' => 'Colissimo Recommandé', 'shippingService' => 'FR_ColiposteColissimoRecommended', 'shippingServiceID' => '7106'), 57109 => array('description' => 'Chronopost Classic International', 'shippingService' => 'FR_ChronopostClassicInternational', 'shippingServiceID' => '57109'), 57110 => array('description' => 'Chronopost Premium International', 'shippingService' => 'FR_ChronopostPremiumInternational', 'shippingServiceID' => '57110'), 7117 => array('description' => 'Chronopost - Chrono Relais', 'shippingService' => 'FR_ChronopostChronoRelais', 'shippingServiceID' => '7117'), 57111 => array('description' => 'UPS Standard', 'shippingService' => 'FR_UPSStandardInternational', 'shippingServiceID' => '57111'), 7111 => array('description' => 'Autre mode d\'envoi de courrier', 'shippingService' => 'FR_Autre', 'shippingServiceID' => '7111'), 57112 => array('description' => 'UPS Express', 'shippingService' => 'FR_UPSExpressInternational', 'shippingServiceID' => '57112'), 7114 => array('description' => 'Autre mode d\'envoi de colis', 'shippingService' => 'FR_AuteModeDenvoiDeColis', 'shippingServiceID' => '7114'), 57113 => array('description' => 'DHL', 'shippingService' => 'FR_DHLInternational', 'shippingServiceID' => '57113'), 57101 => array('description' => 'Frais de livraison internationale fixes', 'shippingService' => 'FR_StandardInternational', 'shippingServiceID' => '57101'), 7116 => array('description' => 'Chronopost', 'shippingService' => 'FR_Chronopost', 'shippingServiceID' => '7116'), 57102 => array('description' => 'Frais fixes pour livraison internationale express', 'shippingService' => 'FR_ExpeditedInternational', 'shippingServiceID' => '57102'), 57103 => array('description' => 'Autres livraisons internationales (voir description)', 'shippingService' => 'FR_OtherInternational', 'shippingServiceID' => '57103'), 7118 => array('description' => 'Chrono 10', 'shippingService' => 'FR_Chrono10', 'shippingServiceID' => '7118'), 7119 => array('description' => 'Chrono 13', 'shippingService' => 'FR_Chrono13', 'shippingServiceID' => '7119'), 7120 => array('description' => 'Chrono 18', 'shippingService' => 'FR_Chrono18', 'shippingServiceID' => '7120'), 7105 => array('description' => 'Coliposte - Colissimo Direct', 'shippingService' => 'FR_ColiposteColissimoDirect', 'shippingServiceID' => '7105'), 7107 => array('description' => 'Chronoposte - Chrono Classic International', 'shippingService' => 'FR_ChronoposteInternationalClassic', 'shippingServiceID' => '7107'), 7108 => array('description' => 'DHL - Express Europack', 'shippingService' => 'FR_DHLExpressEuropack', 'shippingServiceID' => '7108'), 7109 => array('description' => 'UPS - Standard', 'shippingService' => 'FR_UPSStandard', 'shippingServiceID' => '7109'));
}
}
示例10: install
function install()
{
$tab = new Tab();
$tab->id_parent = 1;
$tab->name = array(Language::getIdByIso('fr') => 'Carrousel d\'images', Language::getIdByIso('en') => 'Images carrousel');
$tab->class_name = 'AdminGallerySlider';
$tab->module = 'quadragalleryslider';
$tab->add();
if (!parent::install()) {
return false;
}
Configuration::updateValue('PS_QUADRA_SLIDER_HEIGHT', 200);
Configuration::updateValue('PS_QUADRA_SLIDER_WIDTH', 500);
Configuration::updateValue('PS_QUADRA_V_DISPLAY', 0);
//creation de la table
$this->createTable();
return $this->registerHook('home');
}
示例11: loadData
/**
* Loads the order status data from the order model.
*
* @param Order $order the model.
*/
public function loadData(Order $order)
{
// We prefer to use the English state name for the status code, as we use it as an unique identifier of that
// particular order status. The status label will primarily be in the language of the order.
$id_lang = (int) Language::getIdByIso('en');
if (empty($id_lang)) {
$id_lang = (int) $order->id_lang;
}
$state = $order->getCurrentStateFull($id_lang);
if (!empty($state['name'])) {
$state_name = $state['name'];
$this->code = $this->convertNameToCode($state_name);
if ($id_lang !== (int) $order->id_lang) {
$state = $order->getCurrentStateFull((int) $order->id_lang);
if (!empty($state['name'])) {
$state_name = $state['name'];
}
}
$this->label = $state_name;
}
}
示例12: _installLanguages
protected function _installLanguages($xml, $install_mode = false)
{
$attributes = array();
if (isset($xml->languages->language)) {
foreach ($xml->languages->language as $data) {
$attributes = $data->attributes();
if (Language::getIdByIso($attributes['iso_code'])) {
continue;
}
$native_lang = Language::getLanguages();
$native_iso_code = array();
foreach ($native_lang as $lang) {
$native_iso_code[] = $lang['iso_code'];
}
if (in_array((string) $attributes['iso_code'], $native_iso_code) and !$install_mode or !in_array((string) $attributes['iso_code'], $native_iso_code)) {
$errno = 0;
}
$errstr = '';
if (@fsockopen('www.prestashop.com', 80, $errno, $errstr, 10)) {
if ($lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . _PS_VERSION_ . '&iso_lang=' . $attributes['iso_code']))) {
if ($content = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/gzip/' . $lang_pack->version . '/' . $attributes['iso_code'] . '.gzip')) {
$file = _PS_TRANSLATIONS_DIR_ . $attributes['iso_code'] . '.gzip';
if (file_put_contents($file, $content)) {
$gz = new Archive_Tar($file, true);
if (!$gz->extract(_PS_TRANSLATIONS_DIR_ . '../', false)) {
$this->_errors[] = Tools::displayError('Cannot decompress the translation file of the language: ') . (string) $attributes['iso_code'];
return false;
}
if (!Language::checkAndAddLanguage((string) $attributes['iso_code'])) {
$this->_errors[] = Tools::displayError('An error occurred while creating the language: ') . (string) $attributes['iso_code'];
return false;
}
@unlink($file);
} else {
$this->_errors[] = Tools::displayError('Server does not have permissions for writing.');
}
}
} else {
$this->_errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.');
}
} else {
$this->_errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.');
}
}
}
// change the default language if there is only one language in the localization pack
if (!sizeof($this->_errors) and $install_mode and isset($attributes['iso_code']) and sizeof($xml->languages->language) == 1) {
$this->iso_code_lang = $attributes['iso_code'];
}
return true;
}
示例13: displayFormMails
public function displayFormMails($lang, $noDisplay = false)
{
global $cookie, $currentIndex;
$core_mails = array();
$module_mails = array();
$theme_mails = array();
$str_output = '';
// get all mail subjects, this method parse each files in Prestashop !!
$subject_mail = array();
$modules_has_mails = $this->getModulesHasMails();
$arr_files_to_parse = array(_PS_ROOT_DIR_ . '/controllers', _PS_ROOT_DIR_ . '/classes', PS_ADMIN_DIR . '/tabs', PS_ADMIN_DIR);
$arr_files_to_parse = array_merge($arr_files_to_parse, $modules_has_mails);
foreach ($arr_files_to_parse as $path) {
$subject_mail = self::getSubjectMail($path, $subject_mail);
}
$core_mails = $this->getMailFiles(_PS_MAIL_DIR_, $lang, 'core_mail');
$core_mails['subject'] = $this->getSubjectMailContent(_PS_MAIL_DIR_ . $lang);
foreach ($modules_has_mails as $module_name => $module_path) {
$module_mails[$module_name] = $this->getMailFiles($module_path . '/mails/', $lang, 'module_mail');
$module_mails[$module_name]['subject'] = $core_mails['subject'];
}
// Before 1.4.0.14 each theme folder was parsed,
// This page was really to low to load.
// Now just use the current theme.
if (_THEME_NAME_ !== AdminTranslations::DEFAULT_THEME_NAME) {
if (file_exists(_PS_THEME_DIR_ . 'mails')) {
$theme_mails['theme_mail'] = $this->getMailFiles(_PS_THEME_DIR_ . 'mails/', $lang, 'theme_mail');
$theme_mails['theme_mail']['subject'] = $this->getSubjectMailContent(_PS_THEME_DIR_ . 'mails/' . $lang);
}
if (file_exists(_PS_THEME_DIR_ . '/modules')) {
foreach (scandir(_PS_THEME_DIR_ . '/modules') as $module_dir) {
if ($module_dir[0] != '.' and file_exists(_PS_THEME_DIR_ . 'modules/' . $module_dir . '/mails')) {
$theme_mails[$module_dir] = $this->getMailFiles(_PS_THEME_DIR_ . 'modules/' . $module_dir . '/mails/', $lang, 'theme_module_mail');
$theme_mails[$module_dir]['subject'] = $theme_mails['theme_mail']['subject'];
}
}
}
}
if ($noDisplay) {
$empty = 0;
$total = 0;
$total += (int) $core_mails['total_filled'];
$empty += (int) $core_mails['empty_values'];
foreach ($module_mails as $mod_infos) {
$total += (int) $mod_infos['total_filled'];
$empty += (int) $mod_infos['empty_values'];
}
foreach ($theme_mails as $themes_infos) {
$total += (int) $themes_infos['total_filled'];
$empty += (int) $themes_infos['empty_values'];
}
return array('total' => $total, 'empty' => $empty);
}
$obj_lang = new Language(Language::getIdByIso($lang));
// TinyMCE
$str_output .= $this->getTinyMCEForMails($obj_lang->iso_code);
$str_output .= '<!--' . $this->l('Language') . '-->';
$str_output .= '
<h2>' . $this->l('Language') . ' : ' . Tools::strtoupper($lang) . ' - ' . $this->l('E-mail template translations') . '</h2>' . $this->l('Click on the titles to open fieldsets') . '.<br /><br />';
// display form
$str_output .= '
<form method="post" action="' . $currentIndex . '&token=' . $this->token . '&type=mails&lang=' . $obj_lang->iso_code . '" class="form">';
$str_output .= $this->displayToggleButton();
$str_output .= $this->displaySubmitButtons(Tools::getValue('type'));
$str_output .= '<br/><br/>';
// core emails
$str_output .= $this->l('Core e-mails:');
$str_output .= $this->displayMailContent($core_mails, $subject_mail, $obj_lang, 'core', $this->l('Core e-mails'));
// module mails
$str_output .= $this->l('Modules e-mails:');
foreach ($module_mails as $module_name => $mails) {
$str_output .= $this->displayMailContent($mails, $subject_mail, $obj_lang, Tools::strtolower($module_name), sprintf($this->l('E-mails for %s module'), '<em>' . $module_name . '</em>'), $module_name);
}
// mail theme and module theme
if (!empty($theme_mails)) {
$str_output .= $this->l('Themes e-mails:');
$bool_title = false;
foreach ($theme_mails as $theme_or_module_name => $mails) {
$title = $theme_or_module_name != 'theme_mail' ? ucfirst(_THEME_NAME_) . ' ' . sprintf($this->l('E-mails for %s module'), '<em>' . $theme_or_module_name . '</em>') : ucfirst(_THEME_NAME_) . ' ' . $this->l('e-mails');
if ($theme_or_module_name != 'theme_mail' && !$bool_title) {
$bool_title = true;
$str_output .= $this->l('E-mails modules in theme:');
}
$str_output .= $this->displayMailContent($mails, $subject_mail, $obj_lang, 'theme_' . Tools::strtolower($theme_or_module_name), $title, $theme_or_module_name != 'theme_mail' ? $theme_or_module_name : false);
}
}
$str_output .= '
<input type="hidden" name="lang" value="' . $lang . '" />
<input type="hidden" name="type" value="' . Tools::getValue('type') . '" />';
$str_output .= $this->displaySubmitButtons(Tools::getValue('type'));
$str_output .= '<br /><br />';
$str_output .= '</form>';
echo $str_output;
}
示例14: setCookieLanguage
/**
* Change language in cookie while clicking on a flag
*
* @return string iso code
*/
public static function setCookieLanguage()
{
global $cookie;
/* If language does not exist or is disabled, erase it */
if ($cookie->id_lang) {
$lang = new Language((int) $cookie->id_lang);
if (!Validate::isLoadedObject($lang) or !$lang->active) {
$cookie->id_lang = NULL;
}
}
/* Automatically detect language if not already defined */
if (!$cookie->id_lang and isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$array = explode(',', self::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
if (self::strlen($array[0]) > 2) {
$tab = explode('-', $array[0]);
$string = $tab[0];
} else {
$string = $array[0];
}
if (Validate::isLanguageIsoCode($string)) {
$lang = new Language((int) Language::getIdByIso($string));
if (Validate::isLoadedObject($lang) and $lang->active) {
$cookie->id_lang = (int) $lang->id;
}
}
}
/* If language file not present, you must use default language file */
if (!$cookie->id_lang or !Validate::isUnsignedId($cookie->id_lang)) {
$cookie->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
}
$iso = Language::getIsoById((int) $cookie->id_lang);
@(include_once _PS_THEME_DIR_ . 'lang/' . $iso . '.php');
return $iso;
}
示例15: checkAndAddLanguage
public static function checkAndAddLanguage($iso_code, $lang_pack = false, $only_add = false, $params_lang = null)
{
if (Language::getIdByIso($iso_code)) {
return true;
}
// Initialize the language
$lang = new Language();
$lang->iso_code = Tools::strtolower($iso_code);
$lang->language_code = $iso_code;
// Rewritten afterwards if the language code is available
$lang->active = true;
// If the language pack has not been provided, retrieve it from prestashop.com
if (!$lang_pack) {
$lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . _PS_VERSION_ . '&iso_lang=' . $iso_code));
}
// If a language pack has been found or provided, prefill the language object with the value
if ($lang_pack) {
foreach (get_object_vars($lang_pack) as $key => $value) {
if ($key != 'iso_code' && isset(Language::$definition['fields'][$key])) {
$lang->{$key} = $value;
}
}
}
// Use the values given in parameters to override the data retrieved automatically
if ($params_lang !== null && is_array($params_lang)) {
foreach ($params_lang as $key => $value) {
if ($key != 'iso_code' && isset(Language::$definition['fields'][$key])) {
$lang->{$key} = $value;
}
}
}
if (!$lang->name && $lang->iso_code) {
$lang->name = $lang->iso_code;
}
if (!$lang->validateFields() || !$lang->validateFieldsLang() || !$lang->add(true, false, $only_add)) {
return false;
}
if (isset($params_lang['allow_accented_chars_url']) && in_array($params_lang['allow_accented_chars_url'], array('1', 'true'))) {
Configuration::updateGlobalValue('PS_ALLOW_ACCENTED_CHARS_URL', 1);
}
$flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/' . $iso_code . '.jpg');
if ($flag != null && !preg_match('/<body>/', $flag)) {
$file = fopen(_PS_ROOT_DIR_ . '/img/l/' . (int) $lang->id . '.jpg', 'w');
if ($file) {
fwrite($file, $flag);
fclose($file);
} else {
Language::_copyNoneFlag((int) $lang->id);
}
} else {
Language::_copyNoneFlag((int) $lang->id);
}
$files_copy = array('/en.jpg', '/en-default-' . ImageType::getFormatedName('thickbox') . '.jpg', '/en-default-' . ImageType::getFormatedName('home') . '.jpg', '/en-default-' . ImageType::getFormatedName('large') . '.jpg', '/en-default-' . ImageType::getFormatedName('medium') . '.jpg', '/en-default-' . ImageType::getFormatedName('small') . '.jpg', '/en-default-' . ImageType::getFormatedName('scene') . '.jpg');
foreach (array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_) as $to) {
foreach ($files_copy as $file) {
@copy(_PS_ROOT_DIR_ . '/img/l' . $file, $to . str_replace('/en', '/' . $iso_code, $file));
}
}
return true;
}