MDL-44357 theme: Chunk content in styles_debug for IE
This commit is contained in:
+7
-1
@@ -716,7 +716,13 @@ class theme_config {
|
||||
$baseurl = new moodle_url($CFG->httpswwwroot.'/theme/styles_debug.php');
|
||||
|
||||
if (!empty($this->lessfile)) {
|
||||
$urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'less'));
|
||||
if (core_useragent::is_ie() && !core_useragent::check_ie_version(10)) {
|
||||
// As the LESS file can get quite bit, and IE < 10 has troubles with files containing more than
|
||||
// 4095 selectors, we need to ask styles_debug.php to chunk the file.
|
||||
$urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'less', 'chunk' => 0));
|
||||
} else {
|
||||
$urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'less'));
|
||||
}
|
||||
} else {
|
||||
$css = $this->get_css_files(true);
|
||||
if (!$svg) {
|
||||
|
||||
+20
-1
@@ -36,6 +36,7 @@ $type = optional_param('type', '', PARAM_SAFEDIR);
|
||||
$subtype = optional_param('subtype', '', PARAM_SAFEDIR);
|
||||
$sheet = optional_param('sheet', '', PARAM_SAFEDIR);
|
||||
$usesvg = optional_param('svg', 1, PARAM_BOOL);
|
||||
$chunk = optional_param('chunk', null, PARAM_INT);
|
||||
|
||||
if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
|
||||
// The theme exists in standard location - ok.
|
||||
@@ -53,6 +54,9 @@ if ($type === 'editor') {
|
||||
css_send_uncached_css($csscontent);
|
||||
}
|
||||
|
||||
$chunkurl = new moodle_url($CFG->httpswwwroot . '/theme/styles_debug.php', array('theme' => $themename,
|
||||
'type' => $type, 'subtype' => $subtype, 'sheet' => $sheet, 'usesvg' => $usesvg));
|
||||
|
||||
// We need some kind of caching here because otherwise the page navigation becomes
|
||||
// way too slow in theme designer mode. Feel free to create full cache definition later...
|
||||
$key = "$type $subtype $sheet $usesvg";
|
||||
@@ -60,12 +64,27 @@ $cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'core', 'themede
|
||||
if ($content = $cache->get($key)) {
|
||||
if ($content['created'] > time() - THEME_DESIGNER_CACHE_LIFETIME) {
|
||||
$csscontent = $content['data'];
|
||||
|
||||
// We need to chunk the content.
|
||||
if ($chunk !== null) {
|
||||
$chunks = css_chunk_by_selector_count($csscontent, $chunkurl->out(false));
|
||||
$csscontent = ($chunk === 0) ? end($chunks) : $chunks[$chunk - 1];
|
||||
}
|
||||
|
||||
css_send_uncached_css($csscontent);
|
||||
}
|
||||
}
|
||||
|
||||
$csscontent = $theme->get_css_content_debug($type, $subtype, $sheet);
|
||||
|
||||
$cache->set($key, array('data' => $csscontent, 'created' => time()));
|
||||
|
||||
// We need to chunk the content.
|
||||
if ($chunk !== null) {
|
||||
// The chunks are ordered so that the last chunk is the one containing the @import, and so
|
||||
// the first one to be included. All the other chunks are set in the array before that one.
|
||||
// See {@link css_chunk_by_selector_count()} for more details.
|
||||
$chunks = css_chunk_by_selector_count($csscontent, $chunkurl->out(false));
|
||||
$csscontent = ($chunk === 0) ? end($chunks) : $chunks[$chunk - 1];
|
||||
}
|
||||
|
||||
css_send_uncached_css($csscontent);
|
||||
|
||||
Reference in New Issue
Block a user