MediaWiki REL1_40
LinkHolderArray Class Reference
Collaboration diagram for LinkHolderArray:

Public Member Functions

 __construct (Parser $parent, ILanguageConverter $languageConverter, HookContainer $hookContainer)
 
 __destruct ()
 Reduce memory usage to reduce the impact of circular references.
 
 clear ()
 Clear all stored link holders.
 
 isBig ()
 Returns true if the memory requirements of this object are getting large.
 
 makeHolder (Title $nt, $text='', $trail='', $prefix='')
 Make a link placeholder.
 
 merge ( $other)
 Merge another LinkHolderArray into this one.
 
 replace (&$text)
 Replace link placeholders with actual links, in the buffer.
 
 replaceText ( $text)
 Replace and link placeholders with plain text of links (not HTML-formatted).
 

Public Attributes

array< int, array< int, array > > $internals = []
 Indexed by numeric namespace and link ids, {.
 
array< int, array > $interwikis = []
 Indexed by numeric link id.
 
Parser $parent
 
int $size = 0
 

Protected Member Functions

 doVariants (&$classes)
 Modify $this->internals and $classes according to language variant linking rules.
 
 replaceInternal (&$text)
 Replace internal links.
 
 replaceInterwiki (&$text)
 Replace interwiki links.
 

Detailed Description

Access: internal
for using in Parser only.

Definition at line 36 of file LinkHolderArray.php.

Constructor & Destructor Documentation

◆ __construct()

LinkHolderArray::__construct ( Parser $parent,
ILanguageConverter $languageConverter,
HookContainer $hookContainer )
Parameters
Parser$parent
ILanguageConverter$languageConverter
HookContainer$hookContainer

Definition at line 65 of file LinkHolderArray.php.

References $parent.

◆ __destruct()

LinkHolderArray::__destruct ( )

Reduce memory usage to reduce the impact of circular references.

Definition at line 76 of file LinkHolderArray.php.

Member Function Documentation

◆ clear()

LinkHolderArray::clear ( )

Clear all stored link holders.

Make sure you don't have any text left using these link holders, before you call this

Definition at line 113 of file LinkHolderArray.php.

◆ doVariants()

LinkHolderArray::doVariants ( & $classes)
protected

Modify $this->internals and $classes according to language variant linking rules.

Parameters
string[]&$classes

Definition at line 320 of file LinkHolderArray.php.

References $dbr, $title, DB_REPLICA, MediaWiki\Title\Title\getNamespace(), NS_CATEGORY, NS_SPECIAL, and wfGetDB().

Referenced by replaceInternal().

◆ isBig()

LinkHolderArray::isBig ( )

Returns true if the memory requirements of this object are getting large.

Returns
bool

Definition at line 103 of file LinkHolderArray.php.

◆ makeHolder()

LinkHolderArray::makeHolder ( Title $nt,
$text = '',
$trail = '',
$prefix = '' )

Make a link placeholder.

The text returned can be later resolved to a real link with replaceLinkHolders(). This is done for two reasons: firstly to avoid further parsing of interwiki links, and secondly to allow all existence checks and article length checks (for stub links) to be bundled into a single query.

Parameters
Title$nt
string$text
string$trail[optional]
string$prefix[optional]
Returns
string

Definition at line 131 of file LinkHolderArray.php.

References MediaWiki\Title\Title\getNamespace(), MediaWiki\Title\Title\getPrefixedDBkey(), and MediaWiki\Title\Title\isExternal().

◆ merge()

LinkHolderArray::merge ( $other)

Merge another LinkHolderArray into this one.

Parameters
LinkHolderArray$other

Definition at line 87 of file LinkHolderArray.php.

◆ replace()

LinkHolderArray::replace ( & $text)

Replace link placeholders with actual links, in the buffer.

Parameters
string&$text

Definition at line 159 of file LinkHolderArray.php.

References replaceInternal(), and replaceInterwiki().

◆ replaceInternal()

LinkHolderArray::replaceInternal ( & $text)
protected

Replace internal links.

Parameters
string&$text

Definition at line 168 of file LinkHolderArray.php.

References $dbr, $matches, $res, $title, DB_REPLICA, doVariants(), NS_SPECIAL, and wfGetDB().

Referenced by replace().

◆ replaceInterwiki()

LinkHolderArray::replaceInterwiki ( & $text)
protected

Replace interwiki links.

Parameters
string&$text

Definition at line 293 of file LinkHolderArray.php.

References $matches, and $title.

Referenced by replace().

◆ replaceText()

LinkHolderArray::replaceText ( $text)

Replace and link placeholders with plain text of links (not HTML-formatted).

Parameters
string$text
Returns
string

Definition at line 476 of file LinkHolderArray.php.

References $matches.

Member Data Documentation

◆ $internals

array<int,array<int,array> > LinkHolderArray::$internals = []

Indexed by numeric namespace and link ids, {.

See also
Parser::nextLinkID}

Definition at line 38 of file LinkHolderArray.php.

◆ $interwikis

array<int,array> LinkHolderArray::$interwikis = []

Indexed by numeric link id.

Definition at line 40 of file LinkHolderArray.php.

◆ $parent

Parser LinkHolderArray::$parent

Definition at line 47 of file LinkHolderArray.php.

Referenced by __construct().

◆ $size

int LinkHolderArray::$size = 0

Definition at line 42 of file LinkHolderArray.php.


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