diff options
Diffstat (limited to 'MLEB/Translate/specials')
-rw-r--r-- | MLEB/Translate/specials/SpecialExportTranslations.php | 6 | ||||
-rw-r--r-- | MLEB/Translate/specials/SpecialLanguageStats.php | 39 | ||||
-rw-r--r-- | MLEB/Translate/specials/SpecialMagic.php | 2 | ||||
-rw-r--r-- | MLEB/Translate/specials/SpecialManageGroups.php | 2 | ||||
-rw-r--r-- | MLEB/Translate/specials/SpecialMessageGroupStats.php | 5 | ||||
-rw-r--r-- | MLEB/Translate/specials/SpecialSupportedLanguages.php | 6 | ||||
-rw-r--r-- | MLEB/Translate/specials/SpecialTranslate.php | 4 | ||||
-rw-r--r-- | MLEB/Translate/specials/SpecialTranslations.php | 2 |
8 files changed, 49 insertions, 17 deletions
diff --git a/MLEB/Translate/specials/SpecialExportTranslations.php b/MLEB/Translate/specials/SpecialExportTranslations.php index 8181eee0..8c7b3d2e 100644 --- a/MLEB/Translate/specials/SpecialExportTranslations.php +++ b/MLEB/Translate/specials/SpecialExportTranslations.php @@ -39,8 +39,10 @@ class SpecialExportTranslations extends SpecialPage { if ( $this->groupId ) { $status = $this->checkInput(); if ( !$status->isGood() ) { - $errors = $out->parse( $status->getWikiText( false, false, $lang ) ); - $out->addHTML( Html::rawElement( 'div', [ 'class' => 'error' ], $errors ) ); + TranslateUtils::wrapWikiTextAsInterface( + $out, 'error', + $status->getWikiText( false, false, $lang ) + ); return; } diff --git a/MLEB/Translate/specials/SpecialLanguageStats.php b/MLEB/Translate/specials/SpecialLanguageStats.php index 3fc58c22..d1b1e2d0 100644 --- a/MLEB/Translate/specials/SpecialLanguageStats.php +++ b/MLEB/Translate/specials/SpecialLanguageStats.php @@ -116,6 +116,7 @@ class SpecialLanguageStats extends SpecialPage { $out = $this->getOutput(); $out->addModules( 'ext.translate.special.languagestats' ); + $out->addModuleStyles( 'ext.translate.statstable' ); $params = explode( '/', $par ); @@ -159,11 +160,29 @@ class SpecialLanguageStats extends SpecialPage { "<div class='error'>$1</div>", 'translate-langstats-incomplete' ); + } - // $this->purge is only true if request was posted + if ( $this->incomplete || $this->purge ) { DeferredUpdates::addCallableUpdate( function () { - $flags = $this->purge ? MessageGroupStats::FLAG_NO_CACHE : 0; - $this->loadStatistics( $this->target, $flags ); + // Attempt to recache on the fly the missing stats, unless a + // purge was requested, because that is likely to time out. + // Even though this is executed inside a deferred update, it + // counts towards the maximum execution time limit. If that is + // reached, or any other failure happens, no updates at all + // will be written into the database, as it does only single + // update at the end. Hence we always add a job too, so that + // even the slower updates will get done at some point. In + // regular case (no purge), the job sees that the stats are + // already updated, so it is not much of an overhead. + $jobParams = $this->getCacheRebuildJobParameters( $this->target ); + $jobParams[ 'purge' ] = $this->purge; + $job = MessageGroupStatsRebuildJob::newJob( $jobParams ); + JobQueueGroup::singleton()->push( $job ); + + // $this->purge is only true if request was posted + if ( !$this->purge ) { + $this->loadStatistics( $this->target ); + } } ); } if ( $this->nothing ) { @@ -176,19 +195,23 @@ class SpecialLanguageStats extends SpecialPage { } /** - * Get stats + * Get stats. * @param string $target For which target to get stats * @param int $flags See MessageGroupStats for possible flags * @return array[] */ - protected function loadStatistics( $target, $flags ) { + protected function loadStatistics( $target, $flags = 0 ) { return MessageGroupStats::forLanguage( $target, $flags ); } + protected function getCacheRebuildJobParameters( $target ) { + return [ 'languagecode' => $target ]; + } + /** - * Return the list of allowed values for target here. + * Return true if language exist in the list of allowed languages or false otherwise. * @param string $value - * @return array + * @return bool */ protected function isValidValue( $value ) { $langs = Language::fetchLanguageNames(); @@ -481,7 +504,7 @@ class SpecialLanguageStats extends SpecialPage { $params[] = md5( $groupId ); $params[] = $this->getLanguage()->getCode(); $params[] = md5( $this->target ); - $cachekey = wfMemcKey( __METHOD__, implode( '-', $params ) ); + $cachekey = wfMemcKey( __METHOD__ . '-v3', implode( '-', $params ) ); $cacheval = wfGetCache( CACHE_ANYTHING )->get( $cachekey ); if ( is_string( $cacheval ) ) { return $cacheval; diff --git a/MLEB/Translate/specials/SpecialMagic.php b/MLEB/Translate/specials/SpecialMagic.php index 11d42249..dbf9be19 100644 --- a/MLEB/Translate/specials/SpecialMagic.php +++ b/MLEB/Translate/specials/SpecialMagic.php @@ -52,7 +52,7 @@ class SpecialMagic extends SpecialPage { * * @return string */ - function getDescription() { + public function getDescription() { return $this->msg( 'translate-magic-pagename' )->text(); } diff --git a/MLEB/Translate/specials/SpecialManageGroups.php b/MLEB/Translate/specials/SpecialManageGroups.php index c266d33d..eec1d4be 100644 --- a/MLEB/Translate/specials/SpecialManageGroups.php +++ b/MLEB/Translate/specials/SpecialManageGroups.php @@ -44,7 +44,7 @@ class SpecialManageGroups extends SpecialPage { return 'wiki'; } - function getDescription() { + public function getDescription() { return $this->msg( 'managemessagegroups' )->text(); } diff --git a/MLEB/Translate/specials/SpecialMessageGroupStats.php b/MLEB/Translate/specials/SpecialMessageGroupStats.php index cb8c0b63..8698a7f9 100644 --- a/MLEB/Translate/specials/SpecialMessageGroupStats.php +++ b/MLEB/Translate/specials/SpecialMessageGroupStats.php @@ -42,6 +42,11 @@ class SpecialMessageGroupStats extends SpecialLanguageStats { } /// Overwritten from SpecialLanguageStats + protected function getCacheRebuildJobParameters( $target ) { + return [ 'groupid' => $target ]; + } + + /// Overwritten from SpecialLanguageStats protected function isValidValue( $value ) { $group = MessageGroups::getGroup( $value ); if ( $group ) { diff --git a/MLEB/Translate/specials/SpecialSupportedLanguages.php b/MLEB/Translate/specials/SpecialSupportedLanguages.php index d7f454f1..63f78109 100644 --- a/MLEB/Translate/specials/SpecialSupportedLanguages.php +++ b/MLEB/Translate/specials/SpecialSupportedLanguages.php @@ -33,7 +33,7 @@ class SpecialSupportedLanguages extends SpecialPage { return 'wiki'; } - function getDescription() { + public function getDescription() { return $this->msg( 'supportedlanguages' )->text(); } @@ -354,7 +354,7 @@ class SpecialSupportedLanguages extends SpecialPage { ->numParams( $count, $last )->text(); $last = max( 1, min( $period, $last ) ); $styles['border-bottom'] = '3px solid #' . - $statsTable->getBackgroundColor( $period - $last, $period ); + $statsTable->getBackgroundColor( ( $period - $last ) / $period ); } else { $enc = "<del>$enc</del>"; } @@ -457,7 +457,7 @@ class SpecialSupportedLanguages extends SpecialPage { for ( $i = 0; $i <= $period; $i += 30 ) { $iFormatted = htmlspecialchars( $this->getLanguage()->formatNum( $i ) ); $legend .= '<span style="background-color:#' . - $statsTable->getBackgroundColor( $period - $i, $period ) . + $statsTable->getBackgroundColor( ( $period - $i ) / $period ) . "\"> $iFormatted</span>"; } diff --git a/MLEB/Translate/specials/SpecialTranslate.php b/MLEB/Translate/specials/SpecialTranslate.php index 8eb31229..305c1e00 100644 --- a/MLEB/Translate/specials/SpecialTranslate.php +++ b/MLEB/Translate/specials/SpecialTranslate.php @@ -329,7 +329,9 @@ class SpecialTranslate extends SpecialPage { protected function getGroupDescription( MessageGroup $group ) { $description = $group->getDescription( $this->getContext() ); if ( $description !== null ) { - return $this->getOutput()->parse( $description, true, true ); + return TranslateUtils::parseAsInterface( + $this->getOutput(), $description + ); } return ''; } diff --git a/MLEB/Translate/specials/SpecialTranslations.php b/MLEB/Translate/specials/SpecialTranslations.php index 5329e7a4..d94d4fde 100644 --- a/MLEB/Translate/specials/SpecialTranslations.php +++ b/MLEB/Translate/specials/SpecialTranslations.php @@ -23,7 +23,7 @@ class SpecialTranslations extends SpecialAllPages { return 'pages'; } - function getDescription() { + public function getDescription() { return $this->msg( 'translations' )->text(); } |