mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02: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;
|
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.
|
* Parse a string, and replace any registered shortcodes within it with the result of the mapped callback.
|
||||||
*
|
*
|
||||||
@ -511,9 +530,7 @@ class ShortcodeParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = '';
|
$doc = $bases->item(0)->ownerDocument;
|
||||||
$container = $bases->item(0)->parentNode;
|
|
||||||
$doc = $container->ownerDocument;
|
|
||||||
|
|
||||||
$xp = new DOMXPath($doc);
|
$xp = new DOMXPath($doc);
|
||||||
|
|
||||||
@ -550,9 +567,7 @@ class ShortcodeParser {
|
|||||||
$this->replaceMarkerWithContent($shortcode, $tag);
|
$this->replaceMarkerWithContent($shortcode, $tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($container->childNodes as $child) $res .= $doc->saveHTML($child);
|
return $this->saveHTML($doc);
|
||||||
|
|
||||||
return $res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user