[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/extensions/LocalisationUpdate/reader/ -> ReaderFactory.php (source)

   1  <?php
   2  /**
   3   * @file
   4   * @author Niklas Laxström
   5   * @license GPL-2.0+
   6   */
   7  
   8  /**
   9   * Constructs readers for files based on the names.
  10   */
  11  class LU_ReaderFactory {
  12      /**
  13       * Constructs a suitable reader for a given path.
  14       * @param string $filename Usually a relative path to the file name.
  15       * @return LU_Reader
  16       * @throw MWException
  17       */
  18  	public function getReader( $filename ) {
  19          if ( preg_match( '/i18n\.php$/', $filename ) ) {
  20              return new LU_PHPReader();
  21          }
  22  
  23          // Ugly hack for core i18n files
  24          if ( preg_match( '/Messages(.*)\.php$/', $filename ) ) {
  25              $code = Language::getCodeFromFileName( basename( $filename ), 'Messages' );
  26              return new LU_PHPReader( $code );
  27          }
  28  
  29          if ( preg_match( '/\.json/', $filename ) ) {
  30              $code = basename( $filename, '.json' );
  31              return new LU_JSONReader( $code );
  32          }
  33  
  34          throw new MWException( "Unknown file format: " . $filename );
  35      }
  36  }


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