diff --git a/lib/outputlib.php b/lib/outputlib.php index 0c660b237c6..38f2d8583ed 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -634,16 +634,23 @@ class theme_config { } $baseurl = $CFG->httpswwwroot.'/theme/styles_debug.php'; - foreach ($css['plugins'] as $plugin=>$unused) { - $urls[] = new moodle_url($baseurl, array('theme'=>$this->name,'type'=>'plugin', 'subtype'=>$plugin)); - } - foreach ($css['parents'] as $parent=>$sheets) { - foreach ($sheets as $sheet=>$unused2) { - $urls[] = new moodle_url($baseurl, array('theme'=>$this->name,'type'=>'parent', 'subtype'=>$parent, 'sheet'=>$sheet)); + + if (check_browser_version('MSIE', 5)) { + // lalala, IE does not allow more than 31 linked CSS files from main document + $urls[] = new moodle_url($CFG->httpswwwroot.'/theme/styles_debug.php', array('theme'=>$this->name, 'type'=>'ie')); + + } else { + foreach ($css['plugins'] as $plugin=>$unused) { + $urls[] = new moodle_url($baseurl, array('theme'=>$this->name,'type'=>'plugin', 'subtype'=>$plugin)); + } + foreach ($css['parents'] as $parent=>$sheets) { + foreach ($sheets as $sheet=>$unused2) { + $urls[] = new moodle_url($baseurl, array('theme'=>$this->name,'type'=>'parent', 'subtype'=>$parent, 'sheet'=>$sheet)); + } + } + foreach ($css['theme'] as $sheet=>$unused) { + $urls[] = new moodle_url($baseurl, array('sheet'=>$sheet, 'theme'=>$this->name, 'type'=>'theme')); // sheet first in order to make long urls easier to read } - } - foreach ($css['theme'] as $sheet=>$unused) { - $urls[] = new moodle_url($baseurl, array('sheet'=>$sheet, 'theme'=>$this->name, 'type'=>'theme')); // sheet first in order to make long urls easier to read } } diff --git a/theme/styles_debug.php b/theme/styles_debug.php index 8e26a8fc7d6..2cceb182b33 100644 --- a/theme/styles_debug.php +++ b/theme/styles_debug.php @@ -58,7 +58,10 @@ if (!$css = file_get_contents($candidatesheet)) { $css = unserialize($css); -if ($type === 'plugin') { +if ($type === 'ie') { + send_ie_css($themename, $css); + +} else if ($type === 'plugin') { if (isset($css['plugins'][$subtype])) { send_uncached_css($css['plugins'][$subtype]); } @@ -80,10 +83,10 @@ css_not_found(); // we are not using filelib because we need to fine tune all header // parameters to get the best performance. -function send_uncached_css($css, $lifetime = THEME_DESIGNER_CACHE_LIFETIME) { +function send_uncached_css($css) { header('Content-Disposition: inline; filename="styles_debug.php"'); header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT'); - header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT'); + header('Expires: '. gmdate('D, d M Y H:i:s', time() + THEME_DESIGNER_CACHE_LIFETIME) .' GMT'); header('Pragma: '); header('Accept-Ranges: none'); header('Content-Type: text/css'); @@ -96,4 +99,30 @@ function send_uncached_css($css, $lifetime = THEME_DESIGNER_CACHE_LIFETIME) { function css_not_found() { header('HTTP/1.0 404 not found'); die('CSS was not found, sorry.'); -} \ No newline at end of file +} + +function send_ie_css($themename, $css) { + $output = "/** Unfortunately IE6/7/8 does not support more than 31 CSS files, which means we have to use some ugly hacks :-( **/\n"; + foreach ($css['plugins'] as $plugin=>$unused) { + $output .= "@import url(styles_debug.php?theme=$themename&type=plugin&subtype=$plugin);\n"; + } + foreach ($css['parents'] as $parent=>$sheets) { + foreach ($sheets as $sheet=>$unused2) { + $output .= "@import url(styles_debug.php?theme=$themename&type=parent&subtype=$parent&sheet=$sheet);\n"; + } + } + foreach ($css['theme'] as $sheet=>$unused) { + $output .= "@import url(styles_debug.php?theme=$themename&type=theme&sheet=$sheet);\n"; + } + + header('Content-Disposition: inline; filename="styles_debug.php"'); + header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT'); + header('Expires: '. gmdate('D, d M Y H:i:s', time() + THEME_DESIGNER_CACHE_LIFETIME) .' GMT'); + header('Pragma: '); + header('Accept-Ranges: none'); + header('Content-Type: text/css'); + //header('Content-Length: '.strlen($output)); + + echo $output; + die; +}