[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/resourceloader/ -> ResourceLoaderLanguageNamesModule.php (source)

   1  <?php
   2  /**
   3   * Resource loader module for providing language names.
   4   *
   5   * By default these names will be autonyms however other extensions may
   6   * provided language names in the context language (e.g. cldr extension)
   7   *
   8   * This program is free software; you can redistribute it and/or modify
   9   * it under the terms of the GNU General Public License as published by
  10   * the Free Software Foundation; either version 2 of the License, or
  11   * (at your option) any later version.
  12   *
  13   * This program is distributed in the hope that it will be useful,
  14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16   * GNU General Public License for more details.
  17   *
  18   * You should have received a copy of the GNU General Public License along
  19   * with this program; if not, write to the Free Software Foundation, Inc.,
  20   * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  21   * http://www.gnu.org/copyleft/gpl.html
  22   *
  23   * @file
  24   * @author Ed Sanders
  25   * @author Trevor Parscal
  26   */
  27  
  28  /**
  29   * ResourceLoader module for populating language specific data.
  30   */
  31  class ResourceLoaderLanguageNamesModule extends ResourceLoaderModule {
  32  
  33      protected $targets = array( 'desktop', 'mobile' );
  34  
  35  
  36      /**
  37       * @param ResourceLoaderContext $context
  38       * @return array
  39       */
  40  	protected function getData( ResourceLoaderContext $context ) {
  41          return Language::fetchLanguageNames(
  42              $context->getLanguage(),
  43              'all'
  44          );
  45      }
  46  
  47      /**
  48       * @param ResourceLoaderContext $context
  49       * @return string JavaScript code
  50       */
  51  	public function getScript( ResourceLoaderContext $context ) {
  52          return Xml::encodeJsCall( 'mw.language.setData', array(
  53              $context->getLanguage(),
  54              'languageNames',
  55              $this->getData( $context )
  56          ) );
  57      }
  58  
  59  	public function getDependencies() {
  60          return array( 'mediawiki.language.init' );
  61      }
  62  
  63      /**
  64       * @param ResourceLoaderContext $context
  65       * @return int UNIX timestamp
  66       */
  67  	public function getModifiedTime( ResourceLoaderContext $context ) {
  68          return max( 1, $this->getHashMtime( $context ) );
  69      }
  70  
  71      /**
  72       * @param ResourceLoaderContext $context
  73       * @return string Hash
  74       */
  75  	public function getModifiedHash( ResourceLoaderContext $context ) {
  76          return md5( serialize( $this->getData( $context ) ) );
  77      }
  78  
  79  }


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