--- loncom/interface/lonfeedback.pm 2009/11/21 22:36:23 1.279 +++ loncom/interface/lonfeedback.pm 2009/12/22 06:14:35 1.283 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.279 2009/11/21 22:36:23 www Exp $ +# $Id: lonfeedback.pm,v 1.283 2009/12/22 06:14:35 faziophi Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,7 @@ use Apache::lonnavmaps; use Apache::lonenc(); use Apache::lonrss(); use HTML::LCParser(); +#use HTML::Tidy::libXML; use Apache::lonspeller(); use Apache::longroup; use Cwd; @@ -356,10 +357,10 @@ sub list_discussion { $togglink = 'toggoff'; } - $chglink .= '&changes='.$displinkA.'_'.$displinkB.'_'.$marklink.'_'.$togglink; + $chglink .= '&changes='.$displinkA.'_'.$displinkB.'_'.$marklink.'_'.$togglink; if ($newpostsflag) { - $chglink .= '&previous='.$prevread; + $chglink .= '&previous='.$prevread; } $chglink.=&group_args($group); @@ -416,13 +417,13 @@ imscp_v1p1.xsd http://www.imsglobal.org/ } } else { my $colspan=$maxdepth+1; - $discussion.= qq| - - |; + |); $discussion.='
'. "\n".''; $discussion .= &action_links_bar($colspan,$ressymb,$visible, @@ -450,7 +450,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ $discussion.="\n".''; } $discussion .= (<2) { $discussion .= ''.&mt('Threaded View').'  '. ''.&mt('Chronological View').'   '.&mt('Sorting/Filtering options').''.(' ' x2); } $discussion .=''.&mt('Export').'?  '; @@ -815,7 +815,7 @@ sub action_links_bar { &mt('Preferences on what is marked as NEW'). '
'.&mt('Mark NEW posts no longer new').''; + $discussion .= '">'.&mt('Mark NEW posts no longer new').''; } else { $discussion .= '
'; } @@ -848,7 +848,7 @@ sub postingform_display {
$lt{'note'}
$lt{'title'}: 

- + ENDDISCUSS if ($env{'form.origpage'}) { $postingform .= ''.&mt('Edit').''; @@ -1075,7 +1075,7 @@ sub build_posting_display { $sender.=' '.&mt('Make Visible').''; } @@ -1083,7 +1083,7 @@ sub build_posting_display { $sender.=' '.&mt('Hide').''; @@ -1124,7 +1124,7 @@ sub build_posting_display { $sender.=' '.&mt('Reply').''; @@ -1135,7 +1135,7 @@ sub build_posting_display { $sender.=' '.&mt('Reply').''; } @@ -1245,24 +1245,24 @@ sub build_posting_display { if ($prevread > 0 && $prevread <= $posttime) { $$newitem{$idx} = 1; $$discussionitems[$idx] .= ' -

'. ''.&mt('Show all posts').' '.&mt('to display').' '. @@ -569,7 +569,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ + $lt{'cuse'}:
- $lt{'cuse'}:   END @@ -591,7 +591,7 @@ END   - $lt{'chgt'}? + $lt{'chgt'}?
@@ -646,7 +646,7 @@ END $discussion.='
'. ''."\n". ''."\n". + ' onclick="this.form.submit();" />'."\n". ' 
+
'; } else { $$newitem{$idx} = 0; $$discussionitems[$idx] .= ' -

'.&mt('NEW').'
+
'; } $$discussionitems[$idx] .= ''; if ($$dischash{$toggkey}) { $$discussionitems[$idx].=''; } $$discussionitems[$idx].= '
   '. ''.$subject.'  '. - $sender.' '.$vgrlink.' ('. + ''.$sender.' '.$vgrlink.' ('. &Apache::lonlocal::locallocaltime($posttime).')  '. $ctlink.'
'. - $message.'

'; + $message.''; if ($contrib{$idx.':history'}) { my @postversions = (); $$discussionitems[$idx] .= &mt('This post has been edited by the author.'); @@ -1708,7 +1708,7 @@ $latexHelp

$lt{'title'}:

-

END @@ -1745,7 +1745,7 @@ END $r->print(< - +

END @@ -1952,9 +1952,9 @@ END $r->print(<$lt{'disa'} $lt{$discdisp} - +
- + END $r->print(&Apache::loncommon::end_data_table_row()); @@ -1969,7 +1969,7 @@ END $r->print(<$lt{'dotm'} $lt{$disctogg} - + END my $save = &mt('Save'); $r->print(&Apache::loncommon::end_data_table_row()); @@ -1983,7 +1983,7 @@ END - + END if (exists($env{'form.group'})) { $r->print(''); @@ -2136,17 +2136,17 @@ $start_page

- - - - - - - - - - - + + + + + + + + + + +
$lt{'soor'} $lt{'sprs'} $lt{'spur'} $lt{'spse'} $lt{'spgr'} $lt{'psub'}$lt{'soor'} $lt{'sprs'} $lt{'spur'} $lt{'spse'} $lt{'spgr'} $lt{'psub'}
@@ -2201,7 +2201,7 @@ $start_page
- + END if (exists($env{'form.group'})) { $r->print(''); @@ -2324,7 +2324,7 @@ END
- + $end_page END @@ -2427,7 +2427,7 @@ sub redirect_back { if ($previous > 0) { $qrystr = 'previous='.$previous; if ($feedurl =~ /\?register=1/) { - $feedurl .= '&'.$qrystr; + $feedurl .= '&'.$qrystr; } else { $feedurl .= '?'.$qrystr; } @@ -2436,18 +2436,18 @@ sub redirect_back { if (defined($sort)) { my $sortqry = 'sortposts='.$sort; if (($feedurl =~ /\?register=1/) || ($feedurl =~ /\?previous=/)) { - $feedurl .= '&'.$sortqry; + $feedurl .= '&'.$sortqry; } else { $feedurl .= '?'.$sortqry; } $sorttag = ''; if (defined($numpicks)) { my $userpickqry = 'totposters='.$numpicks; - $feedurl .= '&'.$userpickqry; + $feedurl .= '&'.$userpickqry; $userpicktag = ''; } else { if (ref($sectionpick) eq 'ARRAY') { - $feedurl .= '§ionpick='; + $feedurl .= '&sectionpick='; $sectag .= ''; } else { - $feedurl .= '§ionpick='.$sectionpick; + $feedurl .= '&sectionpick='.$sectionpick; $sectag = ''; } if (ref($grouppick) eq 'ARRAY') { - $feedurl .= '&grouppick='; + $feedurl .= '&grouppick='; $sectag .= ''; } else { - $feedurl .= '&grouppick='.$grouppick; + $feedurl .= '&grouppick='.$grouppick; $grptag = ''; } if (ref($rolefilter) eq 'ARRAY') { - $feedurl .= '&rolefilter='; + $feedurl .= '&rolefilter='; $roletag .= ''; } else { - $feedurl .= '&rolefilter='.$rolefilter; + $feedurl .= '&rolefilter='.$rolefilter; $roletag = ''; } - $feedurl .= '&statusfilter='.$statusfilter; + $feedurl .= '&statusfilter='.$statusfilter; $statustag =''; } } @@ -2679,11 +2679,12 @@ sub clear_out_html { ($override)) { # allows


      • #

        - # + # %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1, BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1, M=>1, ALGEBRA=>1, SUB=>1, SUP=>1, SPAN=>1, - H1=>1, H2=>1, H3=>1, H4=>1, H5=>1); + H1=>1, H2=>1, H3=>1, H4=>1, H5=>1, H6=>1, + TABLE=>1, TR=>1, TD=>1, TH=>1, TBODY=>1); } # Do the substitution of everything that is not explicitly allowed $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/ @@ -2949,6 +2950,30 @@ sub show_preview { ); } +sub contains_block_html { + my ($message)=@_; + return ($message =~ m/ + <(br|h1|h2|h3|h4|h5|h6|p|ol|ul|table|pre|address|blockquote|center|div) + [\s]* + ([\w]+\=['"][\w]+['"])* + [\s]* + ( + [\s]*[\/]>| + >.*<\/\1[\s]*> + )/xs ); +} + +sub tidy_html { + my ($message)=@_; +# my $tidy = HTML::Tidy::libXML->new(); +# my $xhtml = $tidy->clean($message, 'utf-8', 1); +# $xhtml =~ m/(.*)<\/body>/is; +# my $clean = $1; +# # remove any empty block-level tags +# $clean =~ s/<(table|p|div|tbody|blockquote|m|pre|algebra|center|ol|ul|span|h1|h2|h3|h4|h5|h6)\s*\/>//i; +# $message=$clean; + return $message; +} sub newline_to_br { my ($message)=@_; @@ -2982,7 +3007,7 @@ sub generate_preview_button { +onclick="if (typeof(document.$formname.onsubmit)=='function') {document.$formname.onsubmit();};this.form.comment.value=document.$formname.$fieldname.value;this.form.subject.value=document.$formname.subject.value;this.form.submit();" /> ENDPREVIEW } @@ -3041,7 +3066,7 @@ $toolarge
        @@ -3092,7 +3117,7 @@ END $r->print(''."\n"); } $r->print(< + $end_page END @@ -3139,7 +3164,7 @@ sub generate_attachments_button {
        $lt{'clic'}: 
        - Subject: $subject

        + Subject: $subject

        END if ($idx) { if ($attachmenturls) { @@ -3069,7 +3094,7 @@ END
        - $lt{'adda'} + $lt{'adda'}