[LON-CAPA-cvs] cvs: loncom /interface lonsyllabus.pm rat lonwrapper.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 21 Mar 2006 21:50:49 -0000
albertel Tue Mar 21 16:50:49 2006 EDT
Modified files:
/rat lonwrapper.pm
/loncom/interface lonsyllabus.pm
Log:
- eliminate wrapper frameset copy and paste
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.20 rat/lonwrapper.pm:1.21
--- rat/lonwrapper.pm:1.20 Sun Mar 19 18:06:00 2006
+++ rat/lonwrapper.pm Tue Mar 21 16:50:39 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Wrapper for external and binary files as standalone resources
#
-# $Id: lonwrapper.pm,v 1.20 2006/03/19 23:06:00 albertel Exp $
+# $Id: lonwrapper.pm,v 1.21 2006/03/21 21:50:39 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,95 +36,109 @@
# ================================================================ Main Handler
-sub handler {
- my $r=shift;
- &Apache::loncommon::content_type($r,'text/html');
- $r->send_http_header;
-
- return OK if $r->header_only;
-
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['wrapperdisplay']);
- my $orgurl=$r->uri;
- my $url=$orgurl;
- $orgurl.=(($orgurl=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
- $orgurl.=(($orgurl=~/\?/)?'&':'?').'wrapperdisplay=menu';
- $url=~s/^\/adm\/wrapper//;
- my $is_ext = $url =~ m|^/ext/|;
- $url=~s/^\/ext\//http\:\/\//;
- $url=~s|:|:|g;
- if ($env{'form.wrapperdisplay'} eq 'menu') {
+sub simple_menu {
#
# Producing the menu buttons
#
- $r->print('<html><body bgcolor="#FFFFFF">'.
- &Apache::lonmenu::menubuttons(1,'web',1).'</body></html>');
- } else {
-#
-# Actual URL
-#
- if ($url=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
-#
-# This is uploaded homework
-#
- $env{'request.state'}='uploaded';
- &Apache::lonhomework::renderpage($r,$url);
- } else {
-#
-# This is not homework
-#
- if ($is_ext) {
- $ENV{'QUERY_STRING'}=~s/(^|\&)symb=[^\&]*/$1/;
- }
- $url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
- # reappend the query arguments
- my $events='onLoad="'.&Apache::lonmenu::loadevents.
- '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
- my $script=&Apache::lonmenu::registerurl(1,undef);
+ return '<html><body bgcolor="#FFFFFF">'.
+ &Apache::lonmenu::menubuttons(1,'web',1).'</body></html>';
- if ($env{'browser.interface'} eq 'textual') {
+}
+
+
+sub wrapper {
+ my ($topurl,$bottomurl) = @_;
+
+ if ($env{'browser.interface'} eq 'textual') {
#
# ssi-based rendering for text-based interface
#
- $r->print('<html><head>'.
- &Apache::lonmenu::registerurl(1).
- '</head><body bgcolor="#FFFFFF">'.
- &Apache::lonmenu::menubuttons(1).
- &Apache::lonnet::ssi_body($url).'</body></html>');
- } elsif ($env{'environment.remote'} eq 'off') {
-#
-# This is inline remote
-#
- $r->print(<<ENDDOCUMENTINL);
+ return '<html><head>'.
+ &Apache::lonmenu::registerurl(1).
+ '</head><body bgcolor="#FFFFFF">'.
+ &Apache::lonmenu::menubuttons(1).
+ &Apache::lonnet::ssi_body($bottomurl).'</body></html>';
+ }
+
+ my $events='onLoad="'.&Apache::lonmenu::loadevents.
+ '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
+ my $script=&Apache::lonmenu::registerurl(1,undef);
+
+ my $result = <<ENDDOCUMENTINL;
<html>
<head>
$script
</head>
+ENDDOCUMENTINL
+
+ if ($env{'environment.remote'} eq 'off') {
+#
+# This is inline remote
+#
+ $result .= <<ENDDOCUMENTINL;
<frameset rows="180,*" border="0" $events>
-<frame src="$orgurl">
-<frame src="$url">
+<frame src="$topurl">
+<frame src="$bottomurl">
</frameset>
-</html>
ENDDOCUMENTINL
- } else {
+ } else {
#
# frame-based rendering for graphical interface
#
- $r->print(<<ENDDOCUMENT);
-<html>
-<head>
-$script
-</head>
+ $result .=<<ENDDOCUMENT;
<frameset rows="1,*" border="0" $events>
<frame src="/adm/rat/empty.html">
-<frame src="$url">
+<frame src="$bottomurl">
</frameset>
-</html>
ENDDOCUMENT
- }
- } # not homework
- } # not just the menu
- return OK;
+ }
+
+ $result .= "\n</html>\n";
+}
+
+sub handler {
+ my $r=shift;
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+
+ return OK if $r->header_only;
+
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['wrapperdisplay']);
+ if ($env{'form.wrapperdisplay'} eq 'menu') {
+ $r->print(&simple_menu());
+ return OK;
+ }
+
+ my $orgurl=$r->uri;
+ my $url=$orgurl;
+ $orgurl.=(($orgurl=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
+ $orgurl.=(($orgurl=~/\?/)?'&':'?').'wrapperdisplay=menu';
+ $url=~s/^\/adm\/wrapper//;
+ my $is_ext = $url =~ m|^/ext/|;
+ $url=~s/^\/ext\//http\:\/\//;
+ $url=~s|:|:|g;
+#
+# Actual URL
+#
+ if ($url=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
+#
+# This is uploaded homework
+#
+ $env{'request.state'}='uploaded';
+ &Apache::lonhomework::renderpage($r,$url);
+ } else {
+#
+# This is not homework
+#
+ if ($is_ext) {
+ $ENV{'QUERY_STRING'}=~s/(^|\&)symb=[^\&]*/$1/;
+ }
+ $url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
+ # reappend the query arguments
+ $r->print(&wrapper($orgurl,$url));
+ } # not just the menu
+ return OK;
} # handler
1;
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.49 loncom/interface/lonsyllabus.pm:1.50
--- loncom/interface/lonsyllabus.pm:1.49 Tue Mar 21 16:25:33 2006
+++ loncom/interface/lonsyllabus.pm Tue Mar 21 16:50:49 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Syllabus
#
-# $Id: lonsyllabus.pm,v 1.49 2006/03/21 21:25:33 albertel Exp $
+# $Id: lonsyllabus.pm,v 1.50 2006/03/21 21:50:49 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -76,54 +76,19 @@
if ($env{'form.register'}) {
$addentries=' onLoad="'.&Apache::lonmenu::loadevents().
'" onUnload="'.&Apache::lonmenu::unloadevents().'"';
- $r->print(&Apache::lonmenu::registerurl(1));
}
# -------------------------------------------------- Let's see who handles this
my $externalsyllabus=$courseenv{'externalsyllabus'};
if ($externalsyllabus=~/\w/) {
- $r->print(&Apache::loncommon::endheadtag());
+
if ($env{'form.wrapperdisplay'} eq 'menu') {
-#
-# Producing the menu buttons
-#
- $r->print('<body bgcolor="#FFFFFF">'.
- &Apache::lonmenu::menubuttons(1,'web',1).
- &Apache::loncommon::end_page());
- } else {
- if ($env{'browser.interface'} eq 'textual') {
-#
-# ssi-based rendering for text-based interface
-#
- $r->print('<body bgcolor="#FFFFFF">'.
- &Apache::lonmenu::menubuttons(1).
- &Apache::lonnet::ssi_body($externalsyllabus).
- &Apache::loncommon::end_page());
- } elsif ($env{'environment.remote'} eq 'off') {
-#
-# This is inline remote
-#
- $r->print(<<ENDDOCUMENTINL);
-<frameset rows="180,*" border="0" $addentries>
-<frame src="/public/$cdom/$cnum/syllabus?wrapperdisplay=menu">
-<frame src="$externalsyllabus">
-</frameset>
-</html>
-ENDDOCUMENTINL
- } else {
-#
-# frame-based rendering for graphical interface
-#
- $r->print(<<ENDDOCUMENT);
-<frameset rows="1,*" border="0" $addentries>
-<frame src="/adm/rat/empty.html">
-<frame src="$externalsyllabus">
-</frameset>
-</html>
-ENDDOCUMENT
- }
- }
- return OK;
+ $r->print(&Apache::lonwrapper::simple_menu());
+ } else {
+ $r->print(&Apache::lonwrapper::wrapper("/public/$cdom/$cnum/syllabus?wrapperdisplay=menu",
+ $externalsyllabus));
+ }
+ return OK;
}
# ------------------------------ The buck stops here: internal syllabus display