MediaWiki
REL1_24
|
00001 <?php 00002 00015 class SkinFallbackTemplate extends BaseTemplate { 00019 private function findInstalledSkins() { 00020 $styleDirectory = $this->config->get( 'StyleDirectory' ); // @todo we should inject this directly? 00021 // Get all subdirectories which might contains skins 00022 $possibleSkins = scandir( $styleDirectory ); 00023 $possibleSkins = array_filter( $possibleSkins, function ( $maybeDir ) use ( $styleDirectory ) { 00024 return $maybeDir !== '.' && $maybeDir !== '..' && is_dir( "$styleDirectory/$maybeDir" ); 00025 } ); 00026 00027 // Only keep the ones that contain a .php file with the same name inside 00028 $possibleSkins = array_filter( $possibleSkins, function ( $skinDir ) use ( $styleDirectory ) { 00029 return is_file( "$styleDirectory/$skinDir/$skinDir.php" ); 00030 } ); 00031 00032 return $possibleSkins; 00033 } 00034 00040 private function buildHelpfulInformationMessage() { 00041 $defaultSkin = $this->config->get( 'DefaultSkin' ); 00042 $installedSkins = $this->findInstalledSkins(); 00043 $enabledSkins = SkinFactory::getDefaultInstance()->getSkinNames(); 00044 $enabledSkins = array_change_key_case( $enabledSkins, CASE_LOWER ); 00045 00046 if ( $installedSkins ) { 00047 $skinsInstalledText = array(); 00048 $skinsInstalledSnippet = array(); 00049 00050 foreach ( $installedSkins as $skin ) { 00051 $normalizedKey = strtolower( $skin ); 00052 $isEnabled = array_key_exists( $normalizedKey, $enabledSkins ); 00053 if ( $isEnabled ) { 00054 $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-enabled' ) 00055 ->params( $normalizedKey, $skin )->plain(); 00056 } else { 00057 $skinsInstalledText[] = $this->getMsg( 'default-skin-not-found-row-disabled' ) 00058 ->params( $normalizedKey, $skin )->plain(); 00059 $skinsInstalledSnippet[] = "require_once \"\$IP/skins/$skin/$skin.php\";"; 00060 } 00061 } 00062 00063 return $this->getMsg( 'default-skin-not-found' )->params( 00064 $defaultSkin, 00065 implode( "\n", $skinsInstalledText ), 00066 implode( "\n", $skinsInstalledSnippet ) 00067 )->parseAsBlock(); 00068 } else { 00069 return $this->getMsg( 'default-skin-not-found-no-skins' )->params( 00070 $defaultSkin 00071 )->parseAsBlock(); 00072 } 00073 } 00074 00079 public function execute() { 00080 $this->html( 'headelement' ) ?> 00081 00082 <div class="warningbox"> 00083 <?php echo $this->buildHelpfulInformationMessage() ?> 00084 </div> 00085 00086 <form action="<?php $this->text( 'wgScript' ) ?>"> 00087 <input type="hidden" name="title" value="<?php $this->text( 'searchtitle' ) ?>" /> 00088 <h3><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3> 00089 <?php echo $this->makeSearchInput( array( "id" => "searchInput" ) ) ?> 00090 <?php echo $this->makeSearchButton( 'go' ) ?> 00091 </form> 00092 00093 <div class="mw-body" role="main"> 00094 <h1 class="firstHeading"> 00095 <span dir="auto"><?php $this->html( 'title' ) ?></span> 00096 </h1> 00097 00098 <div class="mw-body-content"> 00099 <?php $this->html( 'bodytext' ) ?> 00100 <?php $this->html( 'catlinks' ) ?> 00101 </div> 00102 </div> 00103 00104 <?php $this->printTrail() ?> 00105 </body></html> 00106 00107 <?php 00108 } 00109 }