Diff for /loncom/xml/lonxml.pm between versions 1.505.2.7 and 1.506

version 1.505.2.7, 2011/12/01 04:41:55 version 1.506, 2010/03/10 21:26:10
Line 112  use Apache::lonmaxima(); Line 112  use Apache::lonmaxima();
 use Apache::lonr();  use Apache::lonr();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonhtmlcommon();  use Apache::lonhtmlcommon();
 use Apache::functionplotresponse();  
   
 #====================================   Main subroutine: xmlparse    #====================================   Main subroutine: xmlparse  
   
Line 573  sub inner_xmlparse { Line 572  sub inner_xmlparse {
   if (($ENV{'QUERY_STRING'}) && ($target eq 'web')) {    if (($ENV{'QUERY_STRING'}) && ($target eq 'web')) {
     $finaloutput=&afterburn($finaloutput);      $finaloutput=&afterburn($finaloutput);
   }        }    
   if ($target eq 'modified') {  
 # if modfied, handle startpart and endpart  
      $finaloutput=~s/\<startpartmarker[^\>]*\>(.*)\<endpartmarker[^\>]*\>/<part>$1<\/part>/gs;  
   }  
   return $finaloutput;    return $finaloutput;
 }  }
   
Line 882  sub init_safespace { Line 877  sub init_safespace {
   $safehole->wrap(\&Apache::lonnet::logthis,$safeeval,'&LONCAPA_INTERNAL_LOGTHIS');    $safehole->wrap(\&Apache::lonnet::logthis,$safeeval,'&LONCAPA_INTERNAL_LOGTHIS');
   $safehole->wrap(\&Apache::inputtags::finalizeawards,$safeeval,'&LONCAPA_INTERNAL_FINALIZEAWARDS');    $safehole->wrap(\&Apache::inputtags::finalizeawards,$safeeval,'&LONCAPA_INTERNAL_FINALIZEAWARDS');
   $safehole->wrap(\&Apache::caparesponse::get_sigrange,$safeeval,'&LONCAPA_INTERNAL_get_sigrange');    $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;  #  use Data::Dumper;
 #  $safehole->wrap(\&Data::Dumper::Dumper,$safeeval,'&LONCAPA_INTERNAL_Dumper');  #  $safehole->wrap(\&Data::Dumper::Dumper,$safeeval,'&LONCAPA_INTERNAL_Dumper');
 #need to inspect this class of ops  #need to inspect this class of ops
Line 1534  SIMPLECONTENT Line 1524  SIMPLECONTENT
   
 sub verify_html {  sub verify_html {
     my ($filecontents)=@_;      my ($filecontents)=@_;
     my ($is_html,$is_xml);      if ($filecontents!~/(?:\<|\&lt\;)(?:html|xml)[^\<]*(?:\>|\&gt\;)/is) {
     if ($filecontents =~/(?:\<|\&lt\;)\?xml[^\<]*\?(?:\>|\&gt\;)/is) {         return &mt('File does not have [_1] or [_2] starting tag','&lt;html&gt;','&lt;xml&gt;');
         $is_xml = 1;      }
     } elsif ($filecontents =~/(?:\<|\&lt\;)html(?:\s+[^\<]+|\s*)(?:\>|\&gt\;)/is) {      if ($filecontents!~/(?:\<|\&lt\;)\/(?:html|xml)(?:\>|\&gt\;)/is) {
         $is_html = 1;         return &mt('File does not have [_1] or [_2] ending tag','&lt;html&gt;','&lt;xml&gt;');
     }      }
     unless ($is_xml || $is_html) {      if ($filecontents!~/(?:\<|\&lt\;)(?:body|frameset)[^\<]*(?:\>|\&gt\;)/is) {
         return &mt('File does not have [_1] or [_2] starting tag','&lt;html&gt;','&lt;?xml ?&gt;');         return &mt('File does not have [_1] or [_2] starting tag','&lt;body&gt;','&lt;frameset&gt;');
     }      }
     if ($is_html) {      if ($filecontents!~/(?:\<|\&lt\;)\/(?:body|frameset)[^\<]*(?:\>|\&gt\;)/is) {
         if ($filecontents!~/(?:\<|\&lt\;)\/html(?:\>|\&gt\;)/is) {         return &mt('File does not have [_1] or [_2] ending tag','&lt;body&gt;','&lt;frameset&gt;');
             return &mt('File does not have [_1] ending tag','&lt;html&gt;');  
         }  
         if ($filecontents!~/(?:\<|\&lt\;)(?:body|frameset)[^\<]*(?:\>|\&gt\;)/is) {  
             return &mt('File does not have [_1] or [_2] starting tag','&lt;body&gt;','&lt;frameset&gt;');  
         }  
         if ($filecontents!~/(?:\<|\&lt\;)\/(?:body|frameset)[^\<]*(?:\>|\&gt\;)/is) {  
             return &mt('File does not have [_1] or [_2] ending tag','&lt;body&gt;','&lt;frameset&gt;');  
         }  
     }      }
     return '';      return '';
 }  }
Line 1573  sub renderingoptions { Line 1555  sub renderingoptions {
            &Apache::loncommon::select_form(             &Apache::loncommon::select_form(
                $env{'form.languages'},                 $env{'form.languages'},
                'languages',                 'languages',
                {&Apache::lonlocal::texthash(%langchoices)}).                 &Apache::lonlocal::texthash(%langchoices)).
            '</span>';             '</span>';
     }      }
     $output .=      $output .=
Line 1582  sub renderingoptions { Line 1564  sub renderingoptions {
        &Apache::loncommon::select_form(         &Apache::loncommon::select_form(
            $env{'form.texengine'},             $env{'form.texengine'},
            'texengine',             'texengine',
            {&Apache::lonlocal::texthash             &Apache::lonlocal::texthash
                (''        => '',                 (''        => '',
                 'tth'     => 'tth (TeX to HTML)',                  'tth'     => 'tth (TeX to HTML)',
                 'jsMath'  => 'jsMath',                  'jsMath'  => 'jsMath',
                 'mimetex' => 'mimetex (Convert to Images)')}).                  'mimetex' => 'mimetex (Convert to Images)')).
      '</span>';       '</span>';
     return $output;      return $output;
 }  }
Line 1600  sub inserteditinfo { Line 1582  sub inserteditinfo {
       my $dragmath_button;        my $dragmath_button;
       my ($add_to_onload, $add_to_onresize);        my ($add_to_onload, $add_to_onresize);
       $initialize=&Apache::lonhtmlcommon::spellheader();        $initialize=&Apache::lonhtmlcommon::spellheader();
       if (($filetype eq 'html') && (&Apache::lonhtmlcommon::htmlareabrowser())) {        if ($filetype eq 'html' 
           my $lang = &Apache::lonhtmlcommon::htmlarea_lang();    && (!&Apache::lonhtmlcommon::htmlareablocked() &&
           my %textarea_args = (        &Apache::lonhtmlcommon::htmlareabrowser())) {
                                 fullpage => 'true',    $textarea_id .= '___Frame';
                                 dragmath => 'math',    my $lang = &Apache::lonhtmlcommon::htmlarea_lang();
                               );    $initialize.=(<<FULLPAGE);
           $initialize .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);  
       }  
       $initialize .= (<<FULLPAGE);  
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[  lonca
     function initDocument() {      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');   resize_textarea('$textarea_id','LC_aftertextarea');
     }      }
 // ]]>  
 </script>  </script>
 FULLPAGE  FULLPAGE
       if ($filetype eq 'html') {        } else {
           $dragmath_button = '<span id="math_filecont">'.&Apache::lonhtmlcommon::dragmath_button('filecont',1).'</span>';    $initialize.=(<<FULLPAGE);
           $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');  <script type="text/javascript">
       function initDocument() {
    resize_textarea('$textarea_id','LC_aftertextarea');
       }
   </script>
   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_onload = 'initDocument();';
       $add_to_onresize = "resize_textarea('$textarea_id','LC_aftertextarea');";        $add_to_onresize = "resize_textarea('$textarea_id','LC_aftertextarea');";
   
Line 1629  FULLPAGE Line 1631  FULLPAGE
       }        }
   
       my $titledisplay=&display_title();        my $titledisplay=&display_title();
       my $textareaclass;        my $wysiwyglink;
       my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit',        my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit',
  'vi' => 'Save and View',   'vi' => 'Save and View',
  'dv' => 'Discard Edits and View',   'dv' => 'Discard Edits and View',
  'un' => 'undo',   'un' => 'undo',
  'ed' => 'Edit');   '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 $textarea_events = &Apache::edit::element_change_detection();
       my $form_events     = &Apache::edit::form_change_detection();        my $form_events     = &Apache::edit::form_change_detection();
       my $htmlerror;        my $htmlerror;
Line 1645  FULLPAGE Line 1647  FULLPAGE
               $htmlerror='<span class="LC_error">'.$htmlerror.'</span>';                $htmlerror='<span class="LC_error">'.$htmlerror.'</span>';
           }            }
           if (&Apache::lonhtmlcommon::htmlareabrowser()) {            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=(<<ENDFOOTER);        my $editfooter=(<<ENDFOOTER);
Line 1662  $initialize Line 1668  $initialize
     <div class="LC_edit_problem_discards">      <div class="LC_edit_problem_discards">
       <input type="submit" name="discardview" accesskey="d" value="$lt{'dv'}" />        <input type="submit" name="discardview" accesskey="d" value="$lt{'dv'}" />
       <input type="submit" name="Undo" accesskey="u" value="$lt{'un'}" />        <input type="submit" name="Undo" accesskey="u" value="$lt{'un'}" />
       $htmlerror $dragmath_button        $dragmath_button $spelllink $htmlerror
     </div>      </div>
     <div class="LC_edit_problem_saves">      <div class="LC_edit_problem_saves">
       <input type="submit" name="savethisfile" accesskey="s" value="$lt{'st'}" />        <input type="submit" name="savethisfile" accesskey="s" value="$lt{'st'}" />
       <input type="submit" name="viewmode" accesskey="v" value="$lt{'vi'}" />        <input type="submit" name="viewmode" accesskey="v" value="$lt{'vi'}" />
     </div>      </div>
   </div>    </div>
   <textarea $textarea_events style="width:100%" cols="80" rows="44" name="filecont" id="filecont" $textareaclass>$filecontents</textarea><br />$spelllink    <textarea $textarea_events style="width:100%" cols="80" rows="44" name="filecont" id="filecont">$filecontents</textarea>
   <div id="LC_aftertextarea">    <div id="LC_aftertextarea">
       $wysiwyglink
     <br />      <br />
     $titledisplay      $titledisplay
   </div>    </div>
Line 1821  ENDNOTFOUND Line 1828  ENDNOTFOUND
                 $result = &Apache::lontexconvert::converted(\$filecontents,                  $result = &Apache::lontexconvert::converted(\$filecontents,
                               $env{'form.texengine'});                                $env{'form.texengine'});
                 if ($env{'form.return_only_error_and_warning_counts'}) {                  if ($env{'form.return_only_error_and_warning_counts'}) {
                       if (&verify_html('<html><body>'.$result.'</body></html>')) {
                           $errorcount++;
                       }
                     $result = "$errorcount:$warningcount";                      $result = "$errorcount:$warningcount";
                 }                  }
             } else {              } else {
Line 1845  ENDNOTFOUND Line 1855  ENDNOTFOUND
                               '<tr><td><b><pre>'.$result.                                '<tr><td><b><pre>'.$result.
                               '</pre></b></td></tr></table>';                                '</pre></b></td></tr></table>';
                 }                  }
                 if ($env{'environment.remote'} eq 'off') {                  my $brcrum;
                     my $brcrum;                  if ($env{'request.state'} eq 'construct') {
                     if ($env{'request.state'} eq 'construct') {                      $brcrum = [{'href' => &Apache::loncommon::authorspace(),
                         $brcrum = [{'href' => &Apache::loncommon::authorspace(),                                  'text' => 'Construction Space'},
                                     'text' => 'Construction Space'},                                 {'href' => '',
                                    {'href' => '',                                  'text' => $breadcrumbtext}];
                                     '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();  
                 } else {                  } 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();
             }              }
         }          }
     }      }
Line 1895  ENDNOTFOUND Line 1901  ENDNOTFOUND
                 $header = &Apache::loncommon::head_subbox(                  $header = &Apache::loncommon::head_subbox(
                               &Apache::loncommon::CSTR_pageheader());                                &Apache::loncommon::CSTR_pageheader());
             }              }
     if ($env{'environment.remote'} ne 'off') {  
  $options{'bgcolor'}   = '#FFFFFF';  
  $options{'only_body'} = 1;  
     }  
     my $js =      my $js =
  &Apache::edit::js_change_detection().   &Apache::edit::js_change_detection().
  &Apache::loncommon::resize_textarea_js();   &Apache::loncommon::resize_textarea_js();
Line 2145  sub register_insert_xml { Line 2147  sub register_insert_xml {
     while (my $token = $parser->get_token()) {      while (my $token = $parser->get_token()) {
  if ($token->[0] eq 'S') {   if ($token->[0] eq 'S') {
     my $key;      my $key;
     if ($token->[1] eq 'tag') {      if      ($token->[1] eq 'tag') {
  $tag = $token->[2]{'name'};   $tag = $token->[2]{'name'};
                 if (defined($tag)) {   $insertlist{"$tagnum.tag"} = $tag;
     $insertlist{$tagnum.'.tag'} = $tag;   $insertlist{"$tag.num"}   = $tagnum;
     $insertlist{$tag.'.num'}   = $tagnum;   push(@alltags,$tag);
     push(@alltags,$tag);  
                 }  
     } elsif ($in_help && $token->[1] eq 'file') {      } elsif ($in_help && $token->[1] eq 'file') {
  $key = $tag.'.helpfile';   $key = $tag.'.helpfile';
     } elsif ($in_help && $token->[1] eq 'description') {      } elsif ($in_help && $token->[1] eq 'description') {
Line 2183  sub register_insert_xml { Line 2183  sub register_insert_xml {
           
     # parse the allows and ignore tags set to <show>no</show>      # parse the allows and ignore tags set to <show>no</show>
     foreach my $tag (@alltags) {      foreach my $tag (@alltags) {
         next if (!exists($insertlist{$tag.'.allow'}));          next if (!exists($insertlist{"$tag.allow"}));
  my $allow =  $insertlist{$tag.'.allow'};   my $allow =  $insertlist{"$tag.allow"};
         foreach my $element (split(',',$allow)) {          foreach my $element (split(',',$allow)) {
     $element =~ s/(^\s*|\s*$ )//gx;      $element =~ s/(^\s*|\s*$ )//gx;
     if (!exists($insertlist{$element.'.show'})      if (!exists($insertlist{"$element.show"})
                 || $insertlist{$element.'.show'} ne 'no') {                  || $insertlist{"$element.show"} ne 'no') {
  push(@{ $insertlist{$tag.'.which'} },$element);   push(@{ $insertlist{$tag.'.which'} },$element);
     }      }
  }   }
Line 2283  sub get_tag { Line 2283  sub get_tag {
   
 =pod  =pod
   
 =item &print_pdf_radiobutton(fieldname, value)  =item &print_pdf_radiobutton(fieldname, value,  text)
   
 Returns a latexline to generate a PDF-Form-Radiobutton.  Returns a latexline to generate a PDF-Form-Radiobutton with Text.
 Note: Radiobuttons with equal names are automaticly grouped  
       in a selection-group.  
   
 $fieldname: PDF internalname of the radiobutton(group)  $fieldname: PDF internalname of the radiobutton
 $value:     Value of radiobutton  $value:     Value of radiobutton (read when dumping the PDF data)
   $text:      Text on the rightside of the radiobutton
   
 =cut  =cut
 sub print_pdf_radiobutton {  sub print_pdf_radiobutton {
     my ($fieldname, $value) = @_;      my $result = '';
     return '\radioButton[\symbolchoice{circle}]{'      my ($fieldName, $value, $text) = @_;
            .$fieldname.'}{10bp}{10bp}{'.$value.'}';      $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;
 }  }
   
   

Removed from v.1.505.2.7  
changed lines
  Added in v.1.506


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>