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 ) {
29 return is_file( "$styleDirectory/$skinDir/skin.json" )
30 ||
is_file( "$styleDirectory/$skinDir/$skinDir.php" );
33 return $possibleSkins;
37 * Inform the user why they are seeing this skin.
41 private function buildHelpfulInformationMessage() {
42 $defaultSkin = $this->config
->get( 'DefaultSkin' );
43 $installedSkins = $this->findInstalledSkins();
44 $enabledSkins = SkinFactory
::getDefaultInstance()->getSkinNames();
45 $enabledSkins = array_change_key_case( $enabledSkins, CASE_LOWER
);
47 if ( $installedSkins ) {
48 $skinsInstalledText = [];
49 $skinsInstalledSnippet = [];
51 foreach ( $installedSkins as $skin ) {
52 $normalizedKey = strtolower( $skin );
53 $isEnabled = array_key_exists( $normalizedKey, $enabledSkins );
55 $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-enabled' )
56 ->params( $normalizedKey, $skin )->plain();
58 $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-disabled' )
59 ->params( $normalizedKey, $skin )->plain();
60 $skinsInstalledSnippet[] = $this->getSnippetForSkin( $skin );
64 return $this->getMsg( 'default-skin-not-found' )->params(
66 implode( "\n", $skinsInstalledText ),
67 implode( "\n", $skinsInstalledSnippet ) )->numParams(
68 count( $skinsInstalledText ),
69 count( $skinsInstalledSnippet )
72 return $this->getMsg( 'default-skin-not-found-no-skins' )->params(
79 * Get the appropriate LocalSettings.php snippet to enable the given skin
84 private function getSnippetForSkin( $skin ) {
86 if ( file_exists( "$IP/skins/$skin/skin.json" ) ) {
87 return "wfLoadSkin( '$skin' );";
89 return "require_once \"\$IP/skins/$skin/$skin.php\";";
94 * Outputs the entire contents of the page. No navigation (other than search box), just the big
95 * warning message and page content.
97 public function execute() {
98 $this->html( 'headelement' );
99 echo Html
::warningBox( $this->buildHelpfulInformationMessage() );
101 <form action
="<?php $this->text( 'wgScript' ) ?>">
102 <input type
="hidden" name
="title" value
="<?php $this->text( 'searchtitle' ) ?>" />
103 <h3
><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h3
>
104 <?php
echo $this->makeSearchInput( [ "id" => "searchInput" ] ) ?
>
105 <?php
echo $this->makeSearchButton( 'go' ) ?
>
108 <div
class="mw-body" role
="main">
109 <h1
class="firstHeading"><?php
$this->html( 'title' ) ?
></h1
>
111 <div
class="mw-body-content">
112 <?php
$this->html( 'bodytext' ) ?
>
113 <?php
$this->html( 'catlinks' ) ?
>
117 <?php
$this->printTrail() ?
>