--- loncom/xml/lonxml.pm 2011/12/01 04:41:55 1.505.2.7 +++ loncom/xml/lonxml.pm 2010/03/10 21:26:10 1.506 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.505.2.7 2011/12/01 04:41:55 raeburn Exp $ +# $Id: lonxml.pm,v 1.506 2010/03/10 21:26:10 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -112,7 +112,6 @@ use Apache::lonmaxima(); use Apache::lonr(); use Apache::lonlocal; use Apache::lonhtmlcommon(); -use Apache::functionplotresponse(); #==================================== Main subroutine: xmlparse @@ -573,10 +572,6 @@ 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; } @@ -882,11 +877,6 @@ sub init_safespace { $safehole->wrap(\&Apache::lonnet::logthis,$safeeval,'&LONCAPA_INTERNAL_LOGTHIS'); $safehole->wrap(\&Apache::inputtags::finalizeawards,$safeeval,'&LONCAPA_INTERNAL_FINALIZEAWARDS'); $safehole->wrap(\&Apache::caparesponse::get_sigrange,$safeeval,'&LONCAPA_INTERNAL_get_sigrange'); - $safehole->wrap(\&Apache::functionplotresponse::fpr_val,$safeeval,'&fpr_val'); - $safehole->wrap(\&Apache::functionplotresponse::fpr_f,$safeeval,'&fpr_f'); - $safehole->wrap(\&Apache::functionplotresponse::fpr_dfdx,$safeeval,'&fpr_dfdx'); - $safehole->wrap(\&Apache::functionplotresponse::fpr_d2fdx2,$safeeval,'&fpr_d2fdx2'); - # use Data::Dumper; # $safehole->wrap(\&Data::Dumper::Dumper,$safeeval,'&LONCAPA_INTERNAL_Dumper'); #need to inspect this class of ops @@ -1534,25 +1524,17 @@ SIMPLECONTENT sub verify_html { my ($filecontents)=@_; - 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>'); - } + 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>'); } return ''; } @@ -1573,7 +1555,7 @@ sub renderingoptions { &Apache::loncommon::select_form( $env{'form.languages'}, 'languages', - {&Apache::lonlocal::texthash(%langchoices)}). + &Apache::lonlocal::texthash(%langchoices)). ''; } $output .= @@ -1582,11 +1564,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; } @@ -1600,27 +1582,47 @@ sub inserteditinfo { my $dragmath_button; my ($add_to_onload, $add_to_onresize); $initialize=&Apache::lonhtmlcommon::spellheader(); - 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); - } - $initialize .= (< -// FULLPAGE - if ($filetype eq 'html') { - $dragmath_button = ''.&Apache::lonhtmlcommon::dragmath_button('filecont',1).''; - $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup'); + } else { + $initialize.=(< + function initDocument() { + resize_textarea('$textarea_id','LC_aftertextarea'); + } + +FULLPAGE + if ($filetype eq 'html' || $filetype eq 'tex') { + $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup'); + $dragmath_button = &Apache::lonhtmlcommon::dragmath_button('filecont',1); + } } + $add_to_onload = 'initDocument();'; $add_to_onresize = "resize_textarea('$textarea_id','LC_aftertextarea');"; @@ -1629,13 +1631,13 @@ FULLPAGE } my $titledisplay=&display_title(); - my $textareaclass; + my $wysiwyglink; 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; @@ -1645,7 +1647,11 @@ FULLPAGE $htmlerror=''.$htmlerror.''; } if (&Apache::lonhtmlcommon::htmlareabrowser()) { - $textareaclass = 'class="LC_richDefaultOff"'; + if (&Apache::lonhtmlcommon::htmlareablocked()) { + $wysiwyglink = &Apache::lonhtmlcommon::enablelink($textarea_id); + } else { + $wysiwyglink = &Apache::lonhtmlcommon::disablelink($textarea_id); + } } } my $editfooter=(< - $htmlerror $dragmath_button + $dragmath_button $spelllink $htmlerror
-
$spelllink +
+ $wysiwyglink
$titledisplay
@@ -1821,6 +1828,9 @@ 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 { @@ -1845,26 +1855,22 @@ ENDNOTFOUND '
'.$result.
                               '
'; } - if ($env{'environment.remote'} eq 'off') { - my $brcrum; - if ($env{'request.state'} eq 'construct') { - $brcrum = [{'href' => &Apache::loncommon::authorspace(), - 'text' => 'Construction Space'}, - {'href' => '', - 'text' => $breadcrumbtext}]; - } else { - $brcrum = ''; # FIXME: Where are we? - } - my %options = ('bread_crumbs' => $brcrum, - 'bgcolor' => '#FFFFFF'); - $result = - &Apache::loncommon::start_page(undef,undef,\%options) - .$controls - .$result - .&Apache::loncommon::end_page(); + my $brcrum; + if ($env{'request.state'} eq 'construct') { + $brcrum = [{'href' => &Apache::loncommon::authorspace(), + 'text' => 'Construction Space'}, + {'href' => '', + 'text' => $breadcrumbtext}]; } else { - $result = $controls.$result; + $brcrum = ''; # FIXME: Where are we? } + my %options = ('bread_crumbs' => $brcrum, + 'bgcolor' => '#FFFFFF'); + $result = + &Apache::loncommon::start_page(undef,undef,\%options) + .$controls + .$result + .&Apache::loncommon::end_page(); } } } @@ -1895,10 +1901,6 @@ ENDNOTFOUND $header = &Apache::loncommon::head_subbox( &Apache::loncommon::CSTR_pageheader()); } - if ($env{'environment.remote'} ne 'off') { - $options{'bgcolor'} = '#FFFFFF'; - $options{'only_body'} = 1; - } my $js = &Apache::edit::js_change_detection(). &Apache::loncommon::resize_textarea_js(); @@ -2145,13 +2147,11 @@ sub register_insert_xml { while (my $token = $parser->get_token()) { if ($token->[0] eq 'S') { my $key; - if ($token->[1] eq 'tag') { + if ($token->[1] eq 'tag') { $tag = $token->[2]{'name'}; - if (defined($tag)) { - $insertlist{$tagnum.'.tag'} = $tag; - $insertlist{$tag.'.num'} = $tagnum; - push(@alltags,$tag); - } + $insertlist{"$tagnum.tag"} = $tag; + $insertlist{"$tag.num"} = $tagnum; + push(@alltags,$tag); } elsif ($in_help && $token->[1] eq 'file') { $key = $tag.'.helpfile'; } elsif ($in_help && $token->[1] eq 'description') { @@ -2183,12 +2183,12 @@ sub register_insert_xml { # parse the allows and ignore tags set to no foreach my $tag (@alltags) { - next if (!exists($insertlist{$tag.'.allow'})); - my $allow = $insertlist{$tag.'.allow'}; + next if (!exists($insertlist{"$tag.allow"})); + my $allow = $insertlist{"$tag.allow"}; foreach my $element (split(',',$allow)) { $element =~ s/(^\s*|\s*$ )//gx; - if (!exists($insertlist{$element.'.show'}) - || $insertlist{$element.'.show'} ne 'no') { + if (!exists($insertlist{"$element.show"}) + || $insertlist{"$element.show"} ne 'no') { push(@{ $insertlist{$tag.'.which'} },$element); } } @@ -2283,20 +2283,24 @@ sub get_tag { =pod -=item &print_pdf_radiobutton(fieldname, value) +=item &print_pdf_radiobutton(fieldname, value, text) -Returns a latexline to generate a PDF-Form-Radiobutton. -Note: Radiobuttons with equal names are automaticly grouped - in a selection-group. +Returns a latexline to generate a PDF-Form-Radiobutton with Text. -$fieldname: PDF internalname of the radiobutton(group) -$value: Value of radiobutton +$fieldname: PDF internalname of the radiobutton +$value: Value of radiobutton (read when dumping the PDF data) +$text: Text on the rightside of the radiobutton =cut sub print_pdf_radiobutton { - my ($fieldname, $value) = @_; - return '\radioButton[\symbolchoice{circle}]{' - .$fieldname.'}{10bp}{10bp}{'.$value.'}'; + 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; }