--- loncom/xml/lonxml.pm 2010/02/08 00:35:06 1.505 +++ loncom/xml/lonxml.pm 2010/09/29 16:12:17 1.505.2.4 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.505 2010/02/08 00:35:06 raeburn Exp $ +# $Id: lonxml.pm,v 1.505.2.4 2010/09/29 16:12:17 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -572,6 +572,10 @@ sub inner_xmlparse { if (($ENV{'QUERY_STRING'}) && ($target eq 'web')) { $finaloutput=&afterburn($finaloutput); } + if ($target eq 'modified') { +# if modfied, handle startpart and endpart + $finaloutput=~s/\]*\>(.*)\]*\>/$1<\/part>/gs; + } return $finaloutput; } @@ -1524,17 +1528,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 ''; } @@ -1555,7 +1567,7 @@ sub renderingoptions { &Apache::loncommon::select_form( $env{'form.languages'}, 'languages', - &Apache::lonlocal::texthash(%langchoices)). + {&Apache::lonlocal::texthash(%langchoices)}). ''; } $output .= @@ -1564,11 +1576,11 @@ sub renderingoptions { &Apache::loncommon::select_form( $env{'form.texengine'}, 'texengine', - &Apache::lonlocal::texthash + {&Apache::lonlocal::texthash ('' => '', 'tth' => 'tth (TeX to HTML)', 'jsMath' => 'jsMath', - 'mimetex' => 'mimetex (Convert to Images)')). + 'mimetex' => 'mimetex (Convert to Images)')}). ''; return $output; } @@ -1582,47 +1594,27 @@ sub inserteditinfo { my $dragmath_button; my ($add_to_onload, $add_to_onresize); $initialize=&Apache::lonhtmlcommon::spellheader(); - if ($filetype eq 'html' - && (!&Apache::lonhtmlcommon::htmlareablocked() && - &Apache::lonhtmlcommon::htmlareabrowser())) { - $textarea_id .= '___Frame'; - my $lang = &Apache::lonhtmlcommon::htmlarea_lang(); - $initialize.=(< -lonca - function initDocument() { - var oFCKeditor = new FCKeditor('filecont'); - oFCKeditor.Config['CustomConfigurationsPath'] = '/fckeditor/loncapaconfig.js' ; - oFCKeditor.Config['FullPage'] = true - oFCKeditor.Config['AutoDetectLanguage'] = false; - oFCKeditor.Config['DefaultLanguage'] = "$lang"; - oFCKeditor.ReplaceTextarea(); - } - function check_if_dirty(editor) { - if (editor.IsDirty()) { - unClean(); - } - } - function FCKeditor_OnComplete(editor) { - editor.Events.AttachEvent("OnSelectionChange",check_if_dirty); - resize_textarea('$textarea_id','LC_aftertextarea'); - } - -FULLPAGE - } else { - $initialize.=(< 'true', + dragmath => 'math', + ); + $initialize .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args); + } + $initialize .= (< +// FULLPAGE - if ($filetype eq 'html' || $filetype eq 'tex') { - $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup'); - $dragmath_button = &Apache::lonhtmlcommon::dragmath_button('filecont',1); - } + if ($filetype eq 'html') { + $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');"; @@ -1631,13 +1623,13 @@ FULLPAGE } my $titledisplay=&display_title(); - my $wysiwyglink; + my $textareaclass; my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit', 'vi' => 'Save and View', 'dv' => 'Discard Edits and View', 'un' => 'undo', 'ed' => 'Edit'); - my $spelllink .=&Apache::lonhtmlcommon::spelllink('xmledit','filecont'); + my $spelllink = &Apache::lonhtmlcommon::spelllink('xmledit','filecont'); my $textarea_events = &Apache::edit::element_change_detection(); my $form_events = &Apache::edit::form_change_detection(); my $htmlerror; @@ -1647,11 +1639,7 @@ FULLPAGE $htmlerror=''.$htmlerror.''; } if (&Apache::lonhtmlcommon::htmlareabrowser()) { - if (&Apache::lonhtmlcommon::htmlareablocked()) { - $wysiwyglink = &Apache::lonhtmlcommon::enablelink($textarea_id); - } else { - $wysiwyglink = &Apache::lonhtmlcommon::disablelink($textarea_id); - } + $textareaclass = 'class="LC_richDefaultOff"'; } } my $editfooter=(< - $dragmath_button $spelllink $htmlerror + $htmlerror $dragmath_button
- +
$spelllink
- $wysiwyglink
$titledisplay
@@ -1828,9 +1815,6 @@ ENDNOTFOUND $result = &Apache::lontexconvert::converted(\$filecontents, $env{'form.texengine'}); if ($env{'form.return_only_error_and_warning_counts'}) { - if (&verify_html(''.$result.'')) { - $errorcount++; - } $result = "$errorcount:$warningcount"; } } else { @@ -2291,24 +2275,20 @@ sub get_tag { =pod -=item &print_pdf_radiobutton(fieldname, value, text) +=item &print_pdf_radiobutton(fieldname, value) -Returns a latexline to generate a PDF-Form-Radiobutton with Text. +Returns a latexline to generate a PDF-Form-Radiobutton. +Note: Radiobuttons with equal names are automaticly grouped + in a selection-group. -$fieldname: PDF internalname of the radiobutton -$value: Value of radiobutton (read when dumping the PDF data) -$text: Text on the rightside of the radiobutton +$fieldname: PDF internalname of the radiobutton(group) +$value: Value of radiobutton =cut sub print_pdf_radiobutton { - my $result = ''; - my ($fieldName, $value, $text) = @_; - $result .= '\begin{tabularx}{\textwidth}{p{0cm}X}'."\n"; - $result .= '\radioButton[\symbolchoice{circle}]{'. - $fieldName.'}{10bp}{10bp}{'.$value.'}&'.$text."\n"; - $result .= '\end{tabularx}' . "\n"; - $result .= '\hspace{2mm}' . "\n"; - return $result; + my ($fieldname, $value) = @_; + return '\radioButton[\symbolchoice{circle}]{' + .$fieldname.'}{10bp}{10bp}{'.$value.'}'; }