MediaWiki REL1_28
SearchSuggestion Class Reference

Search suggestion. More...

Collaboration diagram for SearchSuggestion:

Public Member Functions

 __construct ( $score, $text=null, Title $suggestedTitle=null, $suggestedTitleID=null)
 Construct a new suggestion.
 
 getScore ()
 Suggestion score.
 
 getSuggestedTitle ()
 Title object in the case this suggestion is based on a title.
 
 getSuggestedTitleID ()
 Title ID in the case this suggestion is based on a title.
 
 getText ()
 The suggestion text.
 
 getURL ()
 Suggestion URL, can be the link to the Title or maybe in the future a link to the search results for this search suggestion.
 
 setScore ( $score)
 Set the suggestion score.
 
 setSuggestedTitle (Title $title=null)
 Set the suggested title.
 
 setSuggestedTitleID ( $suggestedTitleID=null)
 Set the suggested title ID.
 
 setText ( $text, $setTitle=true)
 Set the suggestion text.
 
 setURL ( $url)
 Set the suggestion URL.
 

Static Public Member Functions

static fromText ( $score, $text)
 Create suggestion from text Will also create a title if text if not empty.
 
static fromTitle ( $score, Title $title)
 Create suggestion from Title.
 

Private Attributes

float null $score
 The suggestion score.
 
Title null $suggestedTitle
 the suggested title
 
int null $suggestedTitleID
 NOTE: even if suggestedTitle is a redirect suggestedTitleID is the ID of the target page.
 
string $text
 the suggestion
 
string $url
 the suggestion URL
 

Detailed Description

Search suggestion.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html A search suggestion

Definition at line 27 of file SearchSuggestion.php.

Constructor & Destructor Documentation

◆ __construct()

SearchSuggestion::__construct (   $score,
  $text = null,
Title  $suggestedTitle = null,
  $suggestedTitleID = null 
)

Construct a new suggestion.

Parameters
float$scorethe suggestion score
string$text,|nullthe suggestion text
Title | null$suggestedTitlethe suggested title
int | null$suggestedTitleIDthe suggested title ID

Definition at line 62 of file SearchSuggestion.php.

References $score, $suggestedTitle, $suggestedTitleID, $text, setSuggestedTitle(), and text.

Member Function Documentation

◆ fromText()

static SearchSuggestion::fromText (   $score,
  $text 
)
static

Create suggestion from text Will also create a title if text if not empty.

Parameters
float$scoreSuggestions score
string$text
Returns
SearchSuggestion

Definition at line 179 of file SearchSuggestion.php.

References $score, and $text.

Referenced by SearchSuggestionSet\fromStrings().

◆ fromTitle()

static SearchSuggestion::fromTitle (   $score,
Title  $title 
)
static

Create suggestion from Title.

Parameters
float$scoreSuggestions score
Title$title
Returns
SearchSuggestion

Definition at line 168 of file SearchSuggestion.php.

References $score, and $title.

Referenced by SearchSuggestionSet\fromTitles(), and SearchEngine\processCompletionResults().

◆ getScore()

SearchSuggestion::getScore ( )

Suggestion score.

Returns
float Suggestion score

Definition at line 133 of file SearchSuggestion.php.

References $score.

Referenced by SearchSuggestionSet\append(), and SearchSuggestionSet\prepend().

◆ getSuggestedTitle()

SearchSuggestion::getSuggestedTitle ( )

Title object in the case this suggestion is based on a title.

May return null if the suggestion is not a Title.

Returns
Title|null

Definition at line 97 of file SearchSuggestion.php.

References $suggestedTitle.

Referenced by SearchEngine\extractTitles(), and SearchEngine\processCompletionResults().

◆ getSuggestedTitleID()

SearchSuggestion::getSuggestedTitleID ( )

Title ID in the case this suggestion is based on a title.

May return null if the suggestion is not a Title.

Returns
int|null

Definition at line 117 of file SearchSuggestion.php.

References $suggestedTitleID.

Referenced by SearchSuggestionSet\append(), and SearchSuggestionSet\prepend().

◆ getText()

SearchSuggestion::getText ( )

The suggestion text.

Returns
string

Definition at line 76 of file SearchSuggestion.php.

References $text.

◆ getURL()

SearchSuggestion::getURL ( )

Suggestion URL, can be the link to the Title or maybe in the future a link to the search results for this search suggestion.

Returns
string Suggestion URL

Definition at line 150 of file SearchSuggestion.php.

References $url.

◆ setScore()

SearchSuggestion::setScore (   $score)

Set the suggestion score.

Parameters
float$score

Definition at line 141 of file SearchSuggestion.php.

References $score.

Referenced by SearchSuggestionSet\append(), and SearchSuggestionSet\prepend().

◆ setSuggestedTitle()

SearchSuggestion::setSuggestedTitle ( Title  $title = null)

Set the suggested title.

Parameters
Title | null$title

Definition at line 105 of file SearchSuggestion.php.

References $title, PROTO_CURRENT, and wfExpandUrl().

Referenced by __construct(), and setText().

◆ setSuggestedTitleID()

SearchSuggestion::setSuggestedTitleID (   $suggestedTitleID = null)

Set the suggested title ID.

Parameters
int | null$suggestedTitleID

Definition at line 125 of file SearchSuggestion.php.

References $suggestedTitleID.

◆ setText()

SearchSuggestion::setText (   $text,
  $setTitle = true 
)

Set the suggestion text.

Parameters
string$text
bool$setTitleShould we also update the title?

Definition at line 85 of file SearchSuggestion.php.

References $text, setSuggestedTitle(), and text.

◆ setURL()

SearchSuggestion::setURL (   $url)

Set the suggestion URL.

Parameters
string$url

Definition at line 158 of file SearchSuggestion.php.

References $url.

Member Data Documentation

◆ $score

float null SearchSuggestion::$score
private

The suggestion score.

Definition at line 53 of file SearchSuggestion.php.

Referenced by __construct(), fromText(), fromTitle(), getScore(), and setScore().

◆ $suggestedTitle

Title null SearchSuggestion::$suggestedTitle
private

the suggested title

Definition at line 41 of file SearchSuggestion.php.

Referenced by __construct(), and getSuggestedTitle().

◆ $suggestedTitleID

int null SearchSuggestion::$suggestedTitleID
private

NOTE: even if suggestedTitle is a redirect suggestedTitleID is the ID of the target page.

the suggested title ID

Definition at line 48 of file SearchSuggestion.php.

Referenced by __construct(), getSuggestedTitleID(), and setSuggestedTitleID().

◆ $text

string SearchSuggestion::$text
private

the suggestion

Definition at line 31 of file SearchSuggestion.php.

Referenced by __construct(), fromText(), getText(), and setText().

◆ $url

string SearchSuggestion::$url
private

the suggestion URL

Definition at line 36 of file SearchSuggestion.php.

Referenced by getURL(), and setURL().


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