Index: trunk/extensions/Translate/scripts/tm-export.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | $optionsWithArgs = array( 'target' ); |
14 | 14 | |
15 | 15 | $dir = dirname( __FILE__ ); $IP = "$dir/../../.."; |
16 | | -@include("$dir/../../CorePath.php"); // Allow override |
| 16 | +@include( "$dir/../../CorePath.php" ); // Allow override |
17 | 17 | define( 'TRANSLATE_CLI', 1 ); |
18 | 18 | require_once( "$IP/maintenance/Maintenance.php" ); |
19 | 19 | |
— | — | @@ -35,20 +35,20 @@ |
36 | 36 | $dbw = new DatabaseSqlite( 'server', 'user', 'password', $target_basename ); |
37 | 37 | swap( $wgSQLiteDataDir, $target_dirname ); |
38 | 38 | |
39 | | - $dbw->setFlag(DBO_TRX); // HUGE speed improvement |
| 39 | + $dbw->setFlag( DBO_TRX ); // HUGE speed improvement |
40 | 40 | |
41 | 41 | $groups = MessageGroups::singleton()->getGroups(); |
42 | 42 | // TODO: encapsulate list of valid language codes |
43 | 43 | $languages = Language::getLanguageNames( false ); |
44 | 44 | unset( $languages['en'] ); |
45 | 45 | |
46 | | - foreach( $groups as $id => $group ) { |
| 46 | + foreach ( $groups as $id => $group ) { |
47 | 47 | if ( $group->isMeta() ) continue; |
48 | 48 | $this->output( "Processing: {$group->getLabel()} ", $id ); |
49 | 49 | $capitalized = MWNamespace::isCapitalized( $group->getNamespace() ); |
50 | 50 | $ns_text = $wgContLang->getNsText( $group->getNamespace() ); |
51 | 51 | |
52 | | - foreach ( $group->load('en') as $key => $definition ) { |
| 52 | + foreach ( $group->load( 'en' ) as $key => $definition ) { |
53 | 53 | // TODO: would be nice to do key normalisation closer to the message groups, to avoid transforming back and forth. |
54 | 54 | // But how to preserve the original keys... |
55 | 55 | $key = strtr( $key, ' ', '_' ); |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | $dbr = wfGetDB( DB_SLAVE ); |
59 | 59 | $tables = array( 'page', 'revision', 'text' ); |
60 | 60 | // selectFields to stfu Revision class |
61 | | - $vars = array_merge(Revision::selectTextFields(), array( 'page_title' ), Revision::selectFields() ); |
| 61 | + $vars = array_merge( Revision::selectTextFields(), array( 'page_title' ), Revision::selectFields() ); |
62 | 62 | $conds = array( |
63 | 63 | 'page_latest = rev_id', |
64 | 64 | 'rev_text_id = old_id', |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | $insert = array( |
74 | 74 | 'text' => $definition, |
75 | 75 | 'context' => "$ns_text:$key", |
76 | | - 'length' => strlen($definition), |
| 76 | + 'length' => strlen( $definition ), |
77 | 77 | 'lang' => 'en' |
78 | 78 | ); |
79 | 79 | |
— | — | @@ -86,7 +86,7 @@ |
87 | 87 | |
88 | 88 | foreach ( $res as $row ) { |
89 | 89 | list( , $code ) = TranslateUtils::figureMessage( $row->page_title ); |
90 | | - $revision = new Revision($row); |
| 90 | + $revision = new Revision( $row ); |
91 | 91 | $insert = array( |
92 | 92 | 'text' => $revision->getText(), |
93 | 93 | 'lang' => $code, |
Index: trunk/extensions/Translate/SpecialFirstSteps.php |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | $this->out->addWikiMsg( 'translate-fs-settings-text' ); |
100 | 100 | $form = new HtmlTag( 'form' ); |
101 | 101 | $items = new TagContainer(); |
102 | | - $form->param( 'method', 'post')->content( $items ); |
| 102 | + $form->param( 'method', 'post' )->content( $items ); |
103 | 103 | $items[] = new RawHtml( Html::hidden( 'step', 'settings' ) ); |
104 | 104 | $items[] = new RawHtml( Xml::submitButton( wfMsg( 'translate-fs-settings-skip' ) ) ); |
105 | 105 | |
— | — | @@ -129,7 +129,7 @@ |
130 | 130 | $this->user->matchEditToken( $wgRequest->getVal( 'token' ) ) && |
131 | 131 | $wgRequest->getText( 'step' ) === 'userpage' ) |
132 | 132 | { |
133 | | - $article = new Article($userpage); |
| 133 | + $article = new Article( $userpage ); |
134 | 134 | $status = $article->doEdit( $wgRequest->getText( $textareaId ), $this->getTitle() ); |
135 | 135 | if ( $status->isOK() ) { |
136 | 136 | $header->content( $header->content . wfMsg( 'translate-fs-pagetitle-done' ) ); |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | |
165 | 165 | $form = new HtmlTag( 'form' ); |
166 | 166 | $items = new TagContainer(); |
167 | | - $form->param( 'method', 'post')->content( $items ); |
| 167 | + $form->param( 'method', 'post' )->content( $items ); |
168 | 168 | |
169 | 169 | $items[] = new RawHtml( Html::hidden( 'step', 'userpage' ) ); |
170 | 170 | $items[] = new RawHtml( Html::hidden( 'token', $this->user->editToken() ) ); |
Index: trunk/extensions/Translate/SpecialSupportedLanguages.php |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | LanguageNames::LIST_MW_AND_CLDR |
33 | 33 | ); |
34 | 34 | $natives = Language::getLanguageNames( false ); |
35 | | - ksort($natives); |
| 35 | + ksort( $natives ); |
36 | 36 | |
37 | 37 | $titles = array(); |
38 | 38 | foreach ( $natives as $code => $_ ) { |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | |
42 | 42 | $dbr = wfGetDB( DB_SLAVE ); |
43 | 43 | $tables = array( 'page', 'revision', 'text' ); |
44 | | - $vars = array_merge(Revision::selectTextFields(), array( 'page_title', 'page_namespace' ), Revision::selectFields() ); |
| 44 | + $vars = array_merge( Revision::selectTextFields(), array( 'page_title', 'page_namespace' ), Revision::selectFields() ); |
45 | 45 | $conds = array( |
46 | 46 | 'page_latest = rev_id', |
47 | 47 | 'rev_text_id = old_id', |
— | — | @@ -54,11 +54,11 @@ |
55 | 55 | $lb = new LinkBatch; |
56 | 56 | |
57 | 57 | foreach ( $res as $row ) { |
58 | | - $rev = new Revision($row); |
| 58 | + $rev = new Revision( $row ); |
59 | 59 | $text = $rev->getText(); |
60 | 60 | $code = strtolower( preg_replace( '!/translators$!', '', $row->page_title ) ); |
61 | 61 | preg_match_all( '!{{user\|([^}|]+)!', $text, $matches, PREG_SET_ORDER ); |
62 | | - foreach( $matches as $match ) { |
| 62 | + foreach ( $matches as $match ) { |
63 | 63 | $user = Title::capitalize( $match[1], NS_USER ); |
64 | 64 | $lb->add( NS_USER, $user ); |
65 | 65 | $lb->add( NS_USER_TALK, $user ); |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | $lb->execute(); |
71 | 71 | global $wgUser; |
72 | 72 | $skin = $wgUser->getSkin(); |
73 | | - foreach ( array_keys($users) as $code ) { |
| 73 | + foreach ( array_keys( $users ) as $code ) { |
74 | 74 | $wgOut->addWikiText( "== [$code] {$locals[$code]} - {$natives[$code]} ==" ); |
75 | 75 | |
76 | 76 | foreach ( $users[$code] as $index => $username ) { |
Index: trunk/extensions/Translate/groups/MediaWikiExtensions.php |
— | — | @@ -212,7 +212,7 @@ |
213 | 213 | $group->setDescriptionMsg( $info['descmsg'], $info['url'] ); |
214 | 214 | } |
215 | 215 | |
216 | | - if( $group->getDescription() == '' ) { |
| 216 | + if ( $group->getDescription() == '' ) { |
217 | 217 | global $wgLang; |
218 | 218 | $group->setDescription( wfMsg( 'translate-group-desc-nodesc' ) ); |
219 | 219 | } |
Index: trunk/extensions/Translate/utils/TranslationEditPage.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | $helpers = new TranslationHelpers( $this->getTitle() ); |
41 | 41 | |
42 | 42 | // jQuery borks on something, probably to :, thus, don't use special chars |
43 | | - $id = Sanitizer::escapeId( sha1($this->getTitle()->getPrefixedText()) ); |
| 43 | + $id = Sanitizer::escapeId( sha1( $this->getTitle()->getPrefixedText() ) ); |
44 | 44 | $helpers->setTextareaId( $id ); |
45 | 45 | |
46 | 46 | global $wgServer, $wgScriptPath, $wgOut; |
Index: trunk/extensions/Translate/utils/Html.php |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | } |
86 | 86 | |
87 | 87 | if ( $value === false ) { |
88 | | - unset($this->params[$name]); |
| 88 | + unset( $this->params[$name] ); |
89 | 89 | } else { |
90 | 90 | $this->params[$name] = $this->assert( 'is_string', $value ); |
91 | 91 | } |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | } |
107 | 107 | |
108 | 108 | if ( $value === false ) { |
109 | | - unset($this->style[$name]); |
| 109 | + unset( $this->style[$name] ); |
110 | 110 | } else { |
111 | 111 | $this->style[$name] = $this->assert( 'is_string', $value ); |
112 | 112 | } |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | $style = $this->collapseStyles(); |
132 | 132 | if ( $style ) $params['style'] = $style; |
133 | 133 | |
134 | | - if ( is_object($this->content) ) { |
| 134 | + if ( is_object( $this->content ) ) { |
135 | 135 | return Html::rawElement( $this->tag, $params, $this->content ); |
136 | 136 | } else { |
137 | 137 | return Html::element( $this->tag, $params, $this->content ); |
— | — | @@ -174,14 +174,14 @@ |
175 | 175 | */ |
176 | 176 | protected function assert( $function, $value, $result = true ) { |
177 | 177 | if ( $function === 'is_string' ) { |
178 | | - if ( is_int($value) || is_float( $value ) ) $value = (string) $value; |
| 178 | + if ( is_int( $value ) || is_float( $value ) ) $value = (string) $value; |
179 | 179 | } |
180 | 180 | |
181 | 181 | $real_result = call_user_func( $function, $value ); |
182 | 182 | if ( $real_result === $result ) return $value; |
183 | 183 | $msg = __METHOD__ . ":expecting $function to be $result"; |
184 | 184 | if ( $this->strict ) { |
185 | | - throw new MWException($msg); |
| 185 | + throw new MWException( $msg ); |
186 | 186 | } else { |
187 | 187 | wfWarn( $msg ); |
188 | 188 | return $value; |
Index: trunk/extensions/Translate/utils/MessageWebImporter.php |
— | — | @@ -350,7 +350,7 @@ |
351 | 351 | |
352 | 352 | $changed = array(); |
353 | 353 | |
354 | | - if( !$user ) { |
| 354 | + if ( !$user ) { |
355 | 355 | $user = self::getFuzzyBot(); |
356 | 356 | } |
357 | 357 | |
— | — | @@ -428,19 +428,19 @@ |
429 | 429 | * @return section element |
430 | 430 | */ |
431 | 431 | public static function makeSectionElement( $legend, $type, $content, $params = array() ) { |
432 | | - if( isset( $params['container'] ) { |
| 432 | + if ( isset( $params['container'] ) ) { |
433 | 433 | $containerParams = array( 'class' => $params['container'] ); |
434 | 434 | } else { |
435 | 435 | $containerParams = array( 'class' => "mw-tpt-sp-section mw-tpt-sp-section-type-{$type}" ); |
436 | 436 | } |
437 | 437 | |
438 | | - if( isset( $params['legend'] ) { |
| 438 | + if ( isset( $params['legend'] ) ) { |
439 | 439 | $legendParams = array( 'class' => $params['legend'] ); |
440 | 440 | } else { |
441 | 441 | $legendParams = array( 'class' => 'mw-translate-manage-legend' ); |
442 | 442 | } |
443 | 443 | |
444 | | - if( isset( $params['content'] ) { |
| 444 | + if ( isset( $params['content'] ) ) { |
445 | 445 | $contentParams = array( 'class' => $params['content'] ); |
446 | 446 | } else { |
447 | 447 | $contentParams = array( 'class' => 'mw-tpt-sp-content' ); |
Index: trunk/extensions/Translate/utils/TranslationHelpers.php |
— | — | @@ -184,7 +184,7 @@ |
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | | - foreach( $sugFields as $field ) { |
| 188 | + foreach ( $sugFields as $field ) { |
189 | 189 | list( $text, $params, $label ) = $field; |
190 | 190 | $legend = array(); |
191 | 191 | foreach ( $label as $acc => $links ) { $legend[] = $acc . ' ' . implode( " ", $links ); } |
— | — | @@ -244,17 +244,17 @@ |
245 | 245 | if ( $google_json === false ) { |
246 | 246 | wfWarn( __METHOD__ . ': Http::get failed' ); |
247 | 247 | return null; |
248 | | - } elseif( !is_object( $response ) ) { |
| 248 | + } elseif ( !is_object( $response ) ) { |
249 | 249 | wfWarn( __METHOD__ . ': Unable to parse reply: ' . strval( $google_json ) ); |
250 | 250 | error_log( __METHOD__ . ': Unable to parse reply: ' . strval( $google_json ) ); |
251 | 251 | return null; |
252 | 252 | } |
253 | 253 | if ( $response->responseStatus === 200 ) { |
254 | 254 | $text = $this->suggestionField( Sanitizer::decodeCharReferences( $response->responseData->translatedText ) ); |
255 | | - return Html::rawElement( 'div', null, self::legend('Google') . $text . self::clear() ); |
256 | | - } elseif( $response->responseDetails === 'invalid translation language pair' ) { |
| 255 | + return Html::rawElement( 'div', null, self::legend( 'Google' ) . $text . self::clear() ); |
| 256 | + } elseif ( $response->responseDetails === 'invalid translation language pair' ) { |
257 | 257 | $unsupported[$code] = true; |
258 | | - $wgMemc->set( $memckey, $unsupported, 60*60*8 ); |
| 258 | + $wgMemc->set( $memckey, $unsupported, 60 * 60 * 8 ); |
259 | 259 | } else { |
260 | 260 | wfWarn( __METHOD__ . ': ' . $response->responseDetails ); |
261 | 261 | error_log( __METHOD__ . ': ' . $response->responseDetails ); |
— | — | @@ -291,7 +291,7 @@ |
292 | 292 | $pairs[$target][$source] = true; |
293 | 293 | } |
294 | 294 | |
295 | | - $wgMemc->set( $memckey, $pairs, 60*60*24 ); |
| 295 | + $wgMemc->set( $memckey, $pairs, 60 * 60 * 24 ); |
296 | 296 | } |
297 | 297 | |
298 | 298 | $codemap = array( 'no' => 'nb' ); |
— | — | @@ -304,7 +304,7 @@ |
305 | 305 | |
306 | 306 | $codemap = array_flip( $codemap ); |
307 | 307 | foreach ( $pairs[$code] as $candidate => $unused ) { |
308 | | - $mwcode = str_replace( '_', '-', strtolower($candidate)); |
| 308 | + $mwcode = str_replace( '_', '-', strtolower( $candidate ) ); |
309 | 309 | if ( isset( $codemap[$mwcode] ) ) $mwcode = $codemap[$mwcode]; |
310 | 310 | |
311 | 311 | $text = TranslateUtils::getMessageContent( $page, $mwcode, $ns ); |
— | — | @@ -326,7 +326,7 @@ |
327 | 327 | $suggestions[] = Html::rawElement( 'div', null, self::legend( "Apertium ($candidate)" ) . $response . self::clear() ); |
328 | 328 | } |
329 | 329 | } |
330 | | - if ( !count($suggestions) ) return null; |
| 330 | + if ( !count( $suggestions ) ) return null; |
331 | 331 | return implode( "\n", $suggestions ); |
332 | 332 | } |
333 | 333 | |
— | — | @@ -598,7 +598,7 @@ |
599 | 599 | $counter++; |
600 | 600 | $id = "tmsug-" . wfTimestamp() . "-$counter"; |
601 | 601 | $contents = TranslateUtils::convertWhiteSpaceToHTML( $contents ); |
602 | | - return $this->adder($id) . "\n" . Html::rawElement( 'span', array( 'id' => $id ), $contents ); |
| 602 | + return $this->adder( $id ) . "\n" . Html::rawElement( 'span', array( 'id' => $id ), $contents ); |
603 | 603 | } |
604 | 604 | |
605 | 605 | public static function editLink( $target, $text, $params = array() ) { |