--- loncom/interface/loncommon.pm 2023/01/23 22:50:32 1.1075.2.161.2.15 +++ loncom/interface/loncommon.pm 2012/05/24 22:56:30 1.1079 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.161.2.15 2023/01/23 22:50:32 raeburn Exp $ +# $Id: loncommon.pm,v 1.1079 2012/05/24 22:56:30 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -61,31 +61,15 @@ use POSIX qw(strftime mktime); use Apache::lonmenu(); use Apache::lonenc(); use Apache::lonlocal; -use Apache::lonnavmaps(); +use Apache::lonnet(); use HTML::Entities; 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 LONCAPA::map(); -use HTTP::Request; 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 File::Copy(); -use File::Path(); -use String::CRC32(); -use Short::URL(); +use DateTime::Locale::Catalog; # ---------------------------------------------- Designs use vars qw(%defaultdesign); @@ -200,7 +184,7 @@ BEGIN { { my $langtabfile = $Apache::lonnet::perlvar{'lonTabDir'}. '/language.tab'; - if ( open(my $fh,'<',$langtabfile) ) { + if ( open(my $fh,"<$langtabfile") ) { while (my $line = <$fh>) { next if ($line=~/^\#/); chomp($line); @@ -221,7 +205,7 @@ BEGIN { { my $copyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}. '/copyright.tab'; - if ( open (my $fh,'<',$copyrightfile) ) { + if ( open (my $fh,"<$copyrightfile") ) { while (my $line = <$fh>) { next if ($line=~/^\#/); chomp($line); @@ -235,7 +219,7 @@ BEGIN { { my $sourcecopyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}. '/source_copyright.tab'; - if ( open (my $fh,'<',$sourcecopyrightfile) ) { + if ( open (my $fh,"<$sourcecopyrightfile") ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); @@ -249,7 +233,7 @@ BEGIN { # -------------------------------------------------------------- default domain designs my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors'; my $designfile = $designdir.'/default.tab'; - if ( open (my $fh,'<',$designfile) ) { + if ( open (my $fh,"<$designfile") ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); @@ -263,12 +247,12 @@ BEGIN { { my $categoryfile = $Apache::lonnet::perlvar{'lonTabDir'}. '/filecategories.tab'; - if ( open (my $fh,'<',$categoryfile) ) { + if ( open (my $fh,"<$categoryfile") ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); my ($extension,$category)=(split(/\s+/,$line,2)); - push(@{$category_extensions{lc($category)}},$extension); + push @{$category_extensions{lc($category)}},$extension; } close($fh); } @@ -278,7 +262,7 @@ BEGIN { { my $typesfile = $Apache::lonnet::perlvar{'lonTabDir'}. '/filetypes.tab'; - if ( open (my $fh,'<',$typesfile) ) { + if ( open (my $fh,"<$typesfile") ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); @@ -431,7 +415,7 @@ sub studentbrowser_javascript { END # output the initial values for the selection lists - $result .= "\n"; my @order = sort(keys(%{$hashref})); if (ref($menuorder) eq 'ARRAY') { @order = @{$menuorder}; @@ -1199,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 ############################################################### @@ -2021,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' @@ -2269,15 +1943,12 @@ sub multiple_select_form { =pod -=item * &select_form($defdom,$name,$hashref,$onchange,$readonly) +=item * &select_form($defdom,$name,$hashref,$onchange) Returns a string containing a \n"; + my $selectform = " form to allow a user to select the domain to preform an operation in. @@ -2476,36 +2143,25 @@ If the $showdomdesc flag is set, the dom The optional $onchange argument specifies what should occur if the domain selector is changed, e.g., 'this.form.submit()' if the form is to be automatically submitted. -The optional $incdoms is a reference to an array of domains which will be the only available options. - -The optional $excdoms is a reference to an array of domains which will be excluded from the available options. - -The optional $disabled argument, if true, adds the disabled attribute to the select tag. +The optional $incdoms is a reference to an array of domains which will be the only available options. =cut #------------------------------------------- sub select_dom_form { - my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms,$disabled) = @_; + my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms) = @_; if ($onchange) { $onchange = ' onchange="'.$onchange.'"'; } - if ($disabled) { - $disabled = ' disabled="disabled"'; - } - my (@domains,%exclude); + my @domains; if (ref($incdoms) eq 'ARRAY') { @domains = sort {lc($a) cmp lc($b)} (@{$incdoms}); } else { @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains()); } if ($includeempty) { @domains=('',@domains); } - if (ref($excdoms) eq 'ARRAY') { - map { $exclude{$_} = 1; } @{$excdoms}; - } - my $selectdomain = "\n"; foreach my $dom (@domains) { - next if ($exclude{$dom}); $selectdomain.="