當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Language::loadLanguages方法代碼示例

本文整理匯總了PHP中Language::loadLanguages方法的典型用法代碼示例。如果您正苦於以下問題:PHP Language::loadLanguages方法的具體用法?PHP Language::loadLanguages怎麽用?PHP Language::loadLanguages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Language的用法示例。


在下文中一共展示了Language::loadLanguages方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: reorderpositions

function reorderpositions()
{
    /* Clean products positions */
    if ($cat = Category::getCategories(1, false, false)) {
        foreach ($cat as $i => $categ) {
            Product::cleanPositions((int) $categ['id_category']);
        }
    }
    //clean Category position and delete old position system
    Language::loadLanguages();
    $language = Language::getLanguages();
    $cat_parent = Db::getInstance()->ExecuteS('SELECT DISTINCT c.id_parent FROM `' . _DB_PREFIX_ . 'category` c WHERE id_category != 1');
    foreach ($cat_parent as $parent) {
        $result = Db::getInstance()->ExecuteS('
							SELECT DISTINCT c.*, cl.*
							FROM `' . _DB_PREFIX_ . 'category` c 
							LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = ' . (int) Configuration::get('PS_LANG_DEFAULT') . ')
							WHERE c.id_parent = ' . (int) $parent['id_parent'] . '
							ORDER BY name ASC');
        foreach ($result as $i => $categ) {
            Db::getInstance()->Execute('
			UPDATE `' . _DB_PREFIX_ . 'category`
			SET `position` = ' . (int) $i . '
			WHERE `id_parent` = ' . (int) $categ['id_parent'] . '
			AND `id_category` = ' . (int) $categ['id_category']);
        }
        $result = Db::getInstance()->ExecuteS('
							SELECT DISTINCT c.*, cl.*
							FROM `' . _DB_PREFIX_ . 'category` c 
							LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category`)
							WHERE c.id_parent = ' . (int) $parent['id_parent'] . '
							ORDER BY name ASC');
        // Remove number from category name
        foreach ($result as $i => $categ) {
            Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'category` c 
			LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category`)
			SET `name` = \'' . preg_replace('/^[0-9]+\\./', '', $categ['name']) . '\' 
			WHERE c.id_category = ' . (int) $categ['id_category'] . ' AND id_lang = \'' . (int) $categ['id_lang'] . '\'');
        }
    }
    /* Clean CMS positions */
    if ($cms_cat = CMSCategory::getCategories(1, false, false)) {
        foreach ($cms_cat as $i => $categ) {
            CMS::cleanPositions((int) $categ['id_cms_category']);
        }
    }
}
開發者ID:priyankajsr19,項目名稱:indusdiva2,代碼行數:47,代碼來源:reorderpositions.php

示例2: generateHtaccess

 public static function generateHtaccess($path, $rewrite_settings, $cache_control, $specific = '', $disableMuliviews = false)
 {
     $tab = array('ErrorDocument' => array(), 'RewriteEngine' => array(), 'RewriteRule' => array());
     $multilang = Language::countActiveLanguages() > 1;
     // ErrorDocument
     $tab['ErrorDocument']['comment'] = '# Catch 404 errors';
     $tab['ErrorDocument']['content'] = '404 ' . __PS_BASE_URI__ . '404.php';
     // RewriteEngine
     $tab['RewriteEngine']['comment'] = '# URL rewriting module activation';
     // RewriteRules
     $tab['RewriteRule']['comment'] = '# URL rewriting rules';
     // Compatibility with the old image filesystem
     if (Configuration::get('PS_LEGACY_IMAGES')) {
         $tab['RewriteRule']['content']['^([a-z0-9]+)\\-([a-z0-9]+)(\\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1-$2$3.jpg [L]';
         $tab['RewriteRule']['content']['^([0-9]+)\\-([0-9]+)/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1-$2.jpg [L]';
     }
     // Rewriting for product image id < 100 millions
     $tab['RewriteRule']['content']['^([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$1$2.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$1$2$3.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$3/$1$2$3$4.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$3/$4/$1$2$3$4$5.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg [L]';
     $tab['RewriteRule']['content']['^c/([0-9]+)(\\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\\.jpg$'] = 'img/c/$1$2.jpg [L]';
     $tab['RewriteRule']['content']['^c/([a-zA-Z-]+)/[a-zA-Z0-9-]+\\.jpg$'] = 'img/c/$1.jpg [L]';
     if ($multilang) {
         $tab['RewriteRule']['content']['^([a-z]{2})/[a-zA-Z0-9-]*/([0-9]+)\\-[a-zA-Z0-9-]*\\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\\-[a-zA-Z0-9-]*\\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$2&isolang=$1&noredirect=1 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$2&isolang=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/content/([0-9]+)\\-[a-zA-Z0-9-]*'] = 'cms.php?isolang=$1&id_cms=$2 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/content/category/([0-9]+)\\-[a-zA-Z0-9-]*'] = 'cms.php?isolang=$1&id_cms_category=$2 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)__[a-zA-Z0-9-]*'] = 'supplier.php?isolang=$1&id_supplier=$2 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)_[a-zA-Z0-9-]*'] = 'manufacturer.php?isolang=$1&id_manufacturer=$2 [QSA,L]';
     }
     // PS BASE URI automaticaly prepend the string, do not use PS defines for the image directories
     $tab['RewriteRule']['content']['^([0-9]+)(\\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\\.jpg$'] = 'img/c/$1$2.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9]+)\\-[a-zA-Z0-9-]*\\.html'] = 'product.php?id_product=$1 [QSA,L]';
     $tab['RewriteRule']['content']['^[a-zA-Z0-9-]*/([0-9]+)\\-[a-zA-Z0-9-]*\\.html'] = 'product.php?id_product=$1 [QSA,L]';
     // Notice : the id_category rule has to be after product rules.
     // If not, category with number in their name will result a bug
     $tab['RewriteRule']['content']['^([0-9]+)\\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$1&noredirect=1 [QSA,L]';
     $tab['RewriteRule']['content']['^([0-9]+)\\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$1 [QSA,L]';
     $tab['RewriteRule']['content']['^([0-9]+)__([a-zA-Z0-9-]*)'] = 'supplier.php?id_supplier=$1 [QSA,L]';
     $tab['RewriteRule']['content']['^([0-9]+)_([a-zA-Z0-9-]*)'] = 'manufacturer.php?id_manufacturer=$1 [QSA,L]';
     $tab['RewriteRule']['content']['^content/([0-9]+)\\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms=$1 [QSA,L]';
     $tab['RewriteRule']['content']['^content/category/([0-9]+)\\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms_category=$1 [QSA,L]';
     // Compatibility with the old URLs
     if (!Configuration::get('PS_INSTALL_VERSION') or version_compare(Configuration::get('PS_INSTALL_VERSION'), '1.4.0.7') == -1) {
         // This is a nasty copy/paste of the previous links, but with "lang-en" instead of "en"
         // Do not update it when you add something in the one at the top, it's only for the old links
         $tab['RewriteRule']['content']['^lang-([a-z]{2})/([a-zA-Z0-9-]*)/([0-9]+)\\-([a-zA-Z0-9-]*)\\.html'] = 'product.php?id_product=$3&isolang=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^lang-([a-z]{2})/([0-9]+)\\-([a-zA-Z0-9-]*)\\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^lang-([a-z]{2})/([0-9]+)\\-([a-zA-Z0-9-]*)'] = 'category.php?id_category=$2&isolang=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^content/([0-9]+)\\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^content/category/([0-9]+)\\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms_category=$1 [QSA,L]';
     }
     Language::loadLanguages();
     $default_meta = Meta::getMetasByIdLang((int) Configuration::get('PS_LANG_DEFAULT'));
     if ($multilang) {
         foreach (Language::getLanguages() as $language) {
             foreach (Meta::getMetasByIdLang($language['id_lang']) as $key => $meta) {
                 if (!empty($meta['url_rewrite']) and Validate::isLinkRewrite($meta['url_rewrite'])) {
                     $tab['RewriteRule']['content']['^' . $language['iso_code'] . '/' . $meta['url_rewrite'] . '$'] = $meta['page'] . '.php?isolang=' . $language['iso_code'] . ' [QSA,L]';
                 } elseif (array_key_exists($key, $default_meta) && $default_meta[$key]['url_rewrite'] != '') {
                     $tab['RewriteRule']['content']['^' . $language['iso_code'] . '/' . $default_meta[$key]['url_rewrite'] . '$'] = $default_meta[$key]['page'] . '.php?isolang=' . $language['iso_code'] . ' [QSA,L]';
                 }
             }
             $tab['RewriteRule']['content']['^' . $language['iso_code'] . '$'] = $language['iso_code'] . '/ [QSA,L]';
             $tab['RewriteRule']['content']['^' . $language['iso_code'] . '/([^?&]*)$'] = '$1?isolang=' . $language['iso_code'] . ' [QSA,L]';
         }
     } else {
         foreach ($default_meta as $key => $meta) {
             if (!empty($meta['url_rewrite'])) {
                 $tab['RewriteRule']['content']['^' . $meta['url_rewrite'] . '$'] = $meta['page'] . '.php [QSA,L]';
             } elseif (array_key_exists($key, $default_meta) && $default_meta[$key]['url_rewrite'] != '') {
                 $tab['RewriteRule']['content']['^' . $default_meta[$key]['url_rewrite'] . '$'] = $default_meta[$key]['page'] . '.php [QSA,L]';
             }
         }
     }
     if (!($writeFd = @fopen($path, 'w'))) {
         return false;
     }
     // PS Comments
     fwrite($writeFd, "# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution\n");
     fwrite($writeFd, "# WARNING: PLEASE DO NOT MODIFY THIS FILE MANUALLY. IF NECESSARY, ADD YOUR SPECIFIC CONFIGURATION WITH THE HTACCESS GENERATOR IN BACK OFFICE\n");
     fwrite($writeFd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
     if (!empty($specific)) {
         fwrite($writeFd, $specific);
     }
     // RewriteEngine
     fwrite($writeFd, "\n<IfModule mod_rewrite.c>\n");
     if ($disableMuliviews) {
         fwrite($writeFd, "\n# Disable Multiviews\nOptions -Multiviews\n\n");
     }
     fwrite($writeFd, $tab['RewriteEngine']['comment'] . "\nRewriteEngine on\n\n");
     fwrite($writeFd, $tab['RewriteRule']['comment'] . "\n");
     // Webservice
//.........這裏部分代碼省略.........
開發者ID:nicolasjeol,項目名稱:hec-ecommerce,代碼行數:101,代碼來源:Tools14.php

示例3: downloadAndInstallLanguagePack

 public static function downloadAndInstallLanguagePack($iso, $version = null, $params = null, $install = true)
 {
     if (!Validate::isLanguageIsoCode((string) $iso)) {
         return false;
     }
     if ($version == null) {
         $version = _PS_VERSION_;
     }
     $lang_pack = false;
     $lang_pack_ok = false;
     $errors = array();
     $file = _PS_TRANSLATIONS_DIR_ . (string) $iso . '.gzip';
     if (!($lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . $version . '&iso_lang=' . Tools::strtolower((string) $iso)))) {
         $errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.');
     } elseif (!($lang_pack = Tools::jsonDecode($lang_pack_link))) {
         $errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.');
     } elseif (empty($lang_pack->error) && ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/' . $lang_pack->version . '/' . Tools::strtolower($lang_pack->iso_code . '.gzip')))) {
         if (!@file_put_contents($file, $content)) {
             if (is_writable(dirname($file))) {
                 @unlink($file);
                 @file_put_contents($file, $content);
             } elseif (!is_writable($file)) {
                 $errors[] = Tools::displayError('Server does not have permissions for writing.') . ' (' . $file . ')';
             }
         }
     }
     if (!file_exists($file)) {
         $errors[] = Tools::displayError('No language pack is available for your version.');
     } elseif ($install) {
         require_once _PS_TOOL_DIR_ . 'tar/Archive_Tar.php';
         $gz = new Archive_Tar($file, true);
         $files_list = AdminTranslationsController::filterTranslationFiles(Language::getLanguagePackListContent((string) $iso, $gz));
         $files_paths = AdminTranslationsController::filesListToPaths($files_list);
         $i = 0;
         $tmp_array = array();
         foreach ($files_paths as $files_path) {
             $path = dirname($files_path);
             if (is_dir(_PS_TRANSLATIONS_DIR_ . '../' . $path) && !is_writable(_PS_TRANSLATIONS_DIR_ . '../' . $path) && !in_array($path, $tmp_array)) {
                 $errors[] = (!$i++ ? Tools::displayError('The archive cannot be extracted.') . ' ' : '') . Tools::displayError('The server does not have permissions for writing.') . ' ' . sprintf(Tools::displayError('Please check rights for %s'), $path);
                 $tmp_array[] = $path;
             }
         }
         if (defined('_PS_HOST_MODE_')) {
             $mails_files = array();
             $other_files = array();
             foreach ($files_list as $key => $data) {
                 if (substr($data['filename'], 0, 5) == 'mails') {
                     $mails_files[] = $data;
                 } else {
                     $other_files[] = $data;
                 }
             }
             $files_list = $other_files;
         }
         if (!$gz->extractList(AdminTranslationsController::filesListToPaths($files_list), _PS_TRANSLATIONS_DIR_ . '../')) {
             $errors[] = sprintf(Tools::displayError('Cannot decompress the translation file for the following language: %s'), (string) $iso);
         }
         // Clear smarty modules cache
         Tools::clearCache();
         if (!Language::checkAndAddLanguage((string) $iso, $lang_pack, false, $params)) {
             $errors[] = sprintf(Tools::displayError('An error occurred while creating the language: %s'), (string) $iso);
         } else {
             // Reset cache
             Language::loadLanguages();
             AdminTranslationsController::checkAndAddMailsFiles((string) $iso, $files_list);
             AdminTranslationsController::addNewTabs((string) $iso, $files_list);
         }
     }
     return count($errors) ? $errors : true;
 }
開發者ID:ekachandrasetiawan,項目名稱:BeltcareCom,代碼行數:70,代碼來源:Language.php

示例4: getLanguages

 /**
  * Return available languages
  *
  * @param boolean $active Select only active languages
  * @return array Languages
  */
 public static function getLanguages($active = true, $id_shop = false)
 {
     if (!self::$_LANGUAGES) {
         Language::loadLanguages();
     }
     $languages = array();
     foreach (self::$_LANGUAGES as $language) {
         if ($active && !$language['active'] || $id_shop && !isset($language['shops'][(int) $id_shop])) {
             continue;
         }
         $languages[] = $language;
     }
     return $languages;
 }
開發者ID:rrameshsat,項目名稱:Prestashop,代碼行數:20,代碼來源:Language.php

示例5: VALUES

 $sqlParams[] = "INSERT IGNORE INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_SHOP_DOMAIN', '" . Tools::getHttpHost() . "', NOW(), NOW())";
 $sqlParams[] = "INSERT IGNORE INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_SHOP_DOMAIN_SSL', '" . Tools::getHttpHost() . "', NOW(), NOW())";
 $sqlParams[] = "INSERT IGNORE INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_INSTALL_VERSION', '" . pSQL(INSTALL_VERSION) . "', NOW(), NOW())";
 $sqlParams[] = "INSERT IGNORE INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_SHOP_NAME', '" . pSQL($_GET['infosShop']) . "', NOW(), NOW())";
 $sqlParams[] = "INSERT IGNORE INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_SHOP_EMAIL', '" . pSQL($_GET['infosEmail']) . "', NOW(), NOW())";
 $sqlParams[] = "INSERT IGNORE INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_METHOD', '" . pSQL($_GET['infosMailMethod'] == "smtp" ? "2" : "1") . "', NOW(), NOW())";
 $sqlParams[] = 'UPDATE ' . _DB_PREFIX_ . 'configuration SET value = \'' . pSQL($_GET['isoCode']) . '\' WHERE name = \'PS_LOCALE_LANGUAGE\'';
 $sqlParams[] = 'UPDATE ' . _DB_PREFIX_ . 'configuration SET value = \'' . (int) $_GET['catalogMode'] . '\' WHERE name = \'PS_CATALOG_MODE\'';
 $sqlParams[] = "INSERT IGNORE INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_SHOP_ACTIVITY', '" . (int) $_GET['infosActivity'] . "', NOW(), NOW())";
 if ((int) $_GET['infosCountry'] != 0) {
     $sqlParams[] = 'UPDATE ' . _DB_PREFIX_ . 'configuration SET value = ' . (int) $_GET['infosCountry'] . ' WHERE name = \'PS_COUNTRY_DEFAULT\'';
     $sqlParams[] = 'UPDATE ' . _DB_PREFIX_ . 'configuration SET value = "' . pSQL($_GET['infosTimezone']) . '" WHERE name = \'PS_TIMEZONE\'';
     $sql_isocode = Db::getInstance()->getValue('SELECT `iso_code` FROM `' . _DB_PREFIX_ . 'country` WHERE `id_country` = ' . (int) $_GET['infosCountry']);
     $sqlParams[] = 'UPDATE ' . _DB_PREFIX_ . 'configuration SET value = \'' . pSQL($sql_isocode) . '\' WHERE name = \'PS_LOCALE_COUNTRY\'';
 }
 Language::loadLanguages();
 Configuration::loadConfiguration();
 require_once dirname(__FILE__) . '/../../config/defines.inc.php';
 require_once dirname(__FILE__) . '/../../classes/LocalizationPack.php';
 $context = stream_context_create(array('http' => array('timeout' => 5)));
 $localization_file = @Tools::file_get_contents('http://www.prestashop.com/download/localization_pack.php?country=' . $_GET['countryName'], false, $context);
 if (!$localization_file and file_exists(dirname(__FILE__) . '/../../localization/' . strtolower($_GET['countryName']) . '.xml')) {
     $localization_file = @file_get_contents(dirname(__FILE__) . '/../../localization/' . strtolower($_GET['countryName']) . '.xml');
 }
 if ($localization_file) {
     $localizationPack = new LocalizationPackCore();
     $localizationPack->loadLocalisationPack($localization_file, '', true);
     if (Configuration::get('PS_LANG_DEFAULT') == 1) {
         $sqlParams[] = 'UPDATE `' . _DB_PREFIX_ . 'configuration` SET `value` = (SELECT id_lang FROM ' . _DB_PREFIX_ . 'lang WHERE iso_code = \'' . pSQL($_GET['isoCode']) . '\') WHERE name = \'PS_LANG_DEFAULT\'';
         // This request is used when _PS_MODE_DEV_ is set to true
         $sqlParams[] = 'UPDATE `' . _DB_PREFIX_ . 'lang` SET `active` = 0 WHERE `iso_code` != \'' . pSQL($_GET['isoCode']) . '\'';
開發者ID:priyankajsr19,項目名稱:indusdiva2,代碼行數:31,代碼來源:checkShopInfos.php

示例6: submitAddLang

 public function submitAddLang()
 {
     $arr_import_lang = explode('|', Tools::getValue('params_import_language'));
     /* 0 = Language ISO code, 1 = PS version */
     if (Validate::isLangIsoCode($arr_import_lang[0])) {
         $array_stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 10)));
         $content = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/gzip/' . $arr_import_lang[1] . '/' . Tools::strtolower($arr_import_lang[0]) . '.gzip', false, $array_stream_context);
         if ($content) {
             $file = _PS_TRANSLATIONS_DIR_ . $arr_import_lang[0] . '.gzip';
             if ((bool) @file_put_contents($file, $content)) {
                 require_once _PS_TOOL_DIR_ . '/tar/Archive_Tar.php';
                 $gz = new Archive_Tar($file, true);
                 $files_list = AdminTranslationsController::filterTranslationFiles($gz->listContent());
                 if ($error = $gz->extractList(AdminTranslationsController::filesListToPaths($files_list), _PS_TRANSLATIONS_DIR_ . '../')) {
                     if (is_object($error) && !empty($error->message)) {
                         $this->errors[] = Tools::displayError('The archive cannot be extracted.') . ' ' . $error->message;
                     } else {
                         if (!Language::checkAndAddLanguage($arr_import_lang[0])) {
                             $conf = 20;
                         } else {
                             // Reset cache
                             Language::loadLanguages();
                             // Clear smarty modules cache
                             Tools::clearCache();
                             AdminTranslationsController::checkAndAddMailsFiles($arr_import_lang[0], $files_list);
                             if ($tab_errors = AdminTranslationsController::addNewTabs($arr_import_lang[0], $files_list)) {
                                 $this->errors += $tab_errors;
                             }
                         }
                         if (!unlink($file)) {
                             $this->errors[] = sprintf(Tools::displayError('Cannot delete the archive %s.'), $file);
                         }
                         $this->redirect(false, isset($conf) ? $conf : '15');
                     }
                 } elseif (!unlink($file)) {
                     $this->errors[] = sprintf(Tools::displayError('Cannot delete the archive %s.'), $file);
                 }
             } else {
                 $this->errors[] = Tools::displayError('The server does not have permissions for writing.') . ' ' . sprintf(Tools::displayError('Please check rights for %s'), dirname($file));
             }
         } else {
             $this->errors[] = Tools::displayError('Language not found.');
         }
     } else {
         $this->errors[] = Tools::displayError('Invalid parameter');
     }
 }
開發者ID:dev-lav,項目名稱:htdocs,代碼行數:47,代碼來源:AdminTranslationsController.php

示例7: installLanguages

 /**
  * Install languages
  *
  * @return array Association between ID and iso array(id_lang => iso, ...)
  */
 public function installLanguages($languages_list = null)
 {
     if ($languages_list == null || !is_array($languages_list) || !count($languages_list)) {
         $languages_list = $this->language->getIsoList();
     }
     $languages_available = $this->language->getIsoList();
     $languages = array();
     foreach ($languages_list as $iso) {
         if (!in_array($iso, $languages_available)) {
             continue;
         }
         if (!file_exists(_PS_INSTALL_LANGS_PATH_ . $iso . '/language.xml')) {
             throw new PrestashopInstallerException($this->language->l('File "language.xml" not found for language iso "%s"', $iso));
         }
         if (!($xml = @simplexml_load_file(_PS_INSTALL_LANGS_PATH_ . $iso . '/language.xml'))) {
             throw new PrestashopInstallerException($this->language->l('File "language.xml" not valid for language iso "%s"', $iso));
         }
         $params_lang = array('name' => (string) $xml->name, 'iso_code' => substr((string) $xml->language_code, 0, 2), 'allow_accented_chars_url' => (string) $xml->allow_accented_chars_url);
         if (InstallSession::getInstance()->safe_mode) {
             Language::checkAndAddLanguage($iso, false, true, $params_lang);
         } else {
             Language::downloadAndInstallLanguagePack($iso, _PS_INSTALL_VERSION_, $params_lang);
         }
         Language::loadLanguages();
         Tools::clearCache();
         if (!($id_lang = Language::getIdByIso($iso))) {
             throw new PrestashopInstallerException($this->language->l('Cannot install language "%s"', $xml->name ? $xml->name : $iso));
         }
         $languages[$id_lang] = $iso;
         // Copy language flag
         if (is_writable(_PS_IMG_DIR_ . 'l/')) {
             if (!copy(_PS_INSTALL_LANGS_PATH_ . $iso . '/flag.jpg', _PS_IMG_DIR_ . 'l/' . $id_lang . '.jpg')) {
                 throw new PrestashopInstallerException($this->language->l('Cannot copy flag language "%s"', _PS_INSTALL_LANGS_PATH_ . $iso . '/flag.jpg => ' . _PS_IMG_DIR_ . 'l/' . $id_lang . '.jpg'));
             }
         }
     }
     return $languages;
 }
開發者ID:Sosiashvili,項目名稱:docker-prestashop,代碼行數:43,代碼來源:install.php

示例8: installLanguagePack

 public static function installLanguagePack($iso, $params, &$errors = array())
 {
     $file = _PS_TRANSLATIONS_DIR_ . (string) $iso . '.gzip';
     $gz = new \Archive_Tar($file, true);
     $files_list = AdminTranslationsController::filterTranslationFiles(Language::getLanguagePackListContent((string) $iso, $gz));
     $files_paths = AdminTranslationsController::filesListToPaths($files_list);
     $tmp_array = array();
     foreach ($files_paths as $files_path) {
         $path = dirname($files_path);
         if (is_dir(_PS_TRANSLATIONS_DIR_ . '../' . $path) && !is_writable(_PS_TRANSLATIONS_DIR_ . '../' . $path) && !in_array($path, $tmp_array)) {
             $error = Tools::displayError('The server does not have permissions for writing.') . ' ' . sprintf(Tools::displayError('Please check permissions for %s'), $path);
             $errors[] = count($tmp_array) == 0 ? Tools::displayError('The archive cannot be extracted.') . ' ' . $error : $error;
             $tmp_array[] = $path;
         }
     }
     if (defined('_PS_HOST_MODE_')) {
         $mails_files = array();
         $other_files = array();
         foreach ($files_list as $key => $data) {
             if (substr($data['filename'], 0, 5) == 'mails') {
                 $mails_files[] = $data;
             }
         }
         $files_list = array_diff($files_list, $mails_files);
     }
     if (!$gz->extractList(AdminTranslationsController::filesListToPaths($files_list), _PS_TRANSLATIONS_DIR_ . '../')) {
         $errors[] = sprintf(Tools::displayError('Cannot decompress the translation file for the following language: %s'), (string) $iso);
     }
     // Clear smarty modules cache
     Tools::clearCache();
     if (!Language::checkAndAddLanguage((string) $iso, false, false, $params)) {
         $errors[] = sprintf(Tools::displayError('An error occurred while creating the language: %s'), (string) $iso);
     } else {
         // Reset cache
         Language::loadLanguages();
         AdminTranslationsController::checkAndAddMailsFiles((string) $iso, $files_list);
         AdminTranslationsController::addNewTabs((string) $iso, $files_list);
     }
     self::installSfLanguagePack(self::getLocaleByIso($iso), $errors);
     return count($errors) ? $errors : true;
 }
開發者ID:M03G,項目名稱:PrestaShop,代碼行數:41,代碼來源:Language.php

示例9: submitAddLang

 public function submitAddLang()
 {
     $arr_import_lang = explode('|', Tools::getValue('params_import_language'));
     /* 0 = Language ISO code, 1 = PS version */
     if (Validate::isLangIsoCode($arr_import_lang[0])) {
         $array_stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 10)));
         $content = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/gzip/' . $arr_import_lang[1] . '/' . Tools::strtolower($arr_import_lang[0]) . '.gzip', false, $array_stream_context);
         if ($content) {
             $file = _PS_TRANSLATIONS_DIR_ . $arr_import_lang[0] . '.gzip';
             if ((bool) @file_put_contents($file, $content)) {
                 $gz = new \Archive_Tar($file, true);
                 if (_PS_MODE_DEV_) {
                     $gz->setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_WARNING);
                 }
                 $files_list = AdminTranslationsController::filterTranslationFiles($gz->listContent());
                 if ($error = $gz->extractList(AdminTranslationsController::filesListToPaths($files_list), _PS_TRANSLATIONS_DIR_ . '../')) {
                     if (is_object($error) && !empty($error->message)) {
                         $this->errors[] = $this->trans('The archive cannot be extracted.', array(), 'Admin.International.Notification') . ' ' . $error->message;
                     } else {
                         if (!Language::checkAndAddLanguage($arr_import_lang[0])) {
                             $conf = 20;
                         } else {
                             // Reset cache
                             Language::loadLanguages();
                             // Clear smarty modules cache
                             Tools::clearCache();
                             AdminTranslationsController::checkAndAddMailsFiles($arr_import_lang[0], $files_list);
                             if ($tab_errors = AdminTranslationsController::addNewTabs($arr_import_lang[0], $files_list)) {
                                 $this->errors += $tab_errors;
                             }
                         }
                         if (!unlink($file)) {
                             $this->errors[] = sprintf($this->trans('Cannot delete the archive %s.', array(), 'Admin.International.Notification'), $file);
                         }
                         //fetch cldr datas for the new imported locale
                         $languageCode = explode('-', Language::getLanguageCodeByIso($arr_import_lang[0]));
                         $cldrUpdate = new Update(_PS_TRANSLATIONS_DIR_);
                         $cldrUpdate->fetchLocale($languageCode[0] . '-' . Tools::strtoupper($languageCode[1]));
                         $this->redirect(false, isset($conf) ? $conf : '15');
                     }
                 } else {
                     $this->errors[] = sprintf($this->trans('Cannot decompress the translation file for the following language: %s', array(), 'Admin.International.Notification'), $arr_import_lang[0]);
                     $checks = array();
                     foreach ($files_list as $f) {
                         if (isset($f['filename'])) {
                             if (is_file(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $f['filename']) && !is_writable(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $f['filename'])) {
                                 $checks[] = dirname($f['filename']);
                             } elseif (is_dir(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $f['filename']) && !is_writable(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . dirname($f['filename']))) {
                                 $checks[] = dirname($f['filename']);
                             }
                         }
                     }
                     $checks = array_unique($checks);
                     foreach ($checks as $check) {
                         $this->errors[] = sprintf($this->trans('Please check rights for folder and files in %s', array(), 'Admin.Notifications.Error'), $check);
                     }
                     if (!unlink($file)) {
                         $this->errors[] = sprintf($this->trans('Cannot delete the archive %s.', array(), 'Admin.International.Notification'), $file);
                     }
                 }
             } else {
                 $this->errors[] = $this->trans('The server does not have permissions for writing.', array(), 'Admin.Notifications.Error') . ' ' . sprintf($this->trans('Please check rights for %s', array(), 'Admin.Notifications.Error'), dirname($file));
             }
         } else {
             $this->errors[] = $this->trans('Language not found.', array(), 'Admin.International.Notification');
         }
     } else {
         $this->errors[] = $this->trans('Invalid parameter.', array(), 'Admin.Notifications.Error');
     }
 }
開發者ID:M03G,項目名稱:PrestaShop,代碼行數:70,代碼來源:AdminTranslationsController.php

示例10: doUpgrade


//.........這裏部分代碼省略.........
                        if (file_exists($dir . $cache)) {
                            unlink($file . $cache);
                        }
                    }
                }
            }
        }
        // Upgrade languages
        if (!defined('_PS_TOOL_DIR_')) {
            define('_PS_TOOL_DIR_', _PS_ROOT_DIR_ . '/tools/');
        }
        if (!defined('_PS_TRANSLATIONS_DIR_')) {
            define('_PS_TRANSLATIONS_DIR_', _PS_ROOT_DIR_ . '/translations/');
        }
        if (!defined('_PS_MODULES_DIR_')) {
            define('_PS_MODULES_DIR_', _PS_ROOT_DIR_ . '/modules/');
        }
        if (!defined('_PS_MAILS_DIR_')) {
            define('_PS_MAILS_DIR_', _PS_ROOT_DIR_ . '/mails/');
        }
        $langs = $this->db->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'lang` WHERE `active` = 1');
        if (is_array($langs)) {
            foreach ($langs as $lang) {
                $isoCode = $lang['iso_code'];
                if (Validate::isLangIsoCode($isoCode)) {
                    $errorsLanguage = array();
                    Language::downloadLanguagePack($isoCode, _PS_VERSION_, $errorsLanguage);
                    $lang_pack = Language::getLangDetails($isoCode);
                    Language::installSfLanguagePack($lang_pack['locale'], $errorsLanguage);
                    if (!$this->keepMails) {
                        Language::installEmailsLanguagePack($lang_pack, $errorsLanguage);
                    }
                    if (empty($errorsLanguage)) {
                        Language::loadLanguages();
                        // TODO: Update AdminTranslationsController::addNewTabs to install tabs translated
                        $cldrUpdate = new \PrestaShop\PrestaShop\Core\Cldr\Update(_PS_TRANSLATIONS_DIR_);
                        $cldrUpdate->fetchLocale(Language::getLocaleByIso($isoCode));
                    } else {
                        $this->nextErrors[] = $this->l('Error updating translations');
                        $this->nextQuickInfo[] = $this->l('Error updating translations');
                        $this->next_desc = $this->l('Error updating translations');
                        return false;
                    }
                }
            }
        }
        require_once _PS_ROOT_DIR_ . '/src/Core/Foundation/Database/EntityInterface.php';
        if (file_exists(_PS_ROOT_DIR_ . '/classes/Tools.php')) {
            require_once _PS_ROOT_DIR_ . '/classes/Tools.php';
        }
        if (!class_exists('Tools2', false) and class_exists('ToolsCore')) {
            eval('class Tools2 extends ToolsCore{}');
        }
        if (class_exists('Tools2') && method_exists('Tools2', 'generateHtaccess')) {
            $url_rewrite = (bool) $this->db->getvalue('SELECT `value` FROM `' . _DB_PREFIX_ . 'configuration` WHERE name=\'PS_REWRITING_SETTINGS\'');
            if (!defined('_MEDIA_SERVER_1_')) {
                define('_MEDIA_SERVER_1_', '');
            }
            if (!defined('_PS_USE_SQL_SLAVE_')) {
                define('_PS_USE_SQL_SLAVE_', false);
            }
            if (file_exists(_PS_ROOT_DIR_ . '/classes/ObjectModel.php')) {
                require_once _PS_ROOT_DIR_ . '/classes/ObjectModel.php';
            }
            if (!class_exists('ObjectModel', false) and class_exists('ObjectModelCore')) {
                eval('abstract class ObjectModel extends ObjectModelCore{}');
開發者ID:prestashop,項目名稱:autoupgrade,代碼行數:67,代碼來源:AdminSelfUpgrade.php

示例11: downloadAndInstallLanguagePack

 public static function downloadAndInstallLanguagePack($iso, $version = null, $params = null)
 {
     require_once _PS_TOOL_DIR_ . 'tar/Archive_Tar.php';
     if (!Validate::isLanguageIsoCode($iso)) {
         return false;
     }
     if ($version == null) {
         $version = _PS_VERSION_;
     }
     $lang_pack = false;
     $lang_pack_ok = false;
     $errors = array();
     $file = _PS_TRANSLATIONS_DIR_ . $iso . '.gzip';
     if (!($lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . $version . '&iso_lang=' . $iso))) {
         $errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.');
     } elseif (!($lang_pack = Tools::jsonDecode($lang_pack_link))) {
         $errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.');
     } elseif ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/' . $lang_pack->version . '/' . $lang_pack->iso_code . '.gzip')) {
         if (!@file_put_contents($file, $content)) {
             $errors[] = Tools::displayError('Server does not have permissions for writing.');
         }
     }
     if (file_exists($file)) {
         $gz = new Archive_Tar($file, true);
         $files_list = $gz->listContent();
         if (!$gz->extract(_PS_TRANSLATIONS_DIR_ . '../', false)) {
             $errors[] = Tools::displayError('Cannot decompress the translation file for the following language: ') . (string) $iso;
         }
         if (!Language::checkAndAddLanguage((string) $iso, $lang_pack, false, $params)) {
             $errors[] = Tools::displayError('An error occurred while creating the language: ') . (string) $iso;
         } else {
             // Reset cache
             Language::loadLanguages();
             AdminTranslationsController::checkAndAddMailsFiles($iso, $files_list);
             AdminTranslationsController::addNewTabs($iso, $files_list);
         }
         @unlink($file);
     } else {
         $errors[] = Tools::displayError('No language pack is available for your version.');
     }
     return count($errors) ? $errors : true;
 }
開發者ID:FAVHYAN,項目名稱:a3workout,代碼行數:42,代碼來源:Language.php


注:本文中的Language::loadLanguages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。