--- loncom/interface/loncommon.pm 2005/04/22 20:50:07 1.260 +++ loncom/interface/loncommon.pm 2005/09/14 21:25:52 1.273 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.260 2005/04/22 20:50:07 albertel Exp $ +# $Id: loncommon.pm,v 1.273 2005/09/14 21:25:52 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -152,19 +152,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); @@ -418,6 +419,31 @@ sub selectcourse_link { '","'.$udomele.'","'.$desc.'","'.$extra_element.'");'."'>".&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 =item * linked_select_forms(...) @@ -673,7 +699,6 @@ sub help_open_menu { foreach (\$color,\$function,\$topic,\$component_help,\$faq,\$bug,\$origurl) { $$_ = &Apache::lonnet::escape($$_); } - if (!$stayOnPage) { $link = "javascript:helpMenu('open')"; } else { @@ -684,9 +709,10 @@ sub help_open_menu { my $template; if ($text ne "") { $template .= - "". - "'); $i++; }
$text"; + "". + "'.$roleinfo.'
$text"; } + my $nothing=&Apache::lonhtmlcommon::javascript_nothing(); my $html=&Apache::lonxml::xmlbegin(); my $helpicon=&lonhttpdurl("/adm/lonIcons/helpgateway.gif"); $template .= <<"ENDTEMPLATE"; @@ -698,7 +724,7 @@ function helpMenu(target) { if (target == 'open') { var newWindow = null; try { - newWindow = window.open("/adm/rat/empty.html","helpmenu","HEIGHT=$height,WIDTH=$width,resizable=yes,scrollbars=yes" ) + newWindow = window.open($nothing,"helpmenu","HEIGHT=$height,WIDTH=$width,resizable=yes,scrollbars=yes" ) } catch(error) { writeHelp(caller); @@ -712,9 +738,9 @@ function helpMenu(target) { return; } function writeHelp(caller) { - caller.document.write('$htmlLON-CAPA Help Menu') - caller.document.write("") - caller.document.write("") + caller.document.writeln('$htmlLON-CAPA Help Menu') + caller.document.writeln("") + caller.document.writeln("") caller.document.close() caller.focus() } @@ -1984,24 +2010,23 @@ sub syllabuswrapper { } sub track_student_link { - my ($linktext,$sname,$sdom,$target) = @_; - my $link ="/adm/trackstudent"; + my ($linktext,$sname,$sdom,$target,$start) = @_; + my $link ="/adm/trackstudent?"; my $title = 'View recent activity'; if (defined($sname) && $sname !~ /^\s*$/ && defined($sdom) && $sdom !~ /^\s*$/) { - $link .= "?selected_student=$sname:$sdom"; + $link .= "selected_student=$sname:$sdom"; $title .= ' of this student'; - } + } if (defined($target) && $target !~ /^\s*$/) { $target = qq{target="$target"}; } else { $target = ''; } + if ($start) { $link.='&start='.$start; } return qq{$linktext}; } - - =pod =back @@ -2689,7 +2714,7 @@ other decorations will be returned. =cut sub bodytag { - my ($title,$function,$addentries,$bodyonly,$domain,$forcereg,$customtitle)=@_; + my ($title,$function,$addentries,$bodyonly,$domain,$forcereg,$customtitle,$notopbar)=@_; $title=&mt($title); $function = &get_users_function() if (!$function); my $img=&designparm($function.'.img',$domain); @@ -2729,11 +2754,9 @@ a:focus { color: red; background: yellow END + &Apache::lontexconvert::jsMath_reset(); if ($env{'environment.texengine'} eq 'jsMath') { - $bodytag.=''."\n". - ''."\n"; + $bodytag.=&Apache::lontexconvert::jsMath_header(); } my $upperleft=''. - '
'. + '
'. $titleinfo.'
'; if ($env{'request.state'} eq 'construct') { - $bodytag .= &Apache::lonmenu::menubuttons($forcereg,'web',$forcereg,$titletable); + if ($notopbar) { + $bodytag .= $titletable; + } else { + $bodytag .= &Apache::lonmenu::menubuttons($forcereg,'web',$forcereg,$titletable); + } } else { - $bodytag .= &Apache::lonmenu::menubuttons($forcereg,'web',$forcereg). + if ($notopbar) { + $bodytag .= $titletable; + } else { + $bodytag .= &Apache::lonmenu::menubuttons($forcereg,'web',$forcereg). $titletable; + } } return $bodytag; } @@ -2880,10 +2911,7 @@ Returns: A uniform footer for LON-CAPA w sub endbodytag { my $endbodytag=''; - if ($env{'environment.texengine'} eq 'jsMath') { - $endbodytag=''. - "\n".$endbodytag; - } + $endbodytag=&Apache::lontexconvert::jsMath_process()."\n".$endbodytag; return $endbodytag; } @@ -3065,7 +3093,6 @@ sub get_unprocessed_cgi { if (!defined($possible_names) || (grep {$_ eq $name} @$possible_names)) { $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; - &Apache::lonxml::debug("Seting :$name: to :$value:"); unless (defined($env{'form.'.$name})) { &add_to_env('form.'.$name,$value) }; } } @@ -3263,6 +3290,11 @@ Separate a record into fields $record sh =cut +sub takeleft { + my $index=shift; + return substr('0000'.$index,-4,4); +} + sub record_sep { my $record=shift; my %components=(); @@ -3273,7 +3305,7 @@ sub record_sep { my $field=$_; $field=~s/^(\"|\')//; $field=~s/(\"|\')$//; - $components{$i}=$field; + $components{&takeleft($i)}=$field; $i++; } } elsif ($env{'form.upfiletype'} eq 'tab') { @@ -3282,7 +3314,7 @@ sub record_sep { my $field=$_; $field=~s/^(\"|\')//; $field=~s/(\"|\')$//; - $components{$i}=$field; + $components{&takeleft($i)}=$field; $i++; } } else { @@ -3300,7 +3332,7 @@ sub record_sep { $field=~s/^\s*$delimiter//; $field=~s/$delimiter\s*$//; } - $components{$i}=$field; + $components{&takeleft($i)}=$field; $i++; } } @@ -3457,9 +3489,9 @@ sub csv_samples_select_table { $display.''); } $r->print('
'); - if (defined($sone{$_})) { $r->print($sone{$_}."
\n"); } - if (defined($stwo{$_})) { $r->print($stwo{$_}."
\n"); } - if (defined($sthree{$_})) { $r->print($sthree{$_}."
\n"); } + if (defined($sone{$_})) { $r->print($sone{$_}."
\n"); } + if (defined($stwo{$_})) { $r->print($stwo{$_}."
\n"); } + if (defined($sthree{$_})) { $r->print($sthree{$_}."
\n"); } $r->print('