[LON-CAPA-cvs] cvs: loncom /auth lonauth.pm /interface loncommon.pm lonhtmlcommon.pm lonmenu.pm lonspreadsheet.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Mon, 10 Mar 2003 20:21:45 -0000
This is a MIME encoded message
--matthew1047327705
Content-Type: text/plain
matthew Mon Mar 10 15:21:45 2003 EDT
Modified files:
/loncom/auth lonauth.pm
/loncom/interface loncommon.pm lonhtmlcommon.pm lonmenu.pm
lonspreadsheet.pm
Log:
Created loncommon::decode_user_agent() subroutine with code removed from
lonauth.pm. The code was modified to not require $r be passed along
ad nauseum.
Created lonhtmlcommon::javascript_nothing which returns an appropriate value
of nothing for use as the first parameter for window.open. Most notably,
IE on macs get a different version, "'javascript:void(0);'", than everyone
one else, "''". Of course IE on PC appearantly used to require the former
but now requires the latter.
lonmenu.pm and lonspreadsheet.pm were modified to use javascript_nothing.
lonauth was modified to use decode_user_agent.
--matthew1047327705
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20030310152145.txt"
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.44 loncom/auth/lonauth.pm:1.45
--- loncom/auth/lonauth.pm:1.44 Sat Mar 1 22:58:55 2003
+++ loncom/auth/lonauth.pm Mon Mar 10 15:21:45 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# User Authentication Module
#
-# $Id: lonauth.pm,v 1.44 2003/03/02 03:58:55 www Exp $
+# $Id: lonauth.pm,v 1.45 2003/03/10 20:21:45 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,6 +42,7 @@
use CGI::Cookie();
use DynaLoader; # for Crypt::DES version
use Crypt::DES;
+use Apache::loncommon();
use Apache::lonnet();
use Apache::lonmenu();
use Fcntl qw(:flock);
@@ -77,36 +78,8 @@
# ------------------------------------ Check browser type and MathML capability
- my @browsertype=split(/\&/,$r->dir_config("lonBrowsDet"));
- my %mathcap=split(/\&/,$r->dir_config("lonMathML"));
- my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
- my $i;
- my $clientbrowser='unknown';
- my $clientversion='0';
- my $clientmathml='';
- my $clientunicode='0';
- for ($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'; }
+ my ($httpbrowser,$clientbrowser,$clientversion,$clientmathml,
+ $clientunicode,$clientos) = &Apache::loncommon::decode_user_agent($r);
# -------------------------------------- Any accessibility options to remember?
if (($FORM{'interface'}) && ($FORM{'remember'} eq 'true')) {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.86 loncom/interface/loncommon.pm:1.87
--- loncom/interface/loncommon.pm:1.86 Mon Mar 3 08:03:58 2003
+++ loncom/interface/loncommon.pm Mon Mar 10 15:21:45 2003
@@ -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.87 2003/03/10 20:21:45 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -672,6 +672,75 @@
###############################################################
## End of home server <option> list generating code ##
###############################################################
+
+###############################################################
+###############################################################
+
+=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 ##
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.16 loncom/interface/lonhtmlcommon.pm:1.17
--- loncom/interface/lonhtmlcommon.pm:1.16 Fri Mar 7 14:09:11 2003
+++ loncom/interface/lonhtmlcommon.pm Mon Mar 10 15:21:45 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.16 2003/03/07 19:09:11 albertel Exp $
+# $Id: lonhtmlcommon.pm,v 1.17 2003/03/10 20:21:45 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -248,6 +248,42 @@
##############################################
##############################################
+
+=pod
+
+=item &javascript_nothing()
+
+Return an appropriate null for the users browser. This is used
+as the first arguement for window.open calls when you want a blank
+window that you can then write to.
+
+=cut
+
+##############################################
+##############################################
+sub javascript_nothing {
+ # mozilla and other browsers work with "''", but IE on mac does not.
+ my $nothing = "''";
+ my $user_browser;
+ my $user_os;
+ $user_browser = $ENV{'browser.type'} if (exists($ENV{'browser.type'}));
+ $user_os = $ENV{'browser.os'} if (exists($ENV{'browser.os'}));
+ if (! defined($user_browser) || ! defined($user_os)) {
+ (undef,$user_browser,undef,undef,undef,$user_os) =
+ &Apache::loncommon::decode_user_agent();
+ }
+ &Apache::lonnet::logthis(" os = :".$user_os.":");
+ &Apache::lonnet::logthis(" browser = :".$user_browser.":");
+ if ($user_browser eq 'explorer' && $user_os =~ 'mac') {
+ $nothing = "'javascript:void(0);'";
+ }
+ return $nothing;
+}
+
+##############################################
+##############################################
+
+
sub AscendOrderOptions {
my ($order, $page, $formName)=@_;
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.46 loncom/interface/lonmenu.pm:1.47
--- loncom/interface/lonmenu.pm:1.46 Mon Mar 3 15:35:20 2003
+++ loncom/interface/lonmenu.pm Mon Mar 10 15:21:45 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.46 2003/03/03 20:35:20 www Exp $
+# $Id: lonmenu.pm,v 1.47 2003/03/10 20:21:45 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -37,6 +37,7 @@
use strict;
use Apache::lonnet;
use Apache::Constants qw(:common);
+use Apache::lonhtmlcommon();
use Apache::loncommon;
use Apache::File;
use vars qw(@desklines $readdesk);
@@ -401,11 +402,10 @@
# ================================================================= Reopen menu
sub reopenmenu {
- my $nothing='';
if ($ENV{'browser.interface'} eq 'textual') { return ''; }
my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
- if ($ENV{'browser.type'} eq 'explorer') { $nothing='javascript:void(0);'; }
- return('window.open("'.$nothing.'","'.$menuname.'","",false);');
+ my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
+ return('window.open('.$nothing.',"'.$menuname.'","",false);');
}
# =============================================================== Open the menu
@@ -479,11 +479,8 @@
sub openmenu {
my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
if ($ENV{'browser.interface'} eq 'textual') { return ''; }
- if ($ENV{'browser.type'} eq 'explorer') {
- return "window.open('javascript:void(0);','".$menuname."');";
- } else {
- return "window.open('','".$menuname."');";
- }
+ my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
+ return "window.open(".$nothing.",'".$menuname."');";
}
sub rawconfig {
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.175 loncom/interface/lonspreadsheet.pm:1.176
--- loncom/interface/lonspreadsheet.pm:1.175 Fri Mar 7 18:32:05 2003
+++ loncom/interface/lonspreadsheet.pm Mon Mar 10 15:21:45 2003
@@ -1,5 +1,5 @@
#
-# $Id: lonspreadsheet.pm,v 1.175 2003/03/07 23:32:05 albertel Exp $
+# $Id: lonspreadsheet.pm,v 1.176 2003/03/10 20:21:45 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -183,10 +183,7 @@
# Header....
#
$r->print('<html><head><title>LON-CAPA Spreadsheet</title>');
- my $nothing = "''";
- if ($ENV{'browser.type'} eq 'explorer') {
- $nothing = "'javascript:void(0);'";
- }
+ my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
if ($ENV{'request.role'} !~ /^st\./) {
$r->print(<<ENDSCRIPT);
--matthew1047327705--