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 // Only keep the ones that contain a .php file with the same name inside
28 $possibleSkins = array_filter( $possibleSkins, function ( $skinDir ) use ( $styleDirectory ) {
29 return is_file( "$styleDirectory/$skinDir/$skinDir.php" );
32 return $possibleSkins;
36 * Inform the user why they are seeing this skin.
40 private function buildHelpfulInformationMessage() {
41 $defaultSkin = $this->config
->get( 'DefaultSkin' );
42 $installedSkins = $this->findInstalledSkins();
43 $enabledSkins = SkinFactory
::getDefaultInstance()->getSkinNames();
44 $enabledSkins = array_change_key_case( $enabledSkins, CASE_LOWER
);
46 if ( $installedSkins ) {
47 $skinsInstalledText = array();
48 $skinsInstalledSnippet = array();
50 foreach ( $installedSkins as $skin ) {
51 $normalizedKey = strtolower( $skin );
52 $isEnabled = array_key_exists( $normalizedKey, $enabledSkins );
54 $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-enabled' )
55 ->params( $normalizedKey, $skin )->plain();
57 $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-disabled' )
58 ->params( $normalizedKey, $skin )->plain();
59 $skinsInstalledSnippet[] = "require_once \"\$IP/skins/$skin/$skin.php\";";
63 return $this->getMsg( 'default-skin-not-found' )->params(
65 implode( "\n", $skinsInstalledText ),
66 implode( "\n", $skinsInstalledSnippet )
69 return $this->getMsg( 'default-skin-not-found-no-skins' )->params(
76 * Outputs the entire contents of the page. No navigation (other than search box), just the big
77 * warning message and page content.
79 public function execute() {
80 $this->html( 'headelement' ) ?
>
82 <div
class="warningbox">
83 <?php
echo $this->buildHelpfulInformationMessage() ?
>
86 <form action
="<?php $this->text( 'wgScript' ) ?>">
87 <input type
="hidden" name
="title" value
="<?php $this->text( 'searchtitle' ) ?>" />
88 <h3
><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h3
>
89 <?php
echo $this->makeSearchInput( array( "id" => "searchInput" ) ) ?
>
90 <?php
echo $this->makeSearchButton( 'go' ) ?
>
93 <div
class="mw-body" role
="main">
94 <h1
class="firstHeading"><?php
$this->html( 'title' ) ?
></h1
>
96 <div
class="mw-body-content">
97 <?php
$this->html( 'bodytext' ) ?
>
98 <?php
$this->html( 'catlinks' ) ?
>
102 <?php
$this->printTrail() ?
>