Skip to content

Commit 6bb609a

Browse files
committed
fix html body output by widgets
1 parent f1d9f72 commit 6bb609a

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

lib/classes/Parser/MFormParser.php

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,12 @@ private function generateMediaElement(MFormItem $item)
660660
}
661661
}
662662
$html = $dom->C14N(false, true);
663+
if (strpos($html, '<body') !== false) {
664+
preg_match("/<body>(.*)<\/body>/ism", $html, $matches);
665+
if (isset($matches[1])) {
666+
$html = $matches[1];
667+
}
668+
}
663669

664670
break;
665671
case 'medialist':
@@ -681,6 +687,12 @@ private function generateMediaElement(MFormItem $item)
681687
}
682688
}
683689
$html = $dom->C14N(false, true);
690+
if (strpos($html, '<body') !== false) {
691+
preg_match("/<body>(.*)<\/body>/ism", $html, $matches);
692+
if (isset($matches[1])) {
693+
$html = $matches[1];
694+
}
695+
}
684696

685697
break;
686698
}
@@ -781,9 +793,9 @@ private function generateCustomLinkElement(MFormItem $item)
781793
}
782794
}
783795
if (($childNode->hasAttribute('class')
784-
&& $childNode->getAttribute('class') == 'form-control')
796+
&& $childNode->getAttribute('class') == 'form-control')
785797
&& ($childNode->hasAttribute('value')
786-
&& $childNode->getAttribute('value') == '')) {
798+
&& $childNode->getAttribute('value') == '')) {
787799
$childNode->setAttribute('value', $item->getValue());
788800
if (is_array($item->getAttributes()) && sizeof($item->getAttributes()) > 0) {
789801
foreach ($item->getAttributes() as $key => $value) {
@@ -794,6 +806,12 @@ private function generateCustomLinkElement(MFormItem $item)
794806
}
795807
// $html = utf8_encode($divItem->C14N(false,true));
796808
$html = $divItem->C14N(false, true);
809+
if (strpos($html, '<body') !== false) {
810+
preg_match("/<body>(.*)<\/body>/ism", $html, $matches);
811+
if (isset($matches[1])) {
812+
$html = $matches[1];
813+
}
814+
}
797815
break;
798816
}
799817
}
@@ -842,6 +860,12 @@ private function generateLinkElement(MFormItem $item)
842860
}
843861
}
844862
$html = $dom->C14N(false, true);
863+
if (strpos($html, '<body') !== false) {
864+
preg_match("/<body>(.*)<\/body>/ism", $html, $matches);
865+
if (isset($matches[1])) {
866+
$html = $matches[1];
867+
}
868+
}
845869

846870
break;
847871
case 'linklist':
@@ -863,6 +887,12 @@ private function generateLinkElement(MFormItem $item)
863887
}
864888
}
865889
$html = $dom->C14N(false, true);
890+
if (strpos($html, '<body') !== false) {
891+
preg_match("/<body>(.*)<\/body>/ism", $html, $matches);
892+
if (isset($matches[1])) {
893+
$html = $matches[1];
894+
}
895+
}
866896

867897
break;
868898
}

0 commit comments

Comments
 (0)