version 1.106, 2001/08/07 16:54:14
|
version 1.112, 2001/08/15 14:03:03
|
Line 13
|
Line 13
|
# 6/12,6/13 H. K. Ng |
# 6/12,6/13 H. K. Ng |
# 6/16 Gerd Kortemeyer |
# 6/16 Gerd Kortemeyer |
# 7/27 H. K. Ng |
# 7/27 H. K. Ng |
# 8/7 Gerd Kortemeyer |
# 8/7,8/9,8/10,8/11,8/15 Gerd Kortemeyer |
|
|
package Apache::lonxml; |
package Apache::lonxml; |
use vars |
use vars |
Line 97 sub xmlbegin {
|
Line 97 sub xmlbegin {
|
sub xmlend { |
sub xmlend { |
my $discussion=''; |
my $discussion=''; |
if ($ENV{'request.course.id'}) { |
if ($ENV{'request.course.id'}) { |
|
my $crs='/'.$ENV{'request.course.id'}; |
|
if ($ENV{'request.course.sec'}) { |
|
$crs.='_'.$ENV{'request.course.sec'}; |
|
} |
|
$crs=~s/\_/\//g; |
|
my $seeid=&Apache::lonnet::allowed('rin',$crs); |
my $symb=&Apache::lonnet::symbread(); |
my $symb=&Apache::lonnet::symbread(); |
if ($symb) { |
if ($symb) { |
my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'}, |
my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'}, |
Line 107 sub xmlend {
|
Line 113 sub xmlend {
|
'<address><hr /><h2>Course Discussion of Resource</h2>'; |
'<address><hr /><h2>Course Discussion of Resource</h2>'; |
my $idx; |
my $idx; |
for ($idx=1;$idx<=$contrib{'version'};$idx++) { |
for ($idx=1;$idx<=$contrib{'version'};$idx++) { |
my $message=$contrib{$idx.':message'}; |
my $hidden=($contrib{'hidden'}=~/\.$idx\./); |
$message=~s/\n/\<br \/\>/g; |
unless (($hidden) && (!$seeid)) { |
$discussion.='<p><b>'.$contrib{$idx.':sendername'}.' at '. |
my $message=$contrib{$idx.':message'}; |
$contrib{$idx.':senderdomain'}.'</b> ('. |
$message=~s/\n/\<br \/\>/g; |
|
if ($message) { |
|
if ($hidden) { |
|
$message='<font color="#888888">'.$message.'</font>'; |
|
} |
|
my $sender='Anonymous'; |
|
if ((!$contrib{$idx.':anonymous'}) || ($seeid)) { |
|
$sender=$contrib{$idx.':sendername'}.' at '. |
|
$contrib{$idx.':senderdomain'}; |
|
if ($contrib{$idx.':anonymous'}) { |
|
$sender.=' (anonymous)'; |
|
} |
|
if ($seeid) { |
|
if ($hidden) { |
|
$sender.=' <a href="/adm/feedback?unhide='. |
|
$symb.':::'.$idx.'">Make Visible</a>'; |
|
} else { |
|
$sender.=' <a href="/adm/feedback?hide='. |
|
$symb.':::'.$idx.'">Hide</a>'; |
|
} |
|
} |
|
} |
|
$discussion.='<p><b>'.$sender.'</b> ('. |
localtime($contrib{$idx.':timestamp'}). |
localtime($contrib{$idx.':timestamp'}). |
'):<blockquote>'.$message. |
'):<blockquote>'.$message. |
'</blockquote></p>'; |
'</blockquote></p>'; |
|
} |
|
} |
} |
} |
$discussion.='</address>'; |
$discussion.='</address>'; |
} |
} |
Line 122 sub xmlend {
|
Line 152 sub xmlend {
|
return $discussion.'</html>'; |
return $discussion.'</html>'; |
} |
} |
|
|
|
sub checkout { |
|
my ($target,$symb,$tuname,$tudom,$tcrsid)=@_; |
|
unless ($symb) { |
|
$symb=&Apache::lonnet::symbread(); |
|
} |
|
unless ($tuname) { |
|
$tuname=$ENV{'user.name'}; |
|
$tudom=$ENV{'user.domain'}; |
|
$tcrsid=$ENV{'request.course.id'}; |
|
} |
|
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
|
my $infostr=&Apache::lonnet::escape( |
|
$tuname.'&'. |
|
$tudom.'&'. |
|
$tcrsid.'&'. |
|
$symb.'&'. |
|
time.'&'.$ENV{'REMOTE_ADDR'}); |
|
my $token=Apache::lonnet::reply('tmpput:'.$infostr,$lonhost); |
|
if ($token=~/^error\:/) { return ''; } |
|
$token=~s/^(\d+)\_.*\_(\d+)$/$1\_$2\_$lonhost/; |
|
if (&Apache::lonnet::log($tudom,$tuname, |
|
&Apache::lonnet::homeserver($tuname,$tudom), |
|
&Apache::lonnet::escape('Checkout '.$infostr.' - '. |
|
$token)) ne 'ok') { |
|
return ''; |
|
} |
|
if ($target eq 'web') { |
|
return '<img src="/cgi-bin/barcode.gif?encode='.$token.'" />'; |
|
} else { |
|
return $token; |
|
} |
|
} |
|
|
sub fontsettings() { |
sub fontsettings() { |
my $headerstring=''; |
my $headerstring=''; |
if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) { |
if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) { |
Line 172 ENDPARM
|
Line 235 ENDPARM
|
menu.currentStale=0; |
menu.currentStale=0; |
menu.clearbut(3,1); |
menu.clearbut(3,1); |
menu.switchbutton |
menu.switchbutton |
|
(6,3,'catalog.gif','catalog','info','catalog_info()'); |
|
menu.switchbutton |
(8,1,'eval.gif','evaluate','this','gopost("/adm/evaluate",currentURL)'); |
(8,1,'eval.gif','evaluate','this','gopost("/adm/evaluate",currentURL)'); |
menu.switchbutton |
menu.switchbutton |
(8,2,'fdbk.gif','feedback','on this','gopost("/adm/feedback",currentURL)'); |
(8,2,'fdbk.gif','feedback','on this','gopost("/adm/feedback",currentURL)'); |
Line 200 ENDPARM
|
Line 265 ENDPARM
|
menu.clearbut(7,3); |
menu.clearbut(7,3); |
menu.menucltim=menu.setTimeout( |
menu.menucltim=menu.setTimeout( |
'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+ |
'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+ |
'clearbut(9,1);clearbut(9,2);clearbut(9,3);', |
'clearbut(9,1);clearbut(9,2);clearbut(9,3);clearbut(6,3)', |
2000); |
2000); |
|
|
} |
} |
Line 284 sub xmlparse {
|
Line 349 sub xmlparse {
|
} |
} |
|
|
sub htmlclean { |
sub htmlclean { |
my $raw=shift; |
my ($raw,$full)=@_; |
|
|
my $tree = HTML::TreeBuilder->new; |
my $tree = HTML::TreeBuilder->new; |
$tree->ignore_unknown(0); |
$tree->ignore_unknown(0); |
|
|
$tree->parse($raw); |
$tree->parse($raw); |
my %emptyhash=(); |
|
|
|
my $output= $tree->as_HTML(undef,' ',\%emptyhash), "\n"; |
my $output= $tree->as_HTML(undef,' '); |
|
|
$output=~s/\<(br|hr|img)([^\>\/]*)\>/\<$1$2 \/\>/gis; |
$output=~s/\<(br|hr|img|meta|allow)([^\>\/]*)\>/\<$1$2 \/\>/gis; |
$output=~s/\<\/(br|hr|img)\>//gis; |
$output=~s/\<\/(br|hr|img|meta|allow)\>//gis; |
$output=~s/\<[\/]*(body|head|html)\>//gis; |
unless ($full) { |
|
$output=~s/\<[\/]*(body|head|html)\>//gis; |
|
} |
|
|
$tree = $tree->delete; |
$tree = $tree->delete; |
|
|
Line 744 sub parstring {
|
Line 810 sub parstring {
|
|
|
sub writeallows { |
sub writeallows { |
my $thisurl='/res/'.&Apache::lonnet::declutter(shift); |
my $thisurl='/res/'.&Apache::lonnet::declutter(shift); |
|
if ($ENV{'httpref.'.$thisurl}) { |
|
$thisurl=$ENV{'httpref.'.$thisurl}; |
|
} |
my $thisdir=$thisurl; |
my $thisdir=$thisurl; |
$thisdir=~s/\/[^\/]+$//; |
$thisdir=~s/\/[^\/]+$//; |
my %httpref=(); |
my %httpref=(); |
Line 831 SIMPLECONTENT
|
Line 900 SIMPLECONTENT
|
<form method="post"> |
<form method="post"> |
<textarea cols="80" rows="40" name="filecont">$filecontents</textarea> |
<textarea cols="80" rows="40" name="filecont">$filecontents</textarea> |
<br /> |
<br /> |
<input type="submit" name="savethisfile" value="Save this file" /> |
<input type="submit" name="attemptclean" |
|
value="Save and then attempt to clean HTML" /> |
|
<input type="submit" name="savethisfile" value="Save this" /> |
</form> |
</form> |
ENDFOOTER |
ENDFOOTER |
$result=~s/(\<body[^\>]*\>)/$1$editheader/is; |
$result=~s/(\<body[^\>]*\>)/$1$editheader/is; |
Line 862 sub handler {
|
Line 933 sub handler {
|
# Edit action? Save file. |
# Edit action? Save file. |
# |
# |
unless ($ENV{'request.state'} eq 'published') { |
unless ($ENV{'request.state'} eq 'published') { |
if ($ENV{'form.savethisfile'}) { |
if (($ENV{'form.savethisfile'}) || ($ENV{'form.attemptclean'})) { |
&storefile($file,$ENV{'form.filecont'}); |
&storefile($file,$ENV{'form.filecont'}); |
} |
} |
} |
} |
Line 882 sub handler {
|
Line 953 sub handler {
|
ENDNOTFOUND |
ENDNOTFOUND |
$filecontents=''; |
$filecontents=''; |
} else { |
} else { |
|
unless ($ENV{'request.state'} eq 'published') { |
|
if ($ENV{'form.attemptclean'}) { |
|
$filecontents=&htmlclean($filecontents,1); |
|
} |
|
} |
$result = &Apache::lonxml::xmlparse($target,$filecontents,'',%mystyle); |
$result = &Apache::lonxml::xmlparse($target,$filecontents,'',%mystyle); |
} |
} |
|
|