Code

Updated timezone Handling.
[gosa.git] / setup / class_setupStep_Language.inc
1 <?php
3 /*
4    This code is part of GOsa (https://gosa.gonicus.de)
5    Copyright (C) 2007 Fabian Hickert
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 */
23 class Step_Language extends setup_step
24 {
25   var $lang_selected  = "";       /* Language selected from select box  */
26   var $lang           = "en_EN";  /* Detected language */
27   var $languages      = array();
28   var $attributes     = array("lang","lang_selected","timezone");
29   var $header_image   = "images/locale.png";
30   var $timezone       = "Europe/Berlin";
31   var $timezones      = array();
33   function Step_Language()
34   {
35     $this->lang           = get_browser_language();
36     $this->lang_selected  = "";
37     $this->update_strings(); 
38     $this->timezones = get_timezones_array();
39   }
41   function update_strings()
42   {
43     $this->s_title      = _("Language setup");
44     $this->s_title_long = _("Language setup");
45     $this->s_info       = _("This step allows you to select your preferred language.");
46   }
47   
48   function execute()
49   {
50     $this->languages = array(""      => _("Automatic"),
51                              "de_DE" => _("German"),
52                              "fr_FR" => _("French"),
53                              "en_EN" => _("English"),
54                              "zh_CN" => _("Chinese"),
55                              "ru_RU" => _("Russian"));
56     asort($this->languages);
57     $smarty = get_smarty();
58     $smarty->assign("languages",    $this->languages);
59     $smarty->assign("lang",         $this->lang);
60     $smarty->assign("lang_selected",$this->lang_selected);
61     $smarty->assign("timezone"     ,$this->timezone);
62     $smarty->assign("timezones"    ,$this->timezones);
63     return($smarty->fetch(get_template_path("setup_language.tpl",TRUE,dirname(__FILE__))));
64   }
66   function save_object()
67   {
68     if((isset($_POST['lang_selected'])) && isset($this->languages[$_POST['lang_selected']])) {
69       $this->lang_selected = $_POST['lang_selected'];
70       $this->is_completed = TRUE;
72       if($this->lang_selected != ""){
73         $_SESSION['lang'] = $this->lang_selected;
74       }else{
75         $_SESSION['lang'] = $this->lang;
76       }
78       if(isset($_POST['timezone']) && isset($this->timezones[$_POST['timezone']])){
79         $this->timezone = $_POST['timezone'];
80       }
81     }
82   }
83 }
85 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
86 ?>