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


PHP Lang::getActiveLangs方法代码示例

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


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

示例1: actionIndex

 public function actionIndex()
 {
     $page = Menu::model()->findByPk(InfoPages::MAIN_PAGE_ID);
     $langs = Lang::getActiveLangs();
     $countLangs = count($langs);
     if (!isFree() && !isset($_GET['lang']) && ($countLangs > 1 || $countLangs == 1 && param('useLangPrefixIfOneLang'))) {
         $canonicalUrl = Yii::app()->getBaseUrl(true);
         $canonicalUrl .= '/' . Yii::app()->language;
         Yii::app()->clientScript->registerLinkTag('canonical', null, $canonicalUrl);
     }
     Yii::app()->user->setState('searchUrl', NULL);
     $criteriaNews = new CDbCriteria();
     $criteriaNews->limit = 10;
     $criteriaNews->order = 'date_created DESC';
     $newsIndex = News::model()->findAll($criteriaNews);
     if (isset($_GET['is_ajax'])) {
         //			$modeListShow = User::getModeListShow();
         //			if ($modeListShow == 'table') {
         //				# нужны скрипты и стили, поэтому processOutput установлен в true только для table
         //				$this->renderPartial('index', array('page' => $page, 'newsIndex' => $newsIndex), false, true);
         //			}
         //			else {
         $this->renderPartial('index', array('page' => $page, 'newsIndex' => $newsIndex));
         //			}
     } else {
         $this->render('index', array('page' => $page, 'newsIndex' => $newsIndex));
     }
 }
开发者ID:alexjkitty,项目名称:estate,代码行数:28,代码来源:SiteController.php

示例2: actionIndex

 public function actionIndex()
 {
     $this->checkCookieEnabled();
     $this->htmlPageId = 'index';
     $page = Menu::model()->findByPk(InfoPages::MAIN_PAGE_ID);
     if (issetModule('seo')) {
         $seo = SeoFriendlyUrl::model()->findByAttributes(array('model_name' => 'InfoPages', 'model_id' => InfoPages::MAIN_PAGE_ID));
         if ($seo) {
             $this->setSeo($seo);
         }
     }
     $langs = Lang::getActiveLangs();
     $countLangs = count($langs);
     if (!isFree() && !isset($_GET['lang']) && ($countLangs > 1 || $countLangs == 1 && param('useLangPrefixIfOneLang'))) {
         $canonicalUrl = Yii::app()->getBaseUrl(true);
         $canonicalUrl .= '/' . Yii::app()->language;
         Yii::app()->clientScript->registerLinkTag('canonical', null, $canonicalUrl);
     }
     Yii::app()->user->setState('searchUrl', NULL);
     $lastNews = News::getLastNews();
     if (Yii::app()->request->isAjaxRequest) {
         //			$modeListShow = User::getModeListShow();
         //			if ($modeListShow == 'table') {
         //				# нужны скрипты и стили, поэтому processOutput установлен в true только для table
         //				$this->renderPartial('index', array('page' => $page, 'newsIndex' => $lastNews), false, true);
         //			}
         //			else {
         $this->renderPartial('index', array('page' => $page, 'newsIndex' => $lastNews));
         //			}
     } else {
         $this->render('index', array('page' => $page, 'newsIndex' => $lastNews));
     }
 }
开发者ID:barricade86,项目名称:raui,代码行数:33,代码来源:SiteController.php

示例3: afterSave

 public function afterSave()
 {
     $langs = Lang::getActiveLangs();
     foreach ($langs as $lang) {
         Yii::app()->cache->delete(DbMessageSource::CACHE_KEY_PREFIX . '.messages.' . $this->category . '.' . $lang);
     }
     return parent::afterSave();
 }
开发者ID:barricade86,项目名称:raui,代码行数:8,代码来源:TranslateMessage.php

示例4: createUrl

 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     if ($route != 'min/serve' && $route != 'site/uploadimage') {
         $langs = Lang::getActiveLangs();
         $countLangs = count($langs);
         if (!isFree() && empty($params['lang']) && ($countLangs > 1 || $countLangs == 1 && param('useLangPrefixIfOneLang'))) {
             $params['lang'] = Yii::app()->language;
         }
     }
     return parent::createUrl($route, $params, $ampersand);
 }
开发者ID:alexjkitty,项目名称:estate,代码行数:11,代码来源:CustomUrlManager.php

示例5: init

 public function init()
 {
     $this->app = Yii::app();
     $this->showSearchForm = false;
     $this->defaultLang = Yii::app()->language;
     $this->activeLangs = array($this->defaultLang => $this->defaultLang);
     if (!isFree()) {
         $this->defaultLang = Lang::getDefaultLang();
         $this->activeLangs = Lang::getActiveLangs();
     }
     parent::init();
 }
开发者ID:barricade86,项目名称:raui,代码行数:12,代码来源:MainController.php

示例6: actionRegenSeo

 public function actionRegenSeo()
 {
     $modelsAll = SeoFriendlyUrl::model()->findAll();
     $activeLangs = Lang::getActiveLangs();
     foreach ($modelsAll as $model) {
         foreach ($activeLangs as $lang) {
             $field = 'url_' . $lang;
             $model->{$field} = translit($model->{$field});
         }
         $model->save();
     }
     echo 'end';
 }
开发者ID:barricade86,项目名称:raui,代码行数:13,代码来源:MainController.php

示例7: setLang

function setLang($lang = null)
{
    if (isFree()) {
        return;
    }
    $app = Yii::app();
    $lang = $lang ? $lang : Lang::getDefaultLang();
    $app->setLanguage($lang);
    $activeLangs = Lang::getActiveLangs();
    if (isset($_GET['lang'])) {
        $tmplang = $_GET['lang'];
        //deb($tmplang);
        if (isset($activeLangs[$tmplang])) {
            $lang = $tmplang;
            $app->setLanguage($lang);
        }
        setLangCookie($lang);
        /*
         * другой код, например обновление кеша некоторых компонентов, которые изменяются при смене языка
         */
    } else {
        $user = $app->user;
        if ($user->hasState('_lang')) {
            $tmplang = $user->getState('_lang');
            if (isset($activeLangs[$tmplang])) {
                $lang = $tmplang;
                $app->setLanguage($lang);
            } else {
                setLangCookie($lang);
            }
        } else {
            if (isset($app->request->cookies['_lang'])) {
                $tmplang = $app->request->cookies['_lang']->value;
                if (isset($activeLangs[$tmplang])) {
                    $lang = $tmplang;
                    $app->setLanguage($lang);
                } else {
                    setLangCookie($lang);
                }
            }
        }
    }
    Lang::getActiveLangs(false, true);
}
开发者ID:barricade86,项目名称:raui,代码行数:44,代码来源:common.php

示例8: actionViewFeed

 public function actionViewFeed()
 {
     $oldLang = Yii::app()->language;
     Controller::disableProfiler();
     $defaultLangs = Lang::getDefaultLang();
     Yii::app()->language = $defaultLangs;
     // если есть русский или украинский языки, но они не дефолтные. установим на время их.
     if ($defaultLangs != 'ru' || $defaultLangs != 'uk') {
         $allLangs = Lang::getActiveLangs();
         if (array_key_exists('ru', $allLangs)) {
             Yii::app()->language = 'ru';
         } elseif (array_key_exists('uk', $allLangs)) {
             Yii::app()->language = 'uk';
         }
     }
     $items = $this->generateFeed();
     if (is_array($items) && count($items) > 0) {
         header('Content-type: text/xml');
         header('Pragma: public');
         header('Cache-control: private');
         header('Expires: -1');
         $xmlWriter = new XMLWriter();
         $xmlWriter->openMemory();
         $xmlWriter->setIndent(true);
         $xmlWriter->startDocument('1.0', 'UTF-8');
         $xmlWriter->startElement('realty-feed');
         $xmlWriter->writeAttribute('xmlns', 'http://webmaster.yandex.ru/schemas/feed/realty/2010-06');
         $xmlWriter->writeElement('generation-date', $this->generationDate);
         foreach ($items as $item) {
             if (isset($item['id'])) {
                 $this->prepareItem($item, $xmlWriter);
             }
         }
         $xmlWriter->endElement();
         // end realty-feed (xmlns)
         echo $xmlWriter->outputMemory();
     } else {
         echo 'no elements';
     }
     // установим обратно пользовательский язык
     Yii::app()->language = $oldLang;
 }
开发者ID:barricade86,项目名称:raui,代码行数:42,代码来源:MainController.php

示例9: createUrl

 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     if ($route != 'min/serve' && $route != 'site/uploadimage') {
         $langs = Lang::getActiveLangs();
         $countLangs = count($langs);
         $defaultLang = Lang::getDefaultLang();
         if (isset($params['lang']) && $params['lang'] == $defaultLang && $this->isInstalled) {
             if (!param('useBootstrap')) {
                 unset($params['lang']);
             }
         } else {
             if (Yii::app()->language != $defaultLang && !isFree() && empty($params['lang']) && $countLangs > 1) {
                 $params['lang'] = Yii::app()->language;
             }
         }
         if (!$this->isInstalled && $countLangs == 1 && $route != 'install') {
             $params['lang'] = Yii::app()->language;
         }
         if (!$this->isInstalled && $countLangs > 1 && !isset($params['lang']) && $route != 'install') {
             $params['lang'] = Yii::app()->language;
         }
     }
     return parent::createUrl($route, $params, $ampersand);
 }
开发者ID:barricade86,项目名称:raui,代码行数:24,代码来源:CustomUrlManager.php

示例10: beforeSave

 public function beforeSave()
 {
     $className = get_class($this);
     $i18attributes = CActiveRecord::model($className)->i18nFields();
     foreach ($i18attributes as $attribute => $val) {
         $activeLangs = Lang::getActiveLangs(true);
         $defaultValue = $this->{$attribute . '_' . Yii::app()->language};
         foreach ($activeLangs as $lang) {
             $attr = $attribute . '_' . $lang['name_iso'];
             if ($this->isEmpty($this->{$attr}, true)) {
                 $this->{$attr} = $defaultValue;
             }
         }
     }
     return parent::beforeSave();
 }
开发者ID:barricade86,项目名称:raui,代码行数:16,代码来源:ParentModel.php

示例11: getUsedCurrenciesIds

 public static function getUsedCurrenciesIds()
 {
     if (!isset(self::$_usedCurrenciesIds)) {
         self::$_usedCurrenciesIds = array_unique(array_merge(CHtml::listData(Lang::getActiveLangs(1), 'currency_id', 'currency_id'), array(1 => Currency::getDefaultValuteId())));
     }
     return self::$_usedCurrenciesIds;
 }
开发者ID:barricade86,项目名称:raui,代码行数:7,代码来源:Currency.php

示例12: create

 public static function create($attributes)
 {
     $item = new Menu();
     //$item->attributes = $attributes;
     $item->parentId = array_key_exists('parentId', $attributes) ? $attributes['parentId'] : null;
     $item->number = array_key_exists('number', $attributes) ? $attributes['number'] : null;
     $item->active = 0;
     $item->type = self::LINK_NONE;
     if (isFree()) {
         $activeLangs = array(Yii::app()->language);
     } else {
         $activeLangs = Lang::getActiveLangs();
     }
     foreach ($activeLangs as $lang) {
         //$tmp = 'title_'.Yii::app()->language;
         $item->{'title_' . $lang} = array_key_exists('title', $attributes) ? $attributes['title'] : null;
     }
     /*// подставляем урл, если не задан вручную
     		if (!$item->seo_link && $item->title) {
     			if (isset($item->parent) && $item->parent) { # есть родитель
     				if (isset($item->parent->seo_link) && $item->parent->seo_link) {
     					$item->seo_link = $item->parent->seo_link.'/'.translit(mb_strtolower($item->title, 'utf8'));
     				}
     				elseif (isset($item->parent->title) && $item->parent->title) {
     					$item->seo_link = translit(mb_strtolower($item->parent->title, 'utf8')).'/'.translit(mb_strtolower($item->title, 'utf8'));
     				}
     			}
     		}*/
     if (!$item->save()) {
         throw new CHttpException(400, $item->plainErrors());
     }
     $item->normalize();
     return $item;
 }
开发者ID:alexjkitty,项目名称:estate,代码行数:34,代码来源:Menu.php

示例13: createLangUrl

 public function createLangUrl($lang = 'en', $params = array())
 {
     $langs = Lang::getActiveLangs();
     if (count($langs) > 1 && issetModule('seo') && isset(SeoFriendlyUrl::$seoLangUrls[$lang])) {
         if (count($params)) {
             return SeoFriendlyUrl::$seoLangUrls[$lang] . '?' . http_build_query($params);
         }
         return SeoFriendlyUrl::$seoLangUrls[$lang];
     }
     $route = Yii::app()->urlManager->parseUrl(Yii::app()->getRequest());
     $params = array_merge($_GET, $params);
     $params['lang'] = $lang;
     return $this->createUrl('/' . $route, $params);
 }
开发者ID:barricade86,项目名称:raui,代码行数:14,代码来源:Controller.php

示例14: i18nLength

 public function i18nLength($attribute, $params)
 {
     $label = $this->getAttributeLabel($attribute);
     $activeLangs = Lang::getActiveLangs(true);
     foreach ($activeLangs as $lang) {
         $attr = $attribute . '_' . $lang['name_iso'];
         $value = $this->{$attr};
         if (function_exists('mb_strlen')) {
             $length = mb_strlen($value, Yii::app()->charset);
         } else {
             $length = utf8_strlen($value);
         }
         if (isset($params['min']) && $length < $params['min']) {
             $this->addError($attr, Yii::t('common', '{label} is too short for {lang} (minimum is {min} characters).', array('{label}' => $label, '{lang}' => $lang['name'], '{min}' => $params['min'])));
         }
         if (isset($params['max']) && $length > $params['max']) {
             $this->addError($attr, Yii::t('common', '{label} is too long for {lang} (maximum is {max} characters).', array('{label}' => $label, '{lang}' => $lang['name'], '{max}' => $params['max'])));
         }
         if (isset($params['is']) && $length !== $params['is']) {
             $this->addError($attr, Yii::t('common', '{label} is of the wrong length for {lang} (should be {length} characters).', array('{label}' => $label, '{lang}' => $lang['name'], '{length}' => $params['is'])));
         }
     }
 }
开发者ID:alexjkitty,项目名称:estate,代码行数:23,代码来源:ParentModel.php

示例15: publishAssets

 public function publishAssets()
 {
     $assets = dirname(__FILE__) . '/../assets';
     $baseUrl = Yii::app()->assetManager->publish($assets);
     if (is_dir($assets)) {
         Yii::app()->clientScript->registerCoreScript('jquery');
         Yii::app()->clientScript->registerScript(__CLASS__, "\n\t\t\tvar activeLang = " . CJavaScript::encode(Lang::getActiveLangs()) . ";\n\t\t\tvar baseUrl = '" . Yii::app()->request->baseUrl . "';\n\t\t\tvar errorNoFromLang = '" . Yii::t('module_lang', 'Enter a value for this language') . "';\n\t\t\tvar errorTranslate = '" . Yii::t('module_lang', 'Error translate') . "';\n\t\t\tvar successTranslate = '" . Yii::t('module_lang', 'Success translate') . "';\n\t\t\tvar successCopy = '" . Yii::t('module_lang', 'Success copy') . "';\n\t\t", CClientScript::POS_END);
         Yii::app()->clientScript->registerScriptFile($baseUrl . '/translate.js', CClientScript::POS_END);
     } else {
         throw new Exception(Yii::t('common', 'Lang - Error: Couldn\'t find assets folder to publish.'));
     }
 }
开发者ID:alexjkitty,项目名称:estate,代码行数:12,代码来源:langFieldWidget.php


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