MediaWiki  1.30.0
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
30  is_file( "$styleDirectory/$skinDir/skin.json" )
31  || is_file( "$styleDirectory/$skinDir/$skinDir.php" );
32  } );
33 
34  return $possibleSkins;
35  }
36 
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 );
47 
48  if ( $installedSkins ) {
49  $skinsInstalledText = [];
50  $skinsInstalledSnippet = [];
51 
52  foreach ( $installedSkins as $skin ) {
53  $normalizedKey = strtolower( $skin );
54  $isEnabled = array_key_exists( $normalizedKey, $enabledSkins );
55  if ( $isEnabled ) {
56  $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-enabled' )
57  ->params( $normalizedKey, $skin )->plain();
58  } else {
59  $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-disabled' )
60  ->params( $normalizedKey, $skin )->plain();
61  $skinsInstalledSnippet[] = $this->getSnippetForSkin( $skin );
62  }
63  }
64 
65  return $this->getMsg( 'default-skin-not-found' )->params(
66  $defaultSkin,
67  implode( "\n", $skinsInstalledText ),
68  implode( "\n", $skinsInstalledSnippet ) )->numParams(
69  count( $skinsInstalledText ),
70  count( $skinsInstalledSnippet )
71  )->parseAsBlock();
72  } else {
73  return $this->getMsg( 'default-skin-not-found-no-skins' )->params(
74  $defaultSkin
75  )->parseAsBlock();
76  }
77  }
78 
85  private function getSnippetForSkin( $skin ) {
86  global $IP;
87  if ( file_exists( "$IP/skins/$skin/skin.json" ) ) {
88  return "wfLoadSkin( '$skin' );";
89  } else {
90  return "require_once \"\$IP/skins/$skin/$skin.php\";";
91  }
92  }
93 
98  public function execute() {
99  $this->html( 'headelement' ) ?>
100 
101  <div class="warningbox">
102  <?php echo $this->buildHelpfulInformationMessage() ?>
103  </div>
104 
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' ) ?>
110  </form>
111 
112  <div class="mw-body" role="main">
113  <h1 class="firstHeading"><?php $this->html( 'title' ) ?></h1>
114 
115  <div class="mw-body-content">
116  <?php $this->html( 'bodytext' ) ?>
117  <?php $this->html( 'catlinks' ) ?>
118  </div>
119  </div>
120 
121  <?php $this->printTrail() ?>
122  </body></html>
123 
124  <?php
125  }
126 }
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 as and are nearing end of 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:22
BaseTemplate\makeSearchButton
makeSearchButton( $mode, $attrs=[])
Definition: BaseTemplate.php:531
captcha-old.count
count
Definition: captcha-old.py:249
SkinFallbackTemplate\execute
execute()
Outputs the entire contents of the page.
Definition: SkinFallbackTemplate.php:98
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
SkinFallbackTemplate\getSnippetForSkin
getSnippetForSkin( $skin)
Get the appropriate LocalSettings.php snippet to enable the given skin.
Definition: SkinFallbackTemplate.php:85
SkinFallbackTemplate\buildHelpfulInformationMessage
buildHelpfulInformationMessage()
Inform the user why they are seeing this skin.
Definition: SkinFallbackTemplate.php:42
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:35
value
$status value
Definition: SyntaxHighlight.class.php:315
$IP
$IP
Definition: update.php:3
BaseTemplate\printTrail
printTrail()
Output getTrail.
Definition: BaseTemplate.php:750
form
null means default in associative array form
Definition: hooks.txt:1965
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
captcha-old.action
action
Definition: captcha-old.py:212
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:521
QuickTemplate\html
html( $str)
Definition: QuickTemplate.php:126
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:9
$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:1965
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
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