--- loncom/interface/loncommon.pm 2007/03/03 01:33:20 1.512 +++ loncom/interface/loncommon.pm 2007/09/11 20:40:23 1.583 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.512 2007/03/03 01:33:20 albertel Exp $ +# $Id: loncommon.pm,v 1.583 2007/09/11 20:40:23 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -68,8 +68,12 @@ use Apache::lontexconvert(); use Apache::lonclonecourse(); use LONCAPA qw(:DEFAULT :match); +# ---------------------------------------------- Designs +use vars qw(%defaultdesign); + my $readit; + ## ## Global Variables ## @@ -82,10 +86,6 @@ my %scprtag; my %fe; my %fd; my %fm; my %category_extensions; -# ---------------------------------------------- Designs - -my %designhash; - # ---------------------------------------------- Thesaurus variables # # %Keywords: @@ -151,30 +151,18 @@ BEGIN { } } -# -------------------------------------------------------------- domain designs - - my $filename; +# -------------------------------------------------------------- default domain designs my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors'; - opendir(DIR,$designdir); - while ($filename=readdir(DIR)) { - if ($filename!~/\.tab$/) { next; } - my ($domain)=($filename=~/^($match_domain)\./); - { - my $designfile = $designdir.'/'.$filename; - if ( open (my $fh,"<$designfile") ) { - while (my $line = <$fh>) { - next if ($line =~ /^\#/); - chomp($line); - my ($key,$val)=(split(/\=/,$line)); - if ($val) { $designhash{$domain.'.'.$key}=$val; } - } - close($fh); - } - } - + my $designfile = $designdir.'/default.tab'; + if ( open (my $fh,"<$designfile") ) { + while (my $line = <$fh>) { + next if ($line =~ /^\#/); + chomp($line); + my ($key,$val)=(split(/\=/,$line)); + if ($val) { $defaultdesign{$key}=$val; } + } + close($fh); } - closedir(DIR); - # ------------------------------------------------------------- file categories { @@ -346,10 +334,12 @@ sub studentbrowser_javascript { return (<<'ENDSTDBRW'); +RESIZE + +} + +=pod + +=back + =head1 Excel and CSV file utility routines =over 4 @@ -1224,7 +1266,7 @@ sub create_workbook { =item * create_text_file -Create a file to write to and eventually make available to the usre. +Create a file to write to and eventually make available to the user. If file creation fails, outputs an error message on the request object and return undefs. @@ -1270,12 +1312,14 @@ sub create_text_file { sub domain_select { my ($name,$value,$multiple)=@_; my %domains=map { - $_ => $_.' '.$Apache::lonnet::domaindescription{$_} + $_ => $_.' '. &Apache::lonnet::domain($_,'description') } &Apache::lonnet::all_domains(); if ($multiple) { $domains{''}=&mt('Any domain'); + $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))]; return &multiple_select_form($name,$value,4,\%domains); } else { + $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))]; return &select_form($name,$value,%domains); } } @@ -1284,6 +1328,12 @@ sub domain_select { =pod +=head1 Routines for form select boxes + +=over 4 + +=cut + =item * multiple_select_form($name,$value,$size,$hash,$order) Returns a string containing a form to allow a user to select the domain to preform an operation in. @@ -1430,18 +1480,28 @@ See loncreateuser.pm for an example invo If the $includeempty flag is set, it also includes an empty choice ("no domain selected"); +If the $showdomdesc flag is set, the domain name is followed by the domain description. + =cut #------------------------------------------- sub select_dom_form { - my ($defdom,$name,$includeempty) = @_; - my @domains = &Apache::lonnet::all_domains(); + my ($defdom,$name,$includeempty,$showdomdesc) = @_; + my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains()); if ($includeempty) { @domains=('',@domains); } my $selectdomain = ""; return $selectdomain; @@ -1451,23 +1511,6 @@ sub select_dom_form { =pod -=item * get_library_servers($domain) - -Returns a hash which contains keys like '103l3' and values like -'kirk.lite.msu.edu'. All of the keys will be for machines in the -given $domain. - -=cut - -#------------------------------------------- -sub get_library_servers { - return &Apache::lonnet::get_servers($_[0],'library'); -} - -#------------------------------------------- - -=pod - =item * home_server_option_list($domain) returns a string which contains an