MediaWiki  master
SearchSuggestion.php
Go to the documentation of this file.
1 <?php
2 
29  private $text;
30 
34  private $url;
35 
39  private $suggestedTitle;
40 
47 
51  private $score;
52 
62  $this->score = $score;
63  $this->text = $text;
64  if ( $suggestedTitle ) {
66  }
67  $this->suggestedTitleID = $suggestedTitleID;
68  }
69 
74  public function getText() {
75  return $this->text;
76  }
77 
83  public function setText( $text, $setTitle = true ) {
84  $this->text = $text;
85  if ( $setTitle && $text !== '' && $text !== null ) {
87  }
88  }
89 
95  public function getSuggestedTitle() {
96  return $this->suggestedTitle;
97  }
98 
103  public function setSuggestedTitle( Title $title = null ) {
104  $this->suggestedTitle = $title;
105  if ( $title !== null ) {
106  $this->url = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
107  }
108  }
109 
115  public function getSuggestedTitleID() {
117  }
118 
124  $this->suggestedTitleID = $suggestedTitleID;
125  }
126 
131  public function getScore() {
132  return $this->score;
133  }
134 
139  public function setScore( $score ) {
140  $this->score = $score;
141  }
142 
148  public function getURL() {
149  return $this->url;
150  }
151 
156  public function setURL( $url ) {
157  $this->url = $url;
158  }
159 
166  public static function fromTitle( $score, Title $title ) {
167  return new self( $score, $title->getPrefixedText(), $title, $title->getArticleID() );
168  }
169 
177  public static function fromText( $score, $text ) {
178  $suggestion = new self( $score, $text );
179  if ( $text ) {
180  $suggestion->setSuggestedTitle( Title::makeTitle( 0, $text ) );
181  }
182  return $suggestion;
183  }
184 
185 }
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:3027
Search suggestion.
setText( $text, $setTitle=true)
Set the suggestion text.
setSuggestedTitle(Title $title=null)
Set the suggested title.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Title null $suggestedTitle
the suggested title
const PROTO_CURRENT
Definition: Defines.php:202
string $text
the suggestion
getPrefixedText()
Get the prefixed title with spaces.
Definition: Title.php:1724
getSuggestedTitle()
Title object in the case this suggestion is based on a title.
getScore()
Suggestion score.
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
getText()
The suggestion text.
setSuggestedTitleID( $suggestedTitleID=null)
Set the suggested title ID.
static fromText( $score, $text)
Create suggestion from text Will also create a title if text if not empty.
float null $score
The suggestion score.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:767
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
__construct( $score, $text=null, Title $suggestedTitle=null, $suggestedTitleID=null)
Construct a new suggestion.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:592
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
string $url
the suggestion URL
setScore( $score)
Set the suggestion score.
static fromTitle( $score, Title $title)
Create suggestion from Title.
getURL()
Suggestion URL, can be the link to the Title or maybe in the future a link to the search results for ...
getSuggestedTitleID()
Title ID in the case this suggestion is based on a title.
int null $suggestedTitleID
NOTE: even if suggestedTitle is a redirect suggestedTitleID is the ID of the target page...
setURL( $url)
Set the suggestion URL.