23 parent::initPage( $out );
30 private function findInstalledSkins() {
32 $styleDirectory = $config->get( MainConfigNames::StyleDirectory );
34 $possibleSkins = scandir( $styleDirectory );
35 $possibleSkins = array_filter( $possibleSkins,
static function ( $maybeDir ) use ( $styleDirectory ) {
36 return $maybeDir !==
'.' && $maybeDir !==
'..' && is_dir(
"$styleDirectory/$maybeDir" );
40 $possibleSkins = array_filter( $possibleSkins,
static function ( $skinDir ) use ( $styleDirectory ) {
41 return is_file(
"$styleDirectory/$skinDir/skin.json" )
42 || is_file(
"$styleDirectory/$skinDir/$skinDir.php" );
45 return $possibleSkins;
53 private function buildHelpfulInformationMessage() {
55 $defaultSkin = $config->get( MainConfigNames::DefaultSkin );
56 $installedSkins = $this->findInstalledSkins();
57 $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
58 $enabledSkins = $skinFactory->getInstalledSkins();
59 $enabledSkins = array_change_key_case( $enabledSkins, CASE_LOWER );
61 if ( $installedSkins ) {
62 $skinsInstalledText = [];
63 $skinsInstalledSnippet = [];
65 foreach ( $installedSkins as $skinKey ) {
66 $normalizedKey = strtolower( $skinKey );
67 $isEnabled = array_key_exists( $normalizedKey, $enabledSkins );
69 $skinsInstalledText[] = $this->
msg(
'default-skin-not-found-row-enabled' )
70 ->params( $normalizedKey, $skinKey )->plain();
72 $skinsInstalledText[] = $this->
msg(
'default-skin-not-found-row-disabled' )
73 ->params( $normalizedKey, $skinKey )->plain();
74 $skinsInstalledSnippet[] = $this->getSnippetForSkin( $skinKey );
78 return $this->
msg(
'default-skin-not-found' )->params(
80 implode(
"\n", $skinsInstalledText ),
81 implode(
"\n", $skinsInstalledSnippet ) )->numParams(
82 count( $skinsInstalledText ),
83 count( $skinsInstalledSnippet )
86 return $this->
msg(
'default-skin-not-found-no-skins' )->params(
98 private static function getSnippetForSkin( $skin ) {
100 if ( file_exists(
"$IP/skins/$skin/skin.json" ) ) {
101 return "wfLoadSkin( '$skin' );";
103 return "require_once \"\$IP/skins/$skin/$skin.php\";";
118 $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
119 $data = parent::getTemplateData();
123 $skinFactory->getInstalledSkins()[$config->get( MainConfigNames::DefaultSkin )]
125 $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.