| Index: branches/wmf/1.18wmf1/extensions/Translate/MessageCollection.php |
| — | — | @@ -132,8 +132,6 @@ |
| 133 | 133 | * @return \list{String} List of usernames. |
| 134 | 134 | */ |
| 135 | 135 | public function getAuthors() { |
| 136 | | - global $wgTranslateFuzzyBotName; |
| 137 | | - |
| 138 | 136 | $this->loadTranslations(); |
| 139 | 137 | |
| 140 | 138 | $authors = array_flip( $this->authors ); |
| — | — | @@ -155,8 +153,9 @@ |
| 156 | 154 | |
| 157 | 155 | # arsort( $authors, SORT_NUMERIC ); |
| 158 | 156 | ksort( $authors ); |
| | 157 | + $fuzzyBot = FuzzyBot::getName(); |
| 159 | 158 | foreach ( $authors as $author => $edits ) { |
| 160 | | - if ( $author !== $wgTranslateFuzzyBotName ) { |
| | 159 | + if ( $author !== $fuzzyBot ) { |
| 161 | 160 | $filteredAuthors[] = $author; |
| 162 | 161 | } |
| 163 | 162 | } |
| Index: branches/wmf/1.18wmf1/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: branches/wmf/1.18wmf1/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: branches/wmf/1.18wmf1/extensions/Translate/scripts/fuzzy.php |
| — | — | @@ -151,26 +151,6 @@ |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | | - * Create FuzzyBot user if necessary. |
| 156 | | - * @return \type{User} |
| 157 | | - */ |
| 158 | | - public function getImportUser() { |
| 159 | | - static $user = null; |
| 160 | | - |
| 161 | | - if ( $user === null ) { |
| 162 | | - global $wgTranslateFuzzyBotName; |
| 163 | | - $user = User::newFromName( $wgTranslateFuzzyBotName ); |
| 164 | | - |
| 165 | | - if ( !$user->isLoggedIn() ) { |
| 166 | | - STDOUT( "Creating user $wgTranslateFuzzyBotName" ); |
| 167 | | - $user->addToDatabase(); |
| 168 | | - } |
| 169 | | - } |
| 170 | | - |
| 171 | | - return $user; |
| 172 | | - } |
| 173 | | - |
| 174 | | - /** |
| 175 | 155 | * Does the actual edit if possible. |
| 176 | 156 | * @param $title \type{Title} |
| 177 | 157 | * @param $text \string |
| — | — | @@ -181,7 +161,7 @@ |
| 182 | 162 | global $wgTranslateDocumentationLanguageCode, $wgUser; |
| 183 | 163 | |
| 184 | 164 | $oldUser = $wgUser; |
| 185 | | - $wgUser = $this->getImportUser(); |
| | 165 | + $wgUser = FuzzyBot::getUser(); |
| 186 | 166 | |
| 187 | 167 | STDOUT( "Updating {$title->getPrefixedText()}... ", $title ); |
| 188 | 168 | if ( !$title instanceof Title ) { |
| Index: branches/wmf/1.18wmf1/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: branches/wmf/1.18wmf1/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: branches/wmf/1.18wmf1/extensions/Translate/tag/MoveJob.php |
| — | — | @@ -24,10 +24,8 @@ |
| 25 | 25 | * @return MoveJob |
| 26 | 26 | */ |
| 27 | 27 | public static function newJob( Title $source, Title $target, $base, /*User*/ $performer ) { |
| 28 | | - global $wgTranslateFuzzyBotName; |
| 29 | | - |
| 30 | 28 | $job = new self( $source ); |
| 31 | | - $job->setUser( $wgTranslateFuzzyBotName ); |
| | 29 | + $job->setUser( FuzzyBot::getUser() ); |
| 32 | 30 | $job->setTarget( $target->getPrefixedText() ); |
| 33 | 31 | $job->setSummary( wfMsgForContent( 'pt-movepage-logreason', $target->getPrefixedText() ) ); |
| 34 | 32 | $job->setBase( $base ); |
| Index: branches/wmf/1.18wmf1/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: branches/wmf/1.18wmf1/extensions/Translate/utils/FuzzyBot.php |
| — | — | @@ -0,0 +1,29 @@ |
| | 2 | +<?php |
| | 3 | +/** |
| | 4 | + * Do it all maintenance account |
| | 5 | + * |
| | 6 | + * @file |
| | 7 | + * @author Niklas Laxström |
| | 8 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2 or later |
| | 9 | + * @ |
| | 10 | + */ |
| | 11 | + |
| | 12 | +/** |
| | 13 | + * FuzzyBot - the misunderstood workhorse. |
| | 14 | + * @since 2012-01-02 |
| | 15 | + */ |
| | 16 | + |
| | 17 | +class FuzzyBot { |
| | 18 | + public static function getUser() { |
| | 19 | + $bot = User::newFromName( self::getName() ); |
| | 20 | + if ( $bot->isAnon() ) { |
| | 21 | + $bot->addToDatabase(); |
| | 22 | + } |
| | 23 | + return $bot; |
| | 24 | + } |
| | 25 | + |
| | 26 | + public static function getName() { |
| | 27 | + global $wgTranslateFuzzyBotName; |
| | 28 | + return $wgTranslateFuzzyBotName; |
| | 29 | + } |
| | 30 | +} |
| \ No newline at end of file |
| Property changes on: branches/wmf/1.18wmf1/extensions/Translate/utils/FuzzyBot.php |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 31 | + native |
| Index: branches/wmf/1.18wmf1/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 | * |
| Property changes on: branches/wmf/1.18wmf1/extensions/Translate |
| ___________________________________________________________________ |
| Modified: svn:mergeinfo |
| 496 | 481 | Merged /trunk/extensions/Translate:r107816,107818 |
| Index: branches/wmf/1.18wmf1/extensions/WebFonts/resources/ext.webfonts.js |
| — | — | @@ -108,8 +108,7 @@ |
| 109 | 109 | fontFormats = [], |
| 110 | 110 | version = fontconfig.version || "0.0", |
| 111 | 111 | versionSuffix = "?version=" + version + '&20111213', |
| 112 | | - styleString = "<style type='text/css'>" |
| 113 | | - + "@font-face { font-family: '"+fontFamily+"';\n", |
| | 112 | + styleString = "@font-face { font-family: '"+fontFamily+"';\n", |
| 114 | 113 | ua = navigator.userAgent; |
| 115 | 114 | |
| 116 | 115 | if ( fontconfig.eot !== undefined ) { |
| — | — | @@ -140,10 +139,8 @@ |
| 141 | 140 | styleString += fontFormats.join() + ";\n"; |
| 142 | 141 | styleString += "\tfont-weight: normal;}"; |
| 143 | 142 | |
| 144 | | - styleString += "\n</style>\n"; |
| 145 | 143 | // inject the css to the head of the page. |
| 146 | | - // mw.util.addCSS wont work with fontface, and crashes IE. |
| 147 | | - $( styleString ).appendTo( 'head' ); |
| | 144 | + mw.util.addCSS( styleString ); |
| 148 | 145 | }, |
| 149 | 146 | |
| 150 | 147 | /** |
| Property changes on: branches/wmf/1.18wmf1/extensions |
| ___________________________________________________________________ |
| Modified: svn:mergeinfo |
| 151 | 148 | Merged /trunk/extensions:r107043,107783,107816,107818 |