SKIN.DOC
-This document describes the overall architecture of MediaWiki's
-HTML rendering code. It is placed here rather than in comments
-in the code itself to help reduce the code size.
+This document describes the overall architecture of MediaWiki's HTML rendering
+code as well as some history about the skin system. It is placed here rather
+than in comments in the code itself to help reduce the code size.
-Unfortunately there isn't any documentation, and the code's in
-a bit of a mess right now during the transition from the old skin
-code to the new template-based skin code in 1.3.
+== Version 1.4 ==
+
+MediaWiki still use the PHPTal skin system introduced in version 1.3 but some
+changes have been made to the file organisation.
+
+PHP class and PHPTal templates have been moved to /skins/ (respectivly from
+/includes/ and /templates/). This way skin designer and end user just stick to
+one directory.
+
+Two samples are provided to start with, one for PHPTal use (SkinPHPTal.sample)
+and one without (Skin.sample).
+
+
+== Version 1.3 ==
The following might help a bit though.
To change the layout, just edit the PHPTal template (templates/xhtml_slim.pt)
as well as the stylesheets (stylesheets/monobook/*).
+
+
+== pre 1.3 version ==
+
+Unfortunately there isn't any documentation, and the code's in a bit of a mess
+right now during the transition from the old skin code to the new template-based
+skin code in 1.3.
# file names in ./skins/. For display purposes, the Language class has
# internationalized names
#
-/* private */ $wgValidSkinNames = array(
+/*
+$wgValidSkinNames = array(
'standard' => 'Standard',
'nostalgia' => 'Nostalgia',
'cologneblue' => 'CologneBlue'
$wgValidSkinNames['myskin'] = 'MySkin';
$wgValidSkinNames['chick'] = 'Chick';
}
+*/
+
+# Get a list of all skins available in /skins/
+# Build using the regular expression '^(.*).php$'
+# Array keys are all lower case, array value keep the case used by filename
+#
+
+$skinDir = dir($IP.'/skins');
+
+# while code from www.php.net
+while (false !== ($file = $skinDir->read())) {
+ if(preg_match('/^(.*).php$/',$file, $matches)) {
+ $aSkin = $matches[1];
+ $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
+ }
+}
+$skinDir->close();
+unset($matches);
require_once( 'RecentChange.php' );
return in_array( 'bot', $this->mRights );
}
+ # Load a skin if it doesn't exist or return it
+ # FIXME : need to check the old failback system [AV]
function &getSkin() {
- global $IP;
+ global $IP, $wgUsePHPTal;
if ( ! isset( $this->mSkin ) ) {
- # get all skin names available from SkinNames.php
+ # get all skin names available
$skinNames = Skin::getSkinNames();
# get the user skin
$userSkin = $this->getOption( 'skin' );
0 => 'Standard',
1 => 'Nostalgia',
2 => 'CologneBlue');
- # if phptal is enabled we should have monobook skin that superseed
- # the good old SkinStandard.
+ # if phptal is enabled we should have monobook skin that
+ # superseed the good old SkinStandard.
if ( isset( $skinNames['monobook'] ) ) {
$fallback[0] = 'MonoBook';
}
$sn = $skinNames[$userSkin];
}
- # Grab the skin class and initialise it
+ # Grab the skin class and initialise it. Each skin checks for PHPTal
+ # and will not load if it's not enabled.
require_once( $IP.'/skins/'.$sn.'.php' );
+
+ # Check if we got if not failback to default skin
$sn = 'Skin'.$sn;
+ if(!class_exists($sn)) {
+ #FIXME : should we print an error message instead of loading
+ # standard skin ?
+ $sn = 'SkinStandard';
+ require_once( $IP.'/skins/Standard.php' );
+ }
$this->mSkin = new $sn;
}
return $this->mSkin;
<?php
+if ($wgUsePHPTal) {
require_once($IP.'/includes/SkinPHPTal.php');
class SkinChick extends SkinPHPTal {
function printSource() { return ''; }
}
+}
?>
<?php
-
+if ($wgUsePHPTal) {
require_once($IP.'/includes/SkinPHPTal.php');
class SkinDaVinci extends SkinPHPTal {
$this->template = 'MonoBook';
}
}
+
+}
?>
<?php
-
+if ($wgUsePHPTal) {
require_once($IP.'/includes/SkinPHPTal.php');
class SkinMono extends SkinPHPTal {
$this->template = 'MonoBook';
}
}
+
+}
?>
<?php
+if ($wgUsePHPTal) {
require_once($IP.'/includes/SkinPHPTal.php');
class SkinMonoBook extends SkinPHPTal {
}
}
+}
?>
<?php
+if ($wgUsePHPTal) {
require_once($IP.'/includes/SkinPHPTal.php');
$this->skinname = 'myskin';
}
}
+
+}
?>
--- /dev/null
+<?php
+# Your class extension is defined there.
+#
+# Do NOT use PHPTal with this sample, if you want PHPTal support have a look at
+# the other sample : SkinPHPTal.sample.
+#
+# The class name MUST begin with 'Skin' and the rest is the name of the file
+# excluding '.php'
+# This file is named Skin.sample (but it should end with php). So the
+# class name will be 'Skin' . 'Skin'
+
+class SkinSkin extends Skin {
+# Override method below
+#
+
+}
+
+}
+?>
--- /dev/null
+<?php
+# Test if PHPTal is enabled. If not MediaWiki will load the 'standard' skin
+# which doesnt use PHPTal
+if ($wgUsePHPTal) {
+require_once($IP.'/includes/SkinPHPTal.php');
+
+# Your class extension is defined there.
+#
+# The class name MUST begin with 'Skin' and the rest is the name of the file
+# excluding '.php'
+# This file is named SkinPHPTal.sample (but it should end with php). So the
+# class name will be 'Skin' . 'SkinPHPTal'
+
+class SkinSkinPHPTal extends SkinPHPTal {
+ function initPage( &$out ) {
+ SkinPHPTal::initPage( $out );
+ $this->skinname = 'name of your skin all lower case';
+ $this->template = 'phptal template used do not put the .pt';
+ }
+
+# Override method below
+#
+
+}
+
+}
+?>
# Tentative to make a skin for wikimedia.org
# $Id$
+if($wgUsePHPTal) {
require_once($IP.'/includes/SkinPHPTal.php');
$wgExtraSkins['wikimediawiki'] = 'Wikimediawiki';
}
}
-
+}
?>