r111723 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111722‎ | r111723 | r111724 >
Date:04:30, 17 February 2012
Author:santhosh
Status:resolved (Comments)
Tags:i18nreview 
Comment:
First version of ResourceLoaderLanguageModule.
getModifiedTime method is incomplete.
Modified paths:
  • /branches/jsgrammar/includes/AutoLoader.php (modified) (history)
  • /branches/jsgrammar/includes/resourceloader/ResourceLoaderLanguageModule.php (added) (history)
  • /branches/jsgrammar/languages/Language.php (modified) (history)
  • /branches/jsgrammar/resources/Resources.php (modified) (history)

Diff [purge]

Index: branches/jsgrammar/includes/resourceloader/ResourceLoaderLanguageModule.php
@@ -0,0 +1,74 @@
 2+<?php
 3+/**
 4+ * This program is free software; you can redistribute it and/or modify
 5+ * it under the terms of the GNU General Public License as published by
 6+ * the Free Software Foundation; either version 2 of the License, or
 7+ * (at your option) any later version.
 8+ *
 9+ * This program is distributed in the hope that it will be useful,
 10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 12+ * GNU General Public License for more details.
 13+ *
 14+ * You should have received a copy of the GNU General Public License along
 15+ * with this program; if not, write to the Free Software Foundation, Inc.,
 16+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 17+ * http://www.gnu.org/copyleft/gpl.html
 18+ *
 19+ * @file
 20+ * @author Santhosh Thottingal
 21+ * @author Timo Tijhof
 22+ */
 23+
 24+/**
 25+ * ResourceLoader module for generating language specific scripts/css.
 26+ */
 27+class ResourceLoaderLanguageModule extends ResourceLoaderModule {
 28+
 29+ /**
 30+ * Get the grammer forms for the site content language.
 31+ *
 32+ * @return Array
 33+ */
 34+ protected function getSiteLangGrammarForms( ) {
 35+ global $wgContLang;
 36+ return $wgContLang->getGrammarForms();
 37+ }
 38+ /**
 39+ * @param $context ResourceLoaderContext
 40+ * @return string
 41+ */
 42+ public function getScript( ResourceLoaderContext $context ) {
 43+ global $wgContLang;
 44+ $js =
 45+ 'var langCode = ' . FormatJson::encode( $wgContLang->getCode() ) . ', ' .
 46+ "langData = mw.language.data;\n" .
 47+ "if ( langData[langCode] === undefined ) {\n" .
 48+ " langData[langCode] = new mw.Map();\n" .
 49+ "}\n" .
 50+ Xml::encodeJsCall( 'langData[langCode].set',
 51+ array( 'grammarForms', $this->getSiteLangGrammarForms( ) )
 52+ );
 53+ return $js;
 54+ }
 55+ /**
 56+ * @param $context ResourceLoaderContext
 57+ * @return array|int|Mixed
 58+ */
 59+ public function getModifiedTime( ResourceLoaderContext $context ) {
 60+ global $wgCacheEpoch;
 61+ /*
 62+ global $wgContLang, $wgCacheEpoch;
 63+ return max( $wgCacheEpoch, $wgContLang->getLastModified() );
 64+ */
 65+
 66+ return $wgCacheEpoch;
 67+ }
 68+ /**
 69+ * @return array
 70+ */
 71+ public function getDependencies() {
 72+ return array( 'mediawiki.language' );
 73+ }
 74+}
 75+
Property changes on: branches/jsgrammar/includes/resourceloader/ResourceLoaderLanguageModule.php
___________________________________________________________________
Added: svn:eol-style
176 + native
Index: branches/jsgrammar/includes/AutoLoader.php
@@ -732,6 +732,7 @@
733733 'ResourceLoaderUserModule' => 'includes/resourceloader/ResourceLoaderUserModule.php',
734734 'ResourceLoaderUserOptionsModule' => 'includes/resourceloader/ResourceLoaderUserOptionsModule.php',
735735 'ResourceLoaderUserTokensModule' => 'includes/resourceloader/ResourceLoaderUserTokensModule.php',
 736+ 'ResourceLoaderLanguageModule' => 'includes/resourceloader/ResourceLoaderLanguageModule.php',
736737 'ResourceLoaderWikiModule' => 'includes/resourceloader/ResourceLoaderWikiModule.php',
737738
738739 # includes/revisiondelete
Index: branches/jsgrammar/languages/Language.php
@@ -3239,8 +3239,18 @@
32403240 }
32413241 return $forms;
32423242 }
3243 -
32443243 /**
 3244+ * Get the grammar forms for the content language
 3245+ * @return array of grammar forms
 3246+ */
 3247+ function getGrammarForms( ) {
 3248+ global $wgGrammarForms;
 3249+ if ( isset( $wgGrammarForms[$this->getCode()] ) && is_array( $wgGrammarForms[$this->getCode()] ) ) {
 3250+ return $wgGrammarForms[$this->getCode()];
 3251+ }
 3252+ return array();
 3253+ }
 3254+ /**
32453255 * @todo Maybe translate block durations. Note that this function is somewhat misnamed: it
32463256 * deals with translating the *duration* ("1 week", "4 days", etc), not the expiry time
32473257 * (which is an absolute timestamp). Please note: do NOT add this blindly, as it is used
Index: branches/jsgrammar/resources/Resources.php
@@ -12,6 +12,7 @@
1313 'user.options' => array( 'class' => 'ResourceLoaderUserOptionsModule' ),
1414 'user.cssprefs' => array( 'class' => 'ResourceLoaderUserCSSPrefsModule' ),
1515 'user.tokens' => array( 'class' => 'ResourceLoaderUserTokensModule' ),
 16+ 'language' => array( 'class' => 'ResourceLoaderLanguageModule' ),
1617 'filepage' => array( 'class' => 'ResourceLoaderFilePageModule' ),
1718
1819 /* Skins */

Sign-offs

UserFlagDate
Amire80inspected21:21, 19 February 2012

Follow-up revisions

RevisionCommit summaryAuthorDate
r112991[JSGrammar] Various minor tips, tricks and clean up....krinkle23:56, 4 March 2012
r113800Impliment getModifiedTime for ResourceLoaderLanguageDataModule, using CACHE_A...santhosh08:34, 14 March 2012

Comments

#Comment by Krinkle (talk | contribs)   00:13, 5 March 2012

"getModifiedTime method is incomplete"

Status & tagging log