From cffc88eafd5b7eb439415f065496bab03d68bfba Mon Sep 17 00:00:00 2001 From: Aviortheking <2bazert@gmail.com> Date: Mon, 26 Nov 2018 14:41:33 +0100 Subject: [PATCH] tag listing in progress orrection of bug with includes tag --- project/assets/php/tag.txt | 2 ++ project/assets/php/tagHandler.php | 30 ++++++------------------------ 2 files changed, 8 insertions(+), 24 deletions(-) create mode 100644 project/assets/php/tag.txt diff --git a/project/assets/php/tag.txt b/project/assets/php/tag.txt new file mode 100644 index 0000000..a8b3a5c --- /dev/null +++ b/project/assets/php/tag.txt @@ -0,0 +1,2 @@ +bold text +ne pas utiliser c'est juste pour montrer les possibilité \ No newline at end of file diff --git a/project/assets/php/tagHandler.php b/project/assets/php/tagHandler.php index 48bb802..1e6d708 100644 --- a/project/assets/php/tagHandler.php +++ b/project/assets/php/tagHandler.php @@ -144,9 +144,7 @@ class includes extends tag { $attr = $el->getAttribute("file"); $t = $doc->createDocumentFragment(); $p = file_get_contents("../html/includes/".$attr.".html"); - $t->appendXML($p); - - $el->parentNode->appendChild($t); + appendHTML($el->parentNode, $p); } } @@ -230,32 +228,16 @@ class loop extends tag { function appendHTML(DOMNode $parent, $source) { $tmpDoc = new DOMDocument(); - $tmpDoc->loadHTML ($source); + $html = ""; + $html .= $source; + $html .= ""; + $tmpDoc->loadHTML ($html); foreach ($tmpDoc->getElementsByTagName('body')->item(0)->childNodes as $node) { $importedNode = $parent->ownerDocument->importNode ($node, true); - $parent->parentNode->replaceChild ($importedNode, $parent); + $parent->appendChild($importedNode); } } -function renameTag( DOMElement $oldTag, $newTagName ) { - $oldTag = $oldTag->parentNode->appendChild($oldTag); - $document = $oldTag->ownerDocument; - - $newTag = $document->createElement($newTagName); - $oldTag->parentNode->replaceChild($newTag, $oldTag); - - foreach ($oldTag->attributes as $attribute) { - $newTag->setAttribute($attribute->name, $attribute->value); - } - foreach (iterator_to_array($oldTag->childNodes) as $child) { - $newTag->appendChild($oldTag->removeChild($child)); - } - return $newTag; -} - - - - //testing purpose //$content = file_get_contents("./test.html");