From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- .../ResourceLoaderLanguageDataModule.php | 122 +++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 includes/resourceloader/ResourceLoaderLanguageDataModule.php (limited to 'includes/resourceloader/ResourceLoaderLanguageDataModule.php') diff --git a/includes/resourceloader/ResourceLoaderLanguageDataModule.php b/includes/resourceloader/ResourceLoaderLanguageDataModule.php new file mode 100644 index 00000000..c916c4a5 --- /dev/null +++ b/includes/resourceloader/ResourceLoaderLanguageDataModule.php @@ -0,0 +1,122 @@ +language->getGrammarForms(); + } + + /** + * Get the plural forms for the site content language. + * + * @return array + */ + protected function getPluralRules() { + return $this->language->getPluralRules(); + } + + /** + * Get the digit transform table for the content language + * Seperator transform table also required here to convert + * the . and , sign to appropriate forms in content language. + * + * @return array + */ + protected function getDigitTransformTable() { + $digitTransformTable = $this->language->digitTransformTable(); + $separatorTransformTable = $this->language->separatorTransformTable(); + if ( $digitTransformTable ) { + array_merge( $digitTransformTable, (array)$separatorTransformTable ); + } else { + return $separatorTransformTable; + } + return $digitTransformTable; + } + + /** + * Get all the dynamic data for the content language to an array + * + * @return array + */ + protected function getData() { + return array( + 'digitTransformTable' => $this->getDigitTransformTable(), + 'grammarForms' => $this->getSiteLangGrammarForms(), + 'pluralRules' => $this->getPluralRules(), + ); + } + + /** + * @param $context ResourceLoaderContext + * @return string: JavaScript code + */ + public function getScript( ResourceLoaderContext $context ) { + $this->language = Language::factory( $context->getLanguage() ); + return Xml::encodeJsCall( 'mw.language.setData', array( + $this->language->getCode(), + $this->getData() + ) ); + } + + /** + * @param $context ResourceLoaderContext + * @return array|int|Mixed + */ + public function getModifiedTime( ResourceLoaderContext $context ) { + $this->language = Language::factory( $context ->getLanguage() ); + $cache = wfGetCache( CACHE_ANYTHING ); + $key = wfMemcKey( 'resourceloader', 'langdatamodule', 'changeinfo' ); + + $data = $this->getData(); + $hash = md5( serialize( $data ) ); + + $result = $cache->get( $key ); + if ( is_array( $result ) && $result['hash'] === $hash ) { + return $result['timestamp']; + } + $timestamp = wfTimestamp(); + $cache->set( $key, array( + 'hash' => $hash, + 'timestamp' => $timestamp, + ) ); + return $timestamp; + } + + /** + * @return array + */ + public function getDependencies() { + return array( 'mediawiki.language.init' ); + } +} -- cgit v1.2.2