MediaWiki 1.42.1
MediaWiki\Title\NamespaceAwareForeignTitleFactory Class Reference

A parser that translates page titles on a foreign wiki into ForeignTitle objects, using information about the namespace setup on the foreign site. More...

Inherits MediaWiki\Title\ForeignTitleFactory.

Collaboration diagram for MediaWiki\Title\NamespaceAwareForeignTitleFactory:

Public Member Functions

 __construct ( $foreignNamespaces)
 
 createForeignTitle ( $title, $ns=null)
 Create a ForeignTitle object.
 

Protected Member Functions

 parseTitleNoNs ( $title)
 Helper function to parse the title when the namespace ID is not specified.
 
 parseTitleWithNs ( $title, $ns)
 Helper function to parse the title when the namespace value is known.
 

Protected Attributes

array $foreignNamespaces
 

Detailed Description

A parser that translates page titles on a foreign wiki into ForeignTitle objects, using information about the namespace setup on the foreign site.

Definition at line 27 of file NamespaceAwareForeignTitleFactory.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Title\NamespaceAwareForeignTitleFactory::__construct ( $foreignNamespaces)
Parameters
array | null$foreignNamespacesAn array 'id' => 'name' which contains the complete namespace setup of the foreign wiki. Such data could be obtained from siteinfo/namespaces in an XML dump file, or by an action API query such as api.php?action=query&meta=siteinfo&siprop=namespaces. If this data is unavailable, use NaiveForeignTitleFactory instead.

Definition at line 53 of file NamespaceAwareForeignTitleFactory.php.

References MediaWiki\Title\NamespaceAwareForeignTitleFactory\$foreignNamespaces.

Member Function Documentation

◆ createForeignTitle()

MediaWiki\Title\NamespaceAwareForeignTitleFactory::createForeignTitle ( $title,
$ns = null )

Create a ForeignTitle object.

Based on the page title and optionally the namespace ID, of a page on a foreign wiki. These values could be, for example, the <title> and <ns> attributes found in an XML dump.

Parameters
string$titleThe page title
int | null$nsThe namespace ID, or null if this data is not available
Returns
ForeignTitle

Implements MediaWiki\Title\ForeignTitleFactory.

Definition at line 75 of file NamespaceAwareForeignTitleFactory.php.

References MediaWiki\Title\NamespaceAwareForeignTitleFactory\parseTitleNoNs(), and MediaWiki\Title\NamespaceAwareForeignTitleFactory\parseTitleWithNs().

◆ parseTitleNoNs()

MediaWiki\Title\NamespaceAwareForeignTitleFactory::parseTitleNoNs ( $title)
protected

Helper function to parse the title when the namespace ID is not specified.

Parameters
string$title
Returns
ForeignTitle

Definition at line 91 of file NamespaceAwareForeignTitleFactory.php.

Referenced by MediaWiki\Title\NamespaceAwareForeignTitleFactory\createForeignTitle().

◆ parseTitleWithNs()

MediaWiki\Title\NamespaceAwareForeignTitleFactory::parseTitleWithNs ( $title,
$ns )
protected

Helper function to parse the title when the namespace value is known.

Parameters
string$title
int$ns
Returns
ForeignTitle

Definition at line 118 of file NamespaceAwareForeignTitleFactory.php.

Referenced by MediaWiki\Title\NamespaceAwareForeignTitleFactory\createForeignTitle().

Member Data Documentation

◆ $foreignNamespaces

array MediaWiki\Title\NamespaceAwareForeignTitleFactory::$foreignNamespaces
protected

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