Page MenuHomePhabricator

allow own print stylesheets for SkinTemplate based skins
Closed, ResolvedPublic

Description

Author: gernot.hillier

Description:
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.


Version: unspecified
Severity: enhancement

Attached:

Details

Reference
bz13970

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:13 PM
bzimport set Reference to bz13970.
bzimport added a subscriber: Unknown Object (MLST).

ayg wrote:

(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.

gernot.hillier wrote:

(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.

gernot.hillier wrote:

make getPrintCss protected to allow overriding in derived classes...

Attached:

ayg wrote:

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.

ayg wrote:

Er, fixed for real in r34317.