I have opened this in MW bug tracker T76461.
Talk page of extension
Issue in github repo of wysiwyg.
Function onBeforePageDisplay of wysiwyg extension is trying to:
- read certain .css definitons from the page
- extract contents of each .css file and place it as inline style definition on page
- delete orginal -css definition from page
I was trying to debug this with MW1.24.
- For issue 1. I used function buildCssLinksArray of OutputPage.php. With my limited skills of php programming I was able to extract names of style sheets but unable to get all the other data needed (f.ex type of css).
- Issue 2. is not a problem because public function addInlineStyle is available in OutputPage.php.
- For issue 3. I was unable to find a solution.
Is it still possible to have above procedure in MW 1.24?
On the other hand... comments of code block (function onBeforePageDisplay, lines ~194-214) in wysiwyg is referring to some limitation of IE (after max.31 style sheets IE hangs). I do not know if this has been some limitation of some older version of IE or perhaps caused by old version of IE + old CKeditor together. So is this kind of reformatting for style sheets of page necessary at all?
Related code:
public static function onBeforePageDisplay( &$out, &$text ) {
global $wgRequest, $wgScriptPath;
//var_dump($out->styles);
$action = $wgRequest->getText( 'action' );
if (! in_array($action, array('edit', 'submit'))) return $out;
$inlineStyles = array();
foreach ( $out->styles as $key => $val ) {
if (count($out->styles[$key]) > 0) {
if (isset($out->styles[$key]['condition']) ||
isset($out->styles[$key]['dir']) ||
strpos($key, '?') !== false ||
strpos($key, 'jquery.fancybox') !== false) continue;
$count = 1;
$cssFile = dirname(__FILE__) . '/../../' . str_replace($wgScriptPath, '', $key, $count);
$cssFile = str_replace('//', '/', $cssFile);
if (isset($out->styles[$key]['media']) &&
file_exists($cssFile)) {
$cssCont = file_get_contents($cssFile);
if ($cssCont !== false) {
if (! isset($inlineStyles[$out->styles[$key]['media']]))
$inlineStyles[$out->styles[$key]['media']] = '';
$inlineStyles[$out->styles[$key]['media']] .= $cssCont."\n";
unset($out->styles[$key]);
}
}
}
}
foreach($inlineStyles as $media => $css ) {
$out->addInlineStyle( $css );
}
return $out;
}