--- loncom/xml/lonxml.pm 2001/07/27 18:16:22 1.104 +++ loncom/xml/lonxml.pm 2002/01/09 09:50:59 1.148 @@ -1,6 +1,41 @@ # The LearningOnline Network with CAPA # XML Parser Module # +# $Id: lonxml.pm,v 1.148 2002/01/09 09:50:59 albertel Exp $ +# +# Copyright Michigan State University Board of Trustees +# +# This file is part of the LearningOnline Network with CAPA (LON-CAPA). +# +# LON-CAPA is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LON-CAPA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LON-CAPA; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# /home/httpd/html/adm/gpl.txt +# +# http://www.lon-capa.org/ +# +# Copyright for TtHfunc and TtMfunc by Ian Hutchinson. +# TtHfunc and TtMfunc (the "Code") may be compiled and linked into +# binary executable programs or libraries distributed by the +# Michigan State University (the "Licensee"), but any binaries so +# distributed are hereby licensed only for use in the context +# of a program or computational system for which the Licensee is the +# primary author or distributor, and which performs substantial +# additional tasks beyond the translation of (La)TeX into HTML. +# The C source of the Code may not be distributed by the Licensee +# to any other parties under any circumstances. +# # last modified 06/26/00 by Alexander Sakharuk # 11/6 Gerd Kortemeyer # 6/1/1 Gerd Kortemeyer @@ -13,12 +48,22 @@ # 6/12,6/13 H. K. Ng # 6/16 Gerd Kortemeyer # 7/27 H. K. Ng +# 8/7,8/9,8/10,8/11,8/15,8/16,8/17,8/18,8/20,8/23,8/24 Gerd Kortemeyer +# Guy Albertelli +# 9/26 Gerd Kortemeyer +# Dec Guy Albertelli +# YEAR=2002 +# 1/1 Gerd Kortemeyer +# 1/2 Matthew Hall +# 1/3 Gerd Kortemeyer +# 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); @@ -26,13 +71,21 @@ use Math::Random qw(:all); use Opcode; sub register { - my $space; - my @taglist; - my $temptag; - ($space,@taglist) = @_; - foreach $temptag (@taglist) { - $Apache::lonxml::alltags{$temptag}=$space; + my ($space,@taglist) = @_; + foreach my $temptag (@taglist) { + push(@{ $Apache::lonxml::alltags{$temptag} },$space); + } +} + +sub deregister { + my ($space,@taglist) = @_; + foreach my $temptag (@taglist) { + my $tempspace = $Apache::lonxml::alltags{$temptag}[-1]; + if ($tempspace eq $space) { + pop(@{ $Apache::lonxml::alltags{$temptag} }); + } } + #&printalltags(); } use Apache::Constants qw(:common); @@ -44,6 +97,7 @@ 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 @@ -95,6 +149,12 @@ sub xmlbegin { sub xmlend { my $discussion=''; 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(); if ($symb) { my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'}, @@ -105,13 +165,37 @@ sub xmlend { '
'.$contrib{$idx.':sendername'}.' at '.
- $contrib{$idx.':senderdomain'}.' ('.
+ my $hidden=($contrib{'hidden'}=~/\.$idx\./);
+ unless (($hidden) && (!$seeid)) {
+ my $message=$contrib{$idx.':message'};
+ $message=~s/\n/\
/g;
+ if ($message) {
+ if ($hidden) {
+ $message=''.$message.'';
+ }
+ 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.=' Make Visible';
+ } else {
+ $sender.=' Hide';
+ }
+ }
+ }
+ $discussion.='
'.$sender.' ('. localtime($contrib{$idx.':timestamp'}). '):
'.$message. - ''; + ''; + } + } } $discussion.=''; } @@ -120,6 +204,107 @@ sub xmlend { return $discussion.'