|
MediaWiki master
|
Formats change tags for display in HTML and use filter dropdown menus. More...
Public Member Functions | |
| __construct (private readonly ServiceOptions $options, private readonly ChangeTagsStore $changeTagsStore, private readonly WANObjectCache $cache, private readonly LanguageFactory $languageFactory,) | |
| buildTagFilter (string $selected, string $format, IContextSource $context, bool $activeOnly=true, bool $useAllTags=true) | |
| Build a text box to select a change tag. | |
| formatTagsAsSummaryList (?string $tags, MessageLocalizer $localizer, Authority $authority) | |
| Formats the provided tags into HTML for display to a user. | |
| getChangeTagList (LocalizationContext $localizationContext, Authority $authority, bool $activeOnly=true, bool $useAllTags=true, bool $labelsOnly=false) | |
| Get information about change tags for tag filter dropdown menus. | |
| getChangeTagListSummary (LocalizationContext $localizationContext, Authority $authority, bool $activeOnly=true, bool $useAllTags=true) | |
| Get information about change tags, without parsing messages, for tag filter dropdown menus. | |
| getTagDescription (string $tag, MessageLocalizer $localizer) | |
| Get a (short) description for a tag. | |
Public Attributes | |
| const array | CONSTRUCTOR_OPTIONS |
Formats change tags for display in HTML and use filter dropdown menus.
Definition at line 30 of file ChangeTagsFormatter.php.
| MediaWiki\ChangeTags\ChangeTagsFormatter::__construct | ( | private readonly ServiceOptions | $options, |
| private readonly ChangeTagsStore | $changeTagsStore, | ||
| private readonly WANObjectCache | $cache, | ||
| private readonly LanguageFactory | $languageFactory ) |
Definition at line 43 of file ChangeTagsFormatter.php.
| MediaWiki\ChangeTags\ChangeTagsFormatter::buildTagFilter | ( | string | $selected, |
| string | $format, | ||
| IContextSource | $context, | ||
| bool | $activeOnly = true, | ||
| bool | $useAllTags = true ) |
Build a text box to select a change tag.
The tag set can be customized via the $activeOnly and $useAllTags parameters, and defaults to all active tags.
| string | $selected | Tag to select by default |
| string | $format | One of the following formats:
|
Definition at line 177 of file ChangeTagsFormatter.php.
| MediaWiki\ChangeTags\ChangeTagsFormatter::formatTagsAsSummaryList | ( | ?string | $tags, |
| MessageLocalizer | $localizer, | ||
| Authority | $authority ) |
Formats the provided tags into HTML for display to a user.
| string | null | $tags | Comma-separated list of tags (as returned by a database query) |
| MessageLocalizer | $localizer | |
| Authority | $authority |
Definition at line 66 of file ChangeTagsFormatter.php.
| MediaWiki\ChangeTags\ChangeTagsFormatter::getChangeTagList | ( | LocalizationContext | $localizationContext, |
| Authority | $authority, | ||
| bool | $activeOnly = true, | ||
| bool | $useAllTags = true, | ||
| bool | $labelsOnly = false ) |
Get information about change tags for tag filter dropdown menus.
This manipulates the label and description of each tag, which are parsed, stripped and (in the case of description) truncated versions of these messages. Message parsing is expensive, so to detect whether the tag list has changed, use ChangeTagsFormatter::getChangeTagListSummary() instead.
| LocalizationContext | $localizationContext | |
| Authority | $authority | |
| bool | $activeOnly | If true, only show tags which have been used at least once |
| bool | $useAllTags | If true, use all known tags. If false, use only tags defined by MediaWiki core (excluding tags defined by extensions, users, or site config) |
| bool | $labelsOnly | Do not parse descriptions and omit 'description' in the result |
ChangeTagsFormatter::getChangeTagListSummary(), with messages parsed, stripped and truncated Definition at line 364 of file ChangeTagsFormatter.php.
References MediaWiki\Language\MessageLocalizer\msg(), and wfEscapeWikiText().
| MediaWiki\ChangeTags\ChangeTagsFormatter::getChangeTagListSummary | ( | LocalizationContext | $localizationContext, |
| Authority | $authority, | ||
| bool | $activeOnly = true, | ||
| bool | $useAllTags = true ) |
Get information about change tags, without parsing messages, for tag filter dropdown menus.
By default, this will return explicitly-defined and software-defined tags that are currently active (have hits)
Message contents are the raw values (->plain()), because parsing messages is expensive. Even though we're not parsing messages, building a data structure with the contents of hundreds of i18n messages is still not cheap (see T223260#5370610), so this function caches its output in WANCache for up to 24 hours.
Returns an array of associative arrays with information about each tag:
This data is consumed by the mediawiki.rcfilters.filters.ui module, specifically mw.rcfilters.dm.FilterGroup and mw.rcfilters.dm.FilterItem.
| LocalizationContext | $localizationContext | |
| Authority | $authority | |
| bool | $activeOnly | If true, only show tags which have been used at least once |
| bool | $useAllTags | If true, use all known tags. If false, use only tags defined by MediaWiki core (excluding tags defined by extensions, users, or site config) |
Definition at line 278 of file ChangeTagsFormatter.php.
| MediaWiki\ChangeTags\ChangeTagsFormatter::getTagDescription | ( | string | $tag, |
| MessageLocalizer | $localizer ) |
Get a (short) description for a tag.
The description includes the label for the tag along with a help link if defined. If the tag description is an empty string, the tag is considered hidden.
Definition at line 120 of file ChangeTagsFormatter.php.
| const array MediaWiki\ChangeTags\ChangeTagsFormatter::CONSTRUCTOR_OPTIONS |
Definition at line 33 of file ChangeTagsFormatter.php.