--- loncom/interface/loncommon.pm 2005/06/30 17:56:28 1.268
+++ loncom/interface/loncommon.pm 2006/04/20 02:24:08 1.344
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.268 2005/06/30 17:56:28 albertel Exp $
+# $Id: loncommon.pm,v 1.344 2006/04/20 02:24:08 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -58,10 +58,12 @@ use strict;
use Apache::lonnet;
use GDBM_File;
use POSIX qw(strftime mktime);
-use Apache::Constants qw(:common :http :methods);
use Apache::lonmenu();
use Apache::lonlocal;
use HTML::Entities;
+use Apache::lonhtmlcommon();
+use Apache::loncoursedata();
+use Apache::lontexconvert();
my $readit;
@@ -152,19 +154,20 @@ BEGIN {
my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors';
opendir(DIR,$designdir);
while ($filename=readdir(DIR)) {
+ if ($filename!~/\.tab$/) { next; }
my ($domain)=($filename=~/^(\w+)\./);
- {
- 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);
- }
- }
+ {
+ 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);
+ }
+ }
}
closedir(DIR);
@@ -330,7 +333,10 @@ sub storeresurl {
sub studentbrowser_javascript {
unless (
(($env{'request.course.id'}) &&
- (&Apache::lonnet::allowed('srm',$env{'request.course.id'})))
+ (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+ || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'})
+ ))
|| ($env{'request.role'}=~/^(au|dc|su)/)
) { return ''; }
return (<<'ENDSTDBRW');
@@ -361,7 +367,9 @@ ENDSTDBRW
sub selectstudent_link {
my ($form,$unameele,$udomele)=@_;
if ($env{'request.course.id'}) {
- unless (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
+ if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+ && !&Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'})) {
return '';
}
return "
var stdeditbrowser;
- function opencrsbrowser(formname,uname,udom,desc,extra_element) {
+ function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag) {
var url = '/adm/pickcourse?';
var filter;
if (filter != null) {
@@ -402,6 +410,9 @@ sub coursebrowser_javascript {
url += '&domainfilter='+extra_element;
}
}
+ if (multflag !=null && multflag != '') {
+ url += '&multiple='+multflag;
+ }
var title = 'Course_Browser';
var options = 'scrollbars=1,resizable=1,menubar=0';
options += ',width=700,height=600';
@@ -413,10 +424,35 @@ ENDSTDBRW
}
sub selectcourse_link {
- my ($form,$unameele,$udomele,$desc,$extra_element)=@_;
+ my ($form,$unameele,$udomele,$desc,$extra_element,$multflag)=@_;
return "".&mt('Select Course')."";
+ '","'.$udomele.'","'.$desc.'","'.$extra_element.'","'.$multflag.'");'."'>".&mt('Select Course')."";
+}
+
+sub check_uncheck_jscript {
+ my $jscript = <<"ENDSCRT";
+function checkAll(field) {
+ if (field.length > 0) {
+ for (i = 0; i < field.length; i++) {
+ field[i].checked = true ;
+ }
+ } else {
+ field.checked = true
+ }
}
+
+function uncheckAll(field) {
+ if (field.length > 0) {
+ for (i = 0; i < field.length; i++) {
+ field[i].checked = false ;
+ } } else {
+ field.checked = false ;
+ }
+}
+ENDSCRT
+ return $jscript;
+}
+
=pod
@@ -687,8 +723,18 @@ sub help_open_menu {
"
$text";
}
my $nothing=&Apache::lonhtmlcommon::javascript_nothing();
- my $html=&Apache::lonxml::xmlbegin();
my $helpicon=&lonhttpdurl("/adm/lonIcons/helpgateway.gif");
+ my $start_page =
+ &Apache::loncommon::start_page('Help Menu', undef,
+ {'frameset' => 1,
+ 'js_ready' => 1,
+ 'add_entries' => {
+ 'border' => '0',
+ 'rows' => "105,*",},});
+ my $end_page =
+ &Apache::loncommon::end_page({'frameset' => 1,
+ 'js_ready' => 1,});
+
$template .= <<"ENDTEMPLATE";
'."\n".
- ''."\n";
- }
+
+ $bodytag .= &Apache::lontexconvert::init_math_support();
my $upperleft='';
- if ($bodyonly) {
+ if ($bodyonly
+ || ($env{'request.state'} eq 'construct'
+ && $env{'environment.remote'} ne 'off' )) {
return $bodytag;
} elsif ($env{'browser.interface'} eq 'textual') {
# Accessibility
- return $bodytag.&Apache::lonmenu::menubuttons($forcereg,'web',
- $forcereg).
- 'LON-CAPA: '.$title.'';
+ $bodytag.=&Apache::lonmenu::menubuttons($forcereg,$forcereg);
+ if (!$notitle) {
+ $bodytag.='LON-CAPA: '.$title.'';
+ }
+ return $bodytag;
} elsif ($env{'environment.remote'} eq 'off') {
# No Remote
my $roleinfo=(<'.
- ''.
+ ' | '.
$titleinfo.' | '.$roleinfo.' ';
- if ($env{'request.state'} eq 'construct') {
- $bodytag .= &Apache::lonmenu::menubuttons($forcereg,'web',$forcereg,$titletable);
+ }
+ if ($env{'request.state'} eq 'construct') {
+ if ($notopbar) {
+ $bodytag .= $titletable;
+ } else {
+ $bodytag .= &Apache::lonmenu::menubuttons($forcereg,$forcereg,
+ $titletable);
+ }
} else {
- $bodytag .= &Apache::lonmenu::menubuttons($forcereg,'web',$forcereg).
+ if ($notopbar) {
+ $bodytag .= $titletable;
+ } else {
+ $bodytag .= &Apache::lonmenu::menubuttons($forcereg,$forcereg).
$titletable;
+ }
}
return $bodytag;
}
@@ -2823,7 +2918,12 @@ ENDROLE
$dc_info.= $cid.' '.$env{'course.'.$cid.'.internal.coursecode'};
$dc_info = '('.$dc_info.')';
}
+ # Explicit link to get inline menu
+ my $menu=' '.&mt('Switch to Inline Menu Mode').'';
#
+ if ($notitle) {
+ return $bodytag;
+ }
return(<
@@ -2833,7 +2933,7 @@ $upperleft |
-$titleinfo $dc_info
+$titleinfo $dc_info $menu
|
$env{'environment.firstname'}
@@ -2852,6 +2952,62 @@ $titleinfo $dc_info
ENDBODY
}
+sub make_attr_string {
+ my ($register,$attr_ref) = @_;
+
+ if ($attr_ref && !ref($attr_ref)) {
+ die("addentries Must be a hash ref ".
+ join(':',caller(1))." ".
+ join(':',caller(0))." ");
+ }
+
+ if ($register) {
+ my ($on_load,$on_unload);
+ foreach my $key (keys(%{$attr_ref})) {
+ if (lc($key) eq 'onload') {
+ $on_load.=$attr_ref->{$key}.';';
+ delete($attr_ref->{$key});
+
+ } elsif (lc($key) eq 'onunload') {
+ $on_unload.=$attr_ref->{$key}.';';
+ delete($attr_ref->{$key});
+ }
+ }
+ $attr_ref->{'onload'} =
+ &Apache::lonmenu::loadevents(). $on_load;
+ $attr_ref->{'onunload'}=
+ &Apache::lonmenu::unloadevents().$on_unload;
+ }
+
+# Accessibility font enhance
+ if ($env{'browser.fontenhance'} eq 'on') {
+ my $style;
+ foreach my $key (keys(%{$attr_ref})) {
+ if (lc($key) eq 'style') {
+ $style.=$attr_ref->{$key}.';';
+ delete($attr_ref->{$key});
+ }
+ }
+ $attr_ref->{'style'}=$style.'; font-size: x-large;';
+ }
+
+ if ($env{'browser.blackwhite'} eq 'on') {
+ delete($attr_ref->{'font'});
+ delete($attr_ref->{'link'});
+ delete($attr_ref->{'alink'});
+ delete($attr_ref->{'vlink'});
+ delete($attr_ref->{'bgcolor'});
+ delete($attr_ref->{'background'});
+ }
+
+ my $attr_string;
+ foreach my $attr (keys(%$attr_ref)) {
+ $attr_string .= " $attr=\"".$attr_ref->{$attr}.'" ';
+ }
+ return $attr_string;
+}
+
+
###############################################
###############################################
@@ -2859,7 +3015,7 @@ ENDBODY
=back
-=head1 HTTP Helpers
+=head1 HTML Helpers
=over 4
@@ -2867,29 +3023,384 @@ ENDBODY
Returns a uniform footer for LON-CAPA web pages.
-Inputs:
-
-=over 4
+Inputs: none
=back
-Returns: A uniform footer for LON-CAPA web pages.
-
=cut
sub endbodytag {
my $endbodytag=' |