--- loncom/interface/loncommon.pm 2016/09/15 04:18:38 1.1075.2.112 +++ loncom/interface/loncommon.pm 2012/07/07 21:58:14 1.1086 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.112 2016/09/15 04:18:38 raeburn Exp $ +# $Id: loncommon.pm,v 1.1086 2012/07/07 21:58:14 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -67,19 +67,9 @@ use Apache::lonhtmlcommon(); use Apache::loncoursedata(); use Apache::lontexconvert(); use Apache::lonclonecourse(); -use Apache::lonuserutils(); -use Apache::lonuserstate(); -use Apache::courseclassifier(); use LONCAPA qw(:DEFAULT :match); use DateTime::TimeZone; -use DateTime::Locale; -use Encode(); -use Authen::Captcha; -use Captcha::reCAPTCHA; -use JSON::DWIW; -use LWP::UserAgent; -use Crypt::DES; -use DynaLoader; # for Crypt::DES version +use DateTime::Locale::Catalog; # ---------------------------------------------- Designs use vars qw(%defaultdesign); @@ -534,8 +524,7 @@ ENDAUTHORBRW } sub coursebrowser_javascript { - my ($domainfilter,$sec_element,$formname,$role_element,$crstype, - $credits_element,$instcode) = @_; + my ($domainfilter,$sec_element,$formname,$role_element,$crstype) = @_; my $wintitle = 'Course_Browser'; if ($crstype eq 'Community') { $wintitle = 'Community_Browser'; @@ -586,12 +575,6 @@ sub coursebrowser_javascript { var ownername = document.forms[formid].ccuname.value; var ownerdom = document.forms[formid].ccdomain.options[document.forms[formid].ccdomain.selectedIndex].value; url += '&cloner='+ownername+':'+ownerdom; - if (type == 'Course') { - url += '&crscode='+document.forms[formid].crscode.value; - } - } - if (formname == 'requestcrs') { - url += '&crsdom=$domainfilter&crscode=$instcode'; } if (multflag !=null && multflag != '') { url += '&multiple='+multflag; @@ -604,9 +587,8 @@ sub coursebrowser_javascript { } $id_functions ENDSTDBRW - if (($sec_element ne '') || ($role_element ne '') || ($credits_element ne '')) { - $output .= &setsec_javascript($sec_element,$formname,$role_element, - $credits_element); + if (($sec_element ne '') || ($role_element ne '')) { + $output .= &setsec_javascript($sec_element,$formname,$role_element); } $output .= ' // ]]> @@ -763,7 +745,7 @@ ENDUSERBRW } sub setsec_javascript { - my ($sec_element,$formname,$role_element,$credits_element) = @_; + my ($sec_element,$formname,$role_element) = @_; my (@courserolenames,@communityrolenames,$rolestr,$courserolestr, $communityrolestr); if ($role_element ne '') { @@ -858,14 +840,6 @@ function setRole(crstype) { } |; } - if ($credits_element) { - $setsections .= qq| -function setCredits(defaultcredits) { - document.$formname.$credits_element.value = defaultcredits; - return; -} -|; - } return $setsections; } @@ -911,14 +885,10 @@ sub check_uncheck_jscript { function checkAll(field) { if (field.length > 0) { for (i = 0; i < field.length; i++) { - if (!field[i].disabled) { - field[i].checked = true; - } + field[i].checked = true ; } } else { - if (!field.disabled) { - field.checked = true; - } + field.checked = true } } @@ -967,16 +937,15 @@ sub select_datelocale { } $output .= '> '; } - my @languages = &Apache::lonlocal::preferred_languages(); my (@possibles,%locale_names); - my @locales = DateTime::Locale->ids(); - foreach my $id (@locales) { - if ($id ne '') { - my ($en_terr,$native_terr); - my $loc = DateTime::Locale->load($id); - if (ref($loc)) { - $en_terr = $loc->name(); - $native_terr = $loc->native_name(); + my @locales = DateTime::Locale::Catalog::Locales; + foreach my $locale (@locales) { + if (ref($locale) eq 'HASH') { + my $id = $locale->{'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.')'; @@ -990,8 +959,7 @@ sub select_datelocale { $locale_names{$id} = '('.$en_terr.')'; } } - $locale_names{$id} = Encode::encode('UTF-8',$locale_names{$id}); - push(@possibles,$id); + push (@possibles,$id); } } } @@ -1002,7 +970,7 @@ sub select_datelocale { } $output.=">$item"; if ($locale_names{$item} ne '') { - $output.=' '.$locale_names{$item}; + $output.=" $locale_names{$item}\n"; } $output.="\n"; } @@ -1022,7 +990,6 @@ sub select_language { $langchoices{$code} = &plainlanguagedescription($id); } } - %langchoices = &Apache::lonlocal::texthash(%langchoices); return &select_form($selected,$name,\%langchoices); } @@ -1054,12 +1021,6 @@ linked_select_forms takes the following =item * $menuorder, the order of values in the first menu -=item * $onchangefirst, additional javascript call to execute for an onchange - event for the first tag - =back Below is an example of such a hash. Only the 'text', 'default', and @@ -1113,8 +1074,6 @@ sub linked_select_forms { $secondselectname, $hashref, $menuorder, - $onchangefirst, - $onchangesecond ) = @_; my $second = "document.$formname.$secondselectname"; my $first = "document.$formname.$firstselectname"; @@ -1171,7 +1130,7 @@ function select1_changed() { END # output the initial values for the selection lists - $result .= "\n"; my @order = sort(keys(%{$hashref})); if (ref($menuorder) eq 'ARRAY') { @order = @{$menuorder}; @@ -1184,11 +1143,7 @@ END $result .= "\n"; my %select2 = %{$hashref->{$firstdefault}->{'select2'}}; $result .= $middletext; - $result .= ""; -} - - =pod =head1 Excel and CSV file utility routines +=over 4 + =cut ############################################################### @@ -1991,8 +1697,6 @@ sub insert_folding_button { =pod -=over 4 - =item * &csv_translate($text) Translate $text to allow it to be output as a 'comma separated values' @@ -2426,7 +2130,7 @@ sub select_level_form { =pod -=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms) +=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms) Returns a string containing a \n"; foreach my $dom (@domains) { - next if ($exclude{$dom}); $selectdomain.="