--- loncom/interface/loncommon.pm 2008/07/12 14:16:32 1.669 +++ loncom/interface/loncommon.pm 2008/12/03 00:09:56 1.702 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.669 2008/07/12 14:16:32 raeburn Exp $ +# $Id: loncommon.pm,v 1.702 2008/12/03 00:09:56 harmsja Exp $ # # Copyright Michigan State University Board of Trustees # @@ -61,6 +61,7 @@ use POSIX qw(strftime mktime); use Apache::lonmenu(); use Apache::lonenc(); use Apache::lonlocal; +use Apache::lonnet(); use HTML::Entities; use Apache::lonhtmlcommon(); use Apache::loncoursedata(); @@ -68,6 +69,7 @@ use Apache::lontexconvert(); use Apache::lonclonecourse(); use LONCAPA qw(:DEFAULT :match); use DateTime::TimeZone; +use DateTime::Locale::Catalog; # ---------------------------------------------- Designs use vars qw(%defaultdesign); @@ -657,6 +659,57 @@ sub select_timezone { return $output; } +sub select_datelocale { + my ($name,$selected,$onchange,$includeempty)=@_; + my $output=''."\n"; + if ($includeempty) { + $output .= '{'id'}; + if ($id ne '') { + my $en_terr = $locale->{'en_territory'}; + my $native_terr = $locale->{'native_territory'}; + my @languages = &Apache::lonlocal::preferred_languages(); + if (grep(/^en$/,@languages) || !@languages) { + if ($en_terr ne '') { + $locale_names{$id} = '('.$en_terr.')'; + } elsif ($native_terr ne '') { + $locale_names{$id} = $native_terr; + } + } else { + if ($native_terr ne '') { + $locale_names{$id} = $native_terr.' '; + } elsif ($en_terr ne '') { + $locale_names{$id} = '('.$en_terr.')'; + } + } + push (@possibles,$id); + } + } + } + foreach my $item (sort(@possibles)) { + $output.= '$item"; + if ($locale_names{$item} ne '') { + $output.=" $locale_names{$item}\n"; + } + $output.="\n"; + } + $output.=""; + return $output; +} + =pod =item * &linked_select_forms(...) @@ -873,7 +926,7 @@ sub help_open_topic { if ($text ne "") { $template .= "