51 $pageID = $suggestion->getSuggestedTitleID();
52 if ( $pageID && empty( $this->pageMap[$pageID] ) ) {
53 $this->pageMap[$pageID] =
true;
55 $this->suggestions[] = $suggestion;
72 public function map( $callback ) {
73 return array_map( $callback, $this->suggestions );
85 if ( $pageID && isset( $this->pageMap[$pageID] ) ) {
88 if ( $this->
getSize() > 0 && $suggestion->
getScore() >= $this->getWorstScore() ) {
91 $this->suggestions[] = $suggestion;
93 $this->pageMap[$pageID] =
true;
102 foreach ( $set->getSuggestions() as $sugg ) {
112 $removed = array_splice( $this->suggestions, $key, 1 );
113 unset( $this->pageMap[$removed[0]->getSuggestedTitleID()] );
124 if ( $pageID && isset( $this->pageMap[$pageID] ) ) {
127 if ( $this->
getSize() > 0 && $suggestion->
getScore() <= $this->getBestScore() ) {
130 array_unshift( $this->suggestions, $suggestion );
132 $this->pageMap[$pageID] =
true;
140 if ( empty( $this->suggestions ) ) {
143 return $this->suggestions[0]->getScore();
150 if ( empty( $this->suggestions ) ) {
153 return end( $this->suggestions )->getScore();
160 return count( $this->suggestions );
168 if ( count( $this->suggestions ) > $limit ) {
169 $this->suggestions = array_slice( $this->suggestions, 0, $limit );
184 $suggestions = array_map(
function ( $title ) use ( &$score ) {
200 $suggestions = array_map(
function ( $title ) use ( &$score ) {
append(SearchSuggestion $suggestion)
Add a new suggestion at the end.
rescore( $key)
Move the suggestion at index $key to the first position.
shrink( $limit)
Remove any extra elements in the suggestions set.
appendAll(SearchSuggestionSet $set)
Add suggestion set to the end of the current one.
__construct(array $suggestions)
Builds a new set of suggestions.
static fromStrings(array $titles)
Builds a new set of suggestion based on a string array.
getSuggestions()
Get the list of suggestions.
static emptySuggestionSet()
map( $callback)
Call array_map on the suggestions array.
static fromTitles(array $titles)
Builds a new set of suggestion based on a title array.
SearchSuggestion[] $suggestions
prepend(SearchSuggestion $suggestion)
Add a new suggestion at the top.
static fromText( $score, $text)
Create suggestion from text Will also create a title if text if not empty.
getSuggestedTitleID()
Title ID in the case this suggestion is based on a title.
setScore( $score)
Set the suggestion score.
getScore()
Suggestion score.
static fromTitle( $score, Title $title)
Create suggestion from Title.
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles