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" ); } ); // Filter out skins that aren't installed $possibleSkins = array_filter( $possibleSkins, function ( $skinDir ) use ( $styleDirectory ) { return is_file( "$styleDirectory/$skinDir/skin.json" ) || is_file( "$styleDirectory/$skinDir/$skinDir.php" ); } ); return $possibleSkins; } /** * Inform the user why they are seeing this skin. * * @return string */ private function buildHelpfulInformationMessage() { $defaultSkin = $this->config->get( 'DefaultSkin' ); $installedSkins = $this->findInstalledSkins(); $enabledSkins = SkinFactory::getDefaultInstance()->getSkinNames(); $enabledSkins = array_change_key_case( $enabledSkins, CASE_LOWER ); if ( $installedSkins ) { $skinsInstalledText = array(); $skinsInstalledSnippet = array(); foreach ( $installedSkins as $skin ) { $normalizedKey = strtolower( $skin ); $isEnabled = array_key_exists( $normalizedKey, $enabledSkins ); if ( $isEnabled ) { $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-enabled' ) ->params( $normalizedKey, $skin )->plain(); } else { $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-disabled' ) ->params( $normalizedKey, $skin )->plain(); $skinsInstalledSnippet[] = $this->getSnippetForSkin( $skin ); } } return $this->getMsg( 'default-skin-not-found' )->params( $defaultSkin, implode( "\n", $skinsInstalledText ), implode( "\n", $skinsInstalledSnippet ) )->parseAsBlock(); } else { return $this->getMsg( 'default-skin-not-found-no-skins' )->params( $defaultSkin )->parseAsBlock(); } } /** * 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. */ public function execute() { $this->html( 'headelement' ) ?>