Index: trunk/extensions/Translate/utils/MessageWebImporter.php |
— | — | @@ -32,10 +32,15 @@ |
33 | 33 | global $wgUser; |
34 | 34 | return $this->user ? $this->user : $wgUser; |
35 | 35 | } |
36 | | - public function setUser( User $user ) { $this->user = $user; } |
37 | 36 | |
| 37 | + public function setUser( User $user ) { |
| 38 | + $this->user = $user; |
| 39 | + } |
38 | 40 | |
39 | | - public function getGroup() { return $this->group; } |
| 41 | + public function getGroup() { |
| 42 | + return $this->group; |
| 43 | + } |
| 44 | + |
40 | 45 | /** |
41 | 46 | * Group is either MessageGroup object or group id. |
42 | 47 | */ |
— | — | @@ -47,9 +52,14 @@ |
48 | 53 | } |
49 | 54 | } |
50 | 55 | |
51 | | - public function getCode() { return $this->code; } |
52 | | - public function setCode( $code = 'en' ) { $this->code = $code; } |
| 56 | + public function getCode() { |
| 57 | + return $this->code; |
| 58 | + } |
53 | 59 | |
| 60 | + public function setCode( $code = 'en' ) { |
| 61 | + $this->code = $code; |
| 62 | + } |
| 63 | + |
54 | 64 | protected function getAction() { |
55 | 65 | return $this->getTitle()->getFullURL(); |
56 | 66 | } |
— | — | @@ -67,8 +77,7 @@ |
68 | 78 | Xml::openElement( 'form', $formParams ) . |
69 | 79 | Xml::hidden( 'title', $this->getTitle()->getPrefixedText() ) . |
70 | 80 | Xml::hidden( 'token', $this->getUser()->editToken() ) . |
71 | | - Xml::hidden( 'process', 1 ) |
72 | | - ; |
| 81 | + Xml::hidden( 'process', 1 ); |
73 | 82 | } |
74 | 83 | |
75 | 84 | protected function doFooter() { |
— | — | @@ -77,6 +86,7 @@ |
78 | 87 | |
79 | 88 | protected function allowProcess() { |
80 | 89 | global $wgRequest; |
| 90 | + |
81 | 91 | if ( $wgRequest->wasPosted() && |
82 | 92 | $wgRequest->getBool( 'process', false ) && |
83 | 93 | $this->getUser()->matchEditToken( $wgRequest->getVal( 'token' ) ) ) { |
— | — | @@ -95,12 +105,16 @@ |
96 | 106 | } |
97 | 107 | |
98 | 108 | protected function getDefaultAction( $fuzzy, $action ) { |
99 | | - if ( $action ) return $action; |
| 109 | + if ( $action ) { |
| 110 | + return $action; |
| 111 | + } |
| 112 | + |
100 | 113 | return $fuzzy ? 'conflict' : 'import'; |
101 | 114 | } |
102 | 115 | |
103 | 116 | public function execute( $messages ) { |
104 | 117 | global $wgOut; |
| 118 | + |
105 | 119 | $this->out = $wgOut; |
106 | 120 | |
107 | 121 | // Set up diff engine |
— | — | @@ -122,12 +136,14 @@ |
123 | 137 | // Determine changes |
124 | 138 | $alldone = $process; |
125 | 139 | $changed = array(); |
| 140 | + |
126 | 141 | foreach ( $messages as $key => $value ) { |
127 | 142 | $fuzzy = $old = false; |
| 143 | + |
128 | 144 | if ( isset( $collection[$key] ) ) { |
129 | 145 | $old = $collection[$key]->translation(); |
130 | 146 | $fuzzy = TranslateEditAddons::hasFuzzyString( $old ) || |
131 | | - TranslateEditAddons::isFuzzy( self::makeTitle( $group, $key, $code ) ); |
| 147 | + TranslateEditAddons::isFuzzy( self::makeTitle( $group, $key, $code ) ); |
132 | 148 | } |
133 | 149 | |
134 | 150 | // No changes at all, ignore |
— | — | @@ -151,7 +167,9 @@ |
152 | 168 | $action = $wgRequest->getVal( "action-$type-$safekey" ); |
153 | 169 | |
154 | 170 | if ( $process ) { |
155 | | - if ( !count( $changed ) ) $changed[] = '<ul>'; |
| 171 | + if ( !count( $changed ) ) { |
| 172 | + $changed[] = '<ul>'; |
| 173 | + } |
156 | 174 | |
157 | 175 | global $wgLang; |
158 | 176 | if ( $action === null ) { |
— | — | @@ -216,9 +234,13 @@ |
217 | 235 | } |
218 | 236 | |
219 | 237 | if ( $process || ( !count( $changed ) && $code !== 'en' ) ) { |
220 | | - if ( !count( $changed ) ) $this->out->addWikiMsg( 'translate-manage-nochanges-other' ); |
| 238 | + if ( !count( $changed ) ) { |
| 239 | + $this->out->addWikiMsg( 'translate-manage-nochanges-other' ); |
| 240 | + } |
221 | 241 | |
222 | | - if ( !count( $changed ) || strpos( $changed[count( $changed ) - 1], '<li>' ) !== 0 ) $changed[] = '<ul>'; |
| 242 | + if ( !count( $changed ) || strpos( $changed[count( $changed ) - 1], '<li>' ) !== 0 ) { |
| 243 | + $changed[] = '<ul>'; |
| 244 | + } |
223 | 245 | |
224 | 246 | $message = wfMsgExt( 'translate-manage-import-done', 'parseinline' ); |
225 | 247 | $changed[] = "<li>$message</li></ul>"; |
— | — | @@ -333,9 +355,7 @@ |
334 | 356 | $text = "* " . wfMsgExt( $key, array(), $c ); |
335 | 357 | } |
336 | 358 | |
337 | | - return array( 'translate-manage-import-fuzzy', |
338 | | - "\n" . $text |
339 | | - ); |
| 359 | + return array( 'translate-manage-import-fuzzy', "\n" . $text ); |
340 | 360 | } |
341 | 361 | |
342 | 362 | // FIXME: duplicate of SpecialManageGroups::getFuzzyBot() |