4 * Skin template for the fallback skin.
6 * The structure is copied from the example skin (mediawiki/skins/Example).
13 * BaseTemplate class for the fallback skin
15 class SkinFallbackTemplate
extends BaseTemplate
{
19 private function findInstalledSkins() {
20 $styleDirectory = $this->config
->get( 'StyleDirectory' );
21 // Get all subdirectories which might contains skins
22 $possibleSkins = scandir( $styleDirectory );
23 $possibleSkins = array_filter( $possibleSkins, function ( $maybeDir ) use ( $styleDirectory ) {
24 return $maybeDir !== '.' && $maybeDir !== '..' && is_dir( "$styleDirectory/$maybeDir" );
27 // Filter out skins that aren't installed
28 $possibleSkins = array_filter( $possibleSkins, function ( $skinDir ) use ( $styleDirectory ) {
30 is_file( "$styleDirectory/$skinDir/skin.json" )
31 ||
is_file( "$styleDirectory/$skinDir/$skinDir.php" );
34 return $possibleSkins;
38 * Inform the user why they are seeing this skin.
42 private function buildHelpfulInformationMessage() {
43 $defaultSkin = $this->config
->get( 'DefaultSkin' );
44 $installedSkins = $this->findInstalledSkins();
45 $enabledSkins = SkinFactory
::getDefaultInstance()->getSkinNames();
46 $enabledSkins = array_change_key_case( $enabledSkins, CASE_LOWER
);
48 if ( $installedSkins ) {
49 $skinsInstalledText = [];
50 $skinsInstalledSnippet = [];
52 foreach ( $installedSkins as $skin ) {
53 $normalizedKey = strtolower( $skin );
54 $isEnabled = array_key_exists( $normalizedKey, $enabledSkins );
56 $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-enabled' )
57 ->params( $normalizedKey, $skin )->plain();
59 $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-disabled' )
60 ->params( $normalizedKey, $skin )->plain();
61 $skinsInstalledSnippet[] = $this->getSnippetForSkin( $skin );
65 return $this->getMsg( 'default-skin-not-found' )->params(
67 implode( "\n", $skinsInstalledText ),
68 implode( "\n", $skinsInstalledSnippet ) )->numParams(
69 count( $skinsInstalledText ),
70 count( $skinsInstalledSnippet )
73 return $this->getMsg( 'default-skin-not-found-no-skins' )->params(
80 * Get the appropriate LocalSettings.php snippet to enable the given skin
85 private function getSnippetForSkin( $skin ) {
87 if ( file_exists( "$IP/skins/$skin/skin.json" ) ) {
88 return "wfLoadSkin( '$skin' );";
90 return "require_once \"\$IP/skins/$skin/$skin.php\";";
95 * Outputs the entire contents of the page. No navigation (other than search box), just the big
96 * warning message and page content.
98 public function execute() {
99 $this->html( 'headelement' ) ?
>
101 <div
class="warningbox">
102 <?php
echo $this->buildHelpfulInformationMessage() ?
>
105 <form action
="<?php $this->text( 'wgScript' ) ?>">
106 <input type
="hidden" name
="title" value
="<?php $this->text( 'searchtitle' ) ?>" />
107 <h3
><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h3
>
108 <?php
echo $this->makeSearchInput( [ "id" => "searchInput" ] ) ?
>
109 <?php
echo $this->makeSearchButton( 'go' ) ?
>
112 <div
class="mw-body" role
="main">
113 <h1
class="firstHeading"><?php
$this->html( 'title' ) ?
></h1
>
115 <div
class="mw-body-content">
116 <?php
$this->html( 'bodytext' ) ?
>
117 <?php
$this->html( 'catlinks' ) ?
>
121 <?php
$this->printTrail() ?
>