MediaWiki  1.30.0
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...

Inheritance diagram for NamespaceAwareForeignTitleFactory:
Collaboration diagram for NamespaceAwareForeignTitleFactory:

Public Member Functions

 __construct ( $foreignNamespaces)
 
 createForeignTitle ( $title, $ns=null)
 Creates a ForeignTitle object based on the page title, and optionally the namespace ID, of a page on a foreign wiki. More...
 

Protected Member Functions

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

Protected Attributes

array $foreignNamespaces
 

Private Member Functions

 normalizeNamespaceName ( $name)
 Normalizes an array name for $foreignNamespacesFlipped. More...
 

Private Attributes

array $foreignNamespacesFlipped
 

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 26 of file NamespaceAwareForeignTitleFactory.php.

Constructor & Destructor Documentation

◆ __construct()

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 52 of file NamespaceAwareForeignTitleFactory.php.

References $foreignNamespaces, $name, as, and normalizeNamespaceName().

Member Function Documentation

◆ createForeignTitle()

NamespaceAwareForeignTitleFactory::createForeignTitle (   $title,
  $ns = null 
)

Creates 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 ForeignTitleFactory.

Definition at line 72 of file NamespaceAwareForeignTitleFactory.php.

References $title, parseTitleNoNs(), and parseTitleWithNs().

◆ normalizeNamespaceName()

NamespaceAwareForeignTitleFactory::normalizeNamespaceName (   $name)
private

Normalizes an array name for $foreignNamespacesFlipped.

Parameters
string$name
Returns
string

Definition at line 41 of file NamespaceAwareForeignTitleFactory.php.

References $name.

Referenced by __construct(), and parseTitleNoNs().

◆ parseTitleNoNs()

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 88 of file NamespaceAwareForeignTitleFactory.php.

References $title, captcha-old\count, list, and normalizeNamespaceName().

Referenced by createForeignTitle().

◆ parseTitleWithNs()

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 115 of file NamespaceAwareForeignTitleFactory.php.

References $title, and captcha-old\count.

Referenced by createForeignTitle().

Member Data Documentation

◆ $foreignNamespaces

array NamespaceAwareForeignTitleFactory::$foreignNamespaces
protected

Definition at line 30 of file NamespaceAwareForeignTitleFactory.php.

Referenced by __construct().

◆ $foreignNamespacesFlipped

array NamespaceAwareForeignTitleFactory::$foreignNamespacesFlipped
private

Definition at line 34 of file NamespaceAwareForeignTitleFactory.php.


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