mirror of
https://github.com/Aviortheking/Blog_IMIE.git
synced 2025-04-23 19:32:15 +00:00
tag listing in progress
orrection of bug with includes tag
This commit is contained in:
parent
d20469daa1
commit
cffc88eafd
2
project/assets/php/tag.txt
Normal file
2
project/assets/php/tag.txt
Normal file
@ -0,0 +1,2 @@
|
||||
<tag type="bold">bold text</tag>
|
||||
ne pas utiliser c'est juste pour montrer les possibilité
|
@ -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");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user