MediaWiki
REL1_22
|
00001 <?php 00028 class ResourceLoaderLanguageDataModule extends ResourceLoaderModule { 00029 00030 protected $language; 00031 protected $targets = array( 'desktop', 'mobile' ); 00037 protected function getSiteLangGrammarForms() { 00038 return $this->language->getGrammarForms(); 00039 } 00040 00046 protected function getPluralRules() { 00047 return $this->language->getPluralRules(); 00048 } 00049 00055 protected function getDigitGroupingPattern() { 00056 return $this->language->digitGroupingPattern(); 00057 } 00058 00064 protected function getDigitTransformTable() { 00065 return $this->language->digitTransformTable(); 00066 } 00067 00074 protected function getSeparatorTransformTable() { 00075 return $this->language->separatorTransformTable(); 00076 } 00077 00085 protected function getData() { 00086 return array( 00087 'digitTransformTable' => $this->getDigitTransformTable(), 00088 'separatorTransformTable' => $this->getSeparatorTransformTable(), 00089 'grammarForms' => $this->getSiteLangGrammarForms(), 00090 'pluralRules' => $this->getPluralRules(), 00091 'digitGroupingPattern' => $this->getDigitGroupingPattern(), 00092 ); 00093 } 00094 00099 public function getScript( ResourceLoaderContext $context ) { 00100 $this->language = Language::factory( $context->getLanguage() ); 00101 return Xml::encodeJsCall( 'mw.language.setData', array( 00102 $this->language->getCode(), 00103 $this->getData() 00104 ) ); 00105 } 00106 00111 public function getModifiedTime( ResourceLoaderContext $context ) { 00112 return max( 1, $this->getHashMtime( $context ) ); 00113 } 00114 00119 public function getModifiedHash( ResourceLoaderContext $context ) { 00120 $this->language = Language::factory( $context->getLanguage() ); 00121 00122 return md5( serialize( $this->getData() ) ); 00123 } 00124 00128 public function getDependencies() { 00129 return array( 'mediawiki.language.init' ); 00130 } 00131 }