Wikibase
MediaWiki Wikibase extension
Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory Class Reference

A factory for SnakFormatters in a client context, to be reused in different methods that "access repository data" from a client (typically parser functions and Lua scripts). More...

Public Member Functions

 __construct (LanguageFallbackChainFactory $languageFallbackChainFactory, OutputFormatSnakFormatterFactory $snakFormatterFactory, PropertyDataTypeLookup $propertyDataTypeLookup, EntityIdParser $repoItemUriParser, LanguageFallbackLabelDescriptionLookupFactory $languageFallbackLabelDescriptionLookupFactory, $trackUsagesInAllLanguages=false)
 
 newWikitextSnakFormatter (Language $language, UsageAccumulator $usageAccumulator, $type=self::TYPE_ESCAPED_PLAINTEXT)
 This returns a SnakFormatter that will return either "rich" wikitext, or wikitext escaped plain text. More...
 

Public Attributes

const TYPE_ESCAPED_PLAINTEXT = 'escaped-plaintext'
 A plain text format, escaped for wikitext. More...
 
const TYPE_RICH_WIKITEXT = 'rich-wikitext'
 A rich wikitext format. More...
 

Private Member Functions

 getRichWikitextSnakFormatterForOptions (FormatterOptions $options)
 
 getPlainTextSnakFormatterForOptions (FormatterOptions $options)
 Our output format is basically wikitext escaped plain text, except for URLs, these are not wikitext escaped. More...
 

Private Attributes

 $languageFallbackChainFactory
 
 $snakFormatterFactory
 
 $propertyDataTypeLookup
 
 $repoItemUriParser
 
 $languageFallbackLabelDescriptionLookupFactory
 
 $trackUsagesInAllLanguages
 

Detailed Description

A factory for SnakFormatters in a client context, to be reused in different methods that "access repository data" from a client (typically parser functions and Lua scripts).

Author
Katie Filbert < aude..nosp@m.wiki.nosp@m.@gmai.nosp@m.l.co.nosp@m.m >
Marius Hoch

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory::__construct ( LanguageFallbackChainFactory  $languageFallbackChainFactory,
OutputFormatSnakFormatterFactory  $snakFormatterFactory,
PropertyDataTypeLookup  $propertyDataTypeLookup,
EntityIdParser  $repoItemUriParser,
LanguageFallbackLabelDescriptionLookupFactory  $languageFallbackLabelDescriptionLookupFactory,
  $trackUsagesInAllLanguages = false 
)

Member Function Documentation

◆ getPlainTextSnakFormatterForOptions()

Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory::getPlainTextSnakFormatterForOptions ( FormatterOptions  $options)
private

Our output format is basically wikitext escaped plain text, except for URLs, these are not wikitext escaped.

Parameters
FormatterOptions$options
Returns
BinaryOptionDispatchingSnakFormatter

◆ getRichWikitextSnakFormatterForOptions()

Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory::getRichWikitextSnakFormatterForOptions ( FormatterOptions  $options)
private
Parameters
FormatterOptions$options
Returns
EscapingSnakFormatter

◆ newWikitextSnakFormatter()

Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory::newWikitextSnakFormatter ( Language  $language,
UsageAccumulator  $usageAccumulator,
  $type = self::TYPE_ESCAPED_PLAINTEXT 
)

This returns a SnakFormatter that will return either "rich" wikitext, or wikitext escaped plain text.

The only exception are URLs, these are not escaped but plain text.

Parameters
Language$language
UsageAccumulator$usageAccumulator
string$typeOne of DataAccessSnakFormatterFactory::TYPE_*
Returns
SnakFormatter

Member Data Documentation

◆ $languageFallbackChainFactory

Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory::$languageFallbackChainFactory
private

◆ $languageFallbackLabelDescriptionLookupFactory

Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory::$languageFallbackLabelDescriptionLookupFactory
private

◆ $propertyDataTypeLookup

Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory::$propertyDataTypeLookup
private

◆ $repoItemUriParser

Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory::$repoItemUriParser
private

◆ $snakFormatterFactory

Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory::$snakFormatterFactory
private

◆ $trackUsagesInAllLanguages

Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory::$trackUsagesInAllLanguages
private

◆ TYPE_ESCAPED_PLAINTEXT

const Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory::TYPE_ESCAPED_PLAINTEXT = 'escaped-plaintext'

A plain text format, escaped for wikitext.

Values are formatted in simple, textual formats, and any wikitext syntax they might contain (e. g. in string values) is escaped. The only exception are URLs, which are not escaped.

◆ TYPE_RICH_WIKITEXT

const Wikibase\Client\DataAccess\DataAccessSnakFormatterFactory::TYPE_RICH_WIKITEXT = 'rich-wikitext'

A rich wikitext format.

Values may contain markup, such as hyperlinks or <span>s with language tags. Individual formatters still wikitext-escape their contents as needed (e. g. for strings). The result is always wrapped in an outer <span>.


The documentation for this class was generated from the following file: