Index: trunk/extensions/Translate/MessageCollection.php |
— | — | @@ -164,8 +164,6 @@ |
165 | 165 | * @return \list{String} List of usernames. |
166 | 166 | */ |
167 | 167 | public function getAuthors() { |
168 | | - global $wgTranslateFuzzyBotName; |
169 | | - |
170 | 168 | $this->loadTranslations(); |
171 | 169 | |
172 | 170 | $authors = array_flip( $this->authors ); |
— | — | @@ -187,8 +185,9 @@ |
188 | 186 | |
189 | 187 | # arsort( $authors, SORT_NUMERIC ); |
190 | 188 | ksort( $authors ); |
| 189 | + $fuzzyBot = FuzzyBot::getName(); |
191 | 190 | foreach ( $authors as $author => $edits ) { |
192 | | - if ( $author !== $wgTranslateFuzzyBotName ) { |
| 191 | + if ( $author !== $fuzzyBot ) { |
193 | 192 | $filteredAuthors[] = $author; |
194 | 193 | } |
195 | 194 | } |
Index: trunk/extensions/Translate/scripts/sync-group.php |
— | — | @@ -363,27 +363,6 @@ |
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
367 | | - * Initialises FuzzyBot if necessary. |
368 | | - * @return \type{User} |
369 | | - */ |
370 | | - public function getImportUser() { |
371 | | - static $user = null; |
372 | | - |
373 | | - if ( $user === null ) { |
374 | | - global $wgTranslateFuzzyBotName; |
375 | | - |
376 | | - $user = User::newFromName( $wgTranslateFuzzyBotName ); |
377 | | - |
378 | | - if ( !$user->isLoggedIn() ) { |
379 | | - STDOUT( "Creating user $wgTranslateFuzzyBotName" ); |
380 | | - $user->addToDatabase(); |
381 | | - } |
382 | | - } |
383 | | - |
384 | | - return $user; |
385 | | - } |
386 | | - |
387 | | - /** |
388 | 367 | * Does the actual edit. |
389 | 368 | * @param $title Title |
390 | 369 | * @param $translation \string |
— | — | @@ -393,7 +372,7 @@ |
394 | 373 | global $wgUser; |
395 | 374 | |
396 | 375 | $old = $wgUser; |
397 | | - $wgUser = $this->getImportUser(); |
| 376 | + $wgUser = FuzzyBot::getUser(); |
398 | 377 | |
399 | 378 | $flags = EDIT_FORCE_BOT; |
400 | 379 | if ( $this->norc ) { |
Index: trunk/extensions/Translate/scripts/languageeditstats.php |
— | — | @@ -81,8 +81,7 @@ |
82 | 82 | $rows = TranslateUtils::translationChanges( $hours, $bots, $namespaces ); |
83 | 83 | |
84 | 84 | /** |
85 | | - * Get counts for edits per language code after filtering out edits by |
86 | | - * $wgTranslateFuzzyBotName. |
| 85 | + * Get counts for edits per language code after filtering out edits by FuzzyBot |
87 | 86 | */ |
88 | 87 | $codes = array(); |
89 | 88 | foreach ( $rows as $_ ) { |
Index: trunk/extensions/Translate/scripts/fuzzy.php |
— | — | @@ -147,26 +147,6 @@ |
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | | - * Create FuzzyBot user if necessary. |
152 | | - * @return \type{User} |
153 | | - */ |
154 | | - public function getImportUser() { |
155 | | - static $user = null; |
156 | | - |
157 | | - if ( $user === null ) { |
158 | | - global $wgTranslateFuzzyBotName; |
159 | | - $user = User::newFromName( $wgTranslateFuzzyBotName ); |
160 | | - |
161 | | - if ( !$user->isLoggedIn() ) { |
162 | | - STDOUT( "Creating user $wgTranslateFuzzyBotName" ); |
163 | | - $user->addToDatabase(); |
164 | | - } |
165 | | - } |
166 | | - |
167 | | - return $user; |
168 | | - } |
169 | | - |
170 | | - /** |
171 | 151 | * Does the actual edit if possible. |
172 | 152 | * @param $title \type{Title} |
173 | 153 | * @param $text \string |
— | — | @@ -177,7 +157,7 @@ |
178 | 158 | global $wgTranslateDocumentationLanguageCode, $wgUser; |
179 | 159 | |
180 | 160 | $oldUser = $wgUser; |
181 | | - $wgUser = $this->getImportUser(); |
| 161 | + $wgUser = FuzzyBot::getUser(); |
182 | 162 | |
183 | 163 | STDOUT( "Updating {$title->getPrefixedText()}... ", $title ); |
184 | 164 | if ( !$title instanceof Title ) { |
Index: trunk/extensions/Translate/tag/RenderJob.php |
— | — | @@ -20,10 +20,8 @@ |
21 | 21 | * @return RenderJob |
22 | 22 | */ |
23 | 23 | public static function newJob( Title $target ) { |
24 | | - global $wgTranslateFuzzyBotName; |
25 | | - |
26 | 24 | $job = new self( $target ); |
27 | | - $job->setUser( $wgTranslateFuzzyBotName ); |
| 25 | + $job->setUser( FuzzyBot::getUser() ); |
28 | 26 | $job->setFlags( EDIT_FORCE_BOT ); |
29 | 27 | $job->setSummary( wfMsgForContent( 'tpt-render-summary' ) ); |
30 | 28 | |
— | — | @@ -62,7 +60,7 @@ |
63 | 61 | |
64 | 62 | $article = new Article( $title, 0 ); |
65 | 63 | |
66 | | - // @todo Fuzzybot hack |
| 64 | + // @todo FuzzyBot hack |
67 | 65 | PageTranslationHooks::$allowTargetEdit = true; |
68 | 66 | |
69 | 67 | // Do the edit |
Index: trunk/extensions/Translate/tag/DeleteJob.php |
— | — | @@ -25,10 +25,8 @@ |
26 | 26 | * @return DeleteJob |
27 | 27 | */ |
28 | 28 | public static function newJob( Title $target, $base, $full, /*User*/ $performer ) { |
29 | | - global $wgTranslateFuzzyBotName; |
30 | | - |
31 | 29 | $job = new self( $target ); |
32 | | - $job->setUser( $wgTranslateFuzzyBotName ); |
| 30 | + $job->setUser( FuzzyBot::getUser() ); |
33 | 31 | $job->setFull( $full ); |
34 | 32 | $job->setBase( $base ); |
35 | 33 | $msg = $job->getFull() ? 'pt-deletepage-full-logreason' : 'pt-deletepage-lang-logreason'; |
Index: trunk/extensions/Translate/tag/MoveJob.php |
— | — | @@ -23,10 +23,8 @@ |
24 | 24 | * @return MoveJob |
25 | 25 | */ |
26 | 26 | public static function newJob( Title $source, Title $target, array $params, /*User*/ $performer ) { |
27 | | - global $wgTranslateFuzzyBotName; |
28 | | - |
29 | 27 | $job = new self( $source ); |
30 | | - $job->setUser( $wgTranslateFuzzyBotName ); |
| 28 | + $job->setUser( FuzzyBot::getUser() ); |
31 | 29 | $job->setTarget( $target->getPrefixedText() ); |
32 | 30 | $job->setSummary( wfMsgForContent( 'pt-movepage-logreason', $params['base-source'] ) ); |
33 | 31 | $job->setParams( $params ); |
Index: trunk/extensions/Translate/_autoload.php |
— | — | @@ -94,6 +94,7 @@ |
95 | 95 | $wgAutoloadClasses['StringMangler'] = $dir . 'utils/StringMatcher.php'; |
96 | 96 | $wgAutoloadClasses['StringMatcher'] = $dir . 'utils/StringMatcher.php'; |
97 | 97 | $wgAutoloadClasses['FCFontFinder'] = $dir . 'utils/Font.php'; |
| 98 | +$wgAutoloadClasses['FuzzyBot'] = $dir . 'utils/FuzzyBot.php'; |
98 | 99 | |
99 | 100 | $wgAutoloadClasses['TranslatePreferences'] = $dir . 'utils/UserToggles.php'; |
100 | 101 | $wgAutoloadClasses['TranslateToolbox'] = $dir . 'utils/ToolBox.php'; |
Index: trunk/extensions/Translate/utils/MessageWebImporter.php |
— | — | @@ -434,7 +434,7 @@ |
435 | 435 | |
436 | 436 | // Edit with fuzzybot if there is no user. |
437 | 437 | if ( !$user ) { |
438 | | - $user = self::getFuzzyBot(); |
| 438 | + $user = FuzzyBot::getUser(); |
439 | 439 | } |
440 | 440 | |
441 | 441 | // Process all rows. |
— | — | @@ -474,21 +474,6 @@ |
475 | 475 | } |
476 | 476 | |
477 | 477 | /** |
478 | | - * @return User |
479 | | - */ |
480 | | - public static function getFuzzyBot() { |
481 | | - global $wgTranslateFuzzyBotName; |
482 | | - |
483 | | - $user = User::newFromName( $wgTranslateFuzzyBotName ); |
484 | | - |
485 | | - if ( !$user->isLoggedIn() ) { |
486 | | - $user->addToDatabase(); |
487 | | - } |
488 | | - |
489 | | - return $user; |
490 | | - } |
491 | | - |
492 | | - /** |
493 | 478 | * Given a group, message key and language code, creates a title for the |
494 | 479 | * translation page. |
495 | 480 | * |