25 parent::initPage( $out );
32 private function findInstalledSkins() {
34 $styleDirectory = $config->get( MainConfigNames::StyleDirectory );
36 $possibleSkins = scandir( $styleDirectory );
37 $possibleSkins = array_filter( $possibleSkins,
static function ( $maybeDir ) use ( $styleDirectory ) {
38 return $maybeDir !==
'.' && $maybeDir !==
'..' && is_dir(
"$styleDirectory/$maybeDir" );
42 $possibleSkins = array_filter( $possibleSkins,
static function ( $skinDir ) use ( $styleDirectory ) {
43 return is_file(
"$styleDirectory/$skinDir/skin.json" )
44 || is_file(
"$styleDirectory/$skinDir/$skinDir.php" );
47 return $possibleSkins;
55 private function buildHelpfulInformationMessage() {
57 $defaultSkin = $config->get( MainConfigNames::DefaultSkin );
58 $installedSkins = $this->findInstalledSkins();
59 $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
60 $enabledSkins = $skinFactory->getInstalledSkins();
61 $enabledSkins = array_change_key_case( $enabledSkins, CASE_LOWER );
63 if ( $installedSkins ) {
64 $skinsInstalledText = [];
65 $skinsInstalledSnippet = [];
67 foreach ( $installedSkins as $skinKey ) {
68 $normalizedKey = strtolower( $skinKey );
69 $isEnabled = array_key_exists( $normalizedKey, $enabledSkins );
71 $skinsInstalledText[] = $this->
msg(
'default-skin-not-found-row-enabled' )
72 ->params( $normalizedKey, $skinKey )->plain();
74 $skinsInstalledText[] = $this->
msg(
'default-skin-not-found-row-disabled' )
75 ->params( $normalizedKey, $skinKey )->plain();
76 $skinsInstalledSnippet[] = $this->getSnippetForSkin( $skinKey );
80 return $this->
msg(
'default-skin-not-found' )->params(
82 implode(
"\n", $skinsInstalledText ),
83 implode(
"\n", $skinsInstalledSnippet ) )->numParams(
84 count( $skinsInstalledText ),
85 count( $skinsInstalledSnippet )
88 return $this->
msg(
'default-skin-not-found-no-skins' )->params(
100 private static function getSnippetForSkin( $skin ) {
102 if ( file_exists(
"$IP/skins/$skin/skin.json" ) ) {
103 return "wfLoadSkin( '$skin' );";
105 return "require_once \"\$IP/skins/$skin/$skin.php\";";
120 $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
121 $data = parent::getTemplateData();
125 $skinFactory->getInstalledSkins()[$config->get( MainConfigNames::DefaultSkin )]
127 $data[
'html-fallback-warning'] = Html::warningBox( $this->buildHelpfulInformationMessage() );