r14662 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14661‎ | r14662 | r14663 >
Date:13:47, 8 June 2006
Author:midom
Status:old
Tags:
Comment:
Autoload Linker, Skin.php, move $wgValidSkinNames to static private at Skin, use Skin::getSkinNames()...
Modified paths:
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Setup.php
@@ -56,7 +56,6 @@
5757 require_once( 'Hooks.php' );
5858 require_once( 'Namespace.php' );
5959 require_once( 'User.php' );
60 -require_once( 'Skin.php' );
6160 require_once( 'OutputPage.php' );
6261 require_once( 'MagicWord.php' );
6362 require_once( 'Block.php' );
Index: trunk/phase3/includes/Title.php
@@ -1163,8 +1163,7 @@
11641164 * Check that the corresponding skin exists
11651165 */
11661166 function isValidCssJsSubpage() {
1167 - global $wgValidSkinNames;
1168 - return( $this->isCssJsSubpage() && array_key_exists( $this->getSkinFromCssJsSubpage(), $wgValidSkinNames ) );
 1167+ return( $this->isCssJsSubpage() && array_key_exists( $this->getSkinFromCssJsSubpage(), Skin::getSkinNames() ) );
11691168 }
11701169 /**
11711170 * Trim down a .css or .js subpage title to get the corresponding skin name
Index: trunk/phase3/includes/SpecialPreferences.php
@@ -444,7 +444,7 @@
445445 * @access private
446446 */
447447 function mainPrefsForm( $status , $message = '' ) {
448 - global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
 448+ global $wgUser, $wgOut, $wgLang, $wgContLang;
449449 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
450450 global $wgDisableLangConversion;
451451 global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits;
@@ -721,9 +721,9 @@
722722 $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
723723 $mptitle = Title::newMainPage();
724724 $previewtext = wfMsg('skinpreview');
725 - # Only show members of $wgValidSkinNames rather than
 725+ # Only show members of Skin::getSkinNames() rather than
726726 # $skinNames (skins is all skin names from Language.php)
727 - foreach ($wgValidSkinNames as $skinkey => $skinname ) {
 727+ foreach (Skin::getSkinNames() as $skinkey => $skinname ) {
728728 if ( in_array( $skinkey, $wgSkipSkins ) ) {
729729 continue;
730730 }
Index: trunk/phase3/includes/Skin.php
@@ -9,27 +9,8 @@
1010 */
1111
1212 # See skin.txt
13 -require_once( 'Linker.php' );
1413 require_once( 'Image.php' );
1514
16 -# Get a list of available skins
17 -# Build using the regular expression '^(.*).php$'
18 -# Array keys are all lower case, array value keep the case used by filename
19 -#
20 -
21 -$skinDir = dir( $wgStyleDirectory );
22 -
23 -# while code from www.php.net
24 -while (false !== ($file = $skinDir->read())) {
25 - // Skip non-PHP files, hidden files, and '.dep' includes
26 - if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
27 - $aSkin = $matches[1];
28 - $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
29 - }
30 -}
31 -$skinDir->close();
32 -unset($matches);
33 -
3415 /**
3516 * The main skin class that provide methods and properties for all other skins.
3617 * This base class is also the "Standard" skin.
@@ -44,6 +25,8 @@
4526 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
4627 var $rcMoveIndex;
4728 /**#@-*/
 29+
 30+ private static $validSkinNames;
4831
4932 /** Constructor, call parent constructor */
5033 function Skin() { parent::Linker(); }
@@ -54,10 +37,33 @@
5538 * @static
5639 */
5740 function getSkinNames() {
58 - global $wgValidSkinNames;
59 - return $wgValidSkinNames;
 41+ if (!is_array(Skin::$validSkinNames)) {
 42+ Skin::initializeSkinNames();
 43+ }
 44+ return Skin::$validSkinNames;
6045 }
6146
 47+
 48+ /** Initialize a list of available skins
 49+ * Build using the regular expression '^(.*).php$'
 50+ * Array keys are all lower case, array value keep the case used by filename
 51+ */
 52+
 53+ function initializeSkinNames() {
 54+ global $wgStyleDirectory;
 55+ $skinDir = dir( $wgStyleDirectory );
 56+
 57+ # while code from www.php.net
 58+ while (false !== ($file = $skinDir->read())) {
 59+ // Skip non-PHP files, hidden files, and '.dep' includes
 60+ if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
 61+ $aSkin = $matches[1];
 62+ Skin::$validSkinNames[strtolower($aSkin)] = $aSkin;
 63+ }
 64+ }
 65+ $skinDir->close();
 66+ }
 67+
6268 /**
6369 * Normalize a skin preference value to a form that can be loaded.
6470 * If a skin can't be found, it will fall back to the configured

Status & tagging log