本文整理汇总了PHP中Language::isMultiLanguageActivated方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::isMultiLanguageActivated方法的具体用法?PHP Language::isMultiLanguageActivated怎么用?PHP Language::isMultiLanguageActivated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::isMultiLanguageActivated方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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']);
}
}
}
示例2: GetSmartBlogUrl
public static function GetSmartBlogUrl()
{
$ssl_enable = Configuration::get('PS_SSL_ENABLED');
$id_lang = (int) Context::getContext()->language->id;
$id_shop = (int) Context::getContext()->shop->id;
$rewrite_set = (int) Configuration::get('PS_REWRITING_SETTINGS');
$ssl = null;
static $force_ssl = null;
if ($ssl === null) {
if ($force_ssl === null) {
$force_ssl = Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE');
}
$ssl = $force_ssl;
}
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && $id_shop !== null) {
$shop = new Shop($id_shop);
} else {
$shop = Context::getContext()->shop;
}
$base = $ssl == 1 && $ssl_enable == 1 ? 'https://' . $shop->domain_ssl : 'http://' . $shop->domain;
$langUrl = Language::getIsoById($id_lang) . '/';
if (!$rewrite_set && in_array($id_shop, array((int) Context::getContext()->shop->id, null)) || !Language::isMultiLanguageActivated($id_shop) || !(int) Configuration::get('PS_REWRITING_SETTINGS', null, null, $id_shop)) {
$langUrl = '';
}
return $base . $shop->getBaseURI() . $langUrl;
}
示例3: _getMetaLink
/**
* Hydrate $link_sitemap with meta link
*
* @param array $link_sitemap contain all the links for the Google Sitemap file to be generated
* @param string $lang language of link to add
* @param int $index index of the current Google Sitemap file
* @param int $i count of elements added to sitemap main array
* @param int $id_meta meta object identifier
*
* @return bool
*/
private function _getMetaLink(&$link_sitemap, $lang, &$index, &$i, $id_meta = 0)
{
if (method_exists('ShopUrl', 'resetMainDomainCache')) {
ShopUrl::resetMainDomainCache();
}
$link = new Link();
$metas = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'meta` WHERE `id_meta` > ' . (int) $id_meta . ' ORDER BY `id_meta` ASC');
foreach ($metas as $meta) {
$url = '';
if (!in_array($meta['id_meta'], explode(',', Configuration::get('GSITEMAP_DISABLE_LINKS')))) {
if (_PS_VERSION_ >= 1.5) {
$url_rewrite = Db::getInstance()->getValue('SELECT url_rewrite, id_shop FROM `' . _DB_PREFIX_ . 'meta_lang` WHERE `id_meta` = ' . (int) $meta['id_meta'] . ' AND `id_shop` =' . (int) $this->context->shop->id . ' AND `id_lang` = ' . (int) $lang['id_lang']);
Dispatcher::getInstance()->addRoute($meta['page'], isset($url_rewrite) ? $url_rewrite : $meta['page'], $meta['page'], $lang['id_lang']);
$uri_path = Dispatcher::getInstance()->createUrl($meta['page'], $lang['id_lang'], array(), (bool) Configuration::get('PS_REWRITING_SETTINGS'));
$url .= Tools::getShopDomain(true) . ($this->context->shop->virtual_uri ? __PS_BASE_URI__ . $this->context->shop->virtual_uri : __PS_BASE_URI__) . (Language::isMultiLanguageActivated() ? $lang['iso_code'] . '/' : '') . ltrim($uri_path, '/');
} else {
$url = $link->getPageLink($meta['page'] . '.php', true, $lang['id_lang']);
}
if (!$this->_addLinkToSitemap($link_sitemap, array('type' => 'meta', 'page' => $meta['page'], 'link' => $url, 'image' => false), $lang['iso_code'], $index, $i, $meta['id_meta'])) {
return false;
}
}
}
return true;
}
示例4: getLangLink
protected function getLangLink($id_lang = null, Context $context = null, $id_shop = null)
{
if (!$context) {
$context = Context::getContext();
}
if (!$this->allow && in_array($id_shop, array($context->shop->id, null)) || !Language::isMultiLanguageActivated($id_shop) || !(int) Configuration::get('PS_REWRITING_SETTINGS', null, null, $id_shop)) {
return '';
}
if (!$id_lang) {
$id_lang = $context->language->id;
}
return Language::getIsoById($id_lang) . '/';
}
示例5: getCacheId
protected function getCacheId($name = null)
{
$cache_array = array();
$cache_array[] = $name !== null ? $name : $this->name;
if (Configuration::get('PS_SSL_ENABLED')) {
$cache_array[] = (int) Tools::usingSecureMode();
}
if (Shop::isFeatureActive()) {
$cache_array[] = (int) $this->context->shop->id;
}
$cache_array[] = (int) Group::getCurrent()->id;
if (Language::isMultiLanguageActivated()) {
$cache_array[] = (int) $this->context->language->id;
}
if (Currency::isMultiCurrencyActivated()) {
$cache_array[] = (int) $this->context->currency->id;
}
$cache_array[] = (int) $this->context->country->id;
return implode('|', $cache_array);
}
示例6: setRequestUri
/**
* Set request uri and iso lang
*/
protected function setRequestUri()
{
// Get request uri (HTTP_X_REWRITE_URL is used by IIS)
if (isset($_SERVER['REQUEST_URI'])) {
$this->request_uri = $_SERVER['REQUEST_URI'];
} elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
$this->request_uri = $_SERVER['HTTP_X_REWRITE_URL'];
}
$this->request_uri = rawurldecode($this->request_uri);
if (isset(Context::getContext()->shop) && is_object(Context::getContext()->shop)) {
$this->request_uri = preg_replace('#^' . preg_quote(Context::getContext()->shop->getBaseURI(), '#') . '#i', '/', $this->request_uri);
}
// If there are several languages, get language from uri
if ($this->use_routes && Language::isMultiLanguageActivated()) {
if (preg_match('#^/([a-z]{2})(?:/.*)?$#', $this->request_uri, $m)) {
$_GET['isolang'] = $m[1];
$this->request_uri = substr($this->request_uri, 3);
}
}
}
示例7: getLangLink
protected function getLangLink($id_lang = null, Context $context = null)
{
if (!$context) {
$context = Context::getContext();
}
if (!$this->allow || !Language::isMultiLanguageActivated()) {
return '';
}
if (!$id_lang) {
$id_lang = $context->language->id;
}
return Language::getIsoById($id_lang) . '/';
}
示例8: hookHeader
public function hookHeader($params)
{
// Better way to check which file / controller name is loaded
if (!($file = basename(Tools::getValue('controller')))) {
$file = str_replace(array('.php', '-'), '', basename($_SERVER['SCRIPT_NAME']));
}
// Otherwise, create Google Analytics stats
$ganalytics_id = Configuration::get('GANALYTICS_ID');
$multilang = method_exists('Language', 'isMultiLanguageActivated') ? Language::isMultiLanguageActivated() : Language::countActiveLanguages() > 1;
$defaultMetaOrder = Meta::getMetaByPage('order', $this->context->language->id);
$order = ($multilang ? (string) Tools::getValue('isolang') . '/' : '') . $defaultMetaOrder['url_rewrite'];
$pageTrack = preg_match('#(^' . __PS_BASE_URI__ . 'order.php)|(^' . __PS_BASE_URI__ . ($multilang ? (string) Tools::getValue('isolang') . '/' : '') . $defaultMetaOrder['url_rewrite'] . '[^-])#', $_SERVER['REQUEST_URI']) ? '/order/step' . (int) Tools::getValue('step') . '.html' : $file;
$this->context->smarty->assign('ganalytics_id', $ganalytics_id);
$this->context->smarty->assign('pageTrack', $pageTrack);
$this->context->smarty->assign('isOrder', false);
return $this->display(__FILE__, 'header.tpl');
}
示例9: getCacheId
/**
* use this code
* Configuration::updateValue('LEO_CURRENT_RANDOM_CACHE', '1');
* where you want to have RANDOM cache
*/
protected function getCacheId($name = null)
{
$cache_array = array();
$cache_array[] = $name !== null ? $name : $this->name;
if (isset($this->cache_param) && $this->cache_param) {
if (isset($this->cache_param['controller']) && $this->cache_param['controller']) {
$cache_array[] = $this->cache_param['controller'];
}
if (isset($this->cache_param['id']) && $this->cache_param['id']) {
$cache_array[] = $this->cache_param['id'];
}
if (isset($this->cache_param['hook']) && $this->cache_param['hook']) {
$cache_array[] = $this->cache_param['hook'];
}
// save to next time
if (Configuration::get('LEO_CURRENT_RANDOM_CACHE') == 1) {
$random_cache = Configuration::get('LEO_RANDOM_CACHE');
if (!$random_cache) {
# validate module
$random_cache = new stdClass();
} else {
# validate module
$random_cache = Tools::jsonDecode($random_cache);
}
$key = implode('|', $cache_array);
$random_cache->{$key} = date('Ymd');
$leo_random_cache = Tools::jsonEncode($random_cache);
Configuration::updateValue('LEO_RANDOM_CACHE', $leo_random_cache);
}
// Check RANDOM PRODUCT
if ($random_cache = Configuration::get('LEO_RANDOM_CACHE')) {
$key = implode('|', $cache_array);
$value = date('Ymd');
$random_cache = Tools::jsonDecode($random_cache);
if (isset($random_cache->{$key}) && $random_cache->{$key} == $value) {
// cache in one day
$random = date('Ymd') . '_' . rand(1, LeomanagewidgetsHelper::NUMBER_CACHE_FILE);
$cache_array[] = 'random_' . $random;
}
}
}
if (Configuration::get('PS_SSL_ENABLED')) {
$cache_array[] = (int) Tools::usingSecureMode();
}
if (Shop::isFeatureActive()) {
$cache_array[] = (int) $this->context->shop->id;
}
if (Group::isFeatureActive()) {
$cache_array[] = (int) Group::getCurrent()->id;
}
if (Language::isMultiLanguageActivated()) {
$cache_array[] = (int) $this->context->language->id;
}
if (Currency::isMultiCurrencyActivated()) {
$cache_array[] = (int) $this->context->currency->id;
}
$cache_array[] = (int) $this->context->country->id;
return implode('|', $cache_array);
}
示例10: myRealURL
public static function myRealURL()
{
$force_ssl = null;
$allow = (int) Configuration::get('PS_REWRITING_SETTINGS');
$ssl_enable = Configuration::get('PS_SSL_ENABLED');
$context = Context::getContext();
$id_lang = $context->language->id;
$id_shop = $context->shop->id;
if (!defined('_PS_BASE_URL_')) {
define('_PS_BASE_URL_', Tools::getShopDomain(true));
}
if (!defined('_PS_BASE_URL_SSL_')) {
define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true));
}
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && $id_shop !== null) {
$shop = new Shop($id_shop);
} else {
$shop = Context::getContext()->shop;
}
if (isset($ssl) && $ssl === null) {
if ($force_ssl === null) {
$force_ssl = Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE');
}
$ssl = $force_ssl;
}
$base = isset($ssl) && $ssl && $this->ssl_enable ? 'https://' . $shop->domain_ssl : 'http://' . $shop->domain;
$langUrl = Language::getIsoById($id_lang) . '/';
if (!$allow && in_array($id_shop, array($context->shop->id, null)) || !Language::isMultiLanguageActivated($id_shop) || !(int) Configuration::get('PS_REWRITING_SETTINGS', null, null, $id_shop)) {
$langUrl = '';
}
return $base . $shop->getBaseURI() . $langUrl;
}
示例11: hookHeader
function hookHeader($params)
{
if (method_exists('Language', 'isMultiLanguageActivated') && Language::isMultiLanguageActivated() || Language::countActiveLanguages() > 1) {
$multilang = (string) Tools::getValue('isolang') . '/';
} else {
$multilang = '';
}
$defaultMetaOrder = Meta::getMetaByPage('order', $this->context->language->id);
if (strpos($_SERVER['REQUEST_URI'], __PS_BASE_URI__ . 'order.php') === 0 || strpos($_SERVER['REQUEST_URI'], __PS_BASE_URI__ . $multilang . $defaultMetaOrder['url_rewrite']) === 0) {
$this->context->smarty->assign('pageTrack', '/order/step' . (int) Tools::getValue('step') . '.html');
}
$this->context->smarty->assign('ganalytics_id', Configuration::get('GANALYTICS_ID'));
$this->context->smarty->assign('isOrder', false);
return $this->display(__FILE__, 'header.tpl');
}
示例12: getProductLink
public static function getProductLink($product, $id_shop = null, $context = false, $id_lang = false)
{
if (!$context) {
$context = Context::getContext();
}
$dispatcher = Dispatcher::getInstance();
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && $id_shop !== null) {
$shop = new Shop($id_shop);
} else {
$shop = $context->shop;
}
$force_routes = (bool) Configuration::get('PS_REWRITING_SETTINGS');
$base = 'http://' . $shop->domain . $shop->getBaseURI();
if (!$force_routes && in_array($id_shop, array($context->shop->id, null)) || !Language::isMultiLanguageActivated($id_shop) || !(int) Configuration::get('PS_REWRITING_SETTINGS', null, null, $id_shop)) {
$base .= '';
} else {
$base .= self::$_exportLanguageObj->iso_code . '/';
}
//$base.= self::$_exportLanguageObj->iso_code . '/';
$params = array();
$params['id'] = $product['id_product'];
$params['rewrite'] = $product['link_rewrite'];
$params['ean13'] = $product['ean13'];
$params['category'] = Category::getLinkRewrite((int) $product['id_category_default'], (int) $id_lang);
//Tools::str2url($product['categories'][$product['id_category_default']]);
return $base . $dispatcher->createUrl('product_rule', self::$_exportLanguageObj->id, $params, $force_routes, '', $id_shop);
}
示例13: hookHeader
function hookHeader($params)
{
// Better way to check which file / controller name is loaded
if (!($file = basename(Tools::getValue('controller')))) {
$file = str_replace(array('.php', '-'), '', basename($_SERVER['SCRIPT_NAME']));
}
#PNM-30 - Order confirmation wasn't tracked
// If other controller / file name need to be done, add it to the array
// if (in_array(v, array('orderconfirmation')))
// return '';
// Otherwise, create Google Analytics stats
$ganalytics_id = Configuration::get('GANALYTICS_ID');
$multilang = method_exists('Language', 'isMultiLanguageActivated') ? Language::isMultiLanguageActivated() : Language::countActiveLanguages() > 1;
$defaultMetaOrder = Meta::getMetaByPage('order', $this->context->language->id);
$order = ($multilang ? (string) Tools::getValue('isolang') . '/' : '') . $defaultMetaOrder['url_rewrite'];
$pageTrack = strpos($_SERVER['REQUEST_URI'], __PS_BASE_URI__ . 'order.php') === 0 || strpos($_SERVER['REQUEST_URI'], __PS_BASE_URI__ . ($multilang ? (string) Tools::getValue('isolang') . '/' : '') . $defaultMetaOrder['url_rewrite']) === 0 ? '/order/step' . (int) Tools::getValue('step') . '.html' : $file;
$this->context->smarty->assign('ganalytics_id', $ganalytics_id);
$this->context->smarty->assign('pageTrack', $pageTrack);
$this->context->smarty->assign('isOrder', false);
return $this->display(__FILE__, 'header.tpl');
}