From 5928a9238b6755298fd6c25027561fbfeadb1145 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Thu, 17 Jun 2004 16:31:57 +0000 Subject: [PATCH] EXPERIMENTAL: Stop requiring skin classes we do not use. Save about 210KB memory for a monobook user, should save more when user use standard. --- includes/Setup.php | 3 ++- includes/Skin.php | 21 +++++---------------- includes/SkinPHPTal.php | 1 + includes/User.php | 37 ++++++++++++++++++++++++++++++------- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/includes/Setup.php b/includes/Setup.php index 3268788f73..1ce764194a 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -42,9 +42,9 @@ wfProfileIn( $fname.'-includes' ); require_once( 'GlobalFunctions.php' ); require_once( 'Namespace.php' ); require_once( 'RecentChange.php' ); +require_once( 'User.php' ); require_once( 'Skin.php' ); require_once( 'OutputPage.php' ); -require_once( 'User.php' ); require_once( 'LinkCache.php' ); require_once( 'Title.php' ); require_once( 'Article.php' ); @@ -212,6 +212,7 @@ $wgBlockCache = new BlockCache( true ); wfProfileOut( $fname.'-BlockCache' ); wfProfileIn( $fname.'-User' ); +// HASHAR : implements things relevant to user like skin ! if( $wgCommandLineMode ) { # Used for some maintenance scripts; user session cookies can screw things up # when the database is in an in-between state. diff --git a/includes/Skin.php b/includes/Skin.php index 6cec9574cc..f894425d9a 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1,18 +1,17 @@ 'Standard', - 'nostalgia' => 'Nostalgia', - 'cologneblue' => 'CologneBlue' + 'standard' => 'Standard', + 'nostalgia' => 'Nostalgia', + 'cologneblue' => 'CologneBlue' ); if( $wgUsePHPTal ) { #$wgValidSkinNames[] = 'PHPTal'; @@ -2762,14 +2761,4 @@ class Skin { } } - -require_once( 'SkinStandard.php' ); -require_once( 'SkinNostalgia.php' ); -require_once( 'SkinCologneBlue.php' ); - -if( $wgUsePHPTal ) { - require_once( 'SkinPHPTal.php' ); -} - - ?> diff --git a/includes/SkinPHPTal.php b/includes/SkinPHPTal.php index 53e33ad6bf..de1bb44345 100644 --- a/includes/SkinPHPTal.php +++ b/includes/SkinPHPTal.php @@ -27,6 +27,7 @@ # http://www.gnu.org/copyleft/gpl.html require_once "GlobalFunctions.php"; + global $IP; require_once $IP."/PHPTAL-NP-0.7.0/libs/PHPTAL.php"; class MediaWiki_I18N extends PHPTAL_I18N diff --git a/includes/User.php b/includes/User.php index 4a7874280a..26fe182871 100644 --- a/includes/User.php +++ b/includes/User.php @@ -433,27 +433,50 @@ class User { function &getSkin() { if ( ! isset( $this->mSkin ) ) { + # get all skin names available from SkinNames.php $skinNames = Skin::getSkinNames(); - $s = $this->getOption( 'skin' ); - if ( '' == $s ) { $s = 'standard'; } - - if ( !isset( $skinNames[$s] ) ) { + # get the user skin + $userSkin = $this->getOption( 'skin' ); + if ( $userSkin == '' ) { $userSkin = 'standard'; } + + if ( !isset( $skinNames[$userSkin] ) ) { + # in case the user skin could not be found find a replacement $fallback = array( 0 => 'SkinStandard', 1 => 'SkinNostalgia', 2 => 'SkinCologneBlue'); + # if phptal is enabled we should have monobook skin that superseed + # the good old SkinStandard. if ( isset( $skinNames['monobook'] ) ) { $fallback[0] = 'SkinMonoBook'; } - if(is_numeric($s) && isset( $fallback[$s]) ){ - $sn = $fallback[$s]; + if(is_numeric($userSkin) && isset( $fallback[$userSkin]) ){ + $sn = $fallback[$userSkin]; } else { $sn = 'SkinStandard'; } } else { - $sn = 'Skin' . $skinNames[$s]; + # The user skin is available + $sn = 'Skin' . $skinNames[$userSkin]; + } + + # only require the needed stuff + switch($sn) { + case 'SkinMonoBook': + require_once( 'SkinPHPTal.php' ); + break; + case 'SkinStandard': + require_once( 'SkinStandard.php' ); + break; + case 'SkinNostalgia': + require_once( 'SkinNostalgia.php' ); + break; + case 'SkinCologneBlue': + require_once( 'SkinCologneBlue.php' ); + break; } + # now we can create the skin object $this->mSkin = new $sn; } return $this->mSkin; -- 2.20.1