MediaWiki  master
SearchResult Class Reference
Inheritance diagram for SearchResult:
Collaboration diagram for SearchResult:

Public Member Functions

 getByteSize ()
 
 getCategorySnippet ()
 
 getExtensionData ()
 Get the extension data as: augmentor name => data. More...
 
 getFile ()
 Get the file for this page, if one exists. More...
 
 getInterwikiNamespaceText ()
 
 getInterwikiPrefix ()
 
 getRedirectSnippet ()
 
 getRedirectTitle ()
 
 getSectionSnippet ()
 
 getSectionTitle ()
 
 getTextSnippet ( $terms)
 
 getTimestamp ()
 
 getTitle ()
 
 getTitleSnippet ()
 
 getWordCount ()
 
 isBrokenTitle ()
 Check if this is result points to an invalid title. More...
 
 isFileMatch ()
 Did this match file contents (eg: PDF/DJVU)? More...
 
 isMissingRevision ()
 Check if target page is missing, happens when index is out of date. More...
 
 setExtensionData ( $extensionData)
 Set extension data for this result. More...
 

Static Public Member Functions

static newFromTitle ( $title, SearchResultSet $parentSet=null)
 Return a new SearchResult and initializes it with a title. More...
 

Protected Member Functions

 initFromTitle ( $title)
 Initialize from a Title and if possible initializes a corresponding Revision and File. More...
 
 initText ()
 Lazy initialization of article text from DB. More...
 

Protected Attributes

Closure null $extensionData
 A function returning a set of extension data. More...
 
File $mImage = null
 
Revision $mRevision = null
 
string $mText
 
Title $mTitle
 
SearchEngine $searchEngine
 

Detailed Description

Todo:
FIXME: This class is horribly factored.

It would probably be better to have a useful base class to which you pass some standard information, then let the fancy self-highlighters extend that.

Definition at line 32 of file SearchResult.php.

Member Function Documentation

◆ getByteSize()

SearchResult::getByteSize ( )
Returns
int Size in bytes

Definition at line 237 of file SearchResult.php.

References initText().

Referenced by MediaWiki\Widget\Search\FullSearchResultWidget\generateSizeHtml(), and ApiQuerySearch\getSearchResultData().

◆ getCategorySnippet()

SearchResult::getCategorySnippet ( )
Returns
string Highlighted relevant category name or '' if none or not supported

Definition at line 210 of file SearchResult.php.

Referenced by MediaWiki\Widget\Search\FullSearchResultWidget\generateCategoryHtml(), and ApiQuerySearch\getSearchResultData().

◆ getExtensionData()

SearchResult::getExtensionData ( )

Get the extension data as: augmentor name => data.

Returns
array[]

Definition at line 269 of file SearchResult.php.

Referenced by ApiQuerySearch\getSearchResultData().

◆ getFile()

SearchResult::getFile ( )

Get the file for this page, if one exists.

Returns
File|null

Definition at line 130 of file SearchResult.php.

References $mImage.

Referenced by MediaWiki\Widget\Search\FullSearchResultWidget\generateFileHtml().

◆ getInterwikiNamespaceText()

SearchResult::getInterwikiNamespaceText ( )
Returns
string Interwiki namespace of the title (since we likely can't resolve it locally)

Definition at line 252 of file SearchResult.php.

◆ getInterwikiPrefix()

SearchResult::getInterwikiPrefix ( )
Returns
string Interwiki prefix of the title (return iw even if title is broken)

Definition at line 245 of file SearchResult.php.

◆ getRedirectSnippet()

SearchResult::getRedirectSnippet ( )

◆ getRedirectTitle()

SearchResult::getRedirectTitle ( )

◆ getSectionSnippet()

SearchResult::getSectionSnippet ( )
Returns
string Highlighted relevant section name, null if none or not supported

Definition at line 195 of file SearchResult.php.

Referenced by MediaWiki\Widget\Search\FullSearchResultWidget\generateSectionHtml(), and ApiQuerySearch\getSearchResultData().

◆ getSectionTitle()

SearchResult::getSectionTitle ( )
Returns
Title|null Title object (pagename+fragment) for the section, null if none or not supported

Definition at line 203 of file SearchResult.php.

References null.

Referenced by MediaWiki\Widget\Search\FullSearchResultWidget\generateSectionHtml(), and ApiQuerySearch\getSearchResultData().

◆ getTextSnippet()

SearchResult::getTextSnippet (   $terms)
Parameters
array$termsTerms to highlight
Returns
string Highlighted text snippet, null (and not '') if not supported

Definition at line 152 of file SearchResult.php.

References $wgAdvancedSearchHighlighting, initText(), and list.

Referenced by ApiQuerySearch\getSearchResultData(), MediaWiki\Widget\Search\InterwikiSearchResultWidget\render(), and MediaWiki\Widget\Search\FullSearchResultWidget\render().

◆ getTimestamp()

SearchResult::getTimestamp ( )
Returns
string Timestamp

Definition at line 217 of file SearchResult.php.

Referenced by ApiQuerySearch\getSearchResultData(), and MediaWiki\Widget\Search\FullSearchResultWidget\render().

◆ getTitle()

◆ getTitleSnippet()

◆ getWordCount()

SearchResult::getWordCount ( )
Returns
int Number of words

Definition at line 229 of file SearchResult.php.

References initText().

Referenced by MediaWiki\Widget\Search\FullSearchResultWidget\generateSizeHtml(), and ApiQuerySearch\getSearchResultData().

◆ initFromTitle()

SearchResult::initFromTitle (   $title)
protected

Initialize from a Title and if possible initializes a corresponding Revision and File.

Parameters
Title$title

Definition at line 87 of file SearchResult.php.

References $title, Revision\newFromTitle(), NS_FILE, Hooks\run(), and wfFindFile().

◆ initText()

SearchResult::initText ( )
protected

Lazy initialization of article text from DB.

Definition at line 137 of file SearchResult.php.

References null.

Referenced by getByteSize(), getTextSnippet(), and getWordCount().

◆ isBrokenTitle()

SearchResult::isBrokenTitle ( )

Check if this is result points to an invalid title.

Returns
bool

Definition at line 106 of file SearchResult.php.

Referenced by ApiQuerySearch\getSearchResultData(), and MediaWiki\Widget\Search\FullSearchResultWidget\render().

◆ isFileMatch()

SearchResult::isFileMatch ( )

Did this match file contents (eg: PDF/DJVU)?

Returns
bool

Definition at line 260 of file SearchResult.php.

Referenced by MediaWiki\Widget\Search\FullSearchResultWidget\generateFileHtml(), and ApiQuerySearch\getSearchResultData().

◆ isMissingRevision()

SearchResult::isMissingRevision ( )

Check if target page is missing, happens when index is out of date.

Returns
bool

Definition at line 115 of file SearchResult.php.

References $mImage.

Referenced by ApiQuerySearch\getSearchResultData(), and MediaWiki\Widget\Search\FullSearchResultWidget\render().

◆ newFromTitle()

◆ setExtensionData()

SearchResult::setExtensionData (   $extensionData)

Set extension data for this result.

The data is: augmentor name => data

Parameters
Closure | array$extensionDataTakes no arguments, returns either array of extension data or null.

Definition at line 284 of file SearchResult.php.

References $extensionData, $type, use, and wfDeprecated().

Referenced by SearchResultSet\augmentResult().

Member Data Documentation

◆ $extensionData

Closure null SearchResult::$extensionData
protected

A function returning a set of extension data.

Definition at line 63 of file SearchResult.php.

Referenced by setExtensionData().

◆ $mImage

File SearchResult::$mImage = null
protected

Definition at line 42 of file SearchResult.php.

Referenced by getFile(), and isMissingRevision().

◆ $mRevision

Revision SearchResult::$mRevision = null
protected

Definition at line 37 of file SearchResult.php.

◆ $mText

string SearchResult::$mText
protected

Definition at line 52 of file SearchResult.php.

◆ $mTitle

Title SearchResult::$mTitle
protected

Definition at line 47 of file SearchResult.php.

Referenced by getTitle().

◆ $searchEngine

SearchEngine SearchResult::$searchEngine
protected

Definition at line 57 of file SearchResult.php.


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