r96101 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96100‎ | r96101 | r96102 >
Date:15:26, 2 September 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Remove rest of resource loader compatibility code. Renamed module translate-css to ext.translate to better match naming conventions.
Modified paths:
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/TranslateUtils.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialLanguageStats.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialSupportedLanguages.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialTranslate.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialTranslations.php (modified) (history)
  • /trunk/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageTable.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageWebImporter.php (modified) (history)
  • /trunk/extensions/Translate/utils/TranslationHelpers.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -350,7 +350,7 @@
351351 global $wgOut, $wgContLang;
352352
353353 $wgOut->setSubtitle( $this->user->getSkin()->link( $page->getTitle() ) );
354 - TranslateUtils::injectCSS();
 354+ $wgOut->addModules( 'ext.translate' );
355355
356356 $wgOut->addWikiMsg( 'tpt-showpage-intro' );
357357
Index: trunk/extensions/Translate/tag/PageTranslationHooks.php
@@ -72,9 +72,9 @@
7373 return true;
7474 }
7575
76 - // Only called form hook
 76+ // Only called from hook
7777 public static function injectCss( $outputpage, $text ) {
78 - TranslateUtils::injectCSS();
 78+ $outputpage->addModules( 'ext.translate' );
7979
8080 return true;
8181 }
Index: trunk/extensions/Translate/Translate.php
@@ -130,7 +130,7 @@
131131 );
132132
133133 // Client-side resource modules
134 -$wgResourceModules['translate-css'] = array(
 134+$wgResourceModules['ext.translate'] = array(
135135 'styles' => 'Translate.css',
136136 ) + $resourcePaths;
137137
Index: trunk/extensions/Translate/utils/MessageTable.php
@@ -65,7 +65,7 @@
6666 TranslationHelpers::addModules( $wgOut );
6767 $vars = array( 'trlKeys' => array_values( $this->collection->keys() ) );
6868 $wgOut->addScript( Skin::makeVariablesScript( $vars ) );
69 - TranslateUtils::addModules( $wgOut, 'ext.translate.messagetable' );
 69+ $wgOut->addModules( 'ext.translate.messagetable' );
7070 }
7171
7272 public function header() {
Index: trunk/extensions/Translate/utils/MessageWebImporter.php
@@ -85,7 +85,8 @@
8686 }
8787
8888 protected function doHeader() {
89 - TranslateUtils::injectCSS();
 89+ global $wgOut;
 90+ $wgOut->addModules( 'ext.translate' );
9091
9192 $formParams = array(
9293 'method' => 'post',
Index: trunk/extensions/Translate/utils/TranslationHelpers.php
@@ -1198,12 +1198,12 @@
11991199 }
12001200
12011201 public static function addModules( OutputPage $out ) {
1202 - TranslateUtils::addModules( $out, array(
1203 - 'ext.translate.quickedit',
1204 - ) );
 1202+ $out->addModules( 'ext.translate.quickedit' );
12051203
12061204 // Might be needed, but ajax doesn't load it
12071205 // Globals :(
 1206+ /// @todo: remove when 1.17 is no longer supported.
 1207+ // The RL module name is different in 1.17 and >1.17
12081208 $diff = new DifferenceEngine;
12091209 $diff->showDiffStyle();
12101210 }
Index: trunk/extensions/Translate/specials/SpecialSupportedLanguages.php
@@ -33,7 +33,7 @@
3434 $this->purge = $wgRequest->getVal( 'action' ) === 'purge';
3535
3636 $this->setHeaders();
37 - TranslateUtils::addModules( $wgOut, 'ext.translate.special.supportedlanguages' );
 37+ $wgOut->addModules( 'ext.translate.special.supportedlanguages' );
3838
3939 $cache = wfGetCache( CACHE_ANYTHING );
4040 $cachekey = wfMemcKey( 'translate-supportedlanguages', $wgLang->getCode() );
Index: trunk/extensions/Translate/specials/SpecialTranslate.php
@@ -33,7 +33,7 @@
3434 public function execute( $parameters ) {
3535 global $wgOut, $wgTranslateBlacklist, $wgRequest;
3636
37 - TranslateUtils::addModules( $wgOut, 'ext.translate.special.translate' );
 37+ $wgOut->addModules( 'ext.translate.special.translate' );
3838
3939 $this->setHeaders();
4040
Index: trunk/extensions/Translate/specials/SpecialTranslations.php
@@ -271,6 +271,6 @@
272272 private static function includeAssets() {
273273 global $wgOut;
274274 TranslationHelpers::addModules( $wgOut );
275 - TranslateUtils::addModules( $wgOut, 'ext.translate.messagetable' );
 275+ $wgOut->addModules( 'ext.translate.messagetable' );
276276 }
277277 }
Index: trunk/extensions/Translate/specials/SpecialLanguageStats.php
@@ -37,8 +37,8 @@
3838 $this->setHeaders();
3939 $this->outputHeader();
4040
41 - TranslateUtils::addModules( $wgOut, 'ext.translate.special.languagestats' );
42 - TranslateUtils::addModules( $wgOut, 'ext.translate.messagetable' );
 41+ $wgOut->addModules( 'ext.translate.special.languagestats' );
 42+ $wgOut->addModules( 'ext.translate.messagetable' );
4343
4444 // no UI when including()
4545 if ( !$this->including() ) {
Index: trunk/extensions/Translate/TranslateUtils.php
@@ -318,26 +318,6 @@
319319 }
320320
321321 /**
322 - * Injects extension css (only once).
323 - */
324 - public static function injectCSS() {
325 - global $wgOut;
326 -
327 - if ( method_exists( $wgOut, 'addModules' ) ) {
328 - $wgOut->addModuleStyles( 'translate-css' );
329 - return true;
330 - }
331 -
332 - static $done = false;
333 -
334 - if ( !$done ) {
335 - $wgOut->addExtensionStyle( self::assetPath( 'Translate.css' ) );
336 - }
337 -
338 - return $done = true;
339 - }
340 -
341 - /**
342322 * Construct the web address to given asset.
343323 * @param $path \string Path to the resource relative to extensions root directory.
344324 * @return \string Full or partial web path.
@@ -347,24 +327,6 @@
348328 return "$wgExtensionAssetsPath/Translate/$path";
349329 }
350330
351 - public static function addModules( $out, $modules ) {
352 - if ( method_exists( $out, 'addModules' ) ) {
353 - $out->addModules( $modules );
354 - } else {
355 - global $wgResourceModules;
356 - foreach ( (array) $modules as $module ) {
357 - if ( isset( $wgResourceModules[$module]['styles'] ) ) {
358 - $file = $wgResourceModules[$module]['styles'];
359 - $out->addExtensionStyle( TranslateUtils::assetPath( $file ) );
360 - }
361 - if ( isset( $wgResourceModules[$module]['scripts'] ) ) {
362 - $file = $wgResourceModules[$module]['scripts'];
363 - $out->addScriptFile( TranslateUtils::assetPath( $file ) );
364 - }
365 - }
366 - }
367 - }
368 -
369331 /**
370332 * Gets the path for cache files
371333 * @param $filename \string

Status & tagging log