本文整理汇总了PHP中Language::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::getList方法的具体用法?PHP Language::getList怎么用?PHP Language::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::getList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collectRules
public function collectRules()
{
$multilanguage_support = Yii::app()->params['multilanguage_support'];
if ($multilanguage_support) {
$languages = Language::getList();
$languages = implode('|', array_keys($languages));
$language_pattern = "<language:({$languages})>";
}
$routes = array('/<controller:\\w+>/<id:\\d+>' => '<controller>/view', '/<controller:\\w+>/<action:\\w+>/<id:\\d+>' => '<controller>/<action>', '/<controller:\\w+>/<action:\\w+>' => '<controller>/<action>');
if (Yii::app()->params['collect_routes_from_modules']) {
foreach (Yii::app()->getModules() as $id => $config) {
$module = Yii::app()->getModule($id);
if (method_exists($module, 'routes')) {
$routes = array_merge($routes, $module->routes());
}
}
}
$multilanguage_support = Yii::app()->params['multilanguage_support'];
if ($multilanguage_support) {
$languages = Language::getList();
$languages = implode('|', array_keys($languages));
$language_pattern = "<language:({$languages})>";
}
foreach ($routes as $pattern => $route) {
unset($routes[$pattern]);
$pattern = '/' . trim($pattern, '/');
if ($multilanguage_support) {
$pattern = '/' . $language_pattern . $pattern;
}
$routes[$pattern] = $route;
}
$routes = array_reverse($routes);
$routes['<language:(en|ru)>/<route:.*>'] = '<route>';
Yii::app()->urlManager->addRules($routes);
}
示例2: preFilter
protected function preFilter($filterChain)
{
if (!Yii::app()->params->multilanguage_support)
{
return true;
}
$request = Yii::app()->request;
if ($lang = Yii::app()->request->getParam('language'))
{
Yii::app()->language = $lang;
}
Yii::app()->session['language'] = Yii::app()->language;
if (Yii::app()->request->isPostRequest)
{
return true;
}
$languages = Language::getList();
$url_parts = explode('/', $_SERVER['REQUEST_URI']);
if (!isset($languages[$url_parts[1]]))
{
$request->redirect('/' . Yii::app()->session['language'] . $_SERVER['REQUEST_URI']);
}
return true;
}
示例3: actionManage
public function actionManage()
{
$model = new LanguageMessage(ActiveRecord::SCENARIO_SEARCH);
$model->unsetAttributes();
if (isset($_GET['LanguageMessage'])) {
$model->attributes = $_GET['LanguageMessage'];
}
$this->render('manage', array('model' => $model, 'languages' => Language::getList()));
}
示例4: actionChangeLanguage
public function actionChangeLanguage($set_language, $back_url)
{
$languages = Language::getList();
if (!isset($languages[$set_language])) {
throw new CHttpException("Неизвестный системе язык: '{$set_language}'");
}
Yii::app()->session['language'] = $set_language;
$back_url = explode('/', base64_decode($back_url));
$back_url[1] = $set_language;
$back_url = implode('/', $back_url);
$this->redirect($back_url);
}
示例5: __construct
public function __construct($id, $name, $visibility, $defaultLanguage)
{
$this->id = $id;
$this->name = $name;
$this->visibility = $visibility;
$this->defaultLanguage = $defaultLanguage;
$this->languages = array();
$languages = Language::getList();
foreach ($languages as $language) {
$this->languages[$language] = new Language_Android($language);
}
}
示例6: beforeFormInit
public function beforeFormInit($event)
{
if (!$event->sender->add_elements_from_behaviors) {
return true;
}
$elements = $event->sender->getElements();
$meta = $this->owner->meta();
$languages = Language::getList();
if (isset($meta['language']) && count($languages) > 1) {
$elements['language'] = array('type' => 'dropdownlist', 'items' => $languages);
}
$event->sender->setElements($elements);
}
示例7: attributeLabels
public function attributeLabels()
{
$labels = array();
foreach ($this->meta() as $field_data) {
$labels[$field_data["Field"]] = t($field_data["Comment"]);
}
$languages = Language::getList();
if (count($languages) > 1) {
$labels['language'] = 'Язык';
}
$labels['captcha'] = 'Введите код с картинки';
return $labels;
}
示例8: execute
public function execute()
{
$user = connectionUserModel::create()->getInfo((int) Request::post('id'));
$activeLang = $user['lang'];
$lang = array();
array_map(function ($a) use(&$lang, $activeLang) {
if ($a['iso'] == $activeLang) {
$lang = $a;
}
}, Language::getList());
$fieldModel = new connectionFieldsModel();
$fields = array();
$fields = array_merge($fieldModel->getGroupLocale('info', 'ru'), $fields);
$fields = array_merge($fieldModel->getGroupLocale('interest', 'ru'), $fields);
$this->smarty->assign('lang', $lang);
$this->smarty->assign('user', $user);
$this->smarty->assign('fields', $fields);
}
示例9: postCreate
/**
* Create new page
* @return Redirect
*/
public function postCreate()
{
User::onlyHas("page-create");
$parent = Input::get('parent');
$page = new Post();
$page->parent = $parent;
$page->author_id = Auth::user()->id;
$page->taxonomy_id = $this->taxonomy->id;
$page->save();
foreach (Language::getList() as $lang) {
$pageLang = new PostLang();
$pageLang->lang_id = $lang->id;
$pageLang->post_id = $page->id;
$pageLang->save();
}
$page->ord_num = $page->id;
$page->save();
Log::info("Create page #{$page->id}");
return Redirect::to('page/index/' . $page->id);
}
示例10: lang
public static function lang()
{
if (!is_null(self::$lang)) {
return self::$lang;
}
self::$lang = self::$langDefault;
if (Request::cookie(self::$langKeyCookie)) {
$saveLang = Request::cookie(self::$langKeyCookie);
} else {
$saveLang = Request::getUserLang();
}
$lang = array_map(function ($a) {
return $a['iso'];
}, Language::getList());
if (in_array($saveLang, $lang)) {
self::$lang = $saveLang;
}
Request::cookie(self::$langKeyCookie, self::$lang);
return self::$lang;
}
示例11: cleanLanguages
/**
* Removes all translations that don't differ from the default language
*
* These translations have no effect and thus only distort the progress indication
*
* @param int $repositoryID
* @param int $defaultLanguageID
*/
public static function cleanLanguages($repositoryID, $defaultLanguageID)
{
$languages = Language::getList();
$phraseIDsToDelete = array();
foreach ($languages as $language) {
if ($language != $defaultLanguageID) {
$phraseIDs = self::select("SELECT id FROM phrases AS a WHERE a.repositoryID = " . intval($repositoryID) . " AND a.languageID = " . intval($language) . " AND a.payload = (SELECT payload FROM phrases AS b WHERE b.repositoryID = a.repositoryID AND b.languageID = " . intval($defaultLanguageID) . " AND b.phraseKey = a.phraseKey)");
foreach ($phraseIDs as $phraseID) {
$phraseIDsToDelete[] = intval($phraseID['id']);
}
}
}
self::delete("DELETE FROM phrases WHERE id IN (" . implode(',', $phraseIDsToDelete) . ")");
}
示例12: getHref
public function getHref()
{
if ($this->page) {
$url = $this->page->href;
} else {
if ($this->module_url) {
$url = Yii::app()->controller->createUrl($this->module_url, ['section_id' => $this->id]);
} else {
$url = $this->url;
}
}
if (!empty($url) && mb_substr($url, 0, 1, 'utf-8') != '/') {
$url = '/' . $url;
}
if (count(Language::getList()) > 1) {
$url = '/' . Yii::app()->language . $url;
}
//echo $url . "<br/>";
return $url;
}
示例13: exportRepository
/**
* Exports the given repository and creates a ZIP file containing XML output files
*
* @param Repository $repository the Repository instance to export
* @param string $filename the output file name inside each language folder
* @param int $groupID the group to get the output for (or Phrase::GROUP_ALL)
* @param int $format the format (constant) to use for this export
* @param int $minCompletion the minimum percentage of completion for languages to be eligible for exporting
* @param bool $ignoreIfSameAsDefault ignore phrases which are the same as the default language
* @throws Exception if the repository could not be exported
*/
public static function exportRepository($repository, $filename, $groupID, $format, $minCompletion = 0, $ignoreIfSameAsDefault = false)
{
if (self::isFilenameValid($filename)) {
if ($repository instanceof Repository) {
$exportSuccess = true;
$randomDir = mt_rand(1000000, 9999999);
$savePath = URL::getTempPath(false) . URL::encodeID($repository->getID());
self::deleteDirectoryRecursively($savePath);
// delete all old output files from output directory first
$savePath .= '/' . $randomDir;
// navigate to random directory inside output folder
if (mkdir($savePath, 0755, true)) {
// if output folder could be created
$languages = Language::getList();
$defaultLanguageObject = $repository->getLanguage($repository->getDefaultLanguage());
foreach ($languages as $language) {
$languageObject = $repository->getLanguage($language);
$languageKeys = $languageObject->getKeys();
$ignorePhrasesSameAsDefault = $ignoreIfSameAsDefault && $repository->getDefaultLanguage() != $language;
if ($format == self::FORMAT_ANDROID_XML_ESCAPED_HTML) {
$languageOutput = $languageObject->outputAndroidXMLEscapedHTML($groupID, $ignorePhrasesSameAsDefault, $defaultLanguageObject);
$fileExtension = '.xml';
} elseif ($format == self::FORMAT_JSON) {
$languageOutput = $languageObject->outputJSON($groupID, $ignorePhrasesSameAsDefault, $defaultLanguageObject);
$fileExtension = '.json';
} elseif ($format == self::FORMAT_PLAINTEXT) {
$languageOutput = $languageObject->outputPlaintext($groupID, $ignorePhrasesSameAsDefault, $defaultLanguageObject);
$fileExtension = '.txt';
} else {
$languageOutput = $languageObject->outputAndroidXML($groupID, $ignorePhrasesSameAsDefault, $defaultLanguageObject);
$fileExtension = '.xml';
}
if ($languageOutput->getCompleteness() >= $minCompletion) {
foreach ($languageKeys as $languageKey) {
if (mkdir($savePath . '/' . $languageKey . '/', 0755, true)) {
if (file_put_contents($savePath . '/' . $languageKey . '/' . $filename . $fileExtension, $languageOutput->getContent()) !== false) {
$exportSuccess = true;
} else {
// output file could not be written
$exportSuccess = false;
}
} else {
// sub-directory for language could not be created
$exportSuccess = false;
}
}
}
}
} else {
// output folder could not be created
$exportSuccess = false;
}
if ($exportSuccess) {
$outputPath = URL::getTempPath(true) . URL::encodeID($repository->getID()) . '/' . $randomDir;
if (self::zipFolder($savePath, $savePath . '/Export.zip')) {
UI::redirectToURL($outputPath . '/Export.zip');
}
}
} else {
throw new Exception('The repository must be an instance of class Repository');
}
} else {
throw new Exception('Invalid filename: ' . $filename);
}
}
示例14: isRootUrl
public function isRootUrl($url = null)
{
if (!$url)
{
$url = $_SERVER["REQUEST_URI"];
}
$languages = Language::getList();
return isset($languages[trim($url, "/")]);
}
示例15: run
public function run()
{
$this->render('LanguageSwitcher', array('languages' => Language::getList()));
}