$out->addJsConfigVars( 'wgStructuredChangeFiltersMessages', $messages );
$out->addJsConfigVars( 'wgStructuredChangeFiltersCollapsedState', $collapsed );
- $out->addJsConfigVars(
- 'wgRCFiltersChangeTags',
- $this->getChangeTagList()
- );
$out->addJsConfigVars(
'StructuredChangeFiltersDisplayConfig',
[
'wgStructuredChangeFiltersCollapsedPreferenceName',
static::$collapsedPreferenceName
);
-
- $out->addJsConfigVars(
- 'StructuredChangeFiltersLiveUpdatePollingRate',
- $this->getConfig()->get( 'StructuredChangeFiltersLiveUpdatePollingRate' )
- );
} else {
$out->addBodyClasses( 'mw-rcfilters-disabled' );
}
}
+ /**
+ * Get config vars to export with the mediawiki.rcfilters.filters.ui module.
+ *
+ * @param ResourceLoaderContext $context
+ * @return array
+ */
+ public static function getRcFiltersConfigVars( ResourceLoaderContext $context ) {
+ return [
+ 'RCFiltersChangeTags' => self::getChangeTagList( $context ),
+ 'StructuredChangeFiltersEditWatchlistUrl' =>
+ SpecialPage::getTitleFor( 'EditWatchlist' )->getLocalURL()
+ ];
+ }
+
/**
* Fetch the change tags list for the front end
*
+ * @param ResourceLoaderContext $context
* @return array Tag data
*/
- protected function getChangeTagList() {
+ protected static function getChangeTagList( ResourceLoaderContext $context ) {
$cache = ObjectCache::getMainWANInstance();
- $context = $this->getContext();
return $cache->getWithSetCallback(
- $cache->makeKey( 'changeslistspecialpage-changetags', $context->getLanguage()->getCode() ),
+ $cache->makeKey( 'changeslistspecialpage-changetags', $context->getLanguage() ),
$cache::TTL_MINUTE * 10,
function () use ( $context ) {
$explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
// Sort by hits (disabled for now)
//arsort( $tagHitCounts );
+ // HACK work around ChangeTags::truncateTagDescription() requiring a RequestContext
+ $fakeContext = RequestContext::newExtraneousContext( Title::newFromText( 'Dwimmerlaik' ) );
+ $fakeContext->setLanguage( Language::factory( $context->getLanguage() ) );
+
// Build the list and data
$result = [];
foreach ( $tagHitCounts as $tagName => $hits ) {
ChangeTags::truncateTagDescription(
$tagName,
self::TAG_DESC_CHARACTER_LIMIT,
- $context
+ $fakeContext
),
'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
'hits' => $hits,