EXPERIMENTAL: Stop requiring skin classes we do not use. Save about 210KB memory...
authorAntoine Musso <hashar@users.mediawiki.org>
Thu, 17 Jun 2004 16:31:57 +0000 (16:31 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Thu, 17 Jun 2004 16:31:57 +0000 (16:31 +0000)
includes/Setup.php
includes/Skin.php
includes/SkinPHPTal.php
includes/User.php

index 3268788..1ce7641 100644 (file)
@@ -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.
index 6cec957..f894425 100644 (file)
@@ -1,18 +1,17 @@
 <?php
+# See skin.doc
 
-require_once( 'Feed.php' );
+require_once( 'Feed.php' );  // should not be called if the actual page isn't feed enabled
 require_once( 'Image.php' );
 
-# See skin.doc
-
 # These are the INTERNAL names, which get mapped
 # directly to class names.  For display purposes, the
 # Language class has internationalized names
 #
 /* private */ $wgValidSkinNames = array(
-       'standard' => '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' );
-}
-
-
 ?>
index 53e33ad..de1bb44 100644 (file)
@@ -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
index 4a78742..26fe182 100644 (file)
@@ -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;