Last modified: 2008-05-06 14:57:45 UTC
Created attachment 4880 [details] allow overriding of print stylesheet in SkinTemplate-based skins As discussed with Simetrical on IRC yesterday (see http://tools.wikimedia.de/~amidaniel/chanlogs/%23mediawiki/20080505.txt, threads starting at 14:06:51 and 15:21:37), I developed a small patch for SkinTemplate (Monobook) based skins which allows to override the printing stylesheet (commonPrint.css) in own skins. It simply adds a method getPrintCss() to SkinTemplate which returns the print stylesheet to be used. This method can then be overrided by own skin classes. The attached patch was developed against today's HEAD and tested with an own skin on a MediaWiki 1.11.1 installation.
Bug 2889 related.
(In reply to comment #0) > The attached patch was developed against today's HEAD and tested with an own > skin on a MediaWiki 1.11.1 installation. It can't have been tested too thoroughly, since you didn't declare "global $wgStylePath" in getPrintCss(), so it raised a warning and just returned "/common/commonPrint.css". :) You should always develop MediaWiki with error_reporting( E_ALL | E_STRICT ); ini_set( 'display_errors', '1' );. Also, profiling is unnecessary for a function that does practically nothing. With those changes, patch committed in r34310 (also r34311). (In reply to comment #1) > Bug 2889 related. No, it's not.
(In reply to comment #2) > > The attached patch was developed against today's HEAD and tested with an own > > skin on a MediaWiki 1.11.1 installation. > > It can't have been tested too thoroughly, since you didn't declare "global > $wgStylePath" in getPrintCss(), so it raised a warning and just returned > "/common/commonPrint.css". :) You should always develop MediaWiki with > error_reporting( E_ALL | E_STRICT ); ini_set( 'display_errors', '1' );. Also, > profiling is unnecessary for a function that does practically nothing. Oops, I'm awfully sorry for that! I did test that my use case works (overriding the stylesheet in own skin), but not that I don't break the default path. Ehrm... :-((( However, I saw that I even had another problem in my patch: my comments told to make the function private which you did. This, however, makes it impossible to override it in a sub class (doesn't work for me). So please additionally apply the following patch.
Created attachment 4883 [details] make getPrintCss protected to allow overriding in derived classes...
My quick test with a dummy file seemed to indicate that private functions could be overridden. But you're right, when I try to actually override this in a child skin, it fails. Fixed in r34315.
Er, fixed for real in r34317.