MobileFrontend
MobileoptimisedfrontendforMediaWiki
ApiMobileView Class Reference

Extends Api of MediaWiki with actions for mobile devices. More...

+ Inheritance diagram for ApiMobileView:
+ Collaboration diagram for ApiMobileView:

Public Member Functions

 __construct ( $main, $action)
 Run constructor of ApiBase. More...
 
 getMobileViewPageProps ( $propNames, $data)
 Obtain the requested page properties. More...
 
 execute ()
 Execute the requested Api actions. More...
 
 getAllowedParams ()
 Get allowed Api parameters. More...
 
 getHelpUrls ()
 Returns the Help URL for this Api. More...
 

Static Public Member Functions

static getRequestedSectionIds ( $str, $data, &$missingSections)
 Parses requested sections string into a list of sections. More...
 

Public Attributes

const CACHE_VERSION = 9
 Increment this when changing the format of cached data.
 

Protected Member Functions

 makeTitle ( $name)
 Creates and validates a title. More...
 
 getPageImage (Title $title)
 Wrapper that returns a page image for a given title. More...
 
 findFile ( $title, $options=[])
 Wrapper for wfFindFile. More...
 
 isMainPage ( $title)
 Check if page is the main page after follow redirect when followRedirects is true. More...
 
 getParserOutput (WikiPage $wikiPage, ParserOptions $parserOptions, $oldid=null)
 Performs a page parse. More...
 
 makeWikiPage (Title $title)
 Creates a WikiPage from title. More...
 
 makeParserOptions (WikiPage $wikiPage)
 Call makeParserOptions on a WikiPage with the wrapper output class disabled. More...
 
 parseSectionsData ( $html, Title $title, ParserOutput $parserOutput, $revId=null)
 Parses section data. More...
 
 getExamplesMessages ()
 Returns usage examples for this module. More...
 

Protected Attributes

 $usePageImages
 

Detailed Description

Extends Api of MediaWiki with actions for mobile devices.

For further information see https://www.mediawiki.org/wiki/Extension:MobileFrontend#API

Constructor & Destructor Documentation

◆ __construct()

ApiMobileView::__construct (   $main,
  $action 
)

Run constructor of ApiBase.

Parameters
ApiMain$mainInstance of class ApiMain
string$actionName of this module

Member Function Documentation

◆ execute()

ApiMobileView::execute ( )

Execute the requested Api actions.

Todo:
Write some unit tests for API results

◆ findFile()

ApiMobileView::findFile (   $title,
  $options = [] 
)
protected

Wrapper for wfFindFile.

Parameters
Title | string$titlePage title
array$optionsOptions for wfFindFile (see RepoGroup::findFile)
Returns
File|false

Reimplemented in MockApiMobileView.

◆ getAllowedParams()

ApiMobileView::getAllowedParams ( )

Get allowed Api parameters.

Returns
array

Reimplemented in MockApiMobileView.

◆ getExamplesMessages()

ApiMobileView::getExamplesMessages ( )
protected

Returns usage examples for this module.

See also
ApiBase::getExamplesMessages()
Returns
array

◆ getHelpUrls()

ApiMobileView::getHelpUrls ( )

Returns the Help URL for this Api.

Returns
string

◆ getMobileViewPageProps()

ApiMobileView::getMobileViewPageProps (   $propNames,
  $data 
)

Obtain the requested page properties.

Parameters
string$propNamesrequested list of pageprops separated by '|'. If '*' all page props will be returned.
array$datadata available as returned by getData
Returns
array associative

◆ getPageImage()

ApiMobileView::getPageImage ( Title  $title)
protected

Wrapper that returns a page image for a given title.

Parameters
Title$titlePage title
Returns
File|false

Reimplemented in MockApiMobileView.

◆ getParserOutput()

ApiMobileView::getParserOutput ( WikiPage  $wikiPage,
ParserOptions  $parserOptions,
  $oldid = null 
)
protected

Performs a page parse.

Parameters
WikiPage$wikiPage
ParserOptions$parserOptions
null | int$oldidRevision ID to get the text from, passing null or 0 will get the current revision (default value)
Returns
ParserOutput|bool

Reimplemented in MockApiMobileView.

◆ getRequestedSectionIds()

static ApiMobileView::getRequestedSectionIds (   $str,
  $data,
$missingSections 
)
static

Parses requested sections string into a list of sections.

Parameters
string$strString to parse
array$dataProcessed parser output
array&$missingSectionsUpon return, contains the list of sections that were requested but are not present in parser output (passed by reference)
Returns
array

◆ isMainPage()

ApiMobileView::isMainPage (   $title)
protected

Check if page is the main page after follow redirect when followRedirects is true.

Parameters
Title$titleTitle object to check
Returns
bool

◆ makeParserOptions()

ApiMobileView::makeParserOptions ( WikiPage  $wikiPage)
protected

Call makeParserOptions on a WikiPage with the wrapper output class disabled.

Parameters
WikiPage$wikiPageto call makeParserOptions on.
Returns
ParserOptions

Reimplemented in MockApiMobileView.

◆ makeTitle()

ApiMobileView::makeTitle (   $name)
protected

Creates and validates a title.

Parameters
string$nameTitle content
Returns
Title

Reimplemented in MockApiMobileView.

◆ makeWikiPage()

ApiMobileView::makeWikiPage ( Title  $title)
protected

Creates a WikiPage from title.

Parameters
Title$titlePage title
Returns
WikiPage

Reimplemented in MockApiMobileView.

◆ parseSectionsData()

ApiMobileView::parseSectionsData (   $html,
Title  $title,
ParserOutput  $parserOutput,
  $revId = null 
)
protected

Parses section data.

Parameters
string$htmlRepresenting the entire page
Title$titlePage title
ParserOutput$parserOutput
int | null$revIdThis is a temporary parameter to avoid debug log warnings. Long term the call to wfDebugLog should be moved outside this method (optional)
Returns
array Structure representing the list of sections and their properties:
  • refsections: [] where all keys are section ids of sections with refs that contain references
  • sections: [] a structured array of all the sections inside the page
  • text: [] of the text of each individual section. length === same as sections or of length 1 when there is a mismatch.

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