--- loncom/interface/loncommon.pm 2003/11/04 19:01:01 1.142
+++ loncom/interface/loncommon.pm 2004/07/03 19:12:41 1.195
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.142 2003/11/04 19:01:01 albertel Exp $
+# $Id: loncommon.pm,v 1.195 2004/07/03 19:12:41 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,13 +25,6 @@
#
# http://www.lon-capa.org/
#
-# YEAR=2001
-# 2/13-12/7 Guy Albertelli
-# 12/21 Gerd Kortemeyer
-# 12/25,12/28 Gerd Kortemeyer
-# YEAR=2002
-# 1/4 Gerd Kortemeyer
-# 6/24,7/2 H. K. Ng
# Makes a table out of the previous attempts
# Inputs result_from_symbread, user, domain, course_id
@@ -73,16 +66,15 @@ use HTML::Entities;
my $readit;
-=pod
-
-=head1 Global Variables
-
-=cut
+##
+## Global Variables
+##
# ----------------------------------------------- Filetypes/Languages/Copyright
my %language;
my %supported_language;
my %cprtag;
+my %scprtag;
my %fe; my %fd;
my %category_extensions;
@@ -91,50 +83,19 @@ my %category_extensions;
my %designhash;
# ---------------------------------------------- Thesaurus variables
-
-# FIXME: I don't think it's necessary to document these things;
-# they're privately used - Jeremy
-
-=pod
-
-=over 4
-
-=item * %Keywords
-
-A hash used by &keyword to determine if a word is considered a keyword.
-
-=item * $thesaurus_db_file
-
-Scalar containing the full path to the thesaurus database.
-
-=back
-
-=cut
+#
+# %Keywords:
+# A hash used by &keyword to determine if a word is considered a keyword.
+# $thesaurus_db_file
+# Scalar containing the full path to the thesaurus database.
my %Keywords;
my $thesaurus_db_file;
-# ----------------------------------------------------------------------- BEGIN
-
-# FIXME: I don't think this needs to be documented, it prepares
-# private data structures - Jeremy
-=pod
-
-=head1 General Subroutines
-
-=over 4
-
-=item * BEGIN()
-
-Initialize values from language.tab, copyright.tab, filetypes.tab,
-thesaurus.tab, and filecategories.tab.
-
-=back
-
-=cut
-
-# ----------------------------------------------------------------------- BEGIN
-
+#
+# Initialize values from language.tab, copyright.tab, filetypes.tab,
+# thesaurus.tab, and filecategories.tab.
+#
BEGIN {
# Variable initialization
$thesaurus_db_file = $Apache::lonnet::perlvar{'lonTabDir'}."/thesaurus.db";
@@ -142,32 +103,48 @@ BEGIN {
unless ($readit) {
# ------------------------------------------------------------------- languages
{
- my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
- '/language.tab');
- if ($fh) {
- while (<$fh>) {
- next if /^\#/;
- chomp;
- my ($key,$two,$country,$three,$enc,$val,$sup)=(split(/\t/,$_));
- $language{$key}=$val.' - '.$enc;
- if ($sup) {
- $supported_language{$key}=$sup;
- }
- }
- }
+ my $langtabfile = $Apache::lonnet::perlvar{'lonTabDir'}.
+ '/language.tab';
+ if ( open(my $fh,"<$langtabfile") ) {
+ while (<$fh>) {
+ next if /^\#/;
+ chomp;
+ my ($key,$two,$country,$three,$enc,$val,$sup)=(split(/\t/,$_));
+ $language{$key}=$val.' - '.$enc;
+ if ($sup) {
+ $supported_language{$key}=$sup;
+ }
+ }
+ close($fh);
+ }
}
# ------------------------------------------------------------------ copyrights
{
- my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonIncludes'}.
- '/copyright.tab');
- if ($fh) {
- while (<$fh>) {
- next if /^\#/;
- chomp;
- my ($key,$val)=(split(/\s+/,$_,2));
- $cprtag{$key}=$val;
- }
- }
+ my $copyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}.
+ '/copyright.tab';
+ if ( open (my $fh,"<$copyrightfile") ) {
+ while (<$fh>) {
+ next if /^\#/;
+ chomp;
+ my ($key,$val)=(split(/\s+/,$_,2));
+ $cprtag{$key}=$val;
+ }
+ close($fh);
+ }
+ }
+# ------------------------------------------------------------------ source copyrights
+ {
+ my $sourcecopyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}.
+ '/source_copyright.tab';
+ if ( open (my $fh,"<$sourcecopyrightfile") ) {
+ while (<$fh>) {
+ next if /^\#/;
+ chomp;
+ my ($key,$val)=(split(/\s+/,$_,2));
+ $scprtag{$key}=$val;
+ }
+ close($fh);
+ }
}
# -------------------------------------------------------------- domain designs
@@ -178,15 +155,16 @@ BEGIN {
while ($filename=readdir(DIR)) {
my ($domain)=($filename=~/^(\w+)\./);
{
- my $fh=Apache::File->new($designdir.'/'.$filename);
- if ($fh) {
- while (<$fh>) {
- next if /^\#/;
- chomp;
- my ($key,$val)=(split(/\=/,$_));
- if ($val) { $designhash{$domain.'.'.$key}=$val; }
- }
- }
+ my $designfile = $designdir.'/'.$filename;
+ if ( open (my $fh,"<$designfile") ) {
+ while (<$fh>) {
+ next if /^\#/;
+ chomp;
+ my ($key,$val)=(split(/\=/,$_));
+ if ($val) { $designhash{$domain.'.'.$key}=$val; }
+ }
+ close($fh);
+ }
}
}
@@ -195,32 +173,35 @@ BEGIN {
# ------------------------------------------------------------- file categories
{
- my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
- '/filecategories.tab');
- if ($fh) {
- while (<$fh>) {
- next if /^\#/;
- chomp;
- my ($extension,$category)=(split(/\s+/,$_,2));
- push @{$category_extensions{lc($category)}},$extension;
- }
- }
+ my $categoryfile = $Apache::lonnet::perlvar{'lonTabDir'}.
+ '/filecategories.tab';
+ if ( open (my $fh,"<$categoryfile") ) {
+ while (<$fh>) {
+ next if /^\#/;
+ chomp;
+ my ($extension,$category)=(split(/\s+/,$_,2));
+ push @{$category_extensions{lc($category)}},$extension;
+ }
+ close($fh);
+ }
+
}
# ------------------------------------------------------------------ file types
{
- my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
- '/filetypes.tab');
- if ($fh) {
+ my $typesfile = $Apache::lonnet::perlvar{'lonTabDir'}.
+ '/filetypes.tab';
+ if ( open (my $fh,"<$typesfile") ) {
while (<$fh>) {
- next if (/^\#/);
- chomp;
- my ($ending,$emb,$descr)=split(/\s+/,$_,3);
- if ($descr ne '') {
- $fe{$ending}=lc($emb);
- $fd{$ending}=$descr;
- }
- }
- }
+ next if (/^\#/);
+ chomp;
+ my ($ending,$emb,$descr)=split(/\s+/,$_,3);
+ if ($descr ne '') {
+ $fe{$ending}=lc($emb);
+ $fd{$ending}=$descr;
+ }
+ }
+ close($fh);
+ }
}
&Apache::lonnet::logthis(
"INFO: Read file types");
@@ -246,8 +227,6 @@ containing javascript with two functions
C. Returned string does not contain EscriptE
tags.
-=over 4
-
=item * openbrowser(formname,elementname,only,omit) [javascript]
inputs: formname, elementname, only, omit
@@ -256,10 +235,10 @@ formname and elementname indicate the na
the element that the results of the browsing selection are to be placed in.
Specifying 'only' will restrict the browser to displaying only files
-with the given extension. Can be a comma seperated list.
+with the given extension. Can be a comma separated list.
Specifying 'omit' will restrict the browser to NOT displaying files
-with the given extension. Can be a comma seperated list.
+with the given extension. Can be a comma separated list.
=item * opensearcher(formname, elementname) [javascript]
@@ -268,15 +247,14 @@ Inputs: formname, elementname
formname and elementname specify the name of the html form and the name
of the element the selection from the search results will be placed in.
-=back
-
=cut
sub browser_and_searcher_javascript {
+ my $resurl=&lastresurl();
return < $resurl});
+ &Apache::lonnet::appenv('environment.lastresurl' => $resurl);
+ return 1;
+}
+
sub studentbrowser_javascript {
unless (
(($ENV{'request.course.id'}) &&
@@ -373,7 +368,7 @@ sub coursebrowser_javascript {
return (<
var stdeditbrowser;
- function opencrsbrowser(formname,uname,udom) {
+ function opencrsbrowser(formname,uname,udom,desc) {
var url = '/adm/pickcourse?';
var filter;
if (filter != null) {
@@ -388,7 +383,8 @@ sub coursebrowser_javascript {
}
}
url += 'form=' + formname + '&cnumelement='+uname+
- '&cdomelement='+udom;
+ '&cdomelement='+udom+
+ '&cnameelement='+desc;
var title = 'Course_Browser';
var options = 'scrollbars=1,resizable=1,menubar=0';
options += ',width=700,height=600';
@@ -400,9 +396,9 @@ ENDSTDBRW
}
sub selectcourse_link {
- my ($form,$unameele,$udomele)=@_;
+ my ($form,$unameele,$udomele,$desc)=@_;
return "".&mt('Select Course')."";
+ '","'.$udomele.'","'.$desc.'");'."'>".&mt('Select Course')."";
}
=pod
@@ -521,6 +517,7 @@ function select1_changed() {
// in with the nuclear
for (i=0;i
+
ENDTEMPLATE
if ($text ne '') { $template.='' };
return $template;
@@ -637,15 +637,156 @@ sub helpLatexCheatsheet {
.'';
}
+sub help_open_menu {
+ my ($color,$topic,$component_help,$function,$faq,$bug,$stayOnPage,$width,$height,$text) = @_;
+ $text = "" if (not defined $text);
+ $stayOnPage = 0 if (not defined $stayOnPage);
+ if ($ENV{'browser.interface'} eq 'textual' ||
+ $ENV{'environment.remote'} eq 'off' ) {
+ $stayOnPage=1;
+ }
+ $width = 620 if (not defined $width);
+ $height = 600 if (not defined $height);
+ my $link='';
+ my $title = &mt('Choose your help');
+ my $origurl = $ENV{'REQUEST_URI'};
+ my $timestamp = time;
+ foreach (\$color,\$function,\$topic,\$component_help,\$faq,\$bug,\$origurl) {
+ $$_ = &Apache::lonnet::escape($$_);
+ }
+
+ if (!$stayOnPage) {
+ $link = "javascript:helpMenu('open')";
+ } else {
+ $link = "javascript:helpMenu('display')";
+ }
+ my $banner_link = "/adm/helpmenu?page=banner&color=$color&function=$function&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp";
+ my $details_link = "/adm/helpmenu?page=body&color=$color&function=$function&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp";
+ my $template .= <<"ENDTEMPLATE";
+
+
+ENDTEMPLATE
+ return $template;
+}
+
+sub help_open_bug {
+ my ($topic, $text, $stayOnPage, $width, $height) = @_;
+ unless ($ENV{'user.adv'}) { return ''; }
+ unless ($Apache::lonnet::perlvar{'BugzillaHost'}) { return ''; }
+ $text = "" if (not defined $text);
+ $stayOnPage = 0 if (not defined $stayOnPage);
+ if ($ENV{'browser.interface'} eq 'textual' ||
+ $ENV{'environment.remote'} eq 'off' ) {
+ $stayOnPage=1;
+ }
+ $width = 600 if (not defined $width);
+ $height = 600 if (not defined $height);
+
+ $topic=~s/\W+/\+/g;
+ my $link='';
+ my $template='';
+ my $url=$Apache::lonnet::perlvar{'BugzillaHost'}.'enter_bug.cgi?product=LON-CAPA&bug_file_loc='.
+ &Apache::lonnet::escape($ENV{'REQUEST_URI'}).'&component='.$topic;
+ if (!$stayOnPage)
+ {
+ $link = "javascript:void(open('$url', 'Bugzilla', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height,resizable=yes'))";
+ }
+ else
+ {
+ $link = $url;
+ }
+ # Add the text
+ if ($text ne "")
+ {
+ $template .=
+ "
".
+ "
$text";
+ }
+
+ # Add the graphic
+ my $title = &mt('Report a Bug');
+ $template .= <<"ENDTEMPLATE";
+
+ENDTEMPLATE
+ if ($text ne '') { $template.='
' };
+ return $template;
+
+}
+
+sub help_open_faq {
+ my ($topic, $text, $stayOnPage, $width, $height) = @_;
+ unless ($ENV{'user.adv'}) { return ''; }
+ unless ($Apache::lonnet::perlvar{'FAQHost'}) { return ''; }
+ $text = "" if (not defined $text);
+ $stayOnPage = 0 if (not defined $stayOnPage);
+ if ($ENV{'browser.interface'} eq 'textual' ||
+ $ENV{'environment.remote'} eq 'off' ) {
+ $stayOnPage=1;
+ }
+ $width = 350 if (not defined $width);
+ $height = 400 if (not defined $height);
+
+ $topic=~s/\W+/\+/g;
+ my $link='';
+ my $template='';
+ my $url=$Apache::lonnet::perlvar{'FAQHost'}.'/fom/cache/'.$topic.'.html';
+ if (!$stayOnPage)
+ {
+ $link = "javascript:void(open('$url', 'FAQ-O-Matic', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height,resizable=yes'))";
+ }
+ else
+ {
+ $link = $url;
+ }
+
+ # Add the text
+ if ($text ne "")
+ {
+ $template .=
+ "
".
+ "
$text";
+ }
+
+ # Add the graphic
+ my $title = &mt('View the FAQ');
+ $template .= <<"ENDTEMPLATE";
+
+ENDTEMPLATE
+ if ($text ne '') { $template.='
' };
+ return $template;
+
+}
+
+###############################################################
+###############################################################
+
=pod
=item * csv_translate($text)
-Translate $text to allow it to be output as a 'comma seperated values'
+Translate $text to allow it to be output as a 'comma separated values'
format.
=cut
+###############################################################
+###############################################################
sub csv_translate {
my $text = shift;
$text =~ s/\"/\"\"/g;
@@ -653,6 +794,60 @@ sub csv_translate {
return $text;
}
+
+###############################################################
+###############################################################
+
+=pod
+
+=item * define_excel_formats
+
+Define some commonly used Excel cell formats.
+
+Currently supported formats:
+
+=over 4
+
+=item header
+
+=item bold
+
+=item h1
+
+=item h2
+
+=item h3
+
+=item date
+
+=back
+
+Inputs: $workbook
+
+Returns: $format, a hash reference.
+
+=cut
+
+###############################################################
+###############################################################
+sub define_excel_formats {
+ my ($workbook) = @_;
+ my $format;
+ $format->{'header'} = $workbook->add_format(bold => 1,
+ bottom => 1,
+ align => 'center');
+ $format->{'bold'} = $workbook->add_format(bold=>1);
+ $format->{'h1'} = $workbook->add_format(bold=>1, size=>18);
+ $format->{'h2'} = $workbook->add_format(bold=>1, size=>16);
+ $format->{'h3'} = $workbook->add_format(bold=>1, size=>14);
+ $format->{'date'} = $workbook->add_format(num_format=>
+ 'mmm d yyyy hh:mm AM/PM');
+ return $format;
+}
+
+###############################################################
+###############################################################
+
=pod
=item * change_content_javascript():
@@ -761,11 +956,46 @@ sub get_domains {
my @domains;
my %seen;
foreach (sort values(%Apache::lonnet::hostdom)) {
- push (@domains,$_) unless $seen{$_}++;
+ push (@domains,$_) unless $seen{$_}++;
}
return @domains;
}
+# ------------------------------------------
+
+sub domain_select {
+ my ($name,$value,$multiple)=@_;
+ my %domains=map {
+ $_ => $_.' '.$Apache::lonnet::domaindescription{$_}
+ } &get_domains;
+ if ($multiple) {
+ $domains{''}=&mt('Any domain');
+ return &multiple_select_form($name,$value,4,%domains);
+ } else {
+ return &select_form($name,$value,%domains);
+ }
+}
+
+sub multiple_select_form {
+ my ($name,$value,$size,%hash)=@_;
+ my %selected = map { $_ => 1 } ref($value)?@{$value}:($value);
+ my $output='';
+ if (! defined($size)) {
+ $size = 4;
+ if (scalar(keys(%hash))<4) {
+ $size = scalar(keys(%hash));
+ }
+ }
+ $output.="\n\n";
+ return $output;
+}
+
#-------------------------------------------
=pod
@@ -797,6 +1027,42 @@ sub select_form {
return $selectform;
}
+sub gradeleveldescription {
+ my $gradelevel=shift;
+ my %gradelevels=(0 => 'Not specified',
+ 1 => 'Grade 1',
+ 2 => 'Grade 2',
+ 3 => 'Grade 3',
+ 4 => 'Grade 4',
+ 5 => 'Grade 5',
+ 6 => 'Grade 6',
+ 7 => 'Grade 7',
+ 8 => 'Grade 8',
+ 9 => 'Grade 9',
+ 10 => 'Grade 10',
+ 11 => 'Grade 11',
+ 12 => 'Grade 12',
+ 13 => 'Grade 13',
+ 14 => '100 Level',
+ 15 => '200 Level',
+ 16 => '300 Level',
+ 17 => '400 Level',
+ 18 => 'Graduate Level');
+ return &mt($gradelevels{$gradelevel});
+}
+
+sub select_level_form {
+ my ($deflevel,$name)=@_;
+ unless ($deflevel) { $deflevel=0; }
+ my $selectform = "";
+ return $selectform;
+}
#-------------------------------------------
@@ -913,6 +1179,8 @@ Outputs:
=back
+=back
+
=cut
###############################################################
@@ -951,12 +1219,6 @@ sub decode_user_agent {
$clientunicode,$clientos,);
}
-=pod
-
-=back
-
-=cut
-
###############################################################
## Authentication changing form generation subroutines ##
###############################################################
@@ -997,6 +1259,8 @@ See loncreateuser.pm for invocation and
=back
+=back
+
=cut
#-------------------------------------------
@@ -1024,10 +1288,30 @@ END
$Javascript_toUpperCase = "";
}
+ my $radioval = "'nochange'";
+ if (exists($in{'curr_authtype'}) &&
+ defined($in{'curr_authtype'}) &&
+ $in{'curr_authtype'} ne '') {
+ $radioval = "'$in{'curr_authtype'}arg'";
+ }
+ my $argfield = 'null';
+ if ( grep/^mode$/,(keys %in) ) {
+ if ($in{'mode'} eq 'modifycourse') {
+ if ( grep/^curr_authtype$/,(keys %in) ) {
+ $radioval = "'$in{'curr_authtype'}'";
+ }
+ if ( grep/^curr_autharg$/,(keys %in) ) {
+ unless ($in{'curr_autharg'} eq '') {
+ $argfield = "'$in{'curr_autharg'}'";
+ }
+ }
+ }
+ }
+
$result.=<<"END";
var current = new Object();
-current.radiovalue = 'nochange';
-current.argfield = null;
+current.radiovalue = $radioval;
+current.argfield = $argfield;
function changed_radio(choice,currentform) {
var choicearg = choice + 'arg';
@@ -1087,10 +1371,10 @@ END
sub authform_authorwarning{
my $result='';
- $result=<<"END";
-As a general rule, only authors or co-authors should be filesystem
-authenticated (which allows access to the server filesystem).
-END
+ $result=''.
+ &mt('As a general rule, only authors or co-authors should be '.
+ 'filesystem authenticated '.
+ '(which allows access to the server filesystem).')."\n";
return $result;
}
@@ -1100,12 +1384,10 @@ sub authform_nochange{
kerb_def_dom => 'MSU.EDU',
@_,
);
- my $result='';
- $result.=<<"END";
-
-Do not change login data
-END
+ my $result = &mt('[_1] Do not change login data',
+ '');
return $result;
}
@@ -1116,24 +1398,35 @@ sub authform_kerberos{
kerb_def_auth => 'krb4',
@_,
);
- my $result='';
- my $check4;
- my $check5;
+ my ($check4,$check5,$krbarg);
if ($in{'kerb_def_auth'} eq 'krb5') {
$check5 = " checked=\"on\"";
} else {
$check4 = " checked=\"on\"";
}
- $result.=<<"END";
-
-Kerberos authenticated with domain
-
-Version 4
-Version 5
-END
+ $krbarg = $in{'kerb_def_dom'};
+
+ my $krbcheck = "";
+ if ( grep/^curr_authtype$/,(keys %in) ) {
+ if ($in{'curr_authtype'} =~ m/^krb/) {
+ $krbcheck = " checked=\"on\"";
+ if ( grep/^curr_autharg$/,(keys %in) ) {
+ $krbarg = $in{'curr_autharg'};
+ }
+ }
+ }
+
+ my $jscall = "javascript:changed_radio('krb',$in{'formname'});";
+ my $result .= &mt
+ ('[_1] Kerberos authenticated with domain [_2] '.
+ '[_3] Version 4 [_4] Version 5',
+ '',
+ '',
+ '',
+ '');
return $result;
}
@@ -1143,15 +1436,25 @@ sub authform_internal{
kerb_def_dom => 'MSU.EDU',
@_,
);
- my $result='';
- $result.=<<"END";
-
-Internally authenticated (with initial password
-)
-END
+
+ my $intcheck = "";
+ my $intarg = 'value=""';
+ if ( grep/^curr_authtype$/,(keys %args) ) {
+ if ($args{'curr_authtype'} eq 'int') {
+ $intcheck = " checked=\"on\"";
+ if ( grep/^curr_autharg$/,(keys %args) ) {
+ $intarg = "value=\"$args{'curr_autharg'}\"";
+ }
+ }
+ }
+
+ my $jscall = "javascript:changed_radio('int',$args{'formname'});";
+ my $result.=&mt
+ ('[_1] Internally authenticated (with initial password [_2])',
+ '',
+ '');
return $result;
}
@@ -1161,15 +1464,24 @@ sub authform_local{
kerb_def_dom => 'MSU.EDU',
@_,
);
- my $result='';
- $result.=<<"END";
-
-Local Authentication with argument
-
-END
+
+ my $loccheck = "";
+ my $locarg = 'value=""';
+ if ( grep/^curr_authtype$/,(keys %in) ) {
+ if ($in{'curr_authtype'} eq 'loc') {
+ $loccheck = " checked=\"on\"";
+ if ( grep/^curr_autharg$/,(keys %in) ) {
+ $locarg = "value=\"$in{'curr_autharg'}\"";
+ }
+ }
+ }
+
+ my $jscall = "javascript:changed_radio('loc',$in{'formname'});";
+ my $result.=&mt('[_1] Local Authentication with argument [_2]',
+ '',
+ '');
return $result;
}
@@ -1179,24 +1491,16 @@ sub authform_filesystem{
kerb_def_dom => 'MSU.EDU',
@_,
);
- my $result='';
- $result.=<<"END";
-
-Filesystem authenticated (with initial password
-)
-END
+ my $jscall = "javascript:changed_radio('fsys',$in{'formname'});";
+ my $result.= &mt
+ ('[_1] Filesystem Authenticated (with initial password [_2])',
+ '',
+ '');
return $result;
}
-=pod
-
-=back
-
-=cut
-
###############################################################
## Get Authentication Defaults for Domain ##
###############################################################
@@ -1351,7 +1655,7 @@ sub keyword {
=item * get_related_words
-Look up a word in the thesaurus. Takes a scalar arguement and returns
+Look up a word in the thesaurus. Takes a scalar argument and returns
an array of words. If the keyword is not in the thesaurus, an empty array
will be returned. The order of the words returned is determined by the
database which holds them.
@@ -1416,6 +1720,7 @@ sub plainname {
$names{'lastname'}.' '.$names{'generation'};
$name=~s/\s+$//;
$name=~s/\s+/ /g;
+ if ($name !~ /\S/) { $name=$uname.'@'.$udom; }
return $name;
}
@@ -1487,8 +1792,9 @@ sub noteswrapper {
# ------------------------------------------------------------- Aboutme Wrapper
sub aboutmewrapper {
- my ($link,$username,$domain)=@_;
- return "$link";
+ my ($link,$username,$domain,$target)=@_;
+ return "$link";
}
# ------------------------------------------------------------ Syllabus Wrapper
@@ -1535,6 +1841,16 @@ sub languagedescription {
($supported_language{$code}?' ('.&mt('interface available').')':'');
}
+sub plainlanguagedescription {
+ my $code=shift;
+ return $language{$code};
+}
+
+sub supportedlanguagecode {
+ my $code=shift;
+ return $supported_language{$code};
+}
+
=pod
=item * copyrightids()
@@ -1556,7 +1872,28 @@ returns description of a specified copyr
=cut
sub copyrightdescription {
- return $cprtag{shift(@_)};
+ return &mt($cprtag{shift(@_)});
+}
+=item * source_copyrightids()
+
+returns list of all source copyrights
+
+=cut
+
+sub source_copyrightids {
+ return sort(keys(%scprtag));
+}
+
+=pod
+
+=item * source_copyrightdescription()
+
+returns description of a specified source copyright id
+
+=cut
+
+sub source_copyrightdescription {
+ return &mt($scprtag{shift(@_)});
}
=pod
@@ -1596,6 +1933,14 @@ sub fileembstyle {
return $fe{lc(shift(@_))};
}
+
+sub filecategoryselect {
+ my ($name,$value)=@_;
+ return &select_form($value,$name,
+ '' => &mt('Any category'),
+ map { $_,$_ } sort(keys(%category_extensions)));
+}
+
=pod
=item * filedescription()
@@ -1605,7 +1950,9 @@ returns description for a specified file
=cut
sub filedescription {
- return $fd{lc(shift(@_))};
+ my $file_description = $fd{lc(shift())};
+ $file_description =~ s:([\[\]]):~$1:g;
+ return &mt($file_description);
}
=pod
@@ -1619,7 +1966,9 @@ extra formatting
sub filedescriptionex {
my $ex=shift;
- return '.'.$ex.' '.$fd{lc($ex)};
+ my $file_description = $fd{lc($ex)};
+ $file_description =~ s:([\[\]]):~$1:g;
+ return '.'.$ex.' '.&mt($file_description);
}
# End of .tab access
@@ -1654,13 +2003,13 @@ sub display_languages {
sub preferred_languages {
my @languages=();
- if ($ENV{'environment.languages'}) {
- @languages=split(/\s*(\,|\;|\:)\s*/,$ENV{'environment.languages'});
- }
if ($ENV{'course.'.$ENV{'request.course.id'}.'.languages'}) {
@languages=(@languages,split(/\s*(\,|\;|\:)\s*/,
$ENV{'course.'.$ENV{'request.course.id'}.'.languages'}));
}
+ if ($ENV{'environment.languages'}) {
+ @languages=split(/\s*(\,|\;|\:)\s*/,$ENV{'environment.languages'});
+ }
my $browser=(split(/\;/,$ENV{'HTTP_ACCEPT_LANGUAGE'}))[0];
if ($browser) {
@languages=(@languages,split(/\s*(\,|\;|\:)\s*/,$browser));
@@ -1840,22 +2189,19 @@ show a snapshot of what student was look
=cut
sub get_student_view {
- my ($symb,$username,$domain,$courseid,$target) = @_;
+ my ($symb,$username,$domain,$courseid,$target,$moreenv) = @_;
my ($map,$id,$feedurl) = &Apache::lonnet::decode_symb($symb);
- my (%old,%moreenv);
+ my (%form);
my @elements=('symb','courseid','domain','username');
foreach my $element (@elements) {
- $old{$element}=$ENV{'form.grade_'.$element};
- $moreenv{'form.grade_'.$element}=eval '$'.$element #'
+ $form{'grade_'.$element}=eval '$'.$element #'
}
- if ($target eq 'tex') {$moreenv{'form.grade_target'} = 'tex';}
- &Apache::lonnet::appenv(%moreenv);
- $feedurl=&Apache::lonnet::clutter($feedurl);
- my $userview=&Apache::lonnet::ssi_body($feedurl);
- &Apache::lonnet::delenv('form.grade_');
- foreach my $element (@elements) {
- $ENV{'form.grade_'.$element}=$old{$element};
+ if (defined($moreenv)) {
+ %form=(%form,%{$moreenv});
}
+ if ($target eq 'tex') {$form{'grade_target'} = 'tex';}
+ $feedurl=&Apache::lonnet::clutter($feedurl);
+ my $userview=&Apache::lonnet::ssi_body($feedurl,%form);
$userview=~s/\]*\>//gi;
$userview=~s/\<\/body\>//gi;
$userview=~s/\//gi;
@@ -1878,19 +2224,14 @@ show a snapshot of how student was answe
sub get_student_answers {
my ($symb,$username,$domain,$courseid,%form) = @_;
my ($map,$id,$feedurl) = &Apache::lonnet::decode_symb($symb);
- my (%old,%moreenv);
+ my (%moreenv);
my @elements=('symb','courseid','domain','username');
foreach my $element (@elements) {
- $old{$element}=$ENV{'form.grade_'.$element};
- $moreenv{'form.grade_'.$element}=eval '$'.$element #'
- }
- $moreenv{'form.grade_target'}='answer';
- &Apache::lonnet::appenv(%moreenv);
- my $userview=&Apache::lonnet::ssi('/res/'.$feedurl,%form);
- &Apache::lonnet::delenv('form.grade_');
- foreach my $element (@elements) {
- $ENV{'form.grade_'.$element}=$old{$element};
+ $moreenv{'grade_'.$element}=eval '$'.$element #'
}
+ $moreenv{'grade_target'}='answer';
+ %moreenv=(%form,%moreenv);
+ my $userview=&Apache::lonnet::ssi('/res/'.$feedurl,%moreenv);
return $userview;
}
@@ -1947,21 +2288,6 @@ sub maketime {
$th{'day'},$th{'month'}-1,$th{'year'}-1900,0,0,$th{'dlsav'}));
}
-
-#########################################
-#
-# Retro-fixing of un-backward-compatible time format
-
-sub unsqltime {
- my $timestamp=shift;
- if ($timestamp=~/^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/) {
- $timestamp=&maketime(
- 'year'=>$1,'month'=>$2,'day'=>$3,
- 'hours'=>$4,'minutes'=>$5,'seconds'=>$6);
- }
- return $timestamp;
-}
-
#########################################
sub findallcourses {
@@ -2033,7 +2359,7 @@ sub domainlogo {
my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
return '';
+ '/adm/lonDomLogos/'.$domain.'.gif" alt="'.$domain.'" />';
} elsif(exists($Apache::lonnet::domaindescription{$domain})) {
return $Apache::lonnet::domaindescription{$domain};
} else {
@@ -2121,19 +2447,7 @@ other decorations will be returned.
sub bodytag {
my ($title,$function,$addentries,$bodyonly,$domain,$forcereg)=@_;
$title=&mt($title);
- unless ($function) {
- $function='student';
- if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
- $function='coordinator';
- }
- if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
- $function='admin';
- }
- if (($ENV{'request.role'}=~/^(au|ca)/) ||
- ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
- $function='author';
- }
- }
+ $function = &get_users_function() if (!$function);
my $img=&designparm($function.'.img',$domain);
my $pgbg=&designparm($function.'.pgbg',$domain);
my $tabbg=&designparm($function.'.tabbg',$domain);
@@ -2144,8 +2458,9 @@ sub bodytag {
my $sidebg=&designparm($function.'.sidebg',$domain);
# Accessibility font enhance
unless ($addentries) { $addentries=''; }
+ my $addstyle='';
if ($ENV{'browser.fontenhance'} eq 'on') {
- $addentries.=' style="font-size: x-large"';
+ $addstyle=' font-size: x-large;';
}
# role and realm
my ($role,$realm)
@@ -2163,11 +2478,15 @@ sub bodytag {
if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
# construct main body tag
my $bodytag = <
+h1, h2, h3, th { font-family: Arial, Helvetica, sans-serif }
+a:focus { color: red; background: yellow }
+
+style="margin-top: 0px;$addstyle" $addentries>
END
my $upperleft='';
+ $lonhttpdPort.$img.'" alt="'.$function.'" />';
if ($bodyonly) {
return $bodytag;
} elsif ($ENV{'browser.interface'} eq 'textual') {
@@ -2179,7 +2498,7 @@ END
# No Remote
return $bodytag.&Apache::lonmenu::menubuttons($forcereg,'web',
$forcereg).
- '
');
foreach my $hash (\%sone,\%stwo,\%sthree) {
$r->print('
');
@@ -2561,32 +2958,42 @@ sub csv_print_samples {
$r->print('
'."\n");
}
+######################################################
+######################################################
+
=pod
=item * csv_print_select_table($r,$records,$d)
Prints a table to create associations between values and table columns.
+
$r is an Apache Request ref,
$records is an arrayref from &Apache::loncommon::upfile_record_sep,
-$d is an array of 2 element arrays (internal name, displayed name)
+$d is an array of 2 element arrays (internal name, displayed name,defaultcol)
=cut
+######################################################
+######################################################
sub csv_print_select_table {
my ($r,$records,$d) = @_;
my $i=0;my %sone;
%sone=&record_sep($$records[0]);
- $r->print('Associate columns with student attributes.'."\n".
- '
Attribute
Column
'."\n");
+ $r->print(&mt('Associate columns with student attributes.')."\n".
+ '
'.
+ '
'.&mt('Attribute').'
'.
+ '
'.&mt('Column').'
'."\n");
foreach (@$d) {
- my ($value,$display)=@{ $_ };
+ my ($value,$display,$defaultcol)=@{ $_ };
$r->print('
'.$display.'
');
$r->print('
'."\n");
$i++;
@@ -2595,6 +3002,9 @@ sub csv_print_select_table {
return $i;
}
+######################################################
+######################################################
+
=pod
=item * csv_samples_select_table($r,$records,$d)
@@ -2607,22 +3017,27 @@ $d is an array of 2 element arrays (inte
=cut
+######################################################
+######################################################
sub csv_samples_select_table {
my ($r,$records,$d) = @_;
my %sone; my %stwo; my %sthree;
my $i=0;
-
- $r->print('
Field
Samples
');
+ #
+ $r->print('
'.
+ &mt('Field').'
'.&mt('Samples').'
');
%sone=&record_sep($$records[0]);
if (defined($$records[1])) {%stwo=&record_sep($$records[1]);}
if (defined($$records[2])) {%sthree=&record_sep($$records[2]);}
-
+ #
foreach (sort keys %sone) {
- $r->print('