--- loncom/xml/lonxml.pm 2010/08/08 02:00:44 1.513 +++ loncom/xml/lonxml.pm 2010/09/29 15:56:03 1.517 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.513 2010/08/08 02:00:44 raeburn Exp $ +# $Id: lonxml.pm,v 1.517 2010/09/29 15:56:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1434,17 +1434,25 @@ SIMPLECONTENT sub verify_html { my ($filecontents)=@_; - if ($filecontents!~/(?:\<|\<\;)(?:html|xml)[^\<]*(?:\>|\>\;)/is) { - return &mt('File does not have [_1] or [_2] starting tag','<html>','<xml>'); - } - if ($filecontents!~/(?:\<|\<\;)\/(?:html|xml)(?:\>|\>\;)/is) { - return &mt('File does not have [_1] or [_2] ending tag','<html>','<xml>'); - } - if ($filecontents!~/(?:\<|\<\;)(?:body|frameset)[^\<]*(?:\>|\>\;)/is) { - return &mt('File does not have [_1] or [_2] starting tag','<body>','<frameset>'); - } - if ($filecontents!~/(?:\<|\<\;)\/(?:body|frameset)[^\<]*(?:\>|\>\;)/is) { - return &mt('File does not have [_1] or [_2] ending tag','<body>','<frameset>'); + my ($is_html,$is_xml); + if ($filecontents =~/(?:\<|\<\;)\?xml[^\<]*\?(?:\>|\>\;)/is) { + $is_xml = 1; + } elsif ($filecontents =~/(?:\<|\<\;)html(?:\s+[^\<]+|\s*)[^\<]*(?:\>|\>\;)/is) { + $is_html = 1; + } + unless ($is_xml || $is_html) { + return &mt('File does not have [_1] or [_2] starting tag','<html>','<?xml ?>'); + } + if ($is_html) { + if ($filecontents!~/(?:\<|\<\;)\/html(?:\>|\>\;)/is) { + return &mt('File does not have [_1] ending tag','<html>'); + } + if ($filecontents!~/(?:\<|\<\;)(?:body|frameset)[^\<]*(?:\>|\>\;)/is) { + return &mt('File does not have [_1] or [_2] starting tag','<body>','<frameset>'); + } + if ($filecontents!~/(?:\<|\<\;)\/(?:body|frameset)[^\<]*(?:\>|\>\;)/is) { + return &mt('File does not have [_1] or [_2] ending tag','<body>','<frameset>'); + } } return ''; } @@ -1492,27 +1500,27 @@ sub inserteditinfo { my $dragmath_button; my ($add_to_onload, $add_to_onresize); $initialize=&Apache::lonhtmlcommon::spellheader(); - if (($filetype eq 'html') && (&Apache::lonhtmlcommon::htmlareabrowser())) { + if (($filetype eq 'html') && (&Apache::lonhtmlcommon::htmlareabrowser())) { my $lang = &Apache::lonhtmlcommon::htmlarea_lang(); my %textarea_args = ( fullpage => 'true', dragmath => 'math', ); - $initialize .= - &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args). - (< +// FULLPAGE + if ($filetype eq 'html') { + $dragmath_button = ''.&Apache::lonhtmlcommon::dragmath_button('filecont',1).''; + $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup'); } - if ($filetype eq 'html' || $filetype eq 'tex') { - $dragmath_button = ''.&Apache::lonhtmlcommon::dragmath_button('filecont',1).''; - $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup'); - } - $add_to_onload = 'initDocument();'; $add_to_onresize = "resize_textarea('$textarea_id','LC_aftertextarea');"; @@ -1537,7 +1545,7 @@ FULLPAGE $htmlerror=''.$htmlerror.''; } if (&Apache::lonhtmlcommon::htmlareabrowser()) { - $textareaclass = 'class="LC_richDetectHtml"'; + $textareaclass = 'class="LC_richDefaultOff"'; } } my $editfooter=(<'.$result.'')) { - $errorcount++; - } $result = "$errorcount:$warningcount"; } } else {