[LON-CAPA-cvs] cvs: loncom(version_2_10_X) /xml lonxml.pm

raeburn raeburn@source.lon-capa.org
Mon, 16 Aug 2010 17:29:12 -0000


raeburn		Mon Aug 16 17:29:12 2010 EDT

  Modified files:              (Branch: version_2_10_X)
    /loncom/xml	lonxml.pm 
  Log:
  - Backport 1.509, 1.510, 1.512, 1.513, 1.514.
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.505.2.1 loncom/xml/lonxml.pm:1.505.2.2
--- loncom/xml/lonxml.pm:1.505.2.1	Sun May 30 02:57:01 2010
+++ loncom/xml/lonxml.pm	Mon Aug 16 17:29:11 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.505.2.1 2010/05/30 02:57:01 raeburn Exp $
+# $Id: lonxml.pm,v 1.505.2.2 2010/08/16 17:29:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -572,6 +572,10 @@
   if (($ENV{'QUERY_STRING'}) && ($target eq 'web')) {
     $finaloutput=&afterburn($finaloutput);
   }	    
+  if ($target eq 'modified') {
+# if modfied, handle startpart and endpart
+     $finaloutput=~s/\<startpartmarker[^\>]*\>(.*)\<endpartmarker[^\>]*\>/<part>$1<\/part>/gs;
+  }
   return $finaloutput;
 }
 
@@ -1555,7 +1559,7 @@
            &Apache::loncommon::select_form(
                $env{'form.languages'},
                'languages',
-               &Apache::lonlocal::texthash(%langchoices)).
+               {&Apache::lonlocal::texthash(%langchoices)}).
            '</span>';
     }
     $output .=
@@ -1564,11 +1568,11 @@
        &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)')}).
      '</span>';
     return $output;
 }
@@ -1582,47 +1586,27 @@
       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.=(<<FULLPAGE);
-<script type="text/javascript">
-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');
-    }
-</script>
-FULLPAGE
-      } else {
-	  $initialize.=(<<FULLPAGE);
+      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);
 <script type="text/javascript">
+// <![CDATA[
     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);
-          }
+      if ($filetype eq 'html') {
+          $dragmath_button = '<span id="math_filecont">'.&Apache::lonhtmlcommon::dragmath_button('filecont',1).'</span>';
+          $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');
       }
-
       $add_to_onload = 'initDocument();';
       $add_to_onresize = "resize_textarea('$textarea_id','LC_aftertextarea');";
 
@@ -1631,13 +1615,13 @@
       }
 
       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 +1631,7 @@
               $htmlerror='<span class="LC_error">'.$htmlerror.'</span>';
           }
           if (&Apache::lonhtmlcommon::htmlareabrowser()) {
-              if (&Apache::lonhtmlcommon::htmlareablocked()) {
-                  $wysiwyglink = &Apache::lonhtmlcommon::enablelink($textarea_id);
-              } else {
-                  $wysiwyglink = &Apache::lonhtmlcommon::disablelink($textarea_id);
-              }
+              $textareaclass = 'class="LC_richDetectHtml"';
           }
       }
       my $editfooter=(<<ENDFOOTER);
@@ -1668,16 +1648,15 @@
     <div class="LC_edit_problem_discards">
       <input type="submit" name="discardview" accesskey="d" value="$lt{'dv'}" />
       <input type="submit" name="Undo" accesskey="u" value="$lt{'un'}" />
-      $dragmath_button $spelllink $htmlerror
+      $htmlerror $dragmath_button
     </div>
     <div class="LC_edit_problem_saves">
       <input type="submit" name="savethisfile" accesskey="s" value="$lt{'st'}" />
       <input type="submit" name="viewmode" accesskey="v" value="$lt{'vi'}" />
     </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">
-    $wysiwyglink
     <br />
     $titledisplay
   </div>