langs and default lang now configurable

This commit is contained in:
Ulf Gebhardt 2013-06-26 16:57:32 +02:00
parent 356b059347
commit 626a170b9c
2 changed files with 7 additions and 9 deletions

View File

@ -18,6 +18,9 @@ class config_ids {
const SYS_CONFIG_DB_PASSWORD = 15;
const SYS_CONFIG_DB_DBNAME = 16;
const SYS_CONFIG_LANGS = 21;
const SYS_CONFIG_DEFAULT_LANG = 22;
const SYS_SAI_CONFIG_BASEURL = 50;
const SYS_SAI_CONFIG_NAVIMG = 51;
}

View File

@ -1,13 +1,8 @@
<?php
namespace SYSTEM;
define('LANGS', \serialize(array('deDE', 'enUS')));
class locale {
const SESSION_KEY = 'locale';
const DEFAULT_LANG = 'deDE';
class locale {
const SESSION_KEY = 'locale';
public static function set($lang){
if(!self::isLang($lang)){
@ -23,13 +18,13 @@ class locale {
public static function get(){
$value = \SYSTEM\SECURITY\Security::load(self::SESSION_KEY);
if($value == NULL){
return self::DEFAULT_LANG;}
return \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG);}
return $value;
}
public static function isLang($lang){
if(!\in_array($lang, unserialize(LANGS))){
if(!\in_array($lang, unserialize(\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS)))){
return false;}
return true;
}