From 6e378cf93fa95d67d578eb89c203e69b7de5c12b Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Thu, 2 Apr 2015 10:31:24 -0700 Subject: [PATCH] SkinFallback: Recommend using wfLoadSkin() if possible Change-Id: I4f3841029578305ab692d853c45678f487adbc78 --- includes/skins/SkinFallbackTemplate.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/includes/skins/SkinFallbackTemplate.php b/includes/skins/SkinFallbackTemplate.php index 9cb4ea0d2f..1c5f3a6fc4 100644 --- a/includes/skins/SkinFallbackTemplate.php +++ b/includes/skins/SkinFallbackTemplate.php @@ -24,9 +24,11 @@ class SkinFallbackTemplate extends BaseTemplate { return $maybeDir !== '.' && $maybeDir !== '..' && is_dir( "$styleDirectory/$maybeDir" ); } ); - // Only keep the ones that contain a .php file with the same name inside + // Filter out skins that aren't installed $possibleSkins = array_filter( $possibleSkins, function ( $skinDir ) use ( $styleDirectory ) { - return is_file( "$styleDirectory/$skinDir/$skinDir.php" ); + return + is_file( "$styleDirectory/$skinDir/skin.json" ) + || is_file( "$styleDirectory/$skinDir/$skinDir.php" ); } ); return $possibleSkins; @@ -56,7 +58,7 @@ class SkinFallbackTemplate extends BaseTemplate { } else { $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-disabled' ) ->params( $normalizedKey, $skin )->plain(); - $skinsInstalledSnippet[] = "require_once \"\$IP/skins/$skin/$skin.php\";"; + $skinsInstalledSnippet[] = $this->getSnippetForSkin( $skin ); } } @@ -72,6 +74,21 @@ class SkinFallbackTemplate extends BaseTemplate { } } + /** + * Get the appropriate LocalSettings.php snippet to enable the given skin + * + * @param string $skin + * @return string + */ + private function getSnippetForSkin( $skin ) { + global $IP; + if ( file_exists( "$IP/skins/$skin/skin.json" ) ) { + return "wfLoadSkin( '$skin' );"; + } else { + return "require_once \"\$IP/skins/$skin/$skin.php\";"; + } + } + /** * Outputs the entire contents of the page. No navigation (other than search box), just the big * warning message and page content. -- 2.20.1