r67180 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67179‎ | r67180 | r67181 >
Date:11:47, 1 June 2010
Author:siebrand
Status:deferred
Tags:
Comment:
Code style updates and trailing whitespace removed.
Modified paths:
  • /trunk/extensions/Translate/SpecialTranslationChanges.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)
  • /trunk/extensions/Translate/TranslatePage.php (modified) (history)
  • /trunk/extensions/Translate/TranslateTasks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/TranslatePage.php
@@ -19,7 +19,7 @@
2020 protected $options = null;
2121
2222 function __construct() {
23 - SpecialPage::SpecialPage( 'Translate' );
 23+ parent::__construct( 'Translate' );
2424 }
2525
2626 /**
Index: trunk/extensions/Translate/SpecialTranslationChanges.php
@@ -7,7 +7,7 @@
88 const MSG = 'translationchanges-';
99
1010 function __construct() {
11 - SpecialPage::SpecialPage( 'TranslationChanges' );
 11+ parent::__construct( 'TranslationChanges' );
1212 }
1313
1414 /** Access point for this special page */
Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -14,22 +14,36 @@
1515
1616 static function addNavigation( &$outputpage, &$text ) {
1717 global $wgUser, $wgTitle;
 18+
1819 static $done = false;
19 - if ( $done ) return true;
 20+ if ( $done ) {
 21+ return true;
 22+ }
 23+
2024 $done = true;
2125
22 - if ( !self::isMessageNamespace( $wgTitle ) ) return true;
 26+ if ( !self::isMessageNamespace( $wgTitle ) ) {
 27+ return true;
 28+ }
2329
24 -
2530 list( $key, $code, $group ) = self::getKeyCodeGroup( $wgTitle );
26 - if ( $group === null ) return true;
 31+ if ( $group === null ) {
 32+ return true;
 33+ }
2734
2835 if ( $group instanceof MessageGroupBase ) {
2936 $cache = new MessageGroupCache( $group );
30 - if ( !$cache->exists() ) return true;
 37+ if ( !$cache->exists() ) {
 38+ return true;
 39+ }
 40+
3141 $keys = $cache->getKeys();
3242 $defs = array();
33 - foreach ( $keys as $_ ) $defs[$_] = $cache->get( $_ );
 43+
 44+ foreach ( $keys as $_ ) {
 45+ $defs[$_] = $cache->get( $_ );
 46+ }
 47+
3448 $skip = array_merge( $group->getTags( 'ignored' ), $group->getTags( 'optional' ) );
3549 } else {
3650 $defs = $group->getDefinitions();
@@ -40,7 +54,10 @@
4155
4256 $next = $prev = $def = null;
4357 foreach ( array_keys( $defs ) as $tkey ) {
44 - if ( in_array( $tkey, $skip ) ) continue;
 58+ if ( in_array( $tkey, $skip ) ) {
 59+ continue;
 60+ }
 61+
4562 // Keys can have mixed case, but they have to be unique in a case
4663 // insensitive manner. It is therefore safe and a must to use case
4764 // insensitive comparison method
@@ -52,6 +69,7 @@
5370 $next = $tkey;
5471 break;
5572 }
 73+
5674 $prev = $tkey;
5775 }
5876
@@ -69,6 +87,7 @@
7088 if ( !$title->exists() ) {
7189 $params['action'] = 'edit';
7290 }
 91+
7392 $prevLink = $skin->link( $title,
7493 wfMsgHtml( 'translate-edit-goto-prev' ), array(), $params );
7594 }
@@ -114,13 +133,16 @@
115134
116135 static function intro( $object ) {
117136 $object->suppressIntro = true;
 137+
118138 return true;
119139 }
120140
121141
122142 static function addTools( $object ) {
123 - if ( !self::isMessageNamespace( $object->mTitle ) ) return true;
124 -
 143+ if ( !self::isMessageNamespace( $object->mTitle ) ) {
 144+ return true;
 145+ }
 146+
125147 TranslateEditAddons::addNavigation( $ignored, $object->editFormTextTop );
126148 $object->editFormTextTop .= self::editBoxes( $object );
127149
@@ -128,11 +150,18 @@
129151 }
130152
131153 static function buttonHack( $editpage, &$buttons, $tabindex ) {
132 - if ( !self::isMessageNamespace( $editpage->mTitle ) ) return true;
 154+ if ( !self::isMessageNamespace( $editpage->mTitle ) ) {
 155+ return true;
 156+ }
133157
134158 global $wgLang;
 159+
135160 list( , $code ) = self::figureMessage( $editpage->mTitle );
136 - if ( $code !== 'qqq' ) return true;
 161+
 162+ if ( $code !== 'qqq' ) {
 163+ return true;
 164+ }
 165+
137166 $name = TranslateUtils::getLanguageName( $code, false, $wgLang->getCode() );
138167 $temp = array(
139168 'id' => 'wpSave',
@@ -144,6 +173,7 @@
145174 'title' => wfMsg( 'tooltip-save' ) . ' [' . wfMsg( 'accesskey-save' ) . ']',
146175 );
147176 $buttons['save'] = Xml::element( 'input', $temp, '' );
 177+
148178 return true;
149179 }
150180
@@ -153,6 +183,7 @@
154184 private static function figureMessage( Title $title ) {
155185 $text = $title->getDBkey();
156186 $pos = strrpos( $text, '/' );
 187+
157188 if ( $pos === false ) {
158189 $code = '';
159190 $key = $text;
@@ -160,12 +191,14 @@
161192 $code = substr( $text, $pos + 1 );
162193 $key = substr( $text, 0, $pos );
163194 }
 195+
164196 return array( $key, $code );
165197 }
166198
167199 public static function getKeyCodeGroup( Title $title ) {
168200 list( $key, $code ) = self::figureMessage( $title );
169201 $group = self::getMessageGroup( $title->getNamespace(), $key );
 202+
170203 return array( $key, $code, $group );
171204 }
172205
@@ -178,6 +211,7 @@
179212 */
180213 private static function getMessageGroup( $namespace, $key ) {
181214 global $wgRequest;
 215+
182216 $group = $wgRequest->getText( 'loadgroup', '' );
183217 $mg = MessageGroups::getGroup( $group );
184218
@@ -205,6 +239,7 @@
206240
207241 TranslateUtils::injectCSS();
208242 $wgOut->includeJQuery();
 243+
209244 return $th->getBoxes();
210245 }
211246
@@ -227,17 +262,22 @@
228263 );
229264
230265 $res = $dbr->selectField( $tables, $fields, $conds, __METHOD__ );
 266+
231267 return $res === $id;
232268 }
233269
234270 public static function isMessageNamespace( Title $title ) {
235271 global $wgTranslateMessageNamespaces; ;
 272+
236273 $namespace = $title->getNamespace();
 274+
237275 return in_array( $namespace, $wgTranslateMessageNamespaces, true );
238276 }
239277
240278 public static function tabs( $skin, &$tabs ) {
241 - if ( !self::isMessageNamespace( $skin->mTitle ) ) return true;
 279+ if ( !self::isMessageNamespace( $skin->mTitle ) ) {
 280+ return true;
 281+ }
242282
243283 unset( $tabs['protect'] );
244284
@@ -246,30 +286,39 @@
247287
248288 public static function keepFields( $edit, $out ) {
249289 global $wgRequest;
 290+
250291 $out->addHTML( "\n" .
251292 Xml::hidden( 'loadgroup', $wgRequest->getText( 'loadgroup' ) ) .
252293 Xml::hidden( 'loadtask', $wgRequest->getText( 'loadtask' ) ) .
253294 "\n"
254295 );
 296+
255297 return true;
256298 }
257299
258300 public static function onSave( $article, $user, $text, $summary,
259 - $minor, $_, $_, $flags, $revision ) {
260 -
 301+ $minor, $_, $_, $flags, $revision
 302+ ) {
261303 $title = $article->getTitle();
262304
263 - if ( !self::isMessageNamespace( $title ) ) return true;
 305+ if ( !self::isMessageNamespace( $title ) ) {
 306+ return true;
 307+ }
264308
265309 list( $key, $code, $group ) = self::getKeyCodeGroup( $title );
266310
267311 // Unknown message, do not handle
268 - if ( !$group || !$code ) return true;
 312+ if ( !$group || !$code ) {
 313+ return true;
 314+ }
269315
270316 $groups = TranslateUtils::messageKeyToGroups( $title->getNamespace(), $key );
271317 $cache = new ArrayMemoryCache( 'groupstats' );
272 - foreach ( $groups as $g ) $cache->clear( $g, $code );
273318
 319+ foreach ( $groups as $g ) {
 320+ $cache->clear( $g, $code );
 321+ }
 322+
274323 // Check for explicit tag
275324 $fuzzy = self::hasFuzzyString( $text );
276325
@@ -277,6 +326,7 @@
278327 global $wgTranslateDocumentationLanguageCode;
279328 if ( $code !== $wgTranslateDocumentationLanguageCode ) {
280329 $checker = $group->getChecker();
 330+
281331 if ( $checker ) {
282332 $en = $group->getMessage( $key, 'en' );
283333 $message = new FatMessage( $key, $en );
@@ -284,7 +334,9 @@
285335 $message->setTranslation( $text );
286336
287337 $checks = $checker->checkMessage( $message, $code );
288 - if ( count( $checks ) ) $fuzzy = true;
 338+ if ( count( $checks ) ) {
 339+ $fuzzy = true;
 340+ }
289341 }
290342 }
291343
@@ -315,8 +367,14 @@
316368 // fuzzy>
317369
318370 // Diffs for changed messages
319 - if ( $fuzzy !== false ) return true;
320 - if ( $group instanceof WikiPageMessageGroup ) return true;
 371+ if ( $fuzzy !== false ) {
 372+ return true;
 373+ }
 374+
 375+ if ( $group instanceof WikiPageMessageGroup ) {
 376+ return true;
 377+ }
 378+
321379 $definitionTitle = Title::makeTitleSafe( $title->getNamespace(), "$key/en" );
322380 if ( $definitionTitle && $definitionTitle->exists() ) {
323381 $definitionRevision = $definitionTitle->getLatestRevID();
@@ -336,5 +394,4 @@
337395
338396 return true;
339397 }
340 -
341398 }
Index: trunk/extensions/Translate/Translate.php
@@ -74,7 +74,6 @@
7575 # Translation memory updates
7676 $wgHooks['ArticleSaveComplete'][] = 'TranslationMemoryUpdater::update';
7777
78 -
7978 $wgEnablePageTranslation = false;
8079 $wgPageTranslationNamespace = 1198;
8180 $wgTranslateStaticTags = false;
@@ -146,8 +145,8 @@
147146
148147 /** AC = Available classes */
149148 $wgTranslateAC = array(
150 -'core' => 'CoreMessageGroup',
151 -'core-0-mostused' => 'CoreMostUsedMessageGroup',
 149+ 'core' => 'CoreMessageGroup',
 150+ 'core-0-mostused' => 'CoreMostUsedMessageGroup',
152151 );
153152
154153 /**
@@ -210,7 +209,7 @@
211210 *
212211 * You should be able to do this with:
213212 * for module in 'YAML::Syck' 'PHP::Serialization' 'File::Slurp'; do cpanp -i $module; done
214 -**/
 213+ */
215214 $wgTranslateYamlLibrary = 'spyc';
216215
217216 /**
@@ -238,7 +237,6 @@
239238
240239 global $wgEnablePageTranslation;
241240 if ( $wgEnablePageTranslation ) {
242 -
243241 // Special page + the right to use it
244242 global $wgSpecialPages, $wgAvailableRights;
245243 $wgSpecialPages['PageTranslation'] = 'SpecialPageTranslation';
@@ -280,7 +278,6 @@
281279 $wgHooks['ArticleSave'][] = 'PageTranslationHooks::tpSyntaxCheck';
282280 $wgHooks['EditFilter'][] = 'PageTranslationHooks::tpSyntaxCheckForEditPage';
283281
284 -
285282 // Add transtag to page props for discovery
286283 $wgHooks['ArticleSaveComplete'][] = 'PageTranslationHooks::addTranstag';
287284
@@ -355,7 +352,7 @@
356353
357354 /**
358355 * Enable tmserver translation memory from translatetoolkit.
359 - * Example configuration:
 356+ * Example configuration:
360357 * $wgTranslateTM = array(
361358 * 'server' => 'http://127.0.0.1',
362359 * 'port' => 54321,
Index: trunk/extensions/Translate/TranslateTasks.php
@@ -40,7 +40,6 @@
4141 public function getPagingCB() {
4242 return $this->pagingCB;
4343 }
44 -
4544 }
4645
4746 /**

Status & tagging log