changeset 117:e01ce5722f2b

New change to how we save (X)HTML files. This time we simplify things by using DocumentFragments to load stuff, and preserve CDATA content.
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Sun, 27 Mar 2016 21:33:08 +0200
parents 374e3eff07fd
children e9f562a34fa5
files InputParser.inc
diffstat 1 files changed, 6 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/InputParser.inc	Thu Mar 17 22:34:49 2016 +0100
+++ b/InputParser.inc	Sun Mar 27 21:33:08 2016 +0200
@@ -93,7 +93,7 @@
   {
     //We may need to set and check the contenttype and replace
     //saveHTML with saveXML
-    $retVal = new PageContent($this->master->saveHTML($this->master));
+    $retVal = new PageContent($this->master->saveXML());
     $retVal->setHeader('Content-Language', $this->options->getLang());
     return $retVal;
   }
@@ -212,7 +212,7 @@
       $parent->removeChild($param);
     }
 
-    $body = getElementByTagName($doc,"body");
+    $body = getElementByTagName($doc,"html");
     $files = $body->getElementsByTagName("file");
 
     $toRemove = array();
@@ -264,15 +264,12 @@
 	$callString .= ");";
 	eval($callString);
       }
-      $ndoc = new DOMDocument();
-
-      $ndoc->loadXml("<xml>${file_content}</xml>");
+      $ndoc = $doc->createDocumentFragment();
 
       $parent = $file->parentNode;
-      foreach ($ndoc->firstChild->childNodes as $child) {
-	$clonedChild = $doc->importNode($child, true);
-	$parent->insertBefore($clonedChild, $file);
-      }
+
+      $ndoc->appendXML($file_content);
+      $parent->insertBefore($ndoc, $file);
 
       //We need to iterate in the opposite direction when removing,
       //so best shifting.