Remove dir=auto from firstHeading
[lhc/web/wiklou.git] / includes / skins / SkinFallbackTemplate.php
1 <?php
2
3 /**
4 * Skin template for the fallback skin.
5 *
6 * The structure is copied from the example skin (mediawiki/skins/Example).
7 *
8 * @since 1.24
9 * @file
10 */
11
12 /**
13 * BaseTemplate class for the fallback skin
14 */
15 class SkinFallbackTemplate extends BaseTemplate {
16 /**
17 * @return array
18 */
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 // 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" );
30 } );
31
32 return $possibleSkins;
33 }
34
35 /**
36 * Inform the user why they are seeing this skin.
37 *
38 * @return string
39 */
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 );
45
46 if ( $installedSkins ) {
47 $skinsInstalledText = array();
48 $skinsInstalledSnippet = array();
49
50 foreach ( $installedSkins as $skin ) {
51 $normalizedKey = strtolower( $skin );
52 $isEnabled = array_key_exists( $normalizedKey, $enabledSkins );
53 if ( $isEnabled ) {
54 $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-enabled' )
55 ->params( $normalizedKey, $skin )->plain();
56 } else {
57 $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-disabled' )
58 ->params( $normalizedKey, $skin )->plain();
59 $skinsInstalledSnippet[] = "require_once \"\$IP/skins/$skin/$skin.php\";";
60 }
61 }
62
63 return $this->getMsg( 'default-skin-not-found' )->params(
64 $defaultSkin,
65 implode( "\n", $skinsInstalledText ),
66 implode( "\n", $skinsInstalledSnippet )
67 )->parseAsBlock();
68 } else {
69 return $this->getMsg( 'default-skin-not-found-no-skins' )->params(
70 $defaultSkin
71 )->parseAsBlock();
72 }
73 }
74
75 /**
76 * Outputs the entire contents of the page. No navigation (other than search box), just the big
77 * warning message and page content.
78 */
79 public function execute() {
80 $this->html( 'headelement' ) ?>
81
82 <div class="warningbox">
83 <?php echo $this->buildHelpfulInformationMessage() ?>
84 </div>
85
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' ) ?>
91 </form>
92
93 <div class="mw-body" role="main">
94 <h1 class="firstHeading"><?php $this->html( 'title' ) ?></h1>
95
96 <div class="mw-body-content">
97 <?php $this->html( 'bodytext' ) ?>
98 <?php $this->html( 'catlinks' ) ?>
99 </div>
100 </div>
101
102 <?php $this->printTrail() ?>
103 </body></html>
104
105 <?php
106 }
107 }