--- loncom/interface/loncommon.pm 2006/06/22 20:09:51 1.389
+++ loncom/interface/loncommon.pm 2006/07/19 11:30:36 1.434
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.389 2006/06/22 20:09:51 albertel Exp $
+# $Id: loncommon.pm,v 1.434 2006/07/19 11:30:36 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -706,8 +706,68 @@ sub helpLatexCheatsheet {
.'';
}
+sub general_help {
+ my $helptopic='Student_Intro';
+ if ($env{'request.role'}=~/^(ca|au)/) {
+ $helptopic='Authoring_Intro';
+ } elsif ($env{'request.role'}=~/^cc/) {
+ $helptopic='Course_Coordination_Intro';
+ }
+ return $helptopic;
+}
+
+sub update_help_link {
+ my ($topic,$component_help,$faq,$bug,$stayOnPage) = @_;
+ my $origurl = $ENV{'REQUEST_URI'};
+ $origurl=~s|^/~|/priv/|;
+ my $timestamp = time;
+ foreach my $datum (\$topic,\$component_help,\$faq,\$bug,\$origurl) {
+ $$datum = &escape($$datum);
+ }
+
+ my $banner_link = "/adm/helpmenu?page=banner&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp&stayonpage=$stayOnPage";
+ my $output .= <<"ENDOUTPUT";
+
+ENDOUTPUT
+ return $output;
+}
+
+# now just updates the help link and generates a blue icon
sub help_open_menu {
- my ($color,$topic,$component_help,$function,$faq,$bug,$stayOnPage,$width,$height,$text) = @_;
+ 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;
+ }
+ my $output;
+ if ($component_help) {
+ if (!$text) {
+ $output=&help_open_topic($component_help,undef,$stayOnPage,
+ $width,$height);
+ } else {
+ my $help_text;
+ $help_text=&unescape($topic);
+ $output='
'.
+ &help_open_topic($component_help,$help_text,$stayOnPage,
+ $width,$height).' |
';
+ }
+ }
+ my $banner_link = &update_help_link($topic,$component_help,$faq,$bug,$stayOnPage);
+ return $output.$banner_link;
+}
+
+sub top_nav_help {
+ my ($text) = @_;
+
+ my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height);
+
$text = "" if (not defined $text);
$stayOnPage = 0 if (not defined $stayOnPage);
if ($env{'browser.interface'} eq 'textual' ||
@@ -718,26 +778,15 @@ sub help_open_menu {
$height = 600 if (not defined $height);
my $link='';
my $title = &mt('Get help');
- my $origurl = $ENV{'REQUEST_URI'};
- $origurl=~s|^/~|/priv/|;
- my $timestamp = time;
- foreach my $datum (\$color,\$function,\$topic,\$component_help,\$faq,
- \$bug,\$origurl) {
- $$datum = &escape($$datum);
- }
- if (!$stayOnPage) {
- $link = "javascript:helpMenu('open')";
+ if ($stayOnPage) {
+ $link = "javascript:helpMenu('display')";
} else {
- $link = "javascript:helpMenu('display')";
+ $link = "javascript:helpMenu('open')";
}
- 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 $helptopic=&general_help();
+ my $banner_link = &update_help_link($topic,$component_help,$faq,$bug,$stayOnPage);
+ my $details_link = '/adm/help/'.$helptopic.'.hlp';
my $template;
- if ($text ne "") {
- $template .=
- "".
- "$text";
- }
my $nothing=&Apache::lonhtmlcommon::javascript_nothing();
my $helpicon=&lonhttpdurl("/adm/lonIcons/helpgateway.gif");
my $start_page =
@@ -755,6 +804,7 @@ sub help_open_menu {
-
+$banner_link
+ $text
ENDTEMPLATE
- if ($component_help) {
- if (!$text) {
- $template=&help_open_topic($component_help,undef,$stayOnPage,
- $width,$height).' '.$template;
- } else {
- my $help_text;
- $help_text=&unescape($topic);
- $template=''.
- &help_open_topic($component_help,$help_text,$stayOnPage,
- $width,$height).' | '.$template.
- ' | ';
- }
- }
- if ($text ne '') { $template.=' |
' };
return $template;
}
@@ -1919,12 +1956,20 @@ sub get_related_words {
return ();
}
my @Words=();
+ my $count=0;
if (exists($thesaurus_db{$keyword})) {
# The first element is the number of times
# the word appears. We do not need it now.
- (undef,@Words) = (split(/:/,$thesaurus_db{$keyword}));
- for (my $i=0;$i<=$#Words;$i++) {
- ($Words[$i],undef)= split(/\,/,$Words[$i]);
+ my (undef,@RelatedWords) = (split(/:/,$thesaurus_db{$keyword}));
+ my (undef,$mostfrequentcount)=split(/\,/,$RelatedWords[0]);
+ my $threshold=$mostfrequentcount/10;
+ foreach my $possibleword (@RelatedWords) {
+ my ($word,$wordcount)=split(/\,/,$possibleword);
+ if ($wordcount>$threshold) {
+ push(@Words,$word);
+ $count++;
+ if ($count>10) { last; }
+ }
}
}
untie %thesaurus_db;
@@ -2003,6 +2048,9 @@ sub nickname {
sub getnames {
my ($uname,$udom)=@_;
+ if ($udom eq 'public' && $uname eq 'public') {
+ return ('lastname' => &mt('Public'));
+ }
my $id=$uname.':'.$udom;
my ($names,$cached)=&Apache::lonnet::is_cached_new('namescache',$id);
if ($cached) {
@@ -2725,6 +2773,7 @@ Returns: value of designparamter $which
=cut
+
##############################################
sub designparm {
my ($which,$domain)=@_;
@@ -2739,11 +2788,11 @@ sub designparm {
return '#CCCCCC';
}
}
- if ($env{'environment.color.'.$which}) {
+ if (exists($env{'environment.color.'.$which})) {
return $env{'environment.color.'.$which};
}
$domain=&determinedomain($domain);
- if ($designhash{$domain.'.'.$which}) {
+ if (exists($designhash{$domain.'.'.$which})) {
return $designhash{$domain.'.'.$which};
} else {
return $designhash{'default.'.$which};
@@ -2796,7 +2845,6 @@ Inputs:
=item * $no_inline_link, if true and in remote mode, don't show the
'Switch To Inline Menu' link
-
=back
Returns: A uniform header for LON-CAPA web pages.
@@ -2840,6 +2888,7 @@ sub bodytag {
} else {
$role = &Apache::lonnet::plaintext($role);
}
+
if (!$realm) { $realm=' '; }
# Set messages
my $messages=&domainlogo($domain);
@@ -2867,15 +2916,17 @@ sub bodytag {
return $bodytag;
}
-
+ my $name = &plainname($env{'user.name'},$env{'user.domain'});
+ if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
+ undef($role);
+ } else {
+ $name = &aboutmewrapper($name,$env{'user.name'},$env{'user.domain'});
+ }
my $roleinfo=(<
- $env{'environment.firstname'}
- $env{'environment.middlename'}
- $env{'environment.lastname'}
- $env{'environment.generation'}
+ $name
@@ -2926,7 +2977,7 @@ ENDROLE
$lastitem = $thisdisfn;
}
$titleinfo =
- &Apache::loncommon::help_open_menu('','','','',3,'Authoring').
+ &Apache::loncommon::help_open_menu('','',3,'Authoring').
'
Construction Space: '.
'