Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Vtpl before after support for external elements when using import in templates

givanz14539950a29b
diff --git a/system/vtpl/vtpl.php b/system/vtpl/vtpl.php
index 00b3d13..40a6eb6 100755
--- a/system/vtpl/vtpl.php
+++ b/system/vtpl/vtpl.php
@@ -1398,9 +1398,28 @@ class Vtpl {
if ($nodeList) {
foreach ($nodeList as $node) {
- $f = $this->document->createDocumentFragment();
- $f->appendXML($this->processAttributeConstants($html, $node));
- $node->parentNode->insertBefore($f, $node);
+ if ($this->_external_elements) {
+ if ($this->froms[0][(int) $html[1]] == '@_SELF_@') {
+ $selector = $this->froms[2][(int) $html[1]];
+ $xpath = new DOMXpath($this->document);
+ $result = $xpath->query($this->cssToXpath($selector));
+ } else {
+ $result = $this->loadFromExternalHtml($html, $node);
+ }
+
+ if (! $result) {
+ continue;
+ }
+ //$html = array_reverse($html);
+ foreach ($result as $externalNode) {
+ $importedNode = $this->document->importNode($externalNode, true);
+ $node->parentNode->insertBefore($importedNode, $node);
+ }
+ } else {
+ $f = $this->document->createDocumentFragment();
+ $f->appendXML($this->processAttributeConstants($html, $node));
+ $node->parentNode->insertBefore($f, $node);
+ }
}
}
}
@@ -1412,10 +1431,29 @@ class Vtpl {
if ($nodeList) {
foreach ($nodeList as $node) {
- $f = $this->document->createDocumentFragment();
- $f->appendXML($this->processAttributeConstants($html, $node));
- //$node->parentNode->appendChild( $f );
- $node->parentNode->insertBefore($f, $node->nextSibling);
+ if ($this->_external_elements) {
+ if ($this->froms[0][(int) $html[1]] == '@_SELF_@') {
+ $selector = $this->froms[2][(int) $html[1]];
+ $xpath = new DOMXpath($this->document);
+ $result = $xpath->query($this->cssToXpath($selector));
+ } else {
+ $result = $this->loadFromExternalHtml($html, $node);
+ }
+
+ if (! $result) {
+ continue;
+ }
+ //$html = array_reverse($html);
+ foreach ($result as $externalNode) {
+ $importedNode = $this->document->importNode($externalNode, true);
+ $node->parentNode->insertBefore($importedNode, $node->nextSibling);
+ }
+ } else {
+ $f = $this->document->createDocumentFragment();
+ $f->appendXML($this->processAttributeConstants($html, $node));
+ //$node->parentNode->appendChild( $f );
+ $node->parentNode->insertBefore($f, $node->nextSibling);
+ }
}
}
}