tag listing in progress

orrection of bug with includes tag
This commit is contained in:
Florian Bouillon 2018-11-26 14:41:33 +01:00
parent d20469daa1
commit cffc88eafd
2 changed files with 8 additions and 24 deletions

View File

@ -0,0 +1,2 @@
<tag type="bold">bold text</tag>
ne pas utiliser c'est juste pour montrer les possibilité

View File

@ -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><body>";
$html .= $source;
$html .= "</body></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");