MediaWiki  REL1_31
SkinFallbackTemplate.php
Go to the documentation of this file.
1 <?php
2 
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" );
25  } );
26 
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" );
31  } );
32 
33  return $possibleSkins;
34  }
35 
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 );
46 
47  if ( $installedSkins ) {
48  $skinsInstalledText = [];
49  $skinsInstalledSnippet = [];
50 
51  foreach ( $installedSkins as $skin ) {
52  $normalizedKey = strtolower( $skin );
53  $isEnabled = array_key_exists( $normalizedKey, $enabledSkins );
54  if ( $isEnabled ) {
55  $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-enabled' )
56  ->params( $normalizedKey, $skin )->plain();
57  } else {
58  $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-disabled' )
59  ->params( $normalizedKey, $skin )->plain();
60  $skinsInstalledSnippet[] = $this->getSnippetForSkin( $skin );
61  }
62  }
63 
64  return $this->getMsg( 'default-skin-not-found' )->params(
65  $defaultSkin,
66  implode( "\n", $skinsInstalledText ),
67  implode( "\n", $skinsInstalledSnippet ) )->numParams(
68  count( $skinsInstalledText ),
69  count( $skinsInstalledSnippet )
70  )->parseAsBlock();
71  } else {
72  return $this->getMsg( 'default-skin-not-found-no-skins' )->params(
73  $defaultSkin
74  )->parseAsBlock();
75  }
76  }
77 
84  private function getSnippetForSkin( $skin ) {
85  global $IP;
86  if ( file_exists( "$IP/skins/$skin/skin.json" ) ) {
87  return "wfLoadSkin( '$skin' );";
88  } else {
89  return "require_once \"\$IP/skins/$skin/$skin.php\";";
90  }
91  }
92 
97  public function execute() {
98  $this->html( 'headelement' );
100  ?>
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' ) ?>
106  </form>
107 
108  <div class="mw-body" role="main">
109  <h1 class="firstHeading"><?php $this->html( 'title' ) ?></h1>
110 
111  <div class="mw-body-content">
112  <?php $this->html( 'bodytext' ) ?>
113  <?php $this->html( 'catlinks' ) ?>
114  </div>
115  </div>
116 
117  <?php $this->printTrail() ?>
118  </body></html>
119 
120  <?php
121  }
122 }
BaseTemplate\msg
msg( $str)
Definition: BaseTemplate.php:39
SkinFallbackTemplate
BaseTemplate class for the fallback skin.
Definition: SkinFallbackTemplate.php:15
type
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
Definition: postgres.txt:30
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
BaseTemplate\makeSearchButton
makeSearchButton( $mode, $attrs=[])
Definition: BaseTemplate.php:530
SkinFallbackTemplate\execute
execute()
Outputs the entire contents of the page.
Definition: SkinFallbackTemplate.php:97
SkinFallbackTemplate\getSnippetForSkin
getSnippetForSkin( $skin)
Get the appropriate LocalSettings.php snippet to enable the given skin.
Definition: SkinFallbackTemplate.php:84
SkinFallbackTemplate\buildHelpfulInformationMessage
buildHelpfulInformationMessage()
Inform the user why they are seeing this skin.
Definition: SkinFallbackTemplate.php:41
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
BaseTemplate\printTrail
printTrail()
Output getTrail.
Definition: BaseTemplate.php:748
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
Html\warningBox
static warningBox( $html)
Return a warning box.
Definition: Html.php:702
div
div
Definition: parserTests.txt:6593
BaseTemplate\getMsg
getMsg( $name)
Get a Message object with its context set.
Definition: BaseTemplate.php:35
SkinFallbackTemplate\findInstalledSkins
findInstalledSkins()
Definition: SkinFallbackTemplate.php:19
BaseTemplate\makeSearchInput
makeSearchInput( $attrs=[])
Definition: BaseTemplate.php:520
$skin
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin
Definition: hooks.txt:2011
QuickTemplate\html
html( $str)
Definition: QuickTemplate.php:133
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:22
name
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
Definition: design.txt:12
$IP
$IP
Definition: WebStart.php:52
BaseTemplate
New base template for a skin's template extended from QuickTemplate this class features helper method...
Definition: BaseTemplate.php:26
SkinFactory\getDefaultInstance
static getDefaultInstance()
Definition: SkinFactory.php:50
form
null means default in associative array form
Definition: hooks.txt:1996