LinkTitles extension for MediaWiki
Automatically add links to existing pages.
All Classes Namespaces Functions Variables Modules Pages
LinkTitles\Target Class Reference

Represents a page that is a potential link target. More...

Public Member Functions

 __construct ($namespace, $title, Config &$config)
 Constructs a new Target object. More...
 
 getTitleText ()
 Gets the string representation of the target title. More...
 
 getPrefixedTitleText ()
 
 getNsText ()
 Gets the string representation of the target's namespace. More...
 
 getNsPrefix ()
 Gets the namespace prefix. More...
 
 getRegexSafeTitle ()
 Gets the title string with certain characters escaped that may interfere with regular expressions. More...
 
 getCaseSensitiveRegex ()
 Builds a regular expression of the title. More...
 
 getCaseInsensitiveRegex ()
 Builds a regular expression pattern for the title in a case-insensitive way. More...
 
 getCaseSensitiveLinkValueRegex ()
 Gets the (cached) regex for the link value. More...
 
 getContent ()
 Returns the of the target page. More...
 
 mayLinkTo (Source $source)
 Examines the current target page. More...
 
 isSameTitle (Source $source)
 Determines if the Target's title is the same as another title. More...
 
 redirectsTo ($source)
 Checks whether this target redirects to the source. More...
 

Public Attributes

 $wordStart
 Regex that matches the start of a word; this expression depends on the setting of LinkTitles->wordStartOnly;.
 
 $wordEnd
 Regex that matches the end of a word; this expression depends on the setting of LinkTitles->wordEndOnly;.
 

Private Member Functions

 buildRegex ($searchTerm)
 Builds the basic regex that is used to match target page titles in a source text. More...
 

Private Attributes

 $title
 A Title object for the target page currently being examined.
 
 $content
 Caches the target page content as a object.
 
 $config
 LinkTitles configuration.
 
 $caseSensitiveLinkValueRegex
 
 $nsText
 

Detailed Description

Represents a page that is a potential link target.

Definition at line 29 of file Target.php.

Constructor & Destructor Documentation

LinkTitles\Target::__construct (   $namespace,
  $title,
Config $config 
)

Constructs a new Target object.

The parameters may be taken from database rows, for example.

Parameters
Int$namespaceName space of the target page
String&$titleTitle of the target page

Definition at line 75 of file Target.php.

Member Function Documentation

LinkTitles\Target::buildRegex (   $searchTerm)
private

Builds the basic regex that is used to match target page titles in a source text.

Parameters
String$searchTermTarget page title (special characters must be quoted)
Returns
String regular expression pattern

Definition at line 154 of file Target.php.

LinkTitles\Target::getCaseInsensitiveRegex ( )

Builds a regular expression pattern for the title in a case-insensitive way.

Returns
String case-insensitive regular expression pattern for the title

Definition at line 144 of file Target.php.

LinkTitles\Target::getCaseSensitiveLinkValueRegex ( )

Gets the (cached) regex for the link value.

Depending on the $config->capitalLinks setting, the title has to be searched for either in a strictly case-sensitive way, or in a 'fuzzy' way where the first letter of the title may be either case.

Returns
String regular expression pattern for the link value.

Definition at line 167 of file Target.php.

LinkTitles\Target::getCaseSensitiveRegex ( )

Builds a regular expression of the title.

Returns
String regular expression for this title.

Definition at line 135 of file Target.php.

LinkTitles\Target::getContent ( )

Returns the of the target page.

The value is cached.

Returns
Content of the Target page.

Definition at line 185 of file Target.php.

LinkTitles\Target::getNsPrefix ( )

Gets the namespace prefix.

This is the namespace text followed by a colon, or an empty string if the namespace text evaluates to false (e.g. NS_MAIN).

Returns
String namespace prefix

Definition at line 118 of file Target.php.

LinkTitles\Target::getNsText ( )

Gets the string representation of the target's namespace.

May be false if the namespace is NS_MAIN. The value is cached.

Returns
String|bool Target's namespace

Definition at line 106 of file Target.php.

LinkTitles\Target::getRegexSafeTitle ( )

Gets the title string with certain characters escaped that may interfere with regular expressions.

Returns
String representation of the title, regex-safe

Definition at line 127 of file Target.php.

LinkTitles\Target::getTitleText ( )

Gets the string representation of the target title.

Returns
String title text

Definition at line 92 of file Target.php.

LinkTitles\Target::isSameTitle ( Source  $source)

Determines if the Target's title is the same as another title.

Parameters
Source$sourceSource object.
Returns
boolean True if the $otherTitle is the same, false if not.

Definition at line 225 of file Target.php.

LinkTitles\Target::mayLinkTo ( Source  $source)

Examines the current target page.

Returns true if it may be linked; false if not. This depends on two settings: $wgLinkTitlesCheckRedirect and $wgLinkTitlesEnableNoTargetMagicWord and whether the target page is a redirect or contains the NOAUTOLINKTARGET magic word.

Parameters
Sourcesource
Returns
boolean

Definition at line 202 of file Target.php.

LinkTitles\Target::redirectsTo (   $source)

Checks whether this target redirects to the source.

Parameters
Source$sourceSource page.
Returns
bool True if the target redirects to the source.

Definition at line 234 of file Target.php.


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