--- loncom/interface/loncommon.pm 2006/10/12 18:17:57 1.463 +++ loncom/interface/loncommon.pm 2007/08/24 18:41:50 1.564.2.2 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.463 2006/10/12 18:17:57 albertel Exp $ +# $Id: loncommon.pm,v 1.564.2.2 2007/08/24 18:41:50 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -59,16 +59,21 @@ use Apache::lonnet; use GDBM_File; use POSIX qw(strftime mktime); use Apache::lonmenu(); +use Apache::lonenc(); use Apache::lonlocal; use HTML::Entities; use Apache::lonhtmlcommon(); use Apache::loncoursedata(); use Apache::lontexconvert(); use Apache::lonclonecourse(); -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); + +# ---------------------------------------------- Designs +use vars qw(%defaultdesign); my $readit; + ## ## Global Variables ## @@ -81,10 +86,6 @@ my %scprtag; my %fe; my %fd; my %fm; my %category_extensions; -# ---------------------------------------------- Designs - -my %designhash; - # ---------------------------------------------- Thesaurus variables # # %Keywords: @@ -150,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=~/^(\w+)\./); - { - 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 { @@ -345,10 +334,12 @@ sub studentbrowser_javascript { return (<<'ENDSTDBRW'); + + function getFormIdByName(formname) { + for (var i=0;i".&mt('Select [_1]',$selecttype).""; + return "".&mt('Select Course').""; } sub check_uncheck_jscript { @@ -461,7 +526,8 @@ function uncheckAll(field) { if (field.length > 0) { for (i = 0; i < field.length; i++) { field[i].checked = false ; - } } else { + } + } else { field.checked = false ; } } @@ -645,8 +711,7 @@ sub help_open_topic { my ($topic, $text, $stayOnPage, $width, $height) = @_; $text = "" if (not defined $text); $stayOnPage = 0 if (not defined $stayOnPage); - if ($env{'browser.interface'} eq 'textual' || - $env{'environment.remote'} eq 'off' ) { + if ($env{'browser.interface'} eq 'textual') { $stayOnPage=1; } $width = 350 if (not defined $width); @@ -738,12 +803,17 @@ ENDOUTPUT # now just updates the help link and generates a blue icon sub help_open_menu { my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height,$text) - = @_; - + = @_; $stayOnPage = 0 if (not defined $stayOnPage); - if ($env{'browser.interface'} eq 'textual' || - $env{'environment.remote'} eq 'off' ) { - $stayOnPage=1; + # formerly only used pop-up help (stayOnPage = 0) + # if environment.remote is on (using remote control UI) + # if ($env{'browser.interface'} eq 'textual' || + # $env{'environment.remote'} eq 'off' ) { + # $stayOnPage=1; + #} + # Now making pop-up help the default even with remote control + if ($env{'browser.interface'} eq 'textual') { + $stayOnPage=1; } my $output; if ($component_help) { @@ -1015,7 +1085,7 @@ sub changable_area { =pod =back - + =head1 Excel and CSV file utility routines =over 4 @@ -1149,7 +1219,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. @@ -1190,41 +1260,19 @@ sub create_text_file { ## Home server \n"; + ($dom eq $defdom ? 'selected="selected" ' : '').'>'.$dom; + if ($showdomdesc) { + if ($dom ne '') { + my $domdesc = &Apache::lonnet::domain($dom,'description'); + if ($domdesc ne '') { + $selectdomain .= ' ('.$domdesc.')'; + } + } + } + $selectdomain .= "\n"; } $selectdomain.=""; return $selectdomain; @@ -1374,30 +1464,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 { - my $domain = shift; - my %library_servers; - foreach my $hostid (keys(%Apache::lonnet::libserv)) { - if ($Apache::lonnet::hostdom{$hostid} eq $domain) { - $library_servers{$hostid} = $Apache::lonnet::hostname{$hostid}; - } - } - return %library_servers; -} - -#------------------------------------------- - -=pod - =item * home_server_option_list($domain) returns a string which contains an