diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
commit | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (patch) | |
tree | f1fdd326034e05177596851be6a7127615d81498 /includes/skins/SkinFallbackTemplate.php | |
parent | 9c75fa8ff6d4d38ef552c00fef5969fb154765e8 (diff) | |
parent | f6d65e533c62f6deb21342d4901ece24497b433e (diff) |
Merge commit 'f6d65'
# Conflicts:
# skins/ArchLinux/ArchLinux.php
Diffstat (limited to 'includes/skins/SkinFallbackTemplate.php')
-rw-r--r-- | includes/skins/SkinFallbackTemplate.php | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/includes/skins/SkinFallbackTemplate.php b/includes/skins/SkinFallbackTemplate.php index 603ee5c5..1c5f3a6f 100644 --- a/includes/skins/SkinFallbackTemplate.php +++ b/includes/skins/SkinFallbackTemplate.php @@ -17,16 +17,18 @@ class SkinFallbackTemplate extends BaseTemplate { * @return array */ private function findInstalledSkins() { - $styleDirectory = $this->config->get( 'StyleDirectory' ); // @todo we should inject this directly? + $styleDirectory = $this->config->get( 'StyleDirectory' ); // Get all subdirectories which might contains skins $possibleSkins = scandir( $styleDirectory ); $possibleSkins = array_filter( $possibleSkins, function ( $maybeDir ) use ( $styleDirectory ) { 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 ); } } @@ -73,6 +75,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. */ @@ -91,9 +108,7 @@ class SkinFallbackTemplate extends BaseTemplate { </form> <div class="mw-body" role="main"> - <h1 class="firstHeading"> - <span dir="auto"><?php $this->html( 'title' ) ?></span> - </h1> + <h1 class="firstHeading"><?php $this->html( 'title' ) ?></h1> <div class="mw-body-content"> <?php $this->html( 'bodytext' ) ?> |