mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE: When there are script tags in the body, put requirements script just before them, instead of at the very top of the body. Since this reduces the cost of the (sometimes necessary) script tags in the body, the notice-level error has been removed.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@76207 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
99d132ff9b
commit
6cdc1feab6
@ -620,13 +620,12 @@ class Requirements_Backend {
|
|||||||
$jsRequirements = preg_replace('/>\n*/', '>', $jsRequirements);
|
$jsRequirements = preg_replace('/>\n*/', '>', $jsRequirements);
|
||||||
|
|
||||||
// We put script tags into the body, for performance.
|
// We put script tags into the body, for performance.
|
||||||
// If your template already has script tags in the body, then we put our script tags at the top of the body.
|
// If your template already has script tags in the body, then we put our script
|
||||||
// Otherwise, we put it at the bottom.
|
// tags just before those. Otherwise, we put it at the bottom.
|
||||||
$p1 = strripos($content, '<script');
|
$p1 = strripos($content, '<script');
|
||||||
$p2 = stripos($content, '<body');
|
$p2 = stripos($content, '<body');
|
||||||
if($p1 !== false && $p1 > $p2) {
|
if($p1 !== false && $p1 > $p2) {
|
||||||
user_error("You have a script tag in the body, moving requirements to top of <body> for compatibilty. I recommend removing the script tag from your template's body.", E_USER_NOTICE);
|
$content = substr($content,0,$p1) . $jsRequirements . substr($content,$p1);
|
||||||
$content = eregi_replace("(<body[^>]*>)", "\\1" . $jsRequirements, $content);
|
|
||||||
} else {
|
} else {
|
||||||
$content = eregi_replace("(</body[^>]*>)", $jsRequirements . "\\1", $content);
|
$content = eregi_replace("(</body[^>]*>)", $jsRequirements . "\\1", $content);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user