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

Public Member Functions

 __construct ( $row=null)
 
 getByteSize ()
 
 getFile ()
 Get the file for this page, if one exists. More...
 
 getInterwikiNamespaceText ()
 
 getInterwikiPrefix ()
 
 getRedirectSnippet ()
 
 getRedirectTitle ()
 
 getScore ()
 
 getSectionSnippet ()
 
 getSectionTitle ()
 
 getTextSnippet ( $terms)
 
 getTimestamp ()
 
 getTitle ()
 
 getTitleSnippet ()
 
 getWordCount ()
 
 hasRelated ()
 
 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...
 

Static Public Member Functions

static newFromRow ( $row)
 Return a new SearchResult and initializes it with a row. More...
 
static newFromTitle ( $title)
 Return a new SearchResult and initializes it with a title. More...
 

Protected Member Functions

 initFromRow ( $row)
 Initialize from a database row. More...
 
 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

File $mImage = null
 
Revision $mRevision = null
 
String $mText
 
Title $mTitle
 

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 30 of file SearchResult.php.

Constructor & Destructor Documentation

◆ __construct()

SearchResult::__construct (   $row = null)

Reimplemented in PostgresSearchResult.

Definition at line 72 of file SearchResult.php.

References initFromRow().

Member Function Documentation

◆ getByteSize()

SearchResult::getByteSize ( )
Returns
Integer: size in bytes

Definition at line 238 of file SearchResult.php.

References initText().

◆ getFile()

SearchResult::getFile ( )

Get the file for this page, if one exists.

Returns
File|null

Definition at line 137 of file SearchResult.php.

References $mImage.

◆ getInterwikiNamespaceText()

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

Definition at line 260 of file SearchResult.php.

◆ getInterwikiPrefix()

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

Definition at line 253 of file SearchResult.php.

◆ getRedirectSnippet()

SearchResult::getRedirectSnippet ( )
Returns
String: highlighted redirect name (redirect to this page), '' if none or not supported

Definition at line 190 of file SearchResult.php.

◆ getRedirectTitle()

SearchResult::getRedirectTitle ( )
Returns
Title object for the redirect to this page, null if none or not supported

Definition at line 197 of file SearchResult.php.

◆ getScore()

SearchResult::getScore ( )
Returns
float|null if not supported

Reimplemented in PostgresSearchResult.

Definition at line 144 of file SearchResult.php.

◆ getSectionSnippet()

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

Definition at line 204 of file SearchResult.php.

◆ getSectionTitle()

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

Definition at line 211 of file SearchResult.php.

◆ getTextSnippet()

SearchResult::getTextSnippet (   $terms)
Parameters
array$termsterms to highlight
Returns
String: highlighted text snippet, null (and not '') if not supported

Definition at line 166 of file SearchResult.php.

References global, initText(), list, and SearchEngine\userHighlightPrefs().

◆ getTimestamp()

SearchResult::getTimestamp ( )
Returns
String: timestamp

Definition at line 218 of file SearchResult.php.

◆ getTitle()

SearchResult::getTitle ( )
Returns
Title

Definition at line 129 of file SearchResult.php.

References $mTitle.

◆ getTitleSnippet()

SearchResult::getTitleSnippet ( )
Returns
String: highlighted title, '' if not supported

Definition at line 183 of file SearchResult.php.

◆ getWordCount()

SearchResult::getWordCount ( )
Returns
Integer: number of words

Definition at line 230 of file SearchResult.php.

References initText().

◆ hasRelated()

SearchResult::hasRelated ( )
Returns
Boolean if hit has related articles

Definition at line 246 of file SearchResult.php.

◆ initFromRow()

SearchResult::initFromRow (   $row)
protected

Initialize from a database row.

Makes a Title and passes that to initFromTitle.

Parameters
$rowobject

Definition at line 85 of file SearchResult.php.

References initFromTitle(), and Title\makeTitle().

Referenced by __construct().

◆ initFromTitle()

SearchResult::initFromTitle (   $title)
protected

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

Parameters
$titleTitle

Definition at line 95 of file SearchResult.php.

References $title, array(), Revision\newFromTitle(), NS_FILE, IDBAccessObject\READ_NORMAL, wfFindFile(), and wfRunHooks().

Referenced by initFromRow().

◆ initText()

SearchResult::initText ( )
protected

Lazy initialization of article text from DB.

Definition at line 151 of file SearchResult.php.

References SearchEngine\create().

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

◆ isBrokenTitle()

SearchResult::isBrokenTitle ( )

Check if this is result points to an invalid title.

Returns
Boolean

Definition at line 113 of file SearchResult.php.

◆ isFileMatch()

SearchResult::isFileMatch ( )

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

Definition at line 267 of file SearchResult.php.

◆ isMissingRevision()

SearchResult::isMissingRevision ( )

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

Returns
Boolean

Definition at line 122 of file SearchResult.php.

References $mImage.

◆ newFromRow()

static SearchResult::newFromRow (   $row)
static

Return a new SearchResult and initializes it with a row.

Parameters
$rowobject
Returns
SearchResult

Definition at line 66 of file SearchResult.php.

Referenced by SqlSearchResultSet\next().

◆ newFromTitle()

static SearchResult::newFromTitle (   $title)
static

Return a new SearchResult and initializes it with a title.

Parameters
$titleTitle
Returns
SearchResult

Definition at line 54 of file SearchResult.php.

References $title.

Referenced by SearchNearMatchResultSet\next().

Member Data Documentation

◆ $mImage

File SearchResult::$mImage = null
protected

Definition at line 38 of file SearchResult.php.

Referenced by getFile(), and isMissingRevision().

◆ $mRevision

Revision SearchResult::$mRevision = null
protected

Definition at line 34 of file SearchResult.php.

◆ $mText

String SearchResult::$mText
protected

Definition at line 46 of file SearchResult.php.

◆ $mTitle

Title SearchResult::$mTitle
protected

Definition at line 42 of file SearchResult.php.

Referenced by getTitle().


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