21 parent::initPage( $out );
28 private function findInstalledSkins() {
30 $styleDirectory = $config->get( MainConfigNames::StyleDirectory );
32 $possibleSkins = scandir( $styleDirectory );
33 $possibleSkins = array_filter( $possibleSkins,
static function ( $maybeDir ) use ( $styleDirectory ) {
34 return $maybeDir !==
'.' && $maybeDir !==
'..' && is_dir(
"$styleDirectory/$maybeDir" );
38 $possibleSkins = array_filter( $possibleSkins,
static function ( $skinDir ) use ( $styleDirectory ) {
39 return is_file(
"$styleDirectory/$skinDir/skin.json" )
40 || is_file(
"$styleDirectory/$skinDir/$skinDir.php" );
43 return $possibleSkins;
51 private function buildHelpfulInformationMessage() {
53 $defaultSkin = $config->get( MainConfigNames::DefaultSkin );
54 $installedSkins = $this->findInstalledSkins();
55 $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
56 $enabledSkins = $skinFactory->getInstalledSkins();
57 $enabledSkins = array_change_key_case( $enabledSkins, CASE_LOWER );
59 if ( $installedSkins ) {
60 $skinsInstalledText = [];
61 $skinsInstalledSnippet = [];
63 foreach ( $installedSkins as $skinKey ) {
64 $normalizedKey = strtolower( $skinKey );
65 $isEnabled = array_key_exists( $normalizedKey, $enabledSkins );
67 $skinsInstalledText[] = $this->
msg(
'default-skin-not-found-row-enabled' )
68 ->params( $normalizedKey, $skinKey )->plain();
70 $skinsInstalledText[] = $this->
msg(
'default-skin-not-found-row-disabled' )
71 ->params( $normalizedKey, $skinKey )->plain();
72 $skinsInstalledSnippet[] = $this->getSnippetForSkin( $skinKey );
76 return $this->
msg(
'default-skin-not-found' )->params(
78 implode(
"\n", $skinsInstalledText ),
79 implode(
"\n", $skinsInstalledSnippet ) )->numParams(
80 count( $skinsInstalledText ),
81 count( $skinsInstalledSnippet )
84 return $this->
msg(
'default-skin-not-found-no-skins' )->params(
96 private static function getSnippetForSkin( $skin ) {
98 if ( file_exists(
"$IP/skins/$skin/skin.json" ) ) {
99 return "wfLoadSkin( '$skin' );";
101 return "require_once \"\$IP/skins/$skin/$skin.php\";";
116 $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
117 $data = parent::getTemplateData();
121 $skinFactory->getInstalledSkins()[$config->get( MainConfigNames::DefaultSkin )]
123 $data[
'html-fallback-warning'] = Html::warningBox( $this->buildHelpfulInformationMessage() );
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
This is one of the Core classes and should be read at least once by any new developers.
disableClientCache()
Force the page to send nocache headers.