{
global $template;
- $this->templateFolder = $template;
+ $this->templateFolder = $template;
+ //default fallback for empty setting
+ if($this->templateFolder=="")$this->templateFolder="./template/";
+ //make sure it ends with /
+ if(substr($this->templateFolder,-1,1)!="/")$this->templateFolder.="/";
// check if cookie is set
if (isset($_COOKIE[self::$COOKIE_NAME])) {
$this->lang = $_COOKIE[self::$COOKIE_NAME];
} else {
- $this->lang = substr($_SERVER[HTTP_ACCEPT_LANGUAGE],0,2);
+ $this->lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2);
}
+ //sanity check for $lang -> must only contain letters; fallback is de
+ if(ereg("^[a-zA-Z]+$",$this->lang)===false)
+ $this->lang="de";
+
$this->setLanguageConfig();
}
public static function singleton()
{
if(!self::$instance) {
- self::$instance = new LanguageManager();
- }
-
- return self::$instance;
+ self::$instance = new LanguageManager();
+ }
+
+ return self::$instance;
}
/** set language */