[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/skins/ -> SkinFallbackTemplate.php (source)

   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' ); // @todo we should inject this directly?
  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">
  95                  <span dir="auto"><?php $this->html( 'title' ) ?></span>
  96              </h1>
  97  
  98              <div class="mw-body-content">
  99                  <?php $this->html( 'bodytext' ) ?>
 100                  <?php $this->html( 'catlinks' ) ?>
 101              </div>
 102          </div>
 103  
 104          <?php $this->printTrail() ?>
 105          </body></html>
 106  
 107      <?php
 108      }
 109  }


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1