--- loncom/interface/loncommon.pm 2003/04/03 21:32:23 1.94
+++ loncom/interface/loncommon.pm 2003/06/24 22:16:32 1.107
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.94 2003/04/03 21:32:23 www Exp $
+# $Id: loncommon.pm,v 1.107 2003/06/24 22:16:32 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -79,7 +79,7 @@ use strict;
use Apache::lonnet();
use GDBM_File;
use POSIX qw(strftime mktime);
-use Apache::Constants qw(:common);
+use Apache::Constants qw(:common :http :methods);
use Apache::lonmsg();
use Apache::lonmenu();
my $readit;
@@ -151,8 +151,8 @@ BEGIN {
while (<$fh>) {
next if /^\#/;
chomp;
- my ($key,$val)=(split(/\s+/,$_,2));
- $language{$key}=$val;
+ my ($key,$two,$country,$three,$enc,$val)=(split(/\t/,$_));
+ $language{$key}=$val.' - '.$enc;
}
}
}
@@ -329,7 +329,7 @@ sub studentbrowser_javascript {
}
url += 'form=' + formname + '&unameelement='+uname+
'&udomelement='+udom;
- var title = 'Student Browser';
+ var title = 'Student_Browser';
var options = 'scrollbars=1,resizable=1,menubar=0';
options += ',width=700,height=600';
stdeditbrowser = open(url,title,options,'1');
@@ -363,7 +363,7 @@ sub coursebrowser_javascript {
}
url += 'form=' + formname + '&cnumelement='+uname+
'&cdomelement='+udom;
- var title = 'Course Browser';
+ var title = 'Course_Browser';
var options = 'scrollbars=1,resizable=1,menubar=0';
options += ',width=700,height=600';
stdeditbrowser = open(url,title,options,'1');
@@ -586,6 +586,26 @@ ENDTEMPLATE
}
+# This is a quicky function for Latex cheatsheet editing, since it
+# appears in at least four places
+sub helpLatexCheatsheet {
+ my $other = shift;
+ my $addOther = '';
+ if ($other) {
+ $addOther = Apache::loncommon::help_open_topic($other, shift,
+ undef, undef, 600) .
+ '
';
+ }
+ return ''.
+ $addOther .
+ &Apache::loncommon::help_open_topic("Greek_Symbols",'Greek Symbols',
+ undef,undef,600)
+ .' | '.
+ &Apache::loncommon::help_open_topic("Other_Symbols",'Other Symbols',
+ undef,undef,600)
+ .' | ';
+}
+
=pod
=item csv_translate($text)
@@ -1347,6 +1367,32 @@ sub languagedescription {
return $language{shift(@_)};
}
+# ----------------------------------------------------------- Display Languages
+# returns a hash with all desired display languages
+#
+
+sub display_languages {
+ my %languages=();
+ if ($ENV{'environment.languages'}) {
+ foreach (split(/\s*(\,|\;|\:)\s*/,$ENV{'environment.languages'})) {
+ $languages{$_}=1;
+ }
+ }
+ if ($ENV{'course.'.$ENV{'request.course.id'}.'.languages'}) {
+ foreach (split(/\s*(\,|\;|\:)\s*/,
+ $ENV{'course.'.$ENV{'request.course.id'}.'.languages'})) {
+ $languages{$_}=1;
+ }
+ }
+ &get_unprocessed_cgi($ENV{'QUERY_STRING'},['displaylanguage']);
+ if ($ENV{'form.displaylanguage'}) {
+ foreach (split(/\s*(\,|\;|\:)\s*/,$ENV{'form.displaylanguage'})) {
+ $languages{$_}=1;
+ }
+ }
+ return %languages;
+}
+
# --------------------------------------------------------------- Copyright IDs
sub copyrightids {
return sort(keys(%cprtag));
@@ -1465,6 +1511,41 @@ sub get_previous_attempt {
}
}
+sub relative_to_absolute {
+ my ($url,$output)=@_;
+ my $parser=HTML::TokeParser->new(\$output);
+ my $token;
+ my $thisdir=$url;
+ my @rlinks=();
+ while ($token=$parser->get_token) {
+ if ($token->[0] eq 'S') {
+ if ($token->[1] eq 'a') {
+ if ($token->[2]->{'href'}) {
+ $rlinks[$#rlinks+1]=$token->[2]->{'href'};
+ }
+ } elsif ($token->[1] eq 'img' || $token->[1] eq 'embed' ) {
+ $rlinks[$#rlinks+1]=$token->[2]->{'src'};
+ } elsif ($token->[1] eq 'base') {
+ $thisdir=$token->[2]->{'href'};
+ }
+ }
+ }
+ $thisdir=~s-/[^/]*$--;
+ foreach (@rlinks) {
+ unless (($_=~/^http:\/\//i) ||
+ ($_=~/^\//) ||
+ ($_=~/^javascript:/i) ||
+ ($_=~/^mailto:/i) ||
+ ($_=~/^\#/)) {
+ my $newlocation=&Apache::lonnet::hreflocation($thisdir,$_);
+ $output=~s/(\"|\'|\=\s*)$_(\"|\'|\s|\>)/$1$newlocation$2/;
+ }
+ }
+# -------------------------------------------------- Deal with Applet codebases
+ $output=~s/(\ |