Diff for /loncom/xml/lonxml.pm between versions 1.505 and 1.505.2.3

version 1.505, 2010/02/08 00:35:06 version 1.505.2.3, 2010/09/29 16:02:19
Line 572  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 1524  SIMPLECONTENT Line 1528  SIMPLECONTENT
   
 sub verify_html {  sub verify_html {
     my ($filecontents)=@_;      my ($filecontents)=@_;
     if ($filecontents!~/(?:\<|\&lt\;)(?:html|xml)[^\<]*(?:\>|\&gt\;)/is) {      my ($is_html,$is_xml);
        return &mt('File does not have [_1] or [_2] starting tag','&lt;html&gt;','&lt;xml&gt;');      if ($filecontents =~/(?:\<|\&lt\;)\?xml[^\<]*\?(?:\>|\&gt\;)/is) {
     }          $is_xml = 1;
     if ($filecontents!~/(?:\<|\&lt\;)\/(?:html|xml)(?:\>|\&gt\;)/is) {      } elsif ($filecontents =~/(?:\<|\&lt\;)html(?:\s+[^\<]+|\s*)[^\<]*(?:\>|\&gt\;)/is) {
        return &mt('File does not have [_1] or [_2] ending tag','&lt;html&gt;','&lt;xml&gt;');          $is_html = 1;
     }      }
     if ($filecontents!~/(?:\<|\&lt\;)(?:body|frameset)[^\<]*(?:\>|\&gt\;)/is) {      unless ($is_xml || $is_html) {
        return &mt('File does not have [_1] or [_2] starting tag','&lt;body&gt;','&lt;frameset&gt;');          return &mt('File does not have [_1] or [_2] starting tag','&lt;html&gt;','&lt;?xml ?&gt;');
     }      }
     if ($filecontents!~/(?:\<|\&lt\;)\/(?:body|frameset)[^\<]*(?:\>|\&gt\;)/is) {      if ($is_html) {
        return &mt('File does not have [_1] or [_2] ending tag','&lt;body&gt;','&lt;frameset&gt;');          if ($filecontents!~/(?:\<|\&lt\;)\/html(?:\>|\&gt\;)/is) {
               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 1555  sub renderingoptions { Line 1567  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 1564  sub renderingoptions { Line 1576  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 1582  sub inserteditinfo { Line 1594  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'         if (($filetype eq 'html') && (&Apache::lonhtmlcommon::htmlareabrowser())) {
   && (!&Apache::lonhtmlcommon::htmlareablocked() &&            my $lang = &Apache::lonhtmlcommon::htmlarea_lang();
       &Apache::lonhtmlcommon::htmlareabrowser())) {            my %textarea_args = (
   $textarea_id .= '___Frame';                                  fullpage => 'true',
   my $lang = &Apache::lonhtmlcommon::htmlarea_lang();                                  dragmath => 'math',
   $initialize.=(<<FULLPAGE);                                );
 <script type="text/javascript">            $initialize .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);
 lonca        }
     function initDocument() {        $initialize .= (<<FULLPAGE);
         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');  
     }  
 </script>  
 FULLPAGE  
       } else {  
   $initialize.=(<<FULLPAGE);  
 <script type="text/javascript">  <script type="text/javascript">
   // <![CDATA[
     function initDocument() {      function initDocument() {
  resize_textarea('$textarea_id','LC_aftertextarea');   resize_textarea('$textarea_id','LC_aftertextarea');
     }      }
   // ]]>
 </script>  </script>
 FULLPAGE  FULLPAGE
           if ($filetype eq 'html' || $filetype eq 'tex') {        if ($filetype eq 'html') {
               $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');            $dragmath_button = '<span id="math_filecont">'.&Apache::lonhtmlcommon::dragmath_button('filecont',1).'</span>';
               $dragmath_button = &Apache::lonhtmlcommon::dragmath_button('filecont',1);            $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');
           }  
       }        }
   
       $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 1631  FULLPAGE Line 1623  FULLPAGE
       }        }
   
       my $titledisplay=&display_title();        my $titledisplay=&display_title();
       my $wysiwyglink;        my $textareaclass;
       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 1647  FULLPAGE Line 1639  FULLPAGE
               $htmlerror='<span class="LC_error">'.$htmlerror.'</span>';                $htmlerror='<span class="LC_error">'.$htmlerror.'</span>';
           }            }
           if (&Apache::lonhtmlcommon::htmlareabrowser()) {            if (&Apache::lonhtmlcommon::htmlareabrowser()) {
               if (&Apache::lonhtmlcommon::htmlareablocked()) {                $textareaclass = 'class="LC_richDefaultOff"';
                   $wysiwyglink = &Apache::lonhtmlcommon::enablelink($textarea_id);  
               } else {  
                   $wysiwyglink = &Apache::lonhtmlcommon::disablelink($textarea_id);  
               }  
           }            }
       }        }
       my $editfooter=(<<ENDFOOTER);        my $editfooter=(<<ENDFOOTER);
Line 1668  $initialize Line 1656  $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'}" />
       $dragmath_button $spelllink $htmlerror        $htmlerror $dragmath_button
     </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">$filecontents</textarea>    <textarea $textarea_events style="width:100%" cols="80" rows="44" name="filecont" id="filecont" $textareaclass>$filecontents</textarea><br />$spelllink
   <div id="LC_aftertextarea">    <div id="LC_aftertextarea">
     $wysiwyglink  
     <br />      <br />
     $titledisplay      $titledisplay
   </div>    </div>
Line 1828  ENDNOTFOUND Line 1815  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 2291  sub get_tag { Line 2275  sub get_tag {
   
 =pod  =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  $fieldname: PDF internalname of the radiobutton(group)
 $value:     Value of radiobutton (read when dumping the PDF data)  $value:     Value of radiobutton
 $text:      Text on the rightside of the radiobutton  
   
 =cut  =cut
 sub print_pdf_radiobutton {  sub print_pdf_radiobutton {
     my $result = '';      my ($fieldname, $value) = @_;
     my ($fieldName, $value, $text) = @_;      return '\radioButton[\symbolchoice{circle}]{'
     $result .= '\begin{tabularx}{\textwidth}{p{0cm}X}'."\n";             .$fieldname.'}{10bp}{10bp}{'.$value.'}';
     $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  
changed lines
  Added in v.1.505.2.3


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