63 private $caseSensitiveLinkValueRegex;
76 $this->title = \Title::makeTitleSafe( $namespace, $title );
77 $this->titleValue = $this->title->getTitleValue();
78 $this->config = $config;
84 ( $config->wordStartOnly ) ? $this->wordStart =
'(?<!\pL|\pN)' : $this->wordStart =
'';
85 ( $config->wordEndOnly ) ? $this->wordEnd =
'(?!\pL|\pN)' : $this->wordEnd =
'';
93 return $this->title->getText();
96 public function getPrefixedTitleText() {
97 return $this->title->getPrefixedText();
107 if ( $this->nsText === null ) {
108 $this->nsText = $this->title->getNsText();
110 return $this->nsText;
119 return $this->getNsText() ? $this->getNsText() .
':' :
'';
128 return preg_quote( $this->title->getText(),
'/' );
136 return $this->buildRegex( $this->getCaseSensitiveLinkValueRegex() );
145 return $this->buildRegex( $this->getRegexSafeTitle() ) .
'i';
155 return '/(?<![\:\.\@\/\?\&])' . $this->wordStart . $searchTerm . $this->wordEnd .
'/S';
168 if ( $this->caseSensitiveLinkValueRegex === null ) {
169 $regexSafeTitle = $this->getRegexSafeTitle();
170 if ( $this->config->capitalLinks && preg_match(
'/[a-zA-Z]/', $regexSafeTitle[0] ) ) {
171 $this->caseSensitiveLinkValueRegex =
'((?i)' . $regexSafeTitle[0] .
'(?-i)' . substr($regexSafeTitle, 1) .
')';
173 $this->caseSensitiveLinkValueRegex =
'(' . $regexSafeTitle .
')';
176 return $this->caseSensitiveLinkValueRegex;
186 if ( $this->content === null ) {
187 $this->content = \WikiPage::factory( $this->title )->getContent();
189 return $this->content;
206 if ( $this->config->checkRedirect && $this->redirectsTo( $source ) ) {
212 if ( $this->config->enableNoTargetMagicWord ) {
213 if ( $this->getContent()->matchMagicWord( \MagicWord::get(
'MAG_LINKTITLES_NOTARGET') ) ) {
226 return $this->title->equals( $source->
getTitle() );
235 if ( $this->getContent() ) {
236 $redirectTitle = $this->getContent()->getUltimateRedirectTarget();
237 return $redirectTitle && $redirectTitle->equals( $source->getTitle() );
__construct($namespace, $title, Config &$config)
Constructs a new Target object.
isSameTitle(Source $source)
Determines if the Target's title is the same as another title.
getNsText()
Gets the string representation of the target's namespace.
redirectsTo($source)
Checks whether this target redirects to the source.
getNsPrefix()
Gets the namespace prefix.
$content
Caches the target page content as a object.
mayLinkTo(Source $source)
Examines the current target page.
getTitle()
Gets the title.
getTitleText()
Gets the string representation of the target title.
getCaseSensitiveRegex()
Builds a regular expression of the title.
getCaseSensitiveLinkValueRegex()
Gets the (cached) regex for the link value.
$title
A Title object for the target page currently being examined.
getContent()
Returns the of the target page.
$wordEnd
Regex that matches the end of a word; this expression depends on the setting of LinkTitles->wordEndOn...
Represents a page that is a potential link target.
$wordStart
Regex that matches the start of a word; this expression depends on the setting of LinkTitles->wordSta...
$config
LinkTitles configuration.
getRegexSafeTitle()
Gets the title string with certain characters escaped that may interfere with regular expressions...
Holds LinkTitles configuration.
getCaseInsensitiveRegex()
Builds a regular expression pattern for the title in a case-insensitive way.
The LinkTitles class holds configuration for the LinkTitles extension.
buildRegex($searchTerm)
Builds the basic regex that is used to match target page titles in a source text. ...
Represents a page that is a potential link target.