mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX ShortcodeParser#parse in < PHP 5.3.6 where saveHTML doesnt take arg
This commit is contained in:
parent
cbef44b8d6
commit
76fdb2a2d6
@ -481,6 +481,25 @@ class ShortcodeParser {
|
||||
return $bases;
|
||||
}
|
||||
|
||||
protected function saveHTML($doc) {
|
||||
if (version_compare(PHP_VERSION, '5.3.6', '>=')){
|
||||
$res = '';
|
||||
foreach($doc->firstChild->childNodes as $child) $res .= $doc->saveHTML($child);
|
||||
}
|
||||
else {
|
||||
$res = preg_replace(
|
||||
array(
|
||||
'/^(.*?)<html>/is',
|
||||
'/<\/html>(.*?)$/is',
|
||||
),
|
||||
'',
|
||||
$doc->saveHTML()
|
||||
);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a string, and replace any registered shortcodes within it with the result of the mapped callback.
|
||||
*
|
||||
@ -511,9 +530,7 @@ class ShortcodeParser {
|
||||
}
|
||||
}
|
||||
|
||||
$res = '';
|
||||
$container = $bases->item(0)->parentNode;
|
||||
$doc = $container->ownerDocument;
|
||||
$doc = $bases->item(0)->ownerDocument;
|
||||
|
||||
$xp = new DOMXPath($doc);
|
||||
|
||||
@ -550,9 +567,7 @@ class ShortcodeParser {
|
||||
$this->replaceMarkerWithContent($shortcode, $tag);
|
||||
}
|
||||
|
||||
foreach($container->childNodes as $child) $res .= $doc->saveHTML($child);
|
||||
|
||||
return $res;
|
||||
return $this->saveHTML($doc);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user