BUGFIX Fixed wrong condition in Requirements::includeInHTML() which failed to process requirements if only customCSS() was used

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@71467 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-02-08 19:06:15 +00:00
parent 88720f07c5
commit 023e733b16
2 changed files with 13 additions and 1 deletions

View File

@ -534,7 +534,7 @@ class Requirements_Backend {
function includeInHTML($templateFile, $content) {
if(isset($_GET['debug_profile'])) Profiler::mark("Requirements::includeInHTML");
if(strpos($content, '</head') !== false && ($this->javascript || $this->css || $this->customScript || $this->customHeadTags)) {
if(strpos($content, '</head') !== false && ($this->javascript || $this->customCSS || $this->customScript || $this->customHeadTags)) {
$requirements = '';
$jsRequirements = '';
@ -566,6 +566,7 @@ class Requirements_Backend {
$requirements .= "<link rel=\"stylesheet\" type=\"text/css\"{$media} href=\"$path\" />\n";
}
}
foreach(array_diff_key($this->customCSS, $this->blocked) as $css) {
$requirements .= "<style type=\"text/css\">\n$css\n</style>\n";
}

View File

@ -10,6 +10,17 @@ class RequirementsTest extends SapphireTest {
static $html_template = '<html><head></head><body></body></html>';
function testCustomCSS() {
Requirements::customCSS(".testclass {color:#f00;}");
$html = Requirements::includeInHTML(false, self::$html_template);
$this->assertTrue(
(strpos($html, '.testclass {color:#f00;}') !== false),
'customCSS() shows up in template'
);
}
function testExternalUrls() {
Requirements::javascript('http://www.mydomain.com/test.js');
Requirements::javascript('https://www.mysecuredomain.com/test.js');