CirrusSearch
Elasticsearch-powered search for MediaWiki
Loading...
Searching...
No Matches
CirrusSearch\Search\TitleHelper Class Reference

Utility class build MW Title from elastica Result/ResultSet classes This class can be used in all classes that need to build a Title by reading the elasticsearch output. More...

Public Member Functions

 __construct ( $hostWikiID=null, ?InterwikiResolver $interwikiResolver=null, ?callable $linkSanitizer=null)
 
 makeTitle (\Elastica\Result $r)
 Create a title.
 
 makeRedirectTitle (\Elastica\Result $r, $redirectText, $redirNamespace)
 Build a Title to a redirect, this always works for internal titles.
 
 isExternal (\Elastica\Result $r)
 
 sanitizeSectionFragment ( $id)
 
 getNamespaceText (Title $title)
 

Detailed Description

Utility class build MW Title from elastica Result/ResultSet classes This class can be used in all classes that need to build a Title by reading the elasticsearch output.

Constructor & Destructor Documentation

◆ __construct()

CirrusSearch\Search\TitleHelper::__construct ( $hostWikiID = null,
?InterwikiResolver $interwikiResolver = null,
?callable $linkSanitizer = null )
Parameters
string | null$hostWikiID
InterwikiResolver | null$interwikiResolver
callable | null$linkSanitizer

Member Function Documentation

◆ getNamespaceText()

CirrusSearch\Search\TitleHelper::getNamespaceText ( Title $title)
Parameters
Title$title
Returns
string

◆ isExternal()

CirrusSearch\Search\TitleHelper::isExternal ( \Elastica\Result $r)
Parameters
\Elastica\Result$r
Returns
bool true if this result refers to an external Title

◆ makeRedirectTitle()

CirrusSearch\Search\TitleHelper::makeRedirectTitle ( \Elastica\Result $r,
$redirectText,
$redirNamespace )

Build a Title to a redirect, this always works for internal titles.

For external titles we need to use the namespace_text which is only valid if the redirect namespace is equals to the target title namespace. If the namespaces do not match we return null.

Parameters
\Elastica\Result$r
string$redirectText
int$redirNamespace
Returns
Title|null the Title to the Redirect or null if we can't build it

◆ makeTitle()

CirrusSearch\Search\TitleHelper::makeTitle ( \Elastica\Result $r)

Create a title.

When making interwiki titles we should be providing the namespace text as a portion of the text, rather than a namespace id, because namespace id's are not consistent across wiki's. This additionally prevents the local wiki from localizing the namespace text when it should be using the localized name of the remote wiki.

Parameters
\Elastica\Result$rint $namespace
Returns
Title

◆ sanitizeSectionFragment()

CirrusSearch\Search\TitleHelper::sanitizeSectionFragment ( $id)
Parameters
string$id
Returns
string

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