Timezone selection support
authorJamie Cameron <jcameron@webmin.com>
Thu, 14 Apr 2011 18:11:37 +0000 (11:11 -0700)
committerJamie Cameron <jcameron@webmin.com>
Thu, 14 Apr 2011 18:11:37 +0000 (11:11 -0700)
phpini/CHANGELOG
phpini/edit_misc.cgi
phpini/module.info

index 3da89cc..d8857b6 100644 (file)
@@ -2,3 +2,5 @@
 First version of this module, which can edit the global PHP configuration file and other per-domain files.
 ---- Changes since 1.480 ----
 Added an access control option to limit file IO to a particular Unix user.
+---- Changes since 1.540 ----
+Added support for selecting the timezone on the Other Settings page, thanks to Matt Lewandowsky.
index b944342..c9fbe0a 100755 (executable)
@@ -9,25 +9,13 @@ $conf = &get_config($in{'file'});
 &ui_print_header("<tt>$in{'file'}</tt>", $text{'misc_title'}, "");
 
 # Build list of timezones
-my %tzlist = ({});
-# This may possibly want to be a configuration option, however this is the
-# standard locaation almost certainly used by a particular PHP installation.
-open(TZTAB, "/usr/share/zoneinfo/zone.tab");
-while(<TZTAB>) {
-       chomp;
-       s/#.*$//;
-       next if /^(\s)*$/;
-       # File format is tab-separated with fields, in order:
-       # Country code, Coordinates, Timezone name, Comments
-       my($tz_cc, $tz_coord, $tz_tz, $tz_comm) = split(/\t/);
-       # Stored as a hash for potential future-compatibility.
-       $tzlist{$tz_tz} = { 
-               'country' => $tz_cc, 
-               'coords' => $tz_coord, 
-               'comment' => $tz_comm
-               };
+my %tzlist;
+&foreign_require("time");
+if (defined(&time::list_timezones)) {
+       foreach $t (&time::list_timezones()) {
+               $tzlist{$t->[0]} = { 'comment' => $t->[1] };
+               }
        }
-close(TZTAB);
 
 print &ui_form_start("save_misc.cgi", "post");
 print &ui_hidden("file", $in{'file'}),"\n";
@@ -76,12 +64,15 @@ print &ui_table_row($text{'misc_path'},
        &onoff_radio("cgi.fix_pathinfo"));
 
 # PHP Timezone Dropdown
-$tzlist{''}{'comment'} = "[ Default ]" if not exists $tzlist{''};
+$tzlist{''}{'comment'} = $text{'default'} if not exists $tzlist{''};
 $curr_timezone = &find_value("date.timezone", $conf);
 $tzlist{$curr_timezone}{'comment'} = "Custom timezone" if not exists $tzlist{$curr_timezone};
-# TODO: Figure out a good way to list the descriptions for each timezone.
 print &ui_table_row(&hlink($text{'misc_timezone'}, "misc_timezone"),
-&ui_select("date.timezone", $curr_timezone, [sort keys %tzlist], 1, 0, 0, 0));
+       &ui_select("date.timezone", $curr_timezone,
+                  [ map { $z = $tzlist{$_};
+                          [ $_, $_.($z->{'comment'} ?
+                                    " ($z->{'comment'})" : "")  ] }
+                        (sort keys %tzlist) ], 1, 0, 0, 0), 3);
 
 print &ui_table_end();
 print &ui_form_end([ [ "save", $text{'save'} ] ]);
index 456e056..9f071f7 100644 (file)
@@ -8,3 +8,4 @@ desc_nl=PHP Configuratie
 desc_ko_KR.euc=PHP ¼³Á¤
 desc_ko_KR.UTF-8=PHP 설정
 desc_de=PHP-Konfiguration 
+depends=time