From: Domas Mituzas Date: Thu, 8 Jun 2006 13:47:38 +0000 (+0000) Subject: Autoload Linker, Skin.php, move $wgValidSkinNames to static private at Skin, use... X-Git-Tag: 1.31.0-rc.0~56833 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=abd7248709c4ede3a3689833f2324f8db655bc00;p=lhc%2Fweb%2Fwiklou.git Autoload Linker, Skin.php, move $wgValidSkinNames to static private at Skin, use Skin::getSkinNames()... --- diff --git a/includes/Setup.php b/includes/Setup.php index 390114227c..14dad72034 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -56,7 +56,6 @@ require_once( 'GlobalFunctions.php' ); require_once( 'Hooks.php' ); require_once( 'Namespace.php' ); require_once( 'User.php' ); -require_once( 'Skin.php' ); require_once( 'OutputPage.php' ); require_once( 'MagicWord.php' ); require_once( 'Block.php' ); diff --git a/includes/Skin.php b/includes/Skin.php index dc14640d1e..bf6c9c3d97 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -9,27 +9,8 @@ if ( ! defined( 'MEDIAWIKI' ) ) */ # See skin.txt -require_once( 'Linker.php' ); require_once( 'Image.php' ); -# Get a list of available skins -# Build using the regular expression '^(.*).php$' -# Array keys are all lower case, array value keep the case used by filename -# - -$skinDir = dir( $wgStyleDirectory ); - -# while code from www.php.net -while (false !== ($file = $skinDir->read())) { - // Skip non-PHP files, hidden files, and '.dep' includes - if(preg_match('/^([^.]*)\.php$/',$file, $matches)) { - $aSkin = $matches[1]; - $wgValidSkinNames[strtolower($aSkin)] = $aSkin; - } -} -$skinDir->close(); -unset($matches); - /** * The main skin class that provide methods and properties for all other skins. * This base class is also the "Standard" skin. @@ -44,6 +25,8 @@ class Skin extends Linker { var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle var $rcMoveIndex; /**#@-*/ + + private static $validSkinNames; /** Constructor, call parent constructor */ function Skin() { parent::Linker(); } @@ -54,8 +37,31 @@ class Skin extends Linker { * @static */ function getSkinNames() { - global $wgValidSkinNames; - return $wgValidSkinNames; + if (!is_array(Skin::$validSkinNames)) { + Skin::initializeSkinNames(); + } + return Skin::$validSkinNames; + } + + + /** Initialize a list of available skins + * Build using the regular expression '^(.*).php$' + * Array keys are all lower case, array value keep the case used by filename + */ + + function initializeSkinNames() { + global $wgStyleDirectory; + $skinDir = dir( $wgStyleDirectory ); + + # while code from www.php.net + while (false !== ($file = $skinDir->read())) { + // Skip non-PHP files, hidden files, and '.dep' includes + if(preg_match('/^([^.]*)\.php$/',$file, $matches)) { + $aSkin = $matches[1]; + Skin::$validSkinNames[strtolower($aSkin)] = $aSkin; + } + } + $skinDir->close(); } /** diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 1ade3079c5..704b548ea4 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -444,7 +444,7 @@ class PreferencesForm { * @access private */ function mainPrefsForm( $status , $message = '' ) { - global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames; + global $wgUser, $wgOut, $wgLang, $wgContLang; global $wgAllowRealName, $wgImageLimits, $wgThumbLimits; global $wgDisableLangConversion; global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits; @@ -721,9 +721,9 @@ class PreferencesForm { $wgOut->addHTML( "
\n\n" . wfMsg('skin') . "\n" ); $mptitle = Title::newMainPage(); $previewtext = wfMsg('skinpreview'); - # Only show members of $wgValidSkinNames rather than + # Only show members of Skin::getSkinNames() rather than # $skinNames (skins is all skin names from Language.php) - foreach ($wgValidSkinNames as $skinkey => $skinname ) { + foreach (Skin::getSkinNames() as $skinkey => $skinname ) { if ( in_array( $skinkey, $wgSkipSkins ) ) { continue; } diff --git a/includes/Title.php b/includes/Title.php index 75acdecb69..70c00290b8 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1163,8 +1163,7 @@ class Title { * Check that the corresponding skin exists */ function isValidCssJsSubpage() { - global $wgValidSkinNames; - return( $this->isCssJsSubpage() && array_key_exists( $this->getSkinFromCssJsSubpage(), $wgValidSkinNames ) ); + return( $this->isCssJsSubpage() && array_key_exists( $this->getSkinFromCssJsSubpage(), Skin::getSkinNames() ) ); } /** * Trim down a .css or .js subpage title to get the corresponding skin name