--- loncom/interface/loncommon.pm 2006/06/22 17:56:06 1.386
+++ loncom/interface/loncommon.pm 2006/08/30 19:36:49 1.448
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.386 2006/06/22 17:56:06 albertel Exp $
+# $Id: loncommon.pm,v 1.448 2006/08/30 19:36:49 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -64,6 +64,7 @@ use HTML::Entities;
use Apache::lonhtmlcommon();
use Apache::loncoursedata();
use Apache::lontexconvert();
+use Apache::lonclonecourse();
use LONCAPA;
my $readit;
@@ -285,7 +286,7 @@ sub browser_and_searcher_javascript {
}
url += 'element=' + elementname + '';
var title = 'Browser';
- var options = 'scrollbars=1,resizable=1,menubar=1,location=1';
+ var options = 'scrollbars=1,resizable=1,menubar=0,toolbar=1,location=1';
options += ',width=700,height=600';
editbrowser = open(url,title,options,'1');
editbrowser.focus();
@@ -306,7 +307,7 @@ sub browser_and_searcher_javascript {
}
url += 'element=' + elementname + '';
var title = 'Search';
- var options = 'scrollbars=1,resizable=1,menubar=0';
+ var options = 'scrollbars=1,resizable=1,menubar=0,toolbar=1,location=1';
options += ',width=700,height=600';
editsearcher = open(url,title,options,'1');
editsearcher.focus();
@@ -672,14 +673,14 @@ sub help_open_topic {
{
$template .=
"
".
- "$text";
+ " | $text";
}
# Add the graphic
my $title = &mt('Online Help');
my $helpicon=&lonhttpdurl("/adm/help/gif/smallHelp.gif");
$template .= <<"ENDTEMPLATE";
-
+
ENDTEMPLATE
if ($text ne '') { $template.=' |
' };
return $template;
@@ -706,40 +707,95 @@ 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;
+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';
}
- $width = 620 if (not defined $width);
- $height = 600 if (not defined $height);
- my $link='';
- my $title = &mt('Get help');
+ 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 (\$color,\$function,\$topic,\$component_help,\$faq,
- \$bug,\$origurl) {
+ foreach my $datum (\$topic,\$component_help,\$faq,\$bug,\$origurl) {
$$datum = &escape($$datum);
}
- if (!$stayOnPage) {
- $link = "javascript:helpMenu('open')";
- } else {
- $link = "javascript:helpMenu('display')";
+
+ 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 ($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 $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";
+ 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) = @_;
+
+ $text = &mt($text);
+
+ my $stayOnPage =
+ ($env{'browser.interface'} eq 'textual' ||
+ $env{'environment.remote'} eq 'off' );
+ my $link= ($stayOnPage) ? "javascript:helpMenu('display')"
+ : "javascript:helpMenu('open')";
+ my $banner_link = &update_help_link(undef,undef,undef,undef,$stayOnPage);
+
+ my $title = &mt('Get help');
+
+ return <<"END";
+$banner_link
+ $text
+END
+}
+
+sub help_menu_js {
+ my ($text) = @_;
+
+ my $stayOnPage =
+ ($env{'browser.interface'} eq 'textual' ||
+ $env{'environment.remote'} eq 'off' );
+
+ my $width = 620;
+ my $height = 600;
+ my $helptopic=&general_help();
+ my $details_link = '/adm/help/'.$helptopic.'.hlp';
my $nothing=&Apache::lonhtmlcommon::javascript_nothing();
- my $helpicon=&lonhttpdurl("/adm/lonIcons/helpgateway.gif");
my $start_page =
&Apache::loncommon::start_page('Help Menu', undef,
{'frameset' => 1,
@@ -751,10 +807,11 @@ sub help_open_menu {
&Apache::loncommon::end_page({'frameset' => 1,
'js_ready' => 1,});
- $template .= <<"ENDTEMPLATE";
-
-
+
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;
}
@@ -831,14 +873,14 @@ sub help_open_bug {
{
$template .=
"".
- "$text";
+ " | $text";
}
# Add the graphic
my $title = &mt('Report a Bug');
my $bugicon=&lonhttpdurl("/adm/lonMisc/smallBug.gif");
$template .= <<"ENDTEMPLATE";
-
+
ENDTEMPLATE
if ($text ne '') { $template.=' |
' };
return $template;
@@ -876,14 +918,14 @@ sub help_open_faq {
{
$template .=
"".
- "$text";
+ " | $text";
}
# Add the graphic
my $title = &mt('View the FAQ');
my $faqicon=&lonhttpdurl("/adm/lonMisc/smallFAQ.gif");
$template .= <<"ENDTEMPLATE";
-
+
ENDTEMPLATE
if ($text ne '') { $template.=' |
' };
return $template;
@@ -1919,12 +1961,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 +2053,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) {
@@ -2040,9 +2093,9 @@ sub screenname {
sub messagewrapper {
my ($link,$username,$domain,$subject,$text)=@_;
return
- ''.$link.'';
}
# --------------------------------------------------------------- Notes Wrapper
@@ -2056,6 +2109,9 @@ sub noteswrapper {
sub aboutmewrapper {
my ($link,$username,$domain,$target)=@_;
+ if (!defined($username) && !defined($domain)) {
+ return;
+ }
return ''.$link.'';
}
@@ -2086,7 +2142,9 @@ sub track_student_link {
$target = '';
}
if ($start) { $link.='&start='.$start; }
- return qq{$linktext};
+
+ return qq{$linktext}.
+ &help_open_topic('View_recent_activity');
}
=pod
@@ -2725,6 +2783,7 @@ Returns: value of designparamter $which
=cut
+
##############################################
sub designparm {
my ($which,$domain)=@_;
@@ -2739,11 +2798,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 +2855,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.
@@ -2823,7 +2881,7 @@ sub bodytag {
'alink' => &designparm($function.'.alink',$domain),
'vlink' => &designparm($function.'.vlink',$domain),
'link' => &designparm($function.'.link',$domain),);
- @$addentries{keys(%design)} = @design{keys(%design)};
+ @design{keys(%$addentries)} = @$addentries{keys(%$addentries)};
# role and realm
my ($role,$realm) = split(/\./,$env{'request.role'},2);
@@ -2840,6 +2898,7 @@ sub bodytag {
} else {
$role = &Apache::lonnet::plaintext($role);
}
+
if (!$realm) { $realm=' '; }
# Set messages
my $messages=&domainlogo($domain);
@@ -2847,7 +2906,7 @@ sub bodytag {
my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
- my $extra_body_attr = &make_attr_string($forcereg,$addentries);
+ my $extra_body_attr = &make_attr_string($forcereg,\%design);
# construct main body tag
my $bodytag = "".
@@ -2867,15 +2926,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 +2987,7 @@ ENDROLE
$lastitem = $thisdisfn;
}
$titleinfo =
- &Apache::loncommon::help_open_menu('','','','',3,'Authoring').
+ &Apache::loncommon::help_open_menu('','',3,'Authoring').
'
Construction Space: '.
'