--- loncom/interface/loncommon.pm 2003/03/03 13:03:58 1.86 +++ loncom/interface/loncommon.pm 2003/04/03 03:08:12 1.93 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.86 2003/03/03 13:03:58 www Exp $ +# $Id: loncommon.pm,v 1.93 2003/04/03 03:08:12 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -346,7 +346,37 @@ sub selectstudent_link { return ''; } return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele. - '","'.$udomele.'");'."'>Select</a>"; + '","'.$udomele.'");'."'>Select User</a>"; +} + +sub coursebrowser_javascript { + return (<<'ENDSTDBRW'); +<script type="text/javascript" language="Javascript" > + var stdeditbrowser; + function opencrsbrowser(formname,uname,udom) { + var url = '/adm/pickcourse?'; + var filter; + if (filter != null) { + if (filter != '') { + url += 'filter='+filter+'&'; + } + } + url += 'form=' + formname + '&cnumelement='+uname+ + '&cdomelement='+udom; + var title = 'Course Browser'; + var options = 'scrollbars=1,resizable=1,menubar=0'; + options += ',width=700,height=600'; + stdeditbrowser = open(url,title,options,'1'); + stdeditbrowser.focus(); + } +</script> +ENDSTDBRW +} + +sub selectcourse_link { + my ($form,$unameele,$udomele)=@_; + return "<a href='".'javascript:opencrsbrowser("'.$form.'","'.$unameele. + '","'.$udomele.'");'."'>Select Course</a>"; } ############################################################### @@ -601,18 +631,48 @@ sub get_domains { =pod -=item select_dom_form($defdom,$name) +=item select_form($defdom,$name,%hash) + +Returns a string containing a <select name='$name' size='1'> form to +allow a user to select options from a hash option_name => displayed text. +See lonrights.pm for an example invocation and use. + +=cut + +#------------------------------------------- +sub select_form { + my ($def,$name,%hash) = @_; + my $selectform = "<select name=\"$name\" size=\"1\">\n"; + foreach (sort keys %hash) { + $selectform.="<option value=\"$_\" ". + ($_ eq $def ? 'selected' : ''). + ">".$hash{$_}."</option>\n"; + } + $selectform.="</select>"; + return $selectform; +} + + +#------------------------------------------- + +=pod + +=item select_dom_form($defdom,$name,$includeempty) Returns a string containing a <select name='$name' size='1'> form to allow a user to select the domain to preform an operation in. See loncreateuser.pm for an example invocation and use. +If the $includeempty flag is set, it also includes an empty choice ("no domain +selected"); + =cut #------------------------------------------- sub select_dom_form { - my ($defdom,$name) = @_; + my ($defdom,$name,$includeempty) = @_; my @domains = get_domains(); + if ($includeempty) { @domains=('',@domains); } my $selectdomain = "<select name=\"$name\" size=\"1\">\n"; foreach (@domains) { $selectdomain.="<option value=\"$_\" ". @@ -674,6 +734,75 @@ sub home_server_option_list { ############################################################### ############################################################### +############################################################### + +=pod + +=item &decode_user_agent() + +Inputs: $r + +Outputs: + +=over 4 + +=item $httpbrowser + +=item $clientbrowser + +=item $clientversion + +=item $clientmathml + +=item $clientunicode + +=item $clientos + +=back + +=cut + +############################################################### +############################################################### +sub decode_user_agent { + my @browsertype=split(/\&/,$Apache::lonnet::perlvar{"lonBrowsDet"}); + my %mathcap=split(/\&/,$$Apache::lonnet::perlvar{"lonMathML"}); + my $httpbrowser=$ENV{"HTTP_USER_AGENT"}; + my $clientbrowser='unknown'; + my $clientversion='0'; + my $clientmathml=''; + my $clientunicode='0'; + for (my $i=0;$i<=$#browsertype;$i++) { + my ($bname,$match,$notmatch,$vreg,$minv,$univ)=split(/\:/,$browsertype[$i]); + if (($httpbrowser=~/$match/i) && ($httpbrowser!~/$notmatch/i)) { + $clientbrowser=$bname; + $httpbrowser=~/$vreg/i; + $clientversion=$1; + $clientmathml=($clientversion>=$minv); + $clientunicode=($clientversion>=$univ); + } + } + my $clientos='unknown'; + if (($httpbrowser=~/linux/i) || + ($httpbrowser=~/unix/i) || + ($httpbrowser=~/ux/i) || + ($httpbrowser=~/solaris/i)) { $clientos='unix'; } + if (($httpbrowser=~/vax/i) || + ($httpbrowser=~/vms/i)) { $clientos='vms'; } + if ($httpbrowser=~/next/i) { $clientos='next'; } + if (($httpbrowser=~/mac/i) || + ($httpbrowser=~/powerpc/i)) { $clientos='mac'; } + if ($httpbrowser=~/win/i) { $clientos='win'; } + if ($httpbrowser=~/embed/i) { $clientos='pda'; } + return ($httpbrowser,$clientbrowser,$clientversion,$clientmathml, + $clientunicode,$clientos,); +} + +############################################################### +############################################################### + + +############################################################### ## Authentication changing form generation subroutines ## ############################################################### ## @@ -1589,10 +1718,23 @@ END if ($bodyonly) { return $bodytag; } elsif ($ENV{'browser.interface'} eq 'textual') { +# +# Accessibility rendering +# + return $bodytag.&Apache::lonmenu::menubuttons($forcereg,'web', + $forcereg). + '<h1>LON-CAPA: '.$title.'</h1>'; + } elsif ($ENV{'environment.remote'} eq 'off') { +# +# No-Remote rendering +# return $bodytag.&Apache::lonmenu::menubuttons($forcereg,'web', $forcereg). '<h1>LON-CAPA: '.$title.'</h1>'; } else { +# +# Remote rendering +# return(<<ENDBODY); $bodytag <table width="100%" cellspacing="0" border="0" cellpadding="0">