--- loncom/interface/loncommon.pm 2024/03/03 02:39:28 1.1075.2.161.2.23 +++ loncom/interface/loncommon.pm 2013/03/20 01:26:15 1.1118 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.161.2.23 2024/03/03 02:39:28 raeburn Exp $ +# $Id: loncommon.pm,v 1.1118 2013/03/20 01:26:15 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -61,7 +61,7 @@ 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(); @@ -69,23 +69,12 @@ 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 DateTime::Locale::Catalog; +use Text::Aspell; 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(); # ---------------------------------------------- Designs use vars qw(%defaultdesign); @@ -170,6 +159,7 @@ sub ssi_with_retries { # ----------------------------------------------- Filetypes/Languages/Copyright my %language; my %supported_language; +my %supported_codes; my %latex_language; # For choosing hyphenation in my %latex_language_bykey; # for choosing hyphenation from metadata my %cprtag; @@ -200,18 +190,19 @@ 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); - my ($key,$two,$country,$three,$enc,$val,$sup,$latex)=(split(/\t/,$line)); + my ($key,$code,$country,$three,$enc,$val,$sup,$latex)=(split(/\t/,$line)); $language{$key}=$val.' - '.$enc; if ($sup) { $supported_language{$key}=$sup; + $supported_codes{$key} = $code; } if ($latex) { $latex_language_bykey{$key} = $latex; - $latex_language{$two} = $latex; + $latex_language{$code} = $latex; } } close($fh); @@ -221,7 +212,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 +226,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 +240,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 +254,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 +269,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 +422,7 @@ sub studentbrowser_javascript { -COLORFULEDIT -} - -sub xmleditor_js { - return < - -XMLEDIT -} - -sub insert_folding_button { - my $curDepth = $Apache::lonxml::curdepth; - my $lastresource = $env{'request.ambiguous'}; - - return ""; -} - -=pod - -=item * &iframe_wrapper_headjs() - -emits javascript containing two global vars to facilitate handling of resizing -by code in iframe_wrapper_resizejs() used when an iframe is present in a page -with standard LON-CAPA menus. - -=cut - -# -# Where iframe is in use, if window.onload() executes before the custom resize function -# has been defined (jQuery), two global javascript vars (LCnotready and LCresizedef) -# are used to ensure document.ready() triggers a call to resize, so the iframe contents -# do not obscure the Functions menu. -# - -sub iframe_wrapper_headjs { - return <<"ENDJS"; - - -ENDJS - -} - -=pod - -=item * &iframe_wrapper_resizejs() - -emits javascript used to handle resizing for a page containing -an iframe, to ensure that the iframe does not obscure any -standard LON-CAPA menu items. - -=back - -=cut - -# -# jQuery to use when iframe is in use and a page resize occurs. -# This script will ensure that the iframe does not obscure any -# standard LON-CAPA inline menus (primary, secondary, and/or -# breadcrumbs and Functions menus. Expects javascript from -# &iframe_wrapper_headjs() to be in head portion of the web page, -# e.g., by inclusion in second arg passed to &start_page(). -# - -sub iframe_wrapper_resizejs { - my $offset = 5; - &get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']); - if (($env{'form.inhibitmenu'} eq 'yes') || ($env{'form.only_body'})) { - $offset = 0; - } - return &Apache::lonhtmlcommon::scripttag(< form to allow a user to select options from a ref to a hash containing: option_name => displayed text. An optional $onchange can include -a javascript onchange item, e.g., onchange="this.form.submit();". -An optional arg -- $readonly -- if true will cause the select form -to be disabled, e.g., for the case where an instructor has a section- -specific role, and is viewing/modifying parameters. +a javascript onchange item, e.g., onchange="this.form.submit();" See lonrights.pm for an example invocation and use. @@ -2391,16 +2017,12 @@ See lonrights.pm for an example invocati #------------------------------------------- sub select_form { - my ($def,$name,$hashref,$onchange,$readonly) = @_; + my ($def,$name,$hashref,$onchange) = @_; return unless (ref($hashref) eq 'HASH'); if ($onchange) { $onchange = ' onchange="'.$onchange.'"'; } - my $disabled; - if ($readonly) { - $disabled = ' disabled="disabled"'; - } - my $selectform = "\n"; my @keys; if (exists($hashref->{'select_form_order'})) { @keys=@{$hashref->{'select_form_order'}}; @@ -2569,7 +2191,7 @@ sub select_level_form { =pod -=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms,$disabled) +=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms) Returns a string containing a \n"; + my $selectdomain = "'; + $authtype = ''; } } } @@ -3050,7 +2633,7 @@ sub authform_kerberos { if ($authtype eq '') { $authtype = ''; + $krbcheck.' />'; } if (($can_assign{'krb4'} && $can_assign{'krb5'}) || ($can_assign{'krb4'} && !$can_assign{'krb5'} && @@ -3063,9 +2646,9 @@ sub authform_kerberos { '', - '