Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\Config\DataAccess Class Reference

MediaWiki data access abstract class for Parsoid. More...

+ Inheritance diagram for Wikimedia\Parsoid\Config\DataAccess:

Public Member Functions

 __construct ()
 Base constructor.
 
 getPageInfo ( $pageConfigOrTitle, array $titles)
 Return target data for formatting links.
 
 getFileInfo (PageConfig $pageConfig, array $files)
 Return information about files (images)
 
 parseWikitext (PageConfig $pageConfig, ContentMetadataCollector $metadata, string $wikitext)
 Perform a parse on wikitext.
 
 preprocessWikitext (PageConfig $pageConfig, ContentMetadataCollector $metadata, string $wikitext)
 Preprocess wikitext.
 
 fetchTemplateSource (PageConfig $pageConfig, LinkTarget $title)
 Fetch latest revision of article/template content for transclusion.
 
 fetchTemplateData (PageConfig $pageConfig, LinkTarget $title)
 Fetch templatedata for a title.
 
 logLinterData (PageConfig $pageConfig, array $lints)
 Log linter data.
 
 addTrackingCategory (PageConfig $pageConfig, ContentMetadataCollector $metadata, string $key)
 Add a tracking category with the given key to the metadata for the page.
 

Detailed Description

MediaWiki data access abstract class for Parsoid.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Parsoid\Config\DataAccess::__construct ( )

Base constructor.

This constructor is public because it is used to create mock objects in our test suite.

Member Function Documentation

◆ addTrackingCategory()

Wikimedia\Parsoid\Config\DataAccess::addTrackingCategory ( PageConfig $pageConfig,
ContentMetadataCollector $metadata,
string $key )
abstract

Add a tracking category with the given key to the metadata for the page.

Parameters
PageConfig$pageConfigthe page on which the tracking category is to be added
ContentMetadataCollector$metadataThe metadata for the page
string$keyMessage key (not localized)

Reimplemented in Wikimedia\Parsoid\Mocks\MockDataAccess.

◆ fetchTemplateData()

Wikimedia\Parsoid\Config\DataAccess::fetchTemplateData ( PageConfig $pageConfig,
LinkTarget $title )
abstract

Fetch templatedata for a title.

This replaces TemplateDataRequest

Parameters
PageConfig$pageConfig
LinkTarget$title
Returns
array|null

Reimplemented in Wikimedia\Parsoid\Mocks\MockDataAccess.

◆ fetchTemplateSource()

Wikimedia\Parsoid\Config\DataAccess::fetchTemplateSource ( PageConfig $pageConfig,
LinkTarget $title )
abstract

Fetch latest revision of article/template content for transclusion.

Technically, the ParserOptions might select a different revision other than the latest via ParserOptions::getTemplateCallback() (used for FlaggedRevisions, etc), but the point is that template lookups are by title, not revision id.

This replaces TemplateRequest

Todo
TemplateRequest also returns a bunch of other data, but seems to never use it except for TemplateRequest.setPageSrcInfo() which is replaced by PageConfig.
Parameters
PageConfig$pageConfig
LinkTarget$titleTitle of the page to fetch
Returns
PageContent|null

Reimplemented in Wikimedia\Parsoid\Mocks\MockDataAccess.

◆ getFileInfo()

Wikimedia\Parsoid\Config\DataAccess::getFileInfo ( PageConfig $pageConfig,
array $files )
abstract

Return information about files (images)

This replaces ImageInfoRequest and Batcher.imageinfo()

Parameters
PageConfig$pageConfig
array$files[ [string Name, array Dims] ]. The array may contain
  • width: (int) Requested thumbnail width
  • height: (int) Requested thumbnail height
  • page: (int) Requested thumbnail page number
  • seek: (int) Requested thumbnail time offset
Returns
array [ array|null ], where the array contains
  • width: (int|false) File width, false if unknown
  • height: (int|false) File height, false if unknown
  • size: (int|false) File size in bytes, false if unknown
  • mediatype: (string) File media type
  • mime: (string) File MIME type
  • url: (string) File URL
  • mustRender: (bool) False if the file can be directly rendered by browsers
  • badFile: (bool) Whether the file is on the "bad image list"
  • duration: (float, optional) Duration of the media in seconds
  • thumberror: (string, optional) Error text if thumbnailing failed. Ugh.
  • responsiveUrls: (string[], optional) Map of display densities to URLs.
  • thumbdata: (mixed, optional) MediaWiki File->getAPIData()
  • thumburl: (string, optional) Thumbnail URL
  • thumbwidth: (int, optional) Thumbnail width
  • thumbheight: (int, optional) Thumbnail height
  • timestamp: (string, optional) Timestamp
  • sha1: (string, optional) SHA-1

Reimplemented in Wikimedia\Parsoid\Mocks\MockDataAccess.

◆ getPageInfo()

Wikimedia\Parsoid\Config\DataAccess::getPageInfo ( $pageConfigOrTitle,
array $titles )
abstract

Return target data for formatting links.

Replaces Batcher.getPageProps()

Parameters
PageConfig | LinkTarget$pageConfigOrTitleEither a PageConfig or else just the context title from the PageConfig (as a LinkTarget)
string[]$titles
Returns
array<string,array> [ string Title => array ], where the array contains
  • pageId: (int|null) Page ID
  • revId: (int|null) Current revision of the page
  • missing: (bool) Whether the page is missing
  • known: (bool) Whether the special page is known
  • redirect: (bool) Whether the page is a redirect
  • linkclasses: (string[]) Extensible "link color" information; see ApiQueryInfo::getLinkClasses() in MediaWiki core

Reimplemented in Wikimedia\Parsoid\Config\Api\DataAccess, and Wikimedia\Parsoid\Mocks\MockDataAccess.

◆ logLinterData()

Wikimedia\Parsoid\Config\DataAccess::logLinterData ( PageConfig $pageConfig,
array $lints )
abstract

Log linter data.

Parameters
PageConfig$pageConfig
array$lints

Reimplemented in Wikimedia\Parsoid\Mocks\MockDataAccess.

◆ parseWikitext()

Wikimedia\Parsoid\Config\DataAccess::parseWikitext ( PageConfig $pageConfig,
ContentMetadataCollector $metadata,
string $wikitext )
abstract

Perform a parse on wikitext.

This replaces PHPParseRequest with onlypst = false, and Batcher.parse()

Todo
Parsoid should be able to do this itself.
Parameters
PageConfig$pageConfig
ContentMetadataCollector$metadataWill collect metadata about the parsed content.
string$wikitext
Returns
string Output HTML

Reimplemented in Wikimedia\Parsoid\Mocks\MockDataAccess.

◆ preprocessWikitext()

Wikimedia\Parsoid\Config\DataAccess::preprocessWikitext ( PageConfig $pageConfig,
ContentMetadataCollector $metadata,
string $wikitext )
abstract

Preprocess wikitext.

This replaces PreprocessorRequest and Batcher.preprocess()

Todo
Parsoid should be able to do this itself.
Parameters
PageConfig$pageConfig
ContentMetadataCollector$metadataWill collect metadata about the preprocessed content.
string$wikitext
Returns
string|PFragment Expanded wikitext

Reimplemented in Wikimedia\Parsoid\Mocks\MockDataAccess.


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