--- loncom/interface/loncommon.pm 2004/03/19 03:47:09 1.187
+++ loncom/interface/loncommon.pm 2004/07/12 17:02:07 1.198
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.187 2004/03/19 03:47:09 albertel Exp $
+# $Id: loncommon.pm,v 1.198 2004/07/12 17:02:07 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -74,6 +74,7 @@ my $readit;
my %language;
my %supported_language;
my %cprtag;
+my %scprtag;
my %fe; my %fd;
my %category_extensions;
@@ -131,6 +132,20 @@ BEGIN {
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
@@ -622,6 +637,61 @@ 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&stayonpage=$stayOnPage";
+ 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;
+ if ($text ne "") {
+ $template .=
+ "
".
+ "$text";
+ }
+ $template .= <<"ENDTEMPLATE";
+
+
+ENDTEMPLATE
+ if ($text ne '') { $template.=' |
' };
+ return $template;
+}
+
sub help_open_bug {
my ($topic, $text, $stayOnPage, $width, $height) = @_;
unless ($ENV{'user.adv'}) { return ''; }
@@ -907,21 +977,27 @@ sub domain_select {
} &get_domains;
if ($multiple) {
$domains{''}=&mt('Any domain');
- return &multiple_select_form($name,$value,%domains);
+ return &multiple_select_form($name,$value,4,%domains);
} else {
return &select_form($name,$value,%domains);
}
}
sub multiple_select_form {
- my ($name,$value,%hash)=@_;
+ my ($name,$value,$size,%hash)=@_;
my %selected = map { $_ => 1 } ref($value)?@{$value}:($value);
my $output='';
- my $size =(scalar keys %hash<4?scalar keys %hash:4);
+ if (! defined($size)) {
+ $size = 4;
+ if (scalar(keys(%hash))<4) {
+ $size = scalar(keys(%hash));
+ }
+ }
$output.="\n\n";
return $output;
@@ -1651,6 +1727,7 @@ sub plainname {
$names{'lastname'}.' '.$names{'generation'};
$name=~s/\s+$//;
$name=~s/\s+/ /g;
+ if ($name !~ /\S/) { $name=$uname.'@'.$udom; }
return $name;
}
@@ -1807,6 +1884,30 @@ sub copyrightdescription {
=pod
+=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
+
=item * filecategories()
returns list of all file categories
@@ -1845,7 +1946,7 @@ sub fileembstyle {
sub filecategoryselect {
my ($name,$value)=@_;
- return &select_form($name,$value,
+ return &select_form($value,$name,
'' => &mt('Any category'),
map { $_,$_ } sort(keys(%category_extensions)));
}
@@ -1859,7 +1960,9 @@ returns description for a specified file
=cut
sub filedescription {
- return &mt($fd{lc(shift(@_))});
+ my $file_description = $fd{lc(shift())};
+ $file_description =~ s:([\[\]]):~$1:g;
+ return &mt($file_description);
}
=pod
@@ -1873,7 +1976,9 @@ extra formatting
sub filedescriptionex {
my $ex=shift;
- return '.'.$ex.' '.&mt($fd{lc($ex)});
+ my $file_description = $fd{lc($ex)};
+ $file_description =~ s:([\[\]]):~$1:g;
+ return '.'.$ex.' '.&mt($file_description);
}
# End of .tab access