24 parent::initPage( $out );
31 private function findInstalledSkins() {
33 $styleDirectory = $config->get( MainConfigNames::StyleDirectory );
35 $possibleSkins = scandir( $styleDirectory );
36 $possibleSkins = array_filter( $possibleSkins,
static function ( $maybeDir ) use ( $styleDirectory ) {
37 return $maybeDir !==
'.' && $maybeDir !==
'..' && is_dir(
"$styleDirectory/$maybeDir" );
41 $possibleSkins = array_filter( $possibleSkins,
static function ( $skinDir ) use ( $styleDirectory ) {
42 return is_file(
"$styleDirectory/$skinDir/skin.json" )
43 || is_file(
"$styleDirectory/$skinDir/$skinDir.php" );
46 return $possibleSkins;
54 private function buildHelpfulInformationMessage() {
56 $defaultSkin = $config->get( MainConfigNames::DefaultSkin );
57 $installedSkins = $this->findInstalledSkins();
58 $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
59 $enabledSkins = $skinFactory->getInstalledSkins();
60 $enabledSkins = array_change_key_case( $enabledSkins, CASE_LOWER );
62 if ( $installedSkins ) {
63 $skinsInstalledText = [];
64 $skinsInstalledSnippet = [];
66 foreach ( $installedSkins as $skinKey ) {
67 $normalizedKey = strtolower( $skinKey );
68 $isEnabled = array_key_exists( $normalizedKey, $enabledSkins );
70 $skinsInstalledText[] = $this->
msg(
'default-skin-not-found-row-enabled' )
71 ->params( $normalizedKey, $skinKey )->plain();
73 $skinsInstalledText[] = $this->
msg(
'default-skin-not-found-row-disabled' )
74 ->params( $normalizedKey, $skinKey )->plain();
75 $skinsInstalledSnippet[] = $this->getSnippetForSkin( $skinKey );
79 return $this->
msg(
'default-skin-not-found' )->params(
81 implode(
"\n", $skinsInstalledText ),
82 implode(
"\n", $skinsInstalledSnippet ) )->numParams(
83 count( $skinsInstalledText ),
84 count( $skinsInstalledSnippet )
87 return $this->
msg(
'default-skin-not-found-no-skins' )->params(
99 private static function getSnippetForSkin( $skin ) {
101 if ( file_exists(
"$IP/skins/$skin/skin.json" ) ) {
102 return "wfLoadSkin( '$skin' );";
104 return "require_once \"\$IP/skins/$skin/$skin.php\";";
119 $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
120 $data = parent::getTemplateData();
124 $skinFactory->getInstalledSkins()[$config->get( MainConfigNames::DefaultSkin )]
126 $data[
'html-fallback-warning'] = Html::warningBox( $this->buildHelpfulInformationMessage() );
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()