--- loncom/xml/lonxml.pm 2002/02/21 04:18:59 1.153
+++ loncom/xml/lonxml.pm 2002/03/22 17:52:20 1.161
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.153 2002/02/21 04:18:59 albertel Exp $
+# $Id: lonxml.pm,v 1.161 2002/03/22 17:52:20 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -62,13 +62,14 @@ package Apache::lonxml;
use vars
qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace);
use strict;
-use HTML::TokeParser;
-use HTML::TreeBuilder;
-use Safe;
-use Safe::Hole;
-use Math::Cephes qw(:trigs :hypers :bessels erf erfc);
-use Math::Random qw(:all);
-use Opcode;
+use HTML::TokeParser();
+use HTML::TreeBuilder();
+use HTML::Entities();
+use Safe();
+use Safe::Hole();
+use Math::Cephes();
+use Math::Random();
+use Opcode();
sub register {
my ($space,@taglist) = @_;
@@ -89,15 +90,15 @@ sub deregister {
}
use Apache::Constants qw(:common);
-use Apache::lontexconvert;
-use Apache::style;
-use Apache::run;
-use Apache::londefdef;
-use Apache::scripttag;
-use Apache::edit;
-use Apache::lonnet;
-use Apache::File;
-use Apache::loncommon;
+use Apache::lontexconvert();
+use Apache::style();
+use Apache::run();
+use Apache::londefdef();
+use Apache::scripttag();
+use Apache::edit();
+use Apache::lonnet();
+use Apache::File();
+use Apache::loncommon();
#================================================== Main subroutine: xmlparse
#debugging control, to turn on debugging modify the correct handler
@@ -316,12 +317,17 @@ sub fontsettings() {
sub registerurl {
my $forcereg=shift;
- if ($ENV{'request.publicaccess'}) {
+ my $target = shift;
+ my $result = '';
+ if (($ENV{'request.publicaccess'}) ||
+ ($ENV{'REQUEST_URI'} eq '/res/adm/pages/menu.html')) {
return
'';
}
if ($Apache::lonxml::registered && !$forcereg) { return ''; }
$Apache::lonxml::registered=1;
+ my $nothing='';
+ if ($ENV{'browser.type'} eq 'explorer') { $nothing='javascript:void(0);'; }
if (($ENV{'REQUEST_URI'}!~/^\/(res\/)*adm\//) || ($forcereg)) {
my $hwkadd='';
if ($ENV{'REQUEST_URI'}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
@@ -347,13 +353,13 @@ ENDGRDS
ENDPARM
}
}
- return (<
// BEGIN LON-CAPA Internal
function LONCAPAreg() {
- menu=window.open("","LONCAPAmenu");
+ menu=window.open("$nothing","LONCAPAmenu","",false);
menu.clearTimeout(menu.menucltim);
menu.currentURL=window.location.pathname;
menu.currentStale=0;
@@ -380,7 +386,7 @@ ENDPARM
}
function LONCAPAstale() {
- menu=window.open("","LONCAPAmenu");
+ menu=window.open("$nothing","LONCAPAmenu","",false);
menu.currentStale=1;
menu.switchbutton
(3,1,'reload.gif','return','location','go(currentURL)');
@@ -399,13 +405,13 @@ ENDPARM
ENDREGTHIS
} else {
- return (<
// BEGIN LON-CAPA Internal
function LONCAPAreg() {
- menu=window.open("","LONCAPAmenu");
+ menu=window.open("$nothing","LONCAPAmenu","",false);
menu.currentStale=1;
menu.clearbut(2,1);
menu.clearbut(2,3);
@@ -426,8 +432,52 @@ ENDREGTHIS
// END LON-CAPA Internal
ENDDONOTREGTHIS
-
}
+ if ($target eq 'edit') {
+ # Javascript routines for construction space:
+ # openbrowser and opensearcher will start the file browser
+ # (lonindexer) and searcher (lonsearchcat) respectively.
+ # Inputs are the name of the html form being used
+ # and the name of the element the selected URL should
+ # be placed in.
+ $result .=<<"ENDBROWSERSCRIPT";
+
+ENDBROWSERSCRIPT
+ }
+ return $result;
}
sub loadevents() {
@@ -485,7 +535,7 @@ sub htmlclean {
my $output= $tree->as_HTML(undef,' ');
- $output=~s/\<(br|hr|img|meta|allow)([^\>\/]*)\>/\<$1$2 \/\>/gis;
+ $output=~s/\<(br|hr|img|meta|allow)(.*?)\>/\<$1$2 \/\>/gis;
$output=~s/\<\/(br|hr|img|meta|allow)\>//gis;
unless ($full) {
$output=~s/\<[\/]*(body|head|html)\>//gis;
@@ -978,16 +1028,8 @@ sub writeallows {
#
sub afterburn {
my $result=shift;
- foreach (split(/&/,$ENV{'QUERY_STRING'})) {
- my ($name, $value) = split(/=/,$_);
- $value =~ tr/+/ /;
- $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
- if (($name eq 'highlight')||($name eq 'anchor')||($name eq 'link')) {
- unless ($ENV{'form.'.$name}) {
- $ENV{'form.'.$name}=$value;
- }
- }
- }
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['highlight','anchor','link']);
if ($ENV{'form.highlight'}) {
foreach (split(/\,/,$ENV{'form.highlight'})) {
my $anchorname=$_;
@@ -1049,19 +1091,23 @@ SIMPLECONTENT
sub inserteditinfo {
my ($result,$filecontents)=@_;
- $filecontents =~ s::</textarea>:ig;
+ $filecontents = &HTML::Entities::encode($filecontents);
# my $editheader='Edit below
';
+ my $buttons=(<
+
+
+BUTTONS
my $editfooter=(<
ENDFOOTER
# $result=~s/(\]*\>)/$1$editheader/is;
@@ -1140,7 +1186,7 @@ ENDNOTFOUND
$filecontents='';
if ($ENV{'request.state'} ne 'published') {
$filecontents=&createnewhtml();
- $ENV{'form.showmode'}='Edit'; #force edit mode
+ $ENV{'form.editmode'}='Edit'; #force edit mode
}
} else {
unless ($ENV{'request.state'} eq 'published') {
@@ -1148,7 +1194,7 @@ ENDNOTFOUND
$filecontents=&htmlclean($filecontents,1);
}
}
- if ($ENV{'form.showmode'} ne 'Edit') {
+ if (!$ENV{'form.editmode'} || $ENV{'form.viewmode'}) {
$result = &Apache::lonxml::xmlparse($target,$filecontents,'',%mystyle);
}
}
@@ -1157,7 +1203,7 @@ ENDNOTFOUND
# Edit action? Insert editing commands
#
unless ($ENV{'request.state'} eq 'published') {
- if ($ENV{'form.showmode'} eq 'Edit') {
+ if ($ENV{'form.editmode'} && (!($ENV{'form.viewmode'}))) {
$result='';
$result=&inserteditinfo($result,$filecontents);
}
@@ -1212,6 +1258,7 @@ sub get_param {
if ( ! $context ) { $context = -1; }
my $args ='';
if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }
+ if ( ! $args ) { return undef; }
if ( $args =~ /my \$$param=\"/ ) {
return &Apache::run::run("{$args;".'return $'.$param.'}',$safeeval); #'
} else {